[PATCH linux dev-4.7 v3 1/2] drivers/fsi: Move common read/write code into shared utility

Joel Stanley joel at jms.id.au
Fri Feb 24 11:33:04 AEDT 2017


Hi Eddie,

On Fri, Feb 24, 2017 at 7:27 AM, Eddie James <eajames at linux.vnet.ibm.com> wrote:
> Looks good.
>
> Acked-by: Eddie James <eajames at linux.vnet.ibm.com>

Please don't top post on the mailing list.

Cheers,

Joel

>
>
> On 02/23/2017 01:58 PM, Christopher Bostic wrote:
>>
>> Move common code shared between fsi_master_gpio_read/write into
>> send utility.
>>
>> Signed-off-by: Christopher Bostic <cbostic at linux.vnet.ibm.com>
>>
>> ---
>>
>> v2 - Separate this patch from a collection of other changes in the
>>       v1 related patch.
>> ---
>>   drivers/fsi/fsi-master-gpio.c | 38
>> ++++++++++++++++++--------------------
>>   1 file changed, 18 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
>> index 8c8a8f4..b6feec1 100644
>> --- a/drivers/fsi/fsi-master-gpio.c
>> +++ b/drivers/fsi/fsi-master-gpio.c
>> @@ -354,26 +354,33 @@ static void build_abs_ar_command(struct fsi_gpio_msg
>> *cmd, uint64_t mode,
>>         cmd->msg >>= (64 - cmd->bits);
>>   }
>>
>> +static int send_command(struct fsi_master_gpio *master,
>> +                       struct fsi_gpio_msg *cmd, uint8_t expected,
>> +                       size_t size, void *val)
>> +{
>> +       unsigned long flags;
>> +       int rc;
>> +
>> +       spin_lock_irqsave(&fsi_gpio_cmd_lock, flags);
>> +       serial_out(master, cmd);
>> +       echo_delay(master);
>> +       rc = poll_for_response(master, expected, size, val);
>> +       spin_unlock_irqrestore(&fsi_gpio_cmd_lock, flags);
>> +
>> +       return rc;
>> +}
>> +
>>   static int fsi_master_gpio_read(struct fsi_master *_master, int link,
>>                 uint8_t slave, uint32_t addr, void *val, size_t size)
>>   {
>>         struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
>>         struct fsi_gpio_msg cmd;
>> -       int rc;
>> -       unsigned long flags;
>>
>>         if (link != 0)
>>                 return -ENODEV;
>>
>>         build_abs_ar_command(&cmd, FSI_GPIO_CMD_READ, slave, addr, size,
>> NULL);
>> -
>> -       spin_lock_irqsave(&fsi_gpio_cmd_lock, flags);
>> -       serial_out(master, &cmd);
>> -       echo_delay(master);
>> -       rc = poll_for_response(master, FSI_GPIO_RESP_ACKD, size, val);
>> -       spin_unlock_irqrestore(&fsi_gpio_cmd_lock, flags);
>> -
>> -       return rc;
>> +       return send_command(master, &cmd, FSI_GPIO_RESP_ACKD, size, val);
>>   }
>>
>>   static int fsi_master_gpio_write(struct fsi_master *_master, int link,
>> @@ -381,21 +388,12 @@ static int fsi_master_gpio_write(struct fsi_master
>> *_master, int link,
>>   {
>>         struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
>>         struct fsi_gpio_msg cmd;
>> -       int rc;
>> -       unsigned long flags;
>>
>>         if (link != 0)
>>                 return -ENODEV;
>>
>>         build_abs_ar_command(&cmd, FSI_GPIO_CMD_WRITE, slave, addr, size,
>> val);
>> -
>> -       spin_lock_irqsave(&fsi_gpio_cmd_lock, flags);
>> -       serial_out(master, &cmd);
>> -       echo_delay(master);
>> -       rc = poll_for_response(master, FSI_GPIO_RESP_ACK, size, NULL);
>> -       spin_unlock_irqrestore(&fsi_gpio_cmd_lock, flags);
>> -
>> -       return rc;
>> +       return send_command(master, &cmd, FSI_GPIO_RESP_ACK, size, NULL);
>>   }
>>
>>   /*
>
>


More information about the openbmc mailing list