[PATCH linux dev-4.10 v3 22/31] drivers: fsi: occ: fix white space and bracket problems
Andrew Jeffery
andrew at aj.id.au
Fri Oct 6 10:11:58 AEDT 2017
On Thu, 2017-10-05 at 14:24 -0500, Eddie James wrote:
> From: "Edward A. James" <eajames at us.ibm.com>
>
> For better flow and to meet Linux standards.
>
> Signed-off-by: Edward A. James <eajames at us.ibm.com>
> ---
> drivers/fsi/occ.c | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
> index 4e677c6..f27345c 100644
> --- a/drivers/fsi/occ.c
> +++ b/drivers/fsi/occ.c
> @@ -132,9 +132,8 @@ static void occ_enqueue_xfr(struct occ_xfr *xfr)
>
> static struct occ_client *occ_open_common(struct occ *occ, unsigned long flags)
> {
> - struct occ_client *client;
> + struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
>
> - client = kzalloc(sizeof(*client), GFP_KERNEL);
> if (!client)
> return NULL;
>
> @@ -180,8 +179,9 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
> if (client->read_offset) {
> rc = 0;
> client->read_offset = 0;
> - } else
> + } else {
> rc = -ENOMSG;
> + }
>
> goto done;
> }
> @@ -197,8 +197,10 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
> spin_unlock_irq(&client->lock);
>
> rc = wait_event_interruptible(client->wait,
> - test_bit(XFR_COMPLETE, &xfr->flags) ||
> - test_bit(XFR_CANCELED, &xfr->flags));
> + test_bit(XFR_COMPLETE,
> + &xfr->flags) ||
> + test_bit(XFR_CANCELED,
> + &xfr->flags));
This looks worse. Maybe it's worth pulling the condition out into a helper
function?
>
> spin_lock_irq(&client->lock);
>
> @@ -222,12 +224,14 @@ static ssize_t occ_read_common(struct occ_client *client, char __user *ubuf,
>
> bytes = min(len, xfr->resp_data_length - client->read_offset);
> if (ubuf) {
> - if (copy_to_user(ubuf, &xfr->buf[client->read_offset], bytes)) {
> + if (copy_to_user(ubuf, &xfr->buf[client->read_offset],
> + bytes)) {
> rc = -EFAULT;
> goto done;
> }
> - } else
> + } else {
> memcpy(kbuf, &xfr->buf[client->read_offset], bytes);
> + }
>
> client->read_offset += bytes;
>
> @@ -263,6 +267,7 @@ static ssize_t occ_write_common(struct occ_client *client,
> return -EINVAL;
>
> spin_lock_irq(&client->lock);
> +
> if (test_and_set_bit(CLIENT_XFR_PENDING, &client->flags)) {
> rc = -EBUSY;
> goto done;
> @@ -270,7 +275,6 @@ static ssize_t occ_write_common(struct occ_client *client,
>
> /* clear out the transfer */
> memset(xfr, 0, sizeof(*xfr));
> -
> xfr->buf[0] = 1;
>
> if (ubuf) {
> @@ -278,8 +282,9 @@ static ssize_t occ_write_common(struct occ_client *client,
> rc = -EFAULT;
> goto done;
> }
> - } else
> + } else {
> memcpy(&xfr->buf[1], kbuf, len);
> + }
>
> data_length = (xfr->buf[2] << 8) + xfr->buf[3];
> if (data_length > OCC_CMD_DATA_BYTES) {
> @@ -430,7 +435,7 @@ static int occ_getsram(struct device *sbefifo, u32 address, u8 *data,
> rc = occ_write_sbefifo(client, (const char *)buf, sizeof(buf));
> if (rc)
> goto done;
> -
> +
> resp = kzalloc(data_len, GFP_KERNEL);
> if (!resp) {
> rc = -ENOMEM;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20171006/7f742e28/attachment.sig>
More information about the openbmc
mailing list