]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
staging/mei: refactor mei_wd_host_init function
authorTomas Winkler <tomas.winkler@intel.com>
Tue, 3 Apr 2012 20:34:58 +0000 (23:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 16:38:49 +0000 (09:38 -0700)
The function has returned false in both error and success
cases.

1. change return value to int and return appropriate errno
2. use typical Linux kernel error handling.
3. normalize debug messages

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/mei/interface.h
drivers/staging/mei/wd.c

index f934b094085a820929ddbbc209f8fd5d8a85138e..0d0043575a2a33b9c37a455eb9983e91b6b41b86 100644 (file)
@@ -51,7 +51,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
 
 int mei_wd_send(struct mei_device *dev);
 int mei_wd_stop(struct mei_device *dev, bool preserve);
-bool mei_wd_host_init(struct mei_device *dev);
+int mei_wd_host_init(struct mei_device *dev);
 /*
  * mei_watchdog_register  - Registering watchdog interface
  *   once we got connection to the WD Client
index 57a1642b964b7ccc16045242f72ef4d270a4300e..032cf6766de59b2f79f014509fc50bab503b7995 100644 (file)
@@ -56,11 +56,11 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
  * host_init_wd - mei initialization wd.
  *
  * @dev: the device structure
+ * returns -ENENT if wd client cannot be found
+ *         -EIO if write has failed
  */
-bool mei_wd_host_init(struct mei_device *dev)
+int 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 */
@@ -71,25 +71,21 @@ bool mei_wd_host_init(struct mei_device *dev)
        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;
+       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;
        }
 
-end:
-       return ret;
+       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;
 }
 
 /**