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: <CAHp75VdR9W8U9VmP5WZntzB9qW3fM6qy1Q2-yeBSAG5PJimkaw@mail.gmail.com>
Date:   Tue, 20 Jun 2023 18:15:17 +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@...nel.org,
        krzysztof.kozlowski@...aro.org, conor+dt@...nel.org,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org
Subject: Re: [PATCH v7 2/2] iio: adc: max14001: New driver

On Tue, Jun 20, 2023 at 4:27 PM Kim Seer Paller
<kimseer.paller@...log.com> wrote:
>
> The MAX14001 is configurable, isolated 10-bit ADCs for multi-range
> binary inputs.

...

> +       /*
> +        * Align received data from the receive buffer, reversing and reordering
> +        * it to match the expected MSB-first format.
> +        */
> +       *data = (__force u16)(be16_to_cpu(bitrev16(st->spi_rx_buffer))) &
> +                                                       MAX14001_DATA_MASK;

Using __force in the C files is somehow stinky.

...

> +       /*
> +        * Convert transmit buffer to big-endian format and reverse transmit
> +        * buffer to align with the LSB-first input on SDI port.
> +        */
> +       st->spi_tx_buffer = (__force u16)(cpu_to_be16(bitrev16(

You have a different type of spi_tx_buffer than u16, don't you?

> +                               FIELD_PREP(MAX14001_ADDR_MASK, reg_addr) |
> +                               FIELD_PREP(MAX14001_SET_WRITE_BIT, 1) |
> +                               FIELD_PREP(MAX14001_DATA_MASK, data))));

...

> +       vref = devm_regulator_get_optional(dev, "vref");
> +       if (IS_ERR(vref)) {
> +               if (PTR_ERR(vref) != -ENODEV)
> +                       return dev_err_probe(dev, PTR_ERR(vref),
> +                                            "Failed to get vref regulator");
> +
> +               /* internal reference */
> +               st->vref_mv = 1250;
> +       } else {
> +               ret = regulator_enable(vref);
> +               if (ret)
> +                       return dev_err_probe(dev, ret,
> +                                       "Failed to enable vref regulators\n");
> +
> +               ret = devm_add_action_or_reset(dev, max14001_regulator_disable,
> +                                              vref);
> +               if (ret)
> +                       return ret;
> +
> +               ret = regulator_get_voltage(vref);
> +               if (ret < 0)
> +                       return dev_err_probe(dev, ret,
> +                                            "Failed to get vref\n");
> +
> +               st->vref_mv = ret / 1000;
> +
> +               /* select external voltage reference source for the ADC */
> +               ret = max14001_reg_update(st, MAX14001_CFG,
> +                                         MAX14001_CFG_EXRF, 1);
> +               if (ret < 0)
> +                       return ret;
> +       }

Now, looking at this code I'm wondering if we may have something like
devm_regulator_get_enable_and_voltage_optional()

But it's another story.


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ