Re: [PATCH] iio: adc: ti-ads7138: explicitly include <linux/slab.h>

From: Andy Shevchenko

Date: Fri Apr 24 2026 - 07:34:44 EST


On Fri, Apr 24, 2026 at 11:36:00AM +0100, Jonathan Cameron wrote:
> On Fri, 24 Apr 2026 12:07:24 +0300
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> > On Fri, Apr 24, 2026 at 12:18:10PM +0400, Giorgi Tchankvetadze wrote:

...

> > WRT to the kmalloc() use, wouldn't it be simply better to use
> > i2c_master_send_dmasafe() and kill that kmalloc() dance in the driver?
>
> That sounds backwards. IIRC i2c_master_send_dmasafe() needs a heap allocation
> to ensure a DMA safe buffer. See i2c_get_dma_safe_msg_buf() and
> the check on I2C_M_DMA_SAFE.

Ah, I thought it's opposite, but looking at the usage it seems like it's host
controller driver responsibility to use DMA or not for the transfer.

Why do we need to have kmalloc() here at all? I don't understand that.

> This function is just overly flexible.

--
With Best Regards,
Andy Shevchenko