Re: [PATCH v7 2/2] iio: adc: max14001: New driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 20, 2023 at 4:27 PM Kim Seer Paller
<kimseer.paller@xxxxxxxxxx> 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux