lkml.org 
[lkml]   [2022]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 4/5] iio: pressure: bmp280: Add support for BMP380 sensor family

> > > +
> > > +static int bmp380_read_calib(struct bmp280_data *data, unsigned int chip)
> > > +{
> > > +       int ret;
> > > +       struct bmp380_calib *calib = &data->calib.bmp380;
> > > +       u8 buf[BMP380_CALIB_REG_COUNT];
> >
> > I'd missed this previously but for SPI drivers, we should be providing
> > regmap_bulk accesses with DMA safe buffers.  That means they can't be on the
> > stack and need to be appropriately aligned IIO_DMA_MINALIGN as part of
> > the *data structure.
> >
> > Last time I checked the SPI regmap implementation doesn't currently use
> > the buffers directly but it has in the past and may do again in the future
> > - hence we should be careful to allow for that.
> >
>
> As we only use this buffer once to store temporally the calibration data to
> parse, I would like to avoid adding extra overhead to the device data struct.
> I've been consulting on DMA rules and safety, and if I understood correctly
> (listed the sources below), it should be safe to use a buffer allocated at
> runtime with kmalloc, right?

Yes. That works too.

> * https://elinux.org/images/0/03/20181023-Wolfram-Sang-ELCE18-
> safe_dma_buffers.pdf
> * https://linux-arm-kernel.infradead.narkive.com/vyJqy0RQ/question-devm-
> kmalloc-for-dma
>
> Thanks in advance,
> Angel

\
 
 \ /
  Last update: 2022-07-19 11:24    [W:0.047 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site