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>
This commit is contained in:
parent
787d618225
commit
39db74ce1a
3 changed files with 19 additions and 21 deletions
|
@ -224,13 +224,13 @@ void mei_cl_driver_unregister(struct mei_cl_driver *driver)
|
|||
}
|
||||
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)
|
||||
{
|
||||
struct mei_device *dev;
|
||||
struct mei_me_client *me_cl;
|
||||
struct mei_cl_cb *cb;
|
||||
int rets;
|
||||
ssize_t rets;
|
||||
|
||||
if (WARN_ON(!cl || !cl->dev))
|
||||
return -ENODEV;
|
||||
|
@ -271,12 +271,12 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
|
|||
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_cl_cb *cb;
|
||||
size_t r_length;
|
||||
int err;
|
||||
ssize_t rets;
|
||||
|
||||
if (WARN_ON(!cl || !cl->dev))
|
||||
return -ENODEV;
|
||||
|
@ -286,11 +286,9 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
|
|||
mutex_lock(&dev->device_lock);
|
||||
|
||||
if (!cl->read_cb) {
|
||||
err = mei_cl_read_start(cl, length);
|
||||
if (err < 0) {
|
||||
mutex_unlock(&dev->device_lock);
|
||||
return err;
|
||||
}
|
||||
rets = mei_cl_read_start(cl, length);
|
||||
if (rets < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cl->reading_state != MEI_READ_COMPLETE &&
|
||||
|
@ -313,13 +311,13 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
|
|||
cb = cl->read_cb;
|
||||
|
||||
if (cl->reading_state != MEI_READ_COMPLETE) {
|
||||
r_length = 0;
|
||||
rets = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
r_length = min_t(size_t, length, cb->buf_idx);
|
||||
|
||||
memcpy(buf, cb->response_buffer.data, r_length);
|
||||
rets = r_length;
|
||||
|
||||
mei_io_cb_free(cb);
|
||||
cl->reading_state = MEI_IDLE;
|
||||
|
@ -328,20 +326,20 @@ int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length)
|
|||
out:
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -355,7 +353,7 @@ int mei_cl_send(struct mei_cl_device *device, u8 *buf, size_t length)
|
|||
}
|
||||
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;
|
||||
|
||||
|
|
|
@ -345,9 +345,9 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
|
|||
struct mei_cl_ops *ops);
|
||||
void mei_cl_remove_device(struct mei_cl_device *device);
|
||||
|
||||
int __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);
|
||||
int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
|
||||
ssize_t __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length);
|
||||
ssize_t __mei_cl_send(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_remove_devices(struct mei_device *dev);
|
||||
int mei_cl_bus_init(void);
|
||||
|
|
|
@ -25,8 +25,8 @@ int __mei_cl_driver_register(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);
|
||||
int mei_cl_recv(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);
|
||||
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,
|
||||
u32 events, void *context);
|
||||
|
|
Loading…
Reference in a new issue