提交 39db74ce 编写于 作者: T Tomas Winkler 提交者: Greg Kroah-Hartman

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: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 787d6182
...@@ -224,13 +224,13 @@ void mei_cl_driver_unregister(struct mei_cl_driver *driver) ...@@ -224,13 +224,13 @@ void mei_cl_driver_unregister(struct mei_cl_driver *driver)
} }
EXPORT_SYMBOL_GPL(mei_cl_driver_unregister); EXPORT_SYMBOL_GPL(mei_cl_driver_unregister);
static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, static ssize_t ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
bool blocking) bool blocking)
{ {
struct mei_device *dev; struct mei_device *dev;
struct mei_me_client *me_cl; struct mei_me_client *me_cl;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
int rets; ssize_t rets;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return -ENODEV; return -ENODEV;
...@@ -271,12 +271,12 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, ...@@ -271,12 +271,12 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
return rets; return rets;
} }
int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
{ {
struct mei_device *dev; struct mei_device *dev;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
size_t r_length; size_t r_length;
int err; ssize_t rets;
if (WARN_ON(!cl || !cl->dev)) if (WARN_ON(!cl || !cl->dev))
return -ENODEV; return -ENODEV;
...@@ -286,11 +286,9 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) ...@@ -286,11 +286,9 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
if (!cl->read_cb) { if (!cl->read_cb) {
err = mei_cl_read_start(cl, length); rets = mei_cl_read_start(cl, length);
if (err < 0) { if (rets < 0)
mutex_unlock(&dev->device_lock); goto out;
return err;
}
} }
if (cl->reading_state != MEI_READ_COMPLETE && 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,13 +311,13 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
cb = cl->read_cb; cb = cl->read_cb;
if (cl->reading_state != MEI_READ_COMPLETE) { if (cl->reading_state != MEI_READ_COMPLETE) {
r_length = 0; rets = 0;
goto out; goto out;
} }
r_length = min_t(size_t, length, cb->buf_idx); r_length = min_t(size_t, length, cb->buf_idx);
memcpy(buf, cb->response_buffer.data, r_length); memcpy(buf, cb->response_buffer.data, r_length);
rets = r_length;
mei_io_cb_free(cb); mei_io_cb_free(cb);
cl->reading_state = MEI_IDLE; cl->reading_state = MEI_IDLE;
...@@ -328,20 +326,20 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length) ...@@ -328,20 +326,20 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
out: out:
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
return r_length; return rets;
} }
inline int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length) inline ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length)
{ {
return ___mei_cl_send(cl, buf, length, 0); return ___mei_cl_send(cl, buf, length, 0);
} }
inline int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length) inline ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length)
{ {
return ___mei_cl_send(cl, buf, length, 1); return ___mei_cl_send(cl, buf, length, 1);
} }
int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length)
{ {
struct mei_cl *cl = device->cl; struct mei_cl *cl = device->cl;
...@@ -355,7 +353,7 @@ int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length) ...@@ -355,7 +353,7 @@ int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length)
} }
EXPORT_SYMBOL_GPL(mei_cl_send); EXPORT_SYMBOL_GPL(mei_cl_send);
int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length) ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length)
{ {
struct mei_cl *cl = device->cl; struct mei_cl *cl = device->cl;
......
...@@ -345,9 +345,9 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev, ...@@ -345,9 +345,9 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
struct mei_cl_ops *ops); struct mei_cl_ops *ops);
void mei_cl_remove_device(struct mei_cl_device *device); void mei_cl_remove_device(struct mei_cl_device *device);
int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length); ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length);
int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length); ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length);
int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
void mei_cl_bus_rx_event(struct mei_cl *cl); void mei_cl_bus_rx_event(struct mei_cl *cl);
void mei_cl_bus_remove_devices(struct mei_device *dev); void mei_cl_bus_remove_devices(struct mei_device *dev);
int mei_cl_bus_init(void); int mei_cl_bus_init(void);
......
...@@ -25,8 +25,8 @@ int __mei_cl_driver_register(struct mei_cl_driver *driver, ...@@ -25,8 +25,8 @@ int __mei_cl_driver_register(struct mei_cl_driver *driver,
void mei_cl_driver_unregister(struct mei_cl_driver *driver); void mei_cl_driver_unregister(struct mei_cl_driver *driver);
int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length); ssize_t mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length);
int mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length); ssize_t mei_cl_recv(struct mei_cl_device *device, u8 *buf, size_t length);
typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device, typedef void (*mei_cl_event_cb_t)(struct mei_cl_device *device,
u32 events, void *context); u32 events, void *context);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册