[PATCH 1/3] spi: added spi_resource management
kernel at martin.sperl.org
Tue Dec 1 23:30:51 PST 2015
> On 01.12.2015, at 22:04, Mark Brown <broonie at kernel.org> wrote:
>> On Mon, Nov 30, 2015 at 01:04:52PM +0000, kernel at martin.sperl.org wrote:
>> +static struct spi_res *__spi_res_alloc(struct spi_device *spi,
>> + spi_res_release_t release,
>> + size_t size,
>> + gfp_t gfp)
> This has exactly one (tiny) user. Why is it a separate function?
Readability, mimicking devres code and the option of adding
object caching/reuse here later...
There is a much higher likelihood that spi_resources will be
allocated and then freed several times per second, so this
can save cpu cycles and avoid locks...
>> + sres = kzalloc(tot_size, gfp);
>> + if (unlikely(!sres))
>> + return NULL;
> Don't use likely() or unlikely() annotations unless the code is *really*
> performance critical, just let the optimiser get on with things. The
> annotations most likely cost more time in reading the code than they'll
> ever save.
Same code structure was used with devres, so I copied it.
More information about the linux-rpi-kernel