Skip to contentSkip to conversation

i2c: mux: demux-pinctrl: Fix reading the "master" attribute

PATCH In review Ben Hutchings 3 participants 4 messages Mar 30, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: mux: demux-pinctrl: Fix reading the "master" attribute

sysfs attributes should use the same format for reads and writes, rather than pretty-printing on read.

Fixes 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/i2c/muxes/i2c-demux-pinctrl.c +1 -7
index 7748a0a5ddb9..9e8f3d702314 100644
@@ -144,14 +144,8 @@ static ssize_t cur_master_show(struct device *dev, struct device_attribute *attr
 			   char *buf)
 {
 	struct i2c_demux_pinctrl_priv *priv = dev_get_drvdata(dev);
-	int count = 0, i;
 
-	for (i = 0; i < priv->num_chan && count < PAGE_SIZE; i++)
-		count += scnprintf(buf + count, PAGE_SIZE - count, "%c %d - %s\n",
-				 i == priv->cur_chan ? '*' : ' ', i,
-				 priv->chan[i].parent_np->full_name);
-
-	return count;
+	return sprintf(buf, "%u\n", priv->cur_chan);
 }
 
 static ssize_t cur_master_store(struct device *dev, struct device_attribute *attr,
Signature · 2 lines
Ben Hutchings
Software Developer, Codethink Ltd.
#1 lore raw
Quoted 5 lines · Ben Hutchings

sysfs attributes should use the same format for reads and writes, rather than pretty-printing on read.

Fixes 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")

should that be moved to a debugfs entry or a read-only sysfs?

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#2 lore raw
Quoted 8 lines · Ben Dooks
Quoted 5 lines · Ben Hutchings

sysfs attributes should use the same format for reads and writes, rather than pretty-printing on read.

Fixes 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")

should that be moved to a debugfs entry or a read-only sysfs?

Probably another read-only attribute (like "scaling_governor" vs "scaling_available_governors" in cpufreq).

Ben.

Signature · 2 lines
Ben Hutchings
Software Developer, Codethink Ltd.
#3 lore raw
Quoted 5 lines · Ben Hutchings
Quoted 4 lines · Ben Dooks
Quoted 3 lines · Ben Hutchings

sysfs attributes should use the same format for reads and writes, rather than pretty-printing on read.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")

should that be moved to a debugfs entry or a read-only sysfs?

Probably another read-only attribute (like "scaling_governor" vs "scaling_available_governors" in cpufreq).

I agree. "current_master" and "available_masters" is probably the way to go. Can you do it or shall I?