Skip to content

Commit 701c875

Browse files
andy-shevjic23
authored andcommitted
iio: adc: qcom-spmi-adc5: Fix the channel name
The node name can contain an address part which is unused by the driver. Moreover, this string is propagated into the userspace label, sysfs filenames *and breaking ABI*. Cut the address part out before assigning the channel name. Fixes: 4f47a23 ("iio: adc: qcom-spmi-adc5: convert to device properties") Reported-by: Marijn Suijten <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Marijn Suijten <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 2acd031 commit 701c875

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/iio/adc/qcom-spmi-adc5.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,20 @@ static int adc5_get_fw_channel_data(struct adc5_chip *adc,
626626
struct fwnode_handle *fwnode,
627627
const struct adc5_data *data)
628628
{
629-
const char *name = fwnode_get_name(fwnode), *channel_name;
629+
const char *channel_name;
630+
char *name;
630631
u32 chan, value, varr[2];
631632
u32 sid = 0;
632633
int ret;
633634
struct device *dev = adc->dev;
634635

636+
name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode);
637+
if (!name)
638+
return -ENOMEM;
639+
640+
/* Cut the address part */
641+
name[strchrnul(name, '@') - name] = '\0';
642+
635643
ret = fwnode_property_read_u32(fwnode, "reg", &chan);
636644
if (ret) {
637645
dev_err(dev, "invalid channel number %s\n", name);

0 commit comments

Comments
 (0)