All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute
@ 2016-03-30 16:27 Ben Hutchings
  2016-03-30 16:42 ` [Linux-kernel] " Ben Dooks
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Hutchings @ 2016-03-30 16:27 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, CT kernel

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 <ben.hutchings@codethink.co.uk>
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 7748a0a5ddb9..9e8f3d702314 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -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,

-- 
Ben Hutchings
Software Developer, Codethink Ltd.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Linux-kernel] [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute
  2016-03-30 16:27 [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute Ben Hutchings
@ 2016-03-30 16:42 ` Ben Dooks
  2016-03-30 16:45   ` Ben Hutchings
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Dooks @ 2016-03-30 16:42 UTC (permalink / raw)
  To: Ben Hutchings, Wolfram Sang; +Cc: CT kernel, linux-i2c

On 30/03/16 17:27, Ben Hutchings wrote:
> 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 <ben.hutchings@codethink.co.uk>

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

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-kernel] [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute
  2016-03-30 16:42 ` [Linux-kernel] " Ben Dooks
@ 2016-03-30 16:45   ` Ben Hutchings
  2016-03-30 20:56     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Hutchings @ 2016-03-30 16:45 UTC (permalink / raw)
  To: Ben Dooks; +Cc: Wolfram Sang, CT kernel, linux-i2c

On Wed, 2016-03-30 at 17:42 +0100, Ben Dooks wrote:
> On 30/03/16 17:27, Ben Hutchings wrote:
> > 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 <ben.hutchings@codethink.co.uk>
> 
> 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.

-- 
Ben Hutchings
Software Developer, Codethink Ltd.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-kernel] [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute
  2016-03-30 16:45   ` Ben Hutchings
@ 2016-03-30 20:56     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-03-30 20:56 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: Ben Dooks, CT kernel, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 724 bytes --]

On Wed, Mar 30, 2016 at 05:45:27PM +0100, Ben Hutchings wrote:
> On Wed, 2016-03-30 at 17:42 +0100, Ben Dooks wrote:
> > On 30/03/16 17:27, Ben Hutchings wrote:
> > > 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 <ben.hutchings@codethink.co.uk>
> > 
> > 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?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-30 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30 16:27 [PATCH] i2c: mux: demux-pinctrl: Fix reading the "master" attribute Ben Hutchings
2016-03-30 16:42 ` [Linux-kernel] " Ben Dooks
2016-03-30 16:45   ` Ben Hutchings
2016-03-30 20:56     ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.