lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vfk2=rYh7GO5XUV8cr3C+3nwu4-PfxxVDuG3Vj0a6b=XQ@mail.gmail.com>
Date:   Tue, 13 Jun 2023 12:57:07 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Kim Seer Paller <kimseer.paller@...log.com>
Cc:     jic23@...nel.org, lars@...afoo.de, lgirdwood@...il.com,
        broonie@...nel.org, Michael.Hennerich@...log.com,
        robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
        conor+dt@...nel.org, linux-iio@...r.kernel.org,
        linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v4 2/2] iio: adc: max14001: New driver

On Tue, Jun 13, 2023 at 8:46 AM Kim Seer Paller
<kimseer.paller@...log.com> wrote:
>
> The MAX14001 is a configurable, isolated 10-bit ADC for multi-range
> binary inputs.

...

> +struct max14001_state {
> +       struct spi_device       *spi;
> +       /*
> +        * lock protect agains multiple concurrent accesses, RMW sequence, and

against

> +        * SPI transfer
> +        */
> +       struct mutex            lock;
> +       int                     vref_mv;
> +       /*
> +        * DMA (thus cache coherency maintenance) requires the
> +        * transfer buffers to live in their own cache lines.
> +        */
> +       __be16                  spi_tx_buffer __aligned(IIO_DMA_MINALIGN);
> +       __be16                  spi_rx_buffer;
> +};
> +
> +static int max14001_read(void *context, unsigned int reg_addr, unsigned int *data)
> +{
> +       struct max14001_state *st = context;
> +       int ret;
> +
> +       struct spi_transfer xfers[] = {
> +               {
> +                       .tx_buf = &st->spi_tx_buffer,
> +                       .len = 2,

sizeof()

> +                       .cs_change = 1,
> +               }, {
> +                       .rx_buf = &st->spi_rx_buffer,
> +                       .len = 2,

sizeof()

> +               },
> +       };
> +
> +       st->spi_tx_buffer = bitrev16(cpu_to_be16(FIELD_PREP(MAX14001_ADDR_MASK,
> +                                                               reg_addr)));
> +
> +       ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
> +       if (ret)
> +               return ret;
> +
> +       *data = bitrev16(be16_to_cpu(st->spi_rx_buffer)) & MAX14001_DATA_MASK;
> +
> +       return 0;
> +}

...

> +static const struct iio_chan_spec max14001_channels[] = {
> +       {
> +               .type = IIO_VOLTAGE,
> +               .channel = 0,

Is it required?

> +               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +                                     BIT(IIO_CHAN_INFO_SCALE),
> +       }
> +};

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ