public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MFD: ab8500 chip id exported to sysfs
@ 2010-11-26 12:05 Mattias Wallin
  2010-11-26 15:43 ` Samuel Ortiz
  0 siblings, 1 reply; 3+ messages in thread
From: Mattias Wallin @ 2010-11-26 12:05 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Linus Walleij, Mattias Wallin, Ludovic Barre

This patch adds a file into sysfs for reading out chip id.
It have been requested for modem silent reboot.

Change-Id: I8e2c10e740a90ab210e023df4214b422c01f2efb
Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
Signed-off-by: Ludovic Barre <ludovic.barre@stericsson.com>
---
 drivers/mfd/ab8500-core.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index e64569e..c59e832 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -98,7 +98,7 @@ static int ab8500_get_chip_id(struct device *dev)
 	if (!dev)
 		return -EINVAL;
 	ab8500 = dev_get_drvdata(dev->parent);
-	return (int)ab8500->chip_id;
+	return ab8500 ? (int)ab8500->chip_id : -EINVAL;
 }
 
 static int set_register_interruptible(struct ab8500 *ab8500, u8 bank,
@@ -654,6 +654,26 @@ static struct mfd_cell ab8500_devs[] = {
 	},
 };
 
+static ssize_t show_chip_id(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct ab8500 *ab8500;
+
+	ab8500 = dev_get_drvdata(dev);
+	return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL);
+}
+
+static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL);
+
+static struct attribute *ab8500_sysfs_entries[] = {
+	&dev_attr_chip_id.attr,
+	NULL,
+};
+
+static struct attribute_group ab8500_attr_group = {
+	.attrs	= ab8500_sysfs_entries,
+};
+
 int __devinit ab8500_init(struct ab8500 *ab8500)
 {
 	struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev);
@@ -734,6 +754,10 @@ int __devinit ab8500_init(struct ab8500 *ab8500)
 	if (ret)
 		goto out_freeirq;
 
+	ret = sysfs_create_group(&ab8500->dev->kobj, &ab8500_attr_group);
+	if (ret)
+		dev_err(ab8500->dev, "error creating sysfs entries\n");
+
 	return ret;
 
 out_freeirq:
@@ -747,6 +771,7 @@ out_removeirq:
 
 int __devexit ab8500_exit(struct ab8500 *ab8500)
 {
+	sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group);
 	mfd_remove_devices(ab8500->dev);
 	if (ab8500->irq_base) {
 		free_irq(ab8500->irq, ab8500);
-- 
1.7.2.2


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

* Re: [PATCH] MFD: ab8500 chip id exported to sysfs
  2010-11-26 12:05 [PATCH] MFD: ab8500 chip id exported to sysfs Mattias Wallin
@ 2010-11-26 15:43 ` Samuel Ortiz
  2010-11-30  9:44   ` Mattias Wallin
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Ortiz @ 2010-11-26 15:43 UTC (permalink / raw)
  To: Mattias Wallin; +Cc: linux-kernel, Linus Walleij, Ludovic Barre

Hi Mattias,

On Fri, Nov 26, 2010 at 01:05:25PM +0100, Mattias Wallin wrote:
> This patch adds a file into sysfs for reading out chip id.
> It have been requested for modem silent reboot.
> 
> Change-Id: I8e2c10e740a90ab210e023df4214b422c01f2efb
I suppose this is some internal ID ? Please remove it from the Changelog.


> Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
> Signed-off-by: Ludovic Barre <ludovic.barre@stericsson.com>
> ---
>  drivers/mfd/ab8500-core.c |   27 ++++++++++++++++++++++++++-
>  1 files changed, 26 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
> index e64569e..c59e832 100644
> --- a/drivers/mfd/ab8500-core.c
> +++ b/drivers/mfd/ab8500-core.c
> @@ -98,7 +98,7 @@ static int ab8500_get_chip_id(struct device *dev)
>  	if (!dev)
>  		return -EINVAL;
>  	ab8500 = dev_get_drvdata(dev->parent);
> -	return (int)ab8500->chip_id;
> +	return ab8500 ? (int)ab8500->chip_id : -EINVAL;
Here again, you're squeezing some potential bug fix into this patch.

The rest looks just fine.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* Re: [PATCH] MFD: ab8500 chip id exported to sysfs
  2010-11-26 15:43 ` Samuel Ortiz
@ 2010-11-30  9:44   ` Mattias Wallin
  0 siblings, 0 replies; 3+ messages in thread
From: Mattias Wallin @ 2010-11-30  9:44 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel@vger.kernel.org, Linus WALLEIJ, Ludovic BARRE

Hi,

On 11/26/2010 04:43 PM, Samuel Ortiz wrote:
> Hi Mattias,
> 
> On Fri, Nov 26, 2010 at 01:05:25PM +0100, Mattias Wallin wrote:
>> This patch adds a file into sysfs for reading out chip id.
>> It have been requested for modem silent reboot.
>>
>> Change-Id: I8e2c10e740a90ab210e023df4214b422c01f2efb
> I suppose this is some internal ID ? Please remove it from the Changelog.
Sorry.
> 
> 
>> Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
>> Signed-off-by: Ludovic Barre <ludovic.barre@stericsson.com>
>> ---
>>  drivers/mfd/ab8500-core.c |   27 ++++++++++++++++++++++++++-
>>  1 files changed, 26 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
>> index e64569e..c59e832 100644
>> --- a/drivers/mfd/ab8500-core.c
>> +++ b/drivers/mfd/ab8500-core.c
>> @@ -98,7 +98,7 @@ static int ab8500_get_chip_id(struct device *dev)
>>  	if (!dev)
>>  		return -EINVAL;
>>  	ab8500 = dev_get_drvdata(dev->parent);
>> -	return (int)ab8500->chip_id;
>> +	return ab8500 ? (int)ab8500->chip_id : -EINVAL;
> Here again, you're squeezing some potential bug fix into this patch.
Ok, I'll put this in a seperate patch.
> 
> The rest looks just fine.
> 
> Cheers,
> Samuel.
> 

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

end of thread, other threads:[~2010-11-30  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 12:05 [PATCH] MFD: ab8500 chip id exported to sysfs Mattias Wallin
2010-11-26 15:43 ` Samuel Ortiz
2010-11-30  9:44   ` Mattias Wallin

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