public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: core: use regulator name for sysfs
@ 2013-02-21  7:53 Shawn Joo
  2013-02-21 19:24 ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Shawn Joo @ 2013-02-21  7:53 UTC (permalink / raw)
  To: broonie, linux-kernel; +Cc: sjoo

regulator is named by numbering on sysfs, e.g. regulator.0, regulator.1
it confuses to find desired regulator before counting the order.
add option for regulator name by use_name_onsysfs.
if it is true and name is not NULL, desc's name will be the name.
e.g. if name in desc is "LDO0", then regulator.LDO0 on sysfs.
otherwise it follows origin.

Signed-off-by: Shawn Joo <sjoo@nvidia.com>
---
 drivers/regulator/core.c         |    7 ++++++-
 include/linux/regulator/driver.h |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2785843..4dde54d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3399,7 +3399,12 @@ regulator_register(const struct regulator_desc *regulator_desc,
 	rdev->dev.class = &regulator_class;
 	rdev->dev.of_node = config->of_node;
 	rdev->dev.parent = dev;
-	dev_set_name(&rdev->dev, "regulator.%d",
+	if (regulator_desc->use_name_onsysfs &&
+			regulator_desc->name != NULL)
+		dev_set_name(&rdev->dev, "regulator.%s",
+			regulator_desc->name);
+	else
+		dev_set_name(&rdev->dev, "regulator.%d",
 		     atomic_inc_return(&regulator_no) - 1);
 	ret = device_register(&rdev->dev);
 	if (ret != 0) {
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index d10bb0f..597f8dd 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -224,6 +224,7 @@ struct regulator_desc {
 	unsigned int bypass_mask;
 
 	unsigned int enable_time;
+	bool use_name_onsysfs;
 };
 
 /**
-- 
1.7.0.4


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

* Re: [PATCH] regulator: core: use regulator name for sysfs
  2013-02-21  7:53 [PATCH] regulator: core: use regulator name for sysfs Shawn Joo
@ 2013-02-21 19:24 ` Stephen Warren
  2013-02-21 19:43   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2013-02-21 19:24 UTC (permalink / raw)
  To: Shawn Joo; +Cc: broonie, linux-kernel

On 02/21/2013 12:53 AM, Shawn Joo wrote:
> regulator is named by numbering on sysfs, e.g. regulator.0, regulator.1
> it confuses to find desired regulator before counting the order.
> add option for regulator name by use_name_onsysfs.
> if it is true and name is not NULL, desc's name will be the name.
> e.g. if name in desc is "LDO0", then regulator.LDO0 on sysfs.
> otherwise it follows origin.

Does it make sense to make this change always, rather than based on some
new flag in regulator_desc?

Another place a similar change might be useful is debugfs.

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

* Re: [PATCH] regulator: core: use regulator name for sysfs
  2013-02-21 19:24 ` Stephen Warren
@ 2013-02-21 19:43   ` Mark Brown
  2013-02-21 19:49     ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-02-21 19:43 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Shawn Joo, linux-kernel

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

On Thu, Feb 21, 2013 at 12:24:04PM -0700, Stephen Warren wrote:
> On 02/21/2013 12:53 AM, Shawn Joo wrote:

> > regulator is named by numbering on sysfs, e.g. regulator.0, regulator.1
> > it confuses to find desired regulator before counting the order.
> > add option for regulator name by use_name_onsysfs.
> > if it is true and name is not NULL, desc's name will be the name.
> > e.g. if name in desc is "LDO0", then regulator.LDO0 on sysfs.
> > otherwise it follows origin.

> Does it make sense to make this change always, rather than based on some
> new flag in regulator_desc?

It's certainly insane to change this based on the driver and given that
sysfs is supposed to be an ABI it's questionable if we should do it at
all.  We certainly can't use the descriptor name as that's very likely
to clash if you have more than one PMIC.  Taking a glance through sysfs
on my system what we're doing at the minute is pretty idiomatic, sysfs
isn't really intended for humans but rather for machines to prettify.

> Another place a similar change might be useful is debugfs.

debugfs already uses more human readable names, it uses the supply name
(which is what we should be using if we were going to do anything as
it really ought to be unique already).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] regulator: core: use regulator name for sysfs
  2013-02-21 19:43   ` Mark Brown
@ 2013-02-21 19:49     ` Stephen Warren
  2013-02-21 19:58       ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2013-02-21 19:49 UTC (permalink / raw)
  To: Mark Brown; +Cc: Shawn Joo, linux-kernel

On 02/21/2013 12:43 PM, Mark Brown wrote:
> On Thu, Feb 21, 2013 at 12:24:04PM -0700, Stephen Warren wrote:
>> On 02/21/2013 12:53 AM, Shawn Joo wrote:
> 
>>> regulator is named by numbering on sysfs, e.g. regulator.0,
>>> regulator.1 it confuses to find desired regulator before
>>> counting the order. add option for regulator name by
>>> use_name_onsysfs. if it is true and name is not NULL, desc's
>>> name will be the name. e.g. if name in desc is "LDO0", then
>>> regulator.LDO0 on sysfs. otherwise it follows origin.
> 
>> Does it make sense to make this change always, rather than based
>> on some new flag in regulator_desc?
> 
> It's certainly insane to change this based on the driver and given
> that sysfs is supposed to be an ABI it's questionable if we should
> do it at all.  We certainly can't use the descriptor name as that's
> very likely to clash if you have more than one PMIC.  Taking a
> glance through sysfs on my system what we're doing at the minute is
> pretty idiomatic, sysfs isn't really intended for humans but rather
> for machines to prettify.

Does the ABI describe just the layout of the sysfs filesystem, or also
the names of instances? Certainly the list of names of regulators
won't be in any ABI documentation. That said, I suppose for existing
platforms it'd probably be legitimate for someone to have looked there
and seen the names and assumed they would never change on that
particular platform, so changing them would break an implicit ABI.

>> Another place a similar change might be useful is debugfs.
> 
> debugfs already uses more human readable names, it uses the supply
> name (which is what we should be using if we were going to do
> anything as it really ought to be unique already).

Oh so it does. Was this a recent change? I could have sworn I saw lots
of regulator.n there, but perhaps I'm remembering sysfs.

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

* Re: [PATCH] regulator: core: use regulator name for sysfs
  2013-02-21 19:49     ` Stephen Warren
@ 2013-02-21 19:58       ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-02-21 19:58 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Shawn Joo, linux-kernel

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

On Thu, Feb 21, 2013 at 12:49:26PM -0700, Stephen Warren wrote:
> On 02/21/2013 12:43 PM, Mark Brown wrote:

> > It's certainly insane to change this based on the driver and given
> > that sysfs is supposed to be an ABI it's questionable if we should
> > do it at all.  We certainly can't use the descriptor name as that's
> > very likely to clash if you have more than one PMIC.  Taking a
> > glance through sysfs on my system what we're doing at the minute is
> > pretty idiomatic, sysfs isn't really intended for humans but rather
> > for machines to prettify.

> Does the ABI describe just the layout of the sysfs filesystem, or also
> the names of instances? Certainly the list of names of regulators

Turns out we didn't bother documenting the directory naming.

> won't be in any ABI documentation. That said, I suppose for existing
> platforms it'd probably be legitimate for someone to have looked there
> and seen the names and assumed they would never change on that
> particular platform, so changing them would break an implicit ABI.

Indeed, plus the information is all there.  Like I say the current
pattern seems idiomatic for sysfs but really the issue with the current
patch is the per driver thing which just doesn't make sense.

> >> Another place a similar change might be useful is debugfs.

> > debugfs already uses more human readable names, it uses the supply
> > name (which is what we should be using if we were going to do
> > anything as it really ought to be unique already).

> Oh so it does. Was this a recent change? I could have sworn I saw lots
> of regulator.n there, but perhaps I'm remembering sysfs.

It's always been the same.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-02-21 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-21  7:53 [PATCH] regulator: core: use regulator name for sysfs Shawn Joo
2013-02-21 19:24 ` Stephen Warren
2013-02-21 19:43   ` Mark Brown
2013-02-21 19:49     ` Stephen Warren
2013-02-21 19:58       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox