diff options
| author | Tomas Winkler <tomas.winkler@intel.com> | 2015-03-26 18:27:58 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-04-03 10:18:56 -0400 |
| commit | f3de9b635d93a3d268adda428e1df94091506a42 (patch) | |
| tree | 6b58047776ca5c84302360cc82ca5c874ef0528c /drivers/misc | |
| parent | 1d9013f09203c694e2cba478b05afc6484d55180 (diff) | |
mei: use mei_cl_is_connected consistently
Replace open coded check for cl->state !=/== MEI_FILE_CONNECTED
with mei_cl_is_connected function.
Note that cl->state != MEI_FILE_CONNECTED is not the same
as cl->state == MEI_FILE_DISCONNECTED
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
| -rw-r--r-- | drivers/misc/mei/bus.c | 4 | ||||
| -rw-r--r-- | drivers/misc/mei/client.c | 2 | ||||
| -rw-r--r-- | drivers/misc/mei/interrupt.c | 2 | ||||
| -rw-r--r-- | drivers/misc/mei/main.c | 13 | ||||
| -rw-r--r-- | drivers/misc/mei/wd.c | 18 |
5 files changed, 22 insertions, 17 deletions
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 45896f95fed1..b724a67696fc 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
| @@ -238,7 +238,7 @@ static ssize_t ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, | |||
| 238 | dev = cl->dev; | 238 | dev = cl->dev; |
| 239 | 239 | ||
| 240 | mutex_lock(&dev->device_lock); | 240 | mutex_lock(&dev->device_lock); |
| 241 | if (cl->state != MEI_FILE_CONNECTED) { | 241 | if (!mei_cl_is_connected(cl)) { |
| 242 | rets = -ENODEV; | 242 | rets = -ENODEV; |
| 243 | goto out; | 243 | goto out; |
| 244 | } | 244 | } |
| @@ -474,7 +474,7 @@ int mei_cl_disable_device(struct mei_cl_device *device) | |||
| 474 | 474 | ||
| 475 | mutex_lock(&dev->device_lock); | 475 | mutex_lock(&dev->device_lock); |
| 476 | 476 | ||
| 477 | if (cl->state != MEI_FILE_CONNECTED) { | 477 | if (!mei_cl_is_connected(cl)) { |
| 478 | dev_err(dev->dev, "Already disconnected"); | 478 | dev_err(dev->dev, "Already disconnected"); |
| 479 | err = 0; | 479 | err = 0; |
| 480 | goto out; | 480 | goto out; |
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index e5aeb6fd1ba4..1e99ef6a54a2 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
| @@ -876,7 +876,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file) | |||
| 876 | mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); | 876 | mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT)); |
| 877 | mutex_lock(&dev->device_lock); | 877 | mutex_lock(&dev->device_lock); |
| 878 | 878 | ||
| 879 | if (cl->state != MEI_FILE_CONNECTED) { | 879 | if (!mei_cl_is_connected(cl)) { |
| 880 | cl->state = MEI_FILE_DISCONNECTED; | 880 | cl->state = MEI_FILE_DISCONNECTED; |
| 881 | /* something went really wrong */ | 881 | /* something went really wrong */ |
| 882 | if (!cl->status) | 882 | if (!cl->status) |
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c index 3f23629759db..3f84d2edcde4 100644 --- a/drivers/misc/mei/interrupt.c +++ b/drivers/misc/mei/interrupt.c | |||
| @@ -110,7 +110,7 @@ int mei_cl_irq_read_msg(struct mei_cl *cl, | |||
| 110 | goto out; | 110 | goto out; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | if (cl->state != MEI_FILE_CONNECTED) { | 113 | if (!mei_cl_is_connected(cl)) { |
| 114 | cl_dbg(dev, cl, "not connected\n"); | 114 | cl_dbg(dev, cl, "not connected\n"); |
| 115 | cb->status = -ENODEV; | 115 | cb->status = -ENODEV; |
| 116 | goto out; | 116 | goto out; |
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index a1ec45054988..29fa88b6fa17 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c | |||
| @@ -107,7 +107,7 @@ static int mei_release(struct inode *inode, struct file *file) | |||
| 107 | rets = mei_amthif_release(dev, file); | 107 | rets = mei_amthif_release(dev, file); |
| 108 | goto out; | 108 | goto out; |
| 109 | } | 109 | } |
| 110 | if (cl->state == MEI_FILE_CONNECTED) { | 110 | if (mei_cl_is_connected(cl)) { |
| 111 | cl->state = MEI_FILE_DISCONNECTING; | 111 | cl->state = MEI_FILE_DISCONNECTING; |
| 112 | cl_dbg(dev, cl, "disconnecting\n"); | 112 | cl_dbg(dev, cl, "disconnecting\n"); |
| 113 | rets = mei_cl_disconnect(cl); | 113 | rets = mei_cl_disconnect(cl); |
| @@ -309,9 +309,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, | |||
| 309 | goto out; | 309 | goto out; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | if (cl->state != MEI_FILE_CONNECTED) { | 312 | if (!mei_cl_is_connected(cl)) { |
| 313 | dev_err(dev->dev, "host client = %d, is not connected to ME client = %d", | 313 | cl_err(dev, cl, "is not connected"); |
| 314 | cl->host_client_id, cl->me_client_id); | ||
| 315 | rets = -ENODEV; | 314 | rets = -ENODEV; |
| 316 | goto out; | 315 | goto out; |
| 317 | } | 316 | } |
| @@ -418,7 +417,7 @@ static int mei_ioctl_connect_client(struct file *file, | |||
| 418 | */ | 417 | */ |
| 419 | if (uuid_le_cmp(data->in_client_uuid, mei_amthif_guid) == 0) { | 418 | if (uuid_le_cmp(data->in_client_uuid, mei_amthif_guid) == 0) { |
| 420 | dev_dbg(dev->dev, "FW Client is amthi\n"); | 419 | dev_dbg(dev->dev, "FW Client is amthi\n"); |
| 421 | if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) { | 420 | if (!mei_cl_is_connected(&dev->iamthif_cl)) { |
| 422 | rets = -ENODEV; | 421 | rets = -ENODEV; |
| 423 | goto end; | 422 | goto end; |
| 424 | } | 423 | } |
| @@ -554,7 +553,9 @@ static unsigned int mei_poll(struct file *file, poll_table *wait) | |||
| 554 | 553 | ||
| 555 | mutex_lock(&dev->device_lock); | 554 | mutex_lock(&dev->device_lock); |
| 556 | 555 | ||
| 557 | if (!mei_cl_is_connected(cl)) { | 556 | |
| 557 | if (dev->dev_state != MEI_DEV_ENABLED || | ||
| 558 | !mei_cl_is_connected(cl)) { | ||
| 558 | mask = POLLERR; | 559 | mask = POLLERR; |
| 559 | goto out; | 560 | goto out; |
| 560 | } | 561 | } |
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c index ac1e6235692d..2725f865c3d6 100644 --- a/drivers/misc/mei/wd.c +++ b/drivers/misc/mei/wd.c | |||
| @@ -160,9 +160,10 @@ int mei_wd_send(struct mei_device *dev) | |||
| 160 | */ | 160 | */ |
| 161 | int mei_wd_stop(struct mei_device *dev) | 161 | int mei_wd_stop(struct mei_device *dev) |
| 162 | { | 162 | { |
| 163 | struct mei_cl *cl = &dev->wd_cl; | ||
| 163 | int ret; | 164 | int ret; |
| 164 | 165 | ||
| 165 | if (dev->wd_cl.state != MEI_FILE_CONNECTED || | 166 | if (!mei_cl_is_connected(cl) || |
| 166 | dev->wd_state != MEI_WD_RUNNING) | 167 | dev->wd_state != MEI_WD_RUNNING) |
| 167 | return 0; | 168 | return 0; |
| 168 | 169 | ||
| @@ -170,7 +171,7 @@ int mei_wd_stop(struct mei_device *dev) | |||
| 170 | 171 | ||
| 171 | dev->wd_state = MEI_WD_STOPPING; | 172 | dev->wd_state = MEI_WD_STOPPING; |
| 172 | 173 | ||
| 173 | ret = mei_cl_flow_ctrl_creds(&dev->wd_cl); | 174 | ret = mei_cl_flow_ctrl_creds(cl); |
| 174 | if (ret < 0) | 175 | if (ret < 0) |
| 175 | goto err; | 176 | goto err; |
| 176 | 177 | ||
| @@ -211,13 +212,16 @@ err: | |||
| 211 | */ | 212 | */ |
| 212 | static int mei_wd_ops_start(struct watchdog_device *wd_dev) | 213 | static int mei_wd_ops_start(struct watchdog_device *wd_dev) |
| 213 | { | 214 | { |
| 214 | int err = -ENODEV; | ||
| 215 | struct mei_device *dev; | 215 | struct mei_device *dev; |
| 216 | struct mei_cl *cl; | ||
| 217 | int err = -ENODEV; | ||
| 216 | 218 | ||
| 217 | dev = watchdog_get_drvdata(wd_dev); | 219 | dev = watchdog_get_drvdata(wd_dev); |
| 218 | if (!dev) | 220 | if (!dev) |
| 219 | return -ENODEV; | 221 | return -ENODEV; |
| 220 | 222 | ||
| 223 | cl = &dev->wd_cl; | ||
| 224 | |||
| 221 | mutex_lock(&dev->device_lock); | 225 | mutex_lock(&dev->device_lock); |
| 222 | 226 | ||
| 223 | if (dev->dev_state != MEI_DEV_ENABLED) { | 227 | if (dev->dev_state != MEI_DEV_ENABLED) { |
| @@ -226,8 +230,8 @@ static int mei_wd_ops_start(struct watchdog_device *wd_dev) | |||
| 226 | goto end_unlock; | 230 | goto end_unlock; |
| 227 | } | 231 | } |
| 228 | 232 | ||
| 229 | if (dev->wd_cl.state != MEI_FILE_CONNECTED) { | 233 | if (!mei_cl_is_connected(cl)) { |
| 230 | dev_dbg(dev->dev, "MEI Driver is not connected to Watchdog Client\n"); | 234 | cl_dbg(dev, cl, "MEI Driver is not connected to Watchdog Client\n"); |
| 231 | goto end_unlock; | 235 | goto end_unlock; |
| 232 | } | 236 | } |
| 233 | 237 | ||
| @@ -282,8 +286,8 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) | |||
| 282 | 286 | ||
| 283 | mutex_lock(&dev->device_lock); | 287 | mutex_lock(&dev->device_lock); |
| 284 | 288 | ||
| 285 | if (cl->state != MEI_FILE_CONNECTED) { | 289 | if (!mei_cl_is_connected(cl)) { |
| 286 | dev_err(dev->dev, "wd: not connected.\n"); | 290 | cl_err(dev, cl, "wd: not connected.\n"); |
| 287 | ret = -ENODEV; | 291 | ret = -ENODEV; |
| 288 | goto end; | 292 | goto end; |
| 289 | } | 293 | } |
