Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomas Winkler and committed by
Greg Kroah-Hartman
39db74ce 787d6182

+19 -21
+14 -16
drivers/misc/mei/bus.c
··· 224 224 } 225 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 228 bool blocking) 229 229 { 230 230 struct mei_device *dev; 231 231 struct mei_me_client *me_cl; 232 232 struct mei_cl_cb *cb; 233 - int rets; 233 + ssize_t rets; 234 234 235 235 if (WARN_ON(!cl || !cl->dev)) 236 236 return -ENODEV; ··· 271 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 276 struct mei_device *dev; 277 277 struct mei_cl_cb *cb; 278 278 size_t r_length; 279 - int err; 279 + ssize_t rets; 280 280 281 281 if (WARN_ON(!cl || !cl->dev)) 282 282 return -ENODEV; ··· 286 286 mutex_lock(&dev->device_lock); 287 287 288 288 if (!cl->read_cb) { 289 - err = mei_cl_read_start(cl, length); 290 - if (err < 0) { 291 - mutex_unlock(&dev->device_lock); 292 - return err; 293 - } 289 + rets = mei_cl_read_start(cl, length); 290 + if (rets < 0) 291 + goto out; 294 292 } 295 293 296 294 if (cl->reading_state != MEI_READ_COMPLETE && ··· 311 313 cb = cl->read_cb; 312 314 313 315 if (cl->reading_state != MEI_READ_COMPLETE) { 314 - r_length = 0; 316 + rets = 0; 315 317 goto out; 316 318 } 317 319 318 320 r_length = min_t(size_t, length, cb->buf_idx); 319 - 320 321 memcpy(buf, cb->response_buffer.data, r_length); 322 + rets = r_length; 321 323 322 324 mei_io_cb_free(cb); 323 325 cl->reading_state = MEI_IDLE; ··· 326 328 out: 327 329 mutex_unlock(&dev->device_lock); 328 330 329 - return r_length; 331 + return rets; 330 332 } 331 333 332 - inline int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) 334 + inline ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) 333 335 { 334 336 return ___mei_cl_send(cl, buf, length, 0); 335 337 } 336 338 337 - inline int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) 339 + inline ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) 338 340 { 339 341 return ___mei_cl_send(cl, buf, length, 1); 340 342 } 341 343 342 - int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) 344 + ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) 343 345 { 344 346 struct mei_cl *cl = device->cl; 345 347 ··· 353 355 } 354 356 EXPORT_SYMBOL_GPL(mei_cl_send); 355 357 356 - int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) 358 + ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) 357 359 { 358 360 struct mei_cl *cl = device->cl; 359 361
+3 -3
drivers/misc/mei/mei_dev.h
··· 345 345 struct mei_cl_ops *ops); 346 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); 349 - int __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); 348 + ssize_t __mei_cl_async_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 + ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); 351 351 void mei_cl_bus_rx_event(struct mei_cl *cl); 352 352 void mei_cl_bus_remove_devices(struct mei_device *dev); 353 353 int mei_cl_bus_init(void);
+2 -2
include/linux/mei_cl_bus.h
··· 25 25 26 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); 29 - int mei_cl_recv(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 + ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); 30 30 31 31 typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, 32 32 u32 events, void *context);