[PATCH V2 2/5] spi: core: add spi_replace_transfers method

Martin Sperl kernel at martin.sperl.org
Fri Dec 11 08:04:23 PST 2015


> On 11.12.2015, at 15:37, Andy Shevchenko <andy.shevchenko at gmail.com> wrote:
> 
> On Mon, Dec 7, 2015 at 5:21 PM,  <kernel at martin.sperl.org> wrote:
>> +/* Core methods for spi_message alterations */
>> +
>> +static void __spi_replace_transfers_release(struct spi_master *master,
>> +                                           struct spi_message *msg,
>> +                                           void *res)
>> +{
>> +       struct spi_replaced_transfers *srt = res;
> 
> srt sounds magic
> rxfer might be better?
srt = Spi_Replaced_Transfer - if you like rxfer better I can replace it.

> 
>> +       int i;
> 
> unsigned int i; or size_t to be in align with inserted field.
will do.

>> +       int i;
> 
> Ditto.
> 
>> +
>> +       /* allocate the structure using spi_res */
>> +       srt = spi_res_alloc(msg->spi, __spi_replace_transfers_release,
>> +                           insert * sizeof(struct spi_transfer)
>> +                           + sizeof(struct spi_replaced_transfers)
>> +                           + extradatasize,
>> +                           0);
>> +       if (!srt)
>> +               return NULL;
> 
> ERR_PTR for this API seems better to have.
Can do that.

>> +       srt->inserted = insert;
>> +       for (i = insert - 1; i >= 0 ; i--) {
> 
> This is classical pattern for
> 
> while (--insert >= 0) {
> }
did it slightly differently as size_t is always >= 0 - 
the main reason for using int here...

Martin





More information about the linux-rpi-kernel mailing list