From: Marijn Suijten <marijn.suijten@somainline.org>
To: phone-devel@vger.kernel.org
Cc: ~postmarketos/upstreaming@lists.sr.ht,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@somainline.org>,
"Konrad Dybcio" <konrad.dybcio@somainline.org>,
"Martin Botka" <martin.botka@somainline.org>,
"Jami Kettunen" <jami.kettunen@somainline.org>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Nuno Sá" <nuno.sa@analog.com>, "Luca Weiss" <luca@z3ntu.xyz>,
linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>
Subject: Re: [RFC PATCH] iio: adc: qcom-spmi-vadc: Propagate fw node name/label to extend_name
Date: Sun, 6 Nov 2022 21:24:45 +0100 [thread overview]
Message-ID: <20221106202445.fkobsyc3mohmzqod@SoMainline.org> (raw)
In-Reply-To: <20221106193018.270106-1-marijn.suijten@somainline.org>
Adding Krzysztof to CC for the DT bindings discussion.
On 2022-11-06 20:30:18, Marijn Suijten wrote:
> Much like the ADC5 driver iio_chan_spec::extend_name has to be set for
> friendly/useful names to show up in sysfs, allowing users to correlate
> readout values with the corresponding probe. This name is read from
> firmware, taking both the node name and - if set - node label into
> account. This is particularly useful for custom thermistors being
> attached to otherwise-generically-named GPIOs.
>
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
>
> ---
>
> This RFC may seem a bit controversial as there are multiple patches
> going around in DT-land changing how nodes are labeled [1] (or
> introducing new ones: [2]), seemingly to appease binding conventions
> without considering how the driver propagates them to IIO (and in turn
> what userspace sees in sysfs). I hope we can put together the right
> conventions with this RFC.
>
> Before getting started, note that ADC5 provides this DT/FW node
> name/label in *both* extend_name *and* datasheet_name;
> adc5_channels::datasheet_name provided by the macros remains *unread*
> (except for a non-null check).
> Since the names hardcoded in the driver seem to be somewhat
> "datasheet"-y, and the names in DT typically take the form of a more
> friendly "<device>-therm" indicating where the thermistor (or voltage
> probe) is located on the board or attached to, I have opted to persist
> the original use of vadc_channels::datasheet_name in
> iio_chan_spec::datasheet_name, and only propagate the data from DT/FW
> into extend_name.
> (We should likely rename vadc_channel_prop::datasheet_name to
> extend_name to this end.)
>
> Back when I submitted patches for pm6125 [3] (utilizing ADC5)
> 4f47a236a23d ("iio: adc: qcom-spmi-adc5: convert to device properties")
> didn't yet land, and these patches use the node name to convey a
> useful/friendly name (again, the string literals in ADC5 are unused).
> fwnode_get_name() however includes the `@xx` reg suffix, making for an
> unpleasant reading experience in sysfs.
>
> With all that context in mind, I feel like we should answer the
> following questions:
>
> 1. Should we propagate names from DT/FW at all?
> 2. If so, how should a node be represented in DT? Should it use generic
> node names (which we might not want to use anyway considering the
> `@xx` suffix highlighted above) or labels exclusively?
> 3. If only labels are going to be used in conjunction with generic node
> names, should ADC5 be changed to ignore the node name?
> 4. If a label (or node name) is not set, do we fall back to
> datasheet_name hardcoded in the driver?
> 5. What do we use for datasheet_name vs extend_name?
> 6. Any other vadc drivers that need the same treatment, when we come to
> a resolution?
>
> [1]: https://lore.kernel.org/linux-arm-msm/20221031181022.947412-1-luca@z3ntu.xyz/T/#u
> [2]: https://lore.kernel.org/linux-arm-msm/20221101161801.1058969-2-luca@z3ntu.xyz/
> [3]: https://lore.kernel.org/linux-arm-msm/20220926190148.283805-1-marijn.suijten@somainline.org/T/#u
>
> Thanks for considering this!
> - Marijn
>
> drivers/iio/adc/qcom-spmi-vadc.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
> index bcff0f62b70e..8c6c7fa13cfe 100644
> --- a/drivers/iio/adc/qcom-spmi-vadc.c
> +++ b/drivers/iio/adc/qcom-spmi-vadc.c
> @@ -84,6 +84,7 @@
> * that is an average of multiple measurements.
> * @scale_fn_type: Represents the scaling function to convert voltage
> * physical units desired by the client for the channel.
> + * @datasheet_name: Channel name used in device tree.
> */
> struct vadc_channel_prop {
> unsigned int channel;
> @@ -93,6 +94,7 @@ struct vadc_channel_prop {
> unsigned int hw_settle_time;
> unsigned int avg_samples;
> enum vadc_scale_fn_type scale_fn_type;
> + const char *datasheet_name;
> };
>
> /**
> @@ -652,7 +654,7 @@ static int vadc_get_fw_channel_data(struct device *dev,
> struct vadc_channel_prop *prop,
> struct fwnode_handle *fwnode)
> {
> - const char *name = fwnode_get_name(fwnode);
> + const char *name = fwnode_get_name(fwnode), *channel_name;
> u32 chan, value, varr[2];
> int ret;
>
> @@ -670,6 +672,12 @@ static int vadc_get_fw_channel_data(struct device *dev,
> /* the channel has DT description */
> prop->channel = chan;
>
> + ret = fwnode_property_read_string(fwnode, "label", &channel_name);
> + if (ret)
> + channel_name = name;
> +
> + prop->datasheet_name = channel_name;
> +
> ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
> if (!ret) {
> ret = qcom_vadc_decimation_from_dt(value);
> @@ -771,6 +779,7 @@ static int vadc_get_fw_data(struct vadc_priv *vadc)
>
> iio_chan->channel = prop.channel;
> iio_chan->datasheet_name = vadc_chan->datasheet_name;
> + iio_chan->extend_name = prop.datasheet_name;
> iio_chan->info_mask_separate = vadc_chan->info_mask;
> iio_chan->type = vadc_chan->type;
> iio_chan->indexed = 1;
> --
> 2.38.1
>
next prev parent reply other threads:[~2022-11-06 20:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-06 19:30 [RFC PATCH] iio: adc: qcom-spmi-vadc: Propagate fw node name/label to extend_name Marijn Suijten
2022-11-06 20:24 ` Marijn Suijten [this message]
2022-11-12 16:27 ` Jonathan Cameron
2022-11-30 20:54 ` Marijn Suijten
2022-12-03 17:06 ` Jonathan Cameron
2022-12-21 22:34 ` Marijn Suijten
2022-12-23 17:44 ` Jonathan Cameron
2023-01-16 21:18 ` Marijn Suijten
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=20221106202445.fkobsyc3mohmzqod@SoMainline.org \
--to=marijn.suijten@somainline.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@somainline.org \
--cc=jami.kettunen@somainline.org \
--cc=jic23@kernel.org \
--cc=konrad.dybcio@somainline.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca@z3ntu.xyz \
--cc=martin.botka@somainline.org \
--cc=nuno.sa@analog.com \
--cc=phone-devel@vger.kernel.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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