diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2014-11-27 07:07:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-01-12 08:04:10 -0500 |
commit | 39db74ce1aa83626a0a70ed2abf29a17598fff49 (patch) | |
tree | 3e57345e0161df14173ed443d9a1110c09a8627f | |
parent | 787d61822525295399f97390bca3e1bb4ce7a6b3 (diff) |
mei: bus: use ssize_t as the return type for send and receive
Mei bus receive and send function may return either number
of transmitted bytes or errno. It is better to use ssize_t
type for that purpose that mixing size_t with int.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/mei/bus.c | 30 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 6 | ||||
-rw-r--r-- | include/linux/mei_cl_bus.h | 4 |
3 files changed, 19 insertions, 21 deletions
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index b3a72bca5242..31164dd14bd0 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
@@ -224,13 +224,13 @@ void mei_cl_driver_unregister(struct mei_cl_driver *driver) | |||
224 | } | 224 | } |
225 | EXPORT_SYMBOL_GPL(mei_cl_driver_unregister); | 225 | EXPORT_SYMBOL_GPL(mei_cl_driver_unregister); |
226 | 226 | ||
227 | static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, | 227 | static ssize_t ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, |
228 | bool blocking) | 228 | bool blocking) |
229 | { | 229 | { |
230 | struct mei_device *dev; | 230 | struct mei_device *dev; |
231 | struct mei_me_client *me_cl; | 231 | struct mei_me_client *me_cl; |
232 | struct mei_cl_cb *cb; | 232 | struct mei_cl_cb *cb; |
233 | int rets; | 233 | ssize_t rets; |
234 | 234 | ||
235 | if (WARN_ON(!cl || !cl->dev)) | 235 | if (WARN_ON(!cl || !cl->dev)) |
236 | return -ENODEV; | 236 | return -ENODEV; |
@@ -271,12 +271,12 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, | |||
271 | return rets; | 271 | return rets; |
272 | } | 272 | } |
273 | 273 | ||
274 | int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) | 274 | ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) |
275 | { | 275 | { |
276 | struct mei_device *dev; | 276 | struct mei_device *dev; |
277 | struct mei_cl_cb *cb; | 277 | struct mei_cl_cb *cb; |
278 | size_t r_length; | 278 | size_t r_length; |
279 | int err; | 279 | ssize_t rets; |
280 | 280 | ||
281 | if (WARN_ON(!cl || !cl->dev)) | 281 | if (WARN_ON(!cl || !cl->dev)) |
282 | return -ENODEV; | 282 | return -ENODEV; |
@@ -286,11 +286,9 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) | |||
286 | mutex_lock(&dev->device_lock); | 286 | mutex_lock(&dev->device_lock); |
287 | 287 | ||
288 | if (!cl->read_cb) { | 288 | if (!cl->read_cb) { |
289 | err = mei_cl_read_start(cl, length); | 289 | rets = mei_cl_read_start(cl, length); |
290 | if (err < 0) { | 290 | if (rets < 0) |
291 | mutex_unlock(&dev->device_lock); | 291 | goto out; |
292 | return err; | ||
293 | } | ||
294 | } | 292 | } |
295 | 293 | ||
296 | if (cl->reading_state != MEI_READ_COMPLETE && | 294 | if (cl->reading_state != MEI_READ_COMPLETE && |
@@ -313,13 +311,13 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) | |||
313 | cb = cl->read_cb; | 311 | cb = cl->read_cb; |
314 | 312 | ||
315 | if (cl->reading_state != MEI_READ_COMPLETE) { | 313 | if (cl->reading_state != MEI_READ_COMPLETE) { |
316 | r_length = 0; | 314 | rets = 0; |
317 | goto out; | 315 | goto out; |
318 | } | 316 | } |
319 | 317 | ||
320 | r_length = min_t(size_t, length, cb->buf_idx); | 318 | r_length = min_t(size_t, length, cb->buf_idx); |
321 | |||
322 | memcpy(buf, cb->response_buffer.data, r_length); | 319 | memcpy(buf, cb->response_buffer.data, r_length); |
320 | rets = r_length; | ||
323 | 321 | ||
324 | mei_io_cb_free(cb); | 322 | mei_io_cb_free(cb); |
325 | cl->reading_state = MEI_IDLE; | 323 | cl->reading_state = MEI_IDLE; |
@@ -328,20 +326,20 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) | |||
328 | out: | 326 | out: |
329 | mutex_unlock(&dev->device_lock); | 327 | mutex_unlock(&dev->device_lock); |
330 | 328 | ||
331 | return r_length; | 329 | return rets; |
332 | } | 330 | } |
333 | 331 | ||
334 | inline int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) | 332 | inline ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) |
335 | { | 333 | { |
336 | return ___mei_cl_send(cl, buf, length, 0); | 334 | return ___mei_cl_send(cl, buf, length, 0); |
337 | } | 335 | } |
338 | 336 | ||
339 | inline int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) | 337 | inline ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) |
340 | { | 338 | { |
341 | return ___mei_cl_send(cl, buf, length, 1); | 339 | return ___mei_cl_send(cl, buf, length, 1); |
342 | } | 340 | } |
343 | 341 | ||
344 | int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) | 342 | ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) |
345 | { | 343 | { |
346 | struct mei_cl *cl = device->cl; | 344 | struct mei_cl *cl = device->cl; |
347 | 345 | ||
@@ -355,7 +353,7 @@ int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) | |||
355 | } | 353 | } |
356 | EXPORT_SYMBOL_GPL(mei_cl_send); | 354 | EXPORT_SYMBOL_GPL(mei_cl_send); |
357 | 355 | ||
358 | int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) | 356 | ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) |
359 | { | 357 | { |
360 | struct mei_cl *cl = device->cl; | 358 | struct mei_cl *cl = device->cl; |
361 | 359 | ||
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 3dad74a8d496..7f350af2ee10 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -345,9 +345,9 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev, | |||
345 | struct mei_cl_ops *ops); | 345 | struct mei_cl_ops *ops); |
346 | void mei_cl_remove_device(struct mei_cl_device *device); | 346 | void mei_cl_remove_device(struct mei_cl_device *device); |
347 | 347 | ||
348 | int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length); | 348 | ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length); |
349 | int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length); | 349 | ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length); |
350 | int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); | 350 | ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); |
351 | void mei_cl_bus_rx_event(struct mei_cl *cl); | 351 | void mei_cl_bus_rx_event(struct mei_cl *cl); |
352 | void mei_cl_bus_remove_devices(struct mei_device *dev); | 352 | void mei_cl_bus_remove_devices(struct mei_device *dev); |
353 | int mei_cl_bus_init(void); | 353 | int mei_cl_bus_init(void); |
diff --git a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h index 164aad1f9f12..0819d36a3a74 100644 --- a/include/linux/mei_cl_bus.h +++ b/include/linux/mei_cl_bus.h | |||
@@ -25,8 +25,8 @@ int __mei_cl_driver_register(struct mei_cl_driver *driver, | |||
25 | 25 | ||
26 | void mei_cl_driver_unregister(struct mei_cl_driver *driver); | 26 | void mei_cl_driver_unregister(struct mei_cl_driver *driver); |
27 | 27 | ||
28 | int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length); | 28 | ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length); |
29 | int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); | 29 | ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); |
30 | 30 | ||
31 | typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, | 31 | typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, |
32 | u32 events, void *context); | 32 | u32 events, void *context); |