/** * host_init_wd - mei initialization wd. * * @dev: the device structure * returns -ENENT if wd client cannot be found * -EIO if write has failed */ int mei_wd_host_init(struct mei_device *dev) { mei_cl_init(&dev->wd_cl, dev); /* look for WD client and connect to it */ dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT; /* find ME WD client */ mei_find_me_client_update_filext(dev, &dev->wd_cl, &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); dev_dbg(&dev->pdev->dev, "wd: check client\n"); if (MEI_FILE_CONNECTING != dev->wd_cl.state) { dev_info(&dev->pdev->dev, "wd: failed to find the client\n"); return -ENOENT; } if (mei_connect(dev, &dev->wd_cl)) { dev_err(&dev->pdev->dev, "wd: failed to connect to the client\n"); dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_cl.host_client_id = 0; return -EIO; } dev->wd_cl.timer_count = CONNECT_TIMEOUT; return 0; }
/** * mei_wd_host_init - connect to the watchdog client * * @dev: the device structure * @me_cl: me client * * Return: -ENOTTY if wd client cannot be found * -EIO if write has failed * 0 on success */ int mei_wd_host_init(struct mei_device *dev, struct mei_me_client *me_cl) { struct mei_cl *cl = &dev->wd_cl; int ret; mei_cl_init(cl, dev); dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT; dev->wd_state = MEI_WD_IDLE; ret = mei_cl_link(cl, MEI_WD_HOST_CLIENT_ID); if (ret < 0) { dev_info(dev->dev, "wd: failed link client\n"); return ret; } ret = mei_cl_connect(cl, me_cl, NULL); if (ret) { dev_err(dev->dev, "wd: failed to connect = %d\n", ret); mei_cl_unlink(cl); return ret; } ret = mei_watchdog_register(dev); if (ret) { mei_cl_disconnect(cl); mei_cl_unlink(cl); } return ret; }
/** * mei_amthif_host_init - mei initialization amthif client. * * @dev: the device structure * @me_cl: me client * * Return: 0 on success, <0 on failure. */ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl) { struct mei_cl *cl = &dev->iamthif_cl; int ret; mutex_lock(&dev->device_lock); if (mei_cl_is_connected(cl)) { ret = 0; goto out; } dev->iamthif_state = MEI_IAMTHIF_IDLE; mei_cl_init(cl, dev); ret = mei_cl_link(cl); if (ret < 0) { dev_err(dev->dev, "amthif: failed cl_link %d\n", ret); goto out; } ret = mei_cl_connect(cl, me_cl, NULL); out: mutex_unlock(&dev->device_lock); return ret; }
/** * host_init_wd - mei initialization wd. * * @dev: the device structure */ bool mei_wd_host_init(struct mei_device *dev) { bool ret = false; mei_cl_init(&dev->wd_cl, dev); /* look for WD client and connect to it */ dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT; /* find ME WD client */ mei_find_me_client_update_filext(dev, &dev->wd_cl, &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); dev_dbg(&dev->pdev->dev, "check wd_cl\n"); if (MEI_FILE_CONNECTING == dev->wd_cl.state) { if (mei_connect(dev, &dev->wd_cl)) { dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n"); dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_cl.host_client_id = 0; ret = false; goto end; } else { dev->wd_cl.timer_count = CONNECT_TIMEOUT; } } else { dev_dbg(&dev->pdev->dev, "Failed to find WD client\n"); ret = false; goto end; } end: return ret; }
/** * host_init_wd - mei initialization wd. * * @dev: the device structure */ void mei_wd_host_init(struct mei_device *dev) { mei_cl_init(&dev->wd_cl, dev); /* look for WD client and connect to it */ dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_timeout = watchdog_timeout; if (dev->wd_timeout > 0) { mei_wd_start_setup(dev); /* find ME WD client */ mei_find_me_client_update_filext(dev, &dev->wd_cl, &mei_wd_guid, MEI_WD_HOST_CLIENT_ID); dev_dbg(&dev->pdev->dev, "check wd_cl\n"); if (MEI_FILE_CONNECTING == dev->wd_cl.state) { if (!mei_connect(dev, &dev->wd_cl)) { dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n"); dev->wd_cl.state = MEI_FILE_DISCONNECTED; dev->wd_cl.host_client_id = 0; mei_host_init_iamthif(dev) ; } else { dev->wd_cl.timer_count = CONNECT_TIMEOUT; } } else { dev_dbg(&dev->pdev->dev, "Failed to find WD client\n"); mei_host_init_iamthif(dev) ; } } else { dev->wd_bypass = true; dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n"); mei_host_init_iamthif(dev) ; } }
/** * mei_wd_host_init - connect to the watchdog client * * @dev: the device structure * * returns -ENENT if wd client cannot be found * -EIO if write has failed * 0 on success */ int mei_wd_host_init(struct mei_device *dev) { struct mei_cl *cl = &dev->wd_cl; int i; int ret; mei_cl_init(cl, dev); dev->wd_timeout = MEI_WD_DEFAULT_TIMEOUT; dev->wd_state = MEI_WD_IDLE; /* check for valid client id */ i = mei_me_cl_by_uuid(dev, &mei_wd_guid); if (i < 0) { dev_info(&dev->pdev->dev, "wd: failed to find the client\n"); return -ENOENT; } cl->me_client_id = dev->me_clients[i].client_id; ret = mei_cl_link(cl, MEI_WD_HOST_CLIENT_ID); if (ret < 0) { dev_info(&dev->pdev->dev, "wd: failed link client\n"); return -ENOENT; } cl->state = MEI_FILE_CONNECTING; ret = mei_cl_connect(cl, NULL); if (ret) { dev_err(&dev->pdev->dev, "wd: failed to connect = %d\n", ret); mei_cl_unlink(cl); return ret; } ret = mei_watchdog_register(dev); if (ret) { mei_cl_disconnect(cl); mei_cl_unlink(cl); } return ret; }