i2c: mux: demux-pinctrl: Fix reading the "master" attribute
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.
--- drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/i2c/muxes/i2c-demux-pinctrl.c +1 -7
@@ -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.
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")Signed-off-by Ben Hutchings <[email protected]>
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
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")Signed-off-by Ben Hutchings <[email protected]>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.
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")Signed-off-by Ben Hutchings <[email protected]>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?