From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH v5 2/3] iio: adc: Support ROHM BD79112 ADC/GPIO
Date: Tue, 16 Sep 2025 07:48:03 +0300 [thread overview]
Message-ID: <0b97adc3-4d77-480f-ace9-a53403c62216@gmail.com> (raw)
In-Reply-To: <aMge0jYwYCiY72Yb@smile.fi.intel.com>
On 15/09/2025 17:12, Andy Shevchenko wrote:
> On Mon, Sep 15, 2025 at 10:12:43AM +0300, Matti Vaittinen wrote:
>> The ROHM BD79112 is an ADC/GPIO with 32 channels. The channel inputs can
>> be used as ADC or GPIO. Using the GPIOs as IRQ sources isn't supported.
>>
>> The ADC is 12-bit, supporting input voltages up to 5.7V, and separate I/O
>> voltage supply. Maximum SPI clock rate is 20 MHz (10 MHz with
>> daisy-chain configuration) and maximum sampling rate is 1MSPS.
>>
>> The IC does also support CRC but it is not implemented in the driver.
>
> ...
>
>> +static int bd79112_probe(struct spi_device *spi)
>> +{
>> + struct bd79112_data *data;
>> + struct iio_dev *iio_dev;
>> + struct iio_chan_spec *cs;
>> + struct device *dev = &spi->dev;
>> + unsigned long gpio_pins, pin;
>> + unsigned int i;
>> + int ret;
>> +
>> + iio_dev = devm_iio_device_alloc(dev, sizeof(*data));
>> + if (!iio_dev)
>> + return -ENOMEM;
>> +
>> + data = iio_priv(iio_dev);
>> + data->spi = spi;
>> + data->dev = dev;
>> + data->map = devm_regmap_init(dev, NULL, data, &bd79112_regmap);
>> + if (IS_ERR(data->map))
>> + return dev_err_probe(dev, PTR_ERR(data->map),
>> + "Failed to initialize Regmap\n");
>> +
>> + ret = devm_regulator_get_enable_read_voltage(dev, "vdd");
>> + if (ret < 0)
>> + return dev_err_probe(dev, ret, "Failed to get the Vdd\n");
>
>> + data->vref_mv = ret / 1000;
>
> I still think moving to _mV is the right thing to do.
> There is no 'mv' in the physics for Volts.
I can see you think so :) For me it doesn't look good. This is in-kernel
C-code not physics textbook. For the kernel C it has been convention to
_not_ use capital letters (or CamelCase) for variables. This convention
is strong enough reason for me to avoid mV in a variable name because
the capital letter instantly requires my attention and makes me need to
consider if this is "just a variable". What comes to the vref_mv, there
really are no true downside. It is clear what the _mv suffix denotes and
"there is no 'mv' in physics" is really an artificial problem.
>> + ret = devm_regulator_get_enable(dev, "iovdd");
>> + if (ret < 0)
>> + return dev_err_probe(dev, ret, "Failed to enable I/O voltage\n");
>> +
>> + data->read_xfer[0].tx_buf = &data->read_tx[0];
>> + data->read_xfer[0].len = sizeof(data->read_tx);
>> + data->read_xfer[0].cs_change = 1;
>> + data->read_xfer[1].rx_buf = &data->read_rx;
>> + data->read_xfer[1].len = sizeof(data->read_rx);
>> + spi_message_init_with_transfers(&data->read_msg, data->read_xfer, 2);
>
>> + devm_spi_optimize_message(dev, spi, &data->read_msg);
>
> And if it fails?..
I am not really sure under what conditions this would fail. Without
taking a further look at that - then we just use unoptimized SPI
transfers(?). Could warrant a warning print though.
Thanks for taking a look at this again :)
Yours,
-- Matti
next prev parent reply other threads:[~2025-09-16 4:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 7:11 [PATCH v5 0/3] Support ROHM BD79112 ADC Matti Vaittinen
2025-09-15 7:12 ` [PATCH v5 1/3] dt-bindings: iio: adc: ROHM BD79112 ADC/GPIO Matti Vaittinen
2025-09-15 7:12 ` [PATCH v5 2/3] iio: adc: Support " Matti Vaittinen
2025-09-15 14:12 ` Andy Shevchenko
2025-09-15 20:13 ` Jonathan Cameron
2025-09-16 4:52 ` Matti Vaittinen
2025-09-16 7:41 ` Andy Shevchenko
2025-09-16 8:02 ` Jonathan Cameron
2025-09-16 8:14 ` Matti Vaittinen
2025-09-16 15:08 ` David Lechner
2025-09-16 7:32 ` Andy Shevchenko
2025-09-16 4:48 ` Matti Vaittinen [this message]
2025-09-16 7:39 ` Andy Shevchenko
2025-09-16 8:04 ` Matti Vaittinen
2025-09-15 7:12 ` [PATCH v5 3/3] MAINTAINERS: Support ROHM BD79112 ADC Matti Vaittinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b97adc3-4d77-480f-ace9-a53403c62216@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox