linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / devfreq: Add new name attribute for sysfs
       [not found] <CGME20180829073410epcas1p2f314e6c4c29eacfe3ebd5fb4f7f2f122@epcas1p2.samsung.com>
@ 2018-08-29  7:34 ` Chanwoo Choi
  2018-08-29 10:57   ` Greg KH
  2018-08-29 12:50   ` Bartlomiej Zolnierkiewicz
  0 siblings, 2 replies; 5+ messages in thread
From: Chanwoo Choi @ 2018-08-29  7:34 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi
  Cc: rafael.j.wysocki, chanwoo, linux-pm, linux-kernel, stable

commit 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for
sysfs") changed the node name to devfreq(x). After this commit, it is not
possible to get the device name through /sys/class/devfreq/devfreq(X)/*.

Add new name attribute in order to get device name.

Cc: stable@vger.kernel.org
Fixes: 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/devfreq/devfreq.c | 11 +++++++++++
 include/linux/devfreq.h   |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 4c49bb1330b5..2145563d5ee5 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -620,6 +620,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
 	}
 	devfreq->max_freq = devfreq->scaling_max_freq;

+	devfreq->name = dev_name(devfreq->dev.parent);
+	if (IS_ERR_OR_NULL(devfreq->name))
+		return -EINVAL;
 	dev_set_name(&devfreq->dev, "devfreq%d",
 				atomic_inc_return(&devfreq_no));
 	err = device_register(&devfreq->dev);
@@ -1261,6 +1264,13 @@ static ssize_t trans_stat_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(trans_stat);

+static ssize_t name_show(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%s\n", to_devfreq(dev)->name);
+}
+static DEVICE_ATTR_RO(name);
+
 static struct attribute *devfreq_attrs[] = {
 	&dev_attr_governor.attr,
 	&dev_attr_available_governors.attr,
@@ -1271,6 +1281,7 @@ static ssize_t trans_stat_show(struct device *dev,
 	&dev_attr_min_freq.attr,
 	&dev_attr_max_freq.attr,
 	&dev_attr_trans_stat.attr,
+	&dev_attr_name.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(devfreq);
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index 3aae5b3af87c..f79b5a666102 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -111,6 +111,7 @@ struct devfreq_dev_profile {

 /**
  * struct devfreq - Device devfreq structure
+ * @name:	name of the device
  * @node:	list node - contains the devices with devfreq that have been
  *		registered.
  * @lock:	a mutex to protect accessing devfreq.
@@ -146,6 +147,8 @@ struct devfreq_dev_profile {
  * to protect its own private data in void *data as well.
  */
 struct devfreq {
+	const char *name;
+
 	struct list_head node;

 	struct mutex lock;
--
1.9.1


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

* Re: [PATCH] PM / devfreq: Add new name attribute for sysfs
  2018-08-29  7:34 ` [PATCH] PM / devfreq: Add new name attribute for sysfs Chanwoo Choi
@ 2018-08-29 10:57   ` Greg KH
  2018-08-29 22:50     ` Chanwoo Choi
  2018-08-29 12:50   ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2018-08-29 10:57 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, kyungmin.park, rafael.j.wysocki, chanwoo, linux-pm,
	linux-kernel, stable

On Wed, Aug 29, 2018 at 04:34:06PM +0900, Chanwoo Choi wrote:
> commit 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for
> sysfs") changed the node name to devfreq(x). After this commit, it is not
> possible to get the device name through /sys/class/devfreq/devfreq(X)/*.
> 
> Add new name attribute in order to get device name.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
>  drivers/devfreq/devfreq.c | 11 +++++++++++
>  include/linux/devfreq.h   |  3 +++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 4c49bb1330b5..2145563d5ee5 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -620,6 +620,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	}
>  	devfreq->max_freq = devfreq->scaling_max_freq;
> 
> +	devfreq->name = dev_name(devfreq->dev.parent);
> +	if (IS_ERR_OR_NULL(devfreq->name))
> +		return -EINVAL;
>  	dev_set_name(&devfreq->dev, "devfreq%d",
>  				atomic_inc_return(&devfreq_no));
>  	err = device_register(&devfreq->dev);
> @@ -1261,6 +1264,13 @@ static ssize_t trans_stat_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(trans_stat);
> 
> +static ssize_t name_show(struct device *dev,
> +			struct device_attribute *attr, char *buf)
> +{
> +	return sprintf(buf, "%s\n", to_devfreq(dev)->name);
> +}
> +static DEVICE_ATTR_RO(name);

You need a new Documentation/ABI/ entry for this.

thanks,

greg k-h

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

* Re: [PATCH] PM / devfreq: Add new name attribute for sysfs
  2018-08-29  7:34 ` [PATCH] PM / devfreq: Add new name attribute for sysfs Chanwoo Choi
  2018-08-29 10:57   ` Greg KH
@ 2018-08-29 12:50   ` Bartlomiej Zolnierkiewicz
  2018-08-29 22:59     ` Chanwoo Choi
  1 sibling, 1 reply; 5+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-08-29 12:50 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: myungjoo.ham, kyungmin.park, rafael.j.wysocki, chanwoo, linux-pm,
	linux-kernel, stable


Hi Chanwoo,

On Wednesday, August 29, 2018 04:34:06 PM Chanwoo Choi wrote:
> commit 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for
> sysfs") changed the node name to devfreq(x). After this commit, it is not
> possible to get the device name through /sys/class/devfreq/devfreq(X)/*.
> 
> Add new name attribute in order to get device name.

Could you please describe the issue encountered in more detail
(what the old device name is needed for)?
 
> Cc: stable@vger.kernel.org
> Fixes: 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
>  drivers/devfreq/devfreq.c | 11 +++++++++++
>  include/linux/devfreq.h   |  3 +++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 4c49bb1330b5..2145563d5ee5 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -620,6 +620,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	}
>  	devfreq->max_freq = devfreq->scaling_max_freq;
> 
> +	devfreq->name = dev_name(devfreq->dev.parent);

It seems that 'dev' can be used instead of 'devfreq->dev.parent'.

> +	if (IS_ERR_OR_NULL(devfreq->name))

Error values are not encoded into pointer returned by dev_name()
(drivers/base/ code is only checking for pointer being NULL).

> +		return -EINVAL;

This leaks 'devfreq' object and doesn't encode return value into
pointer returned by devfreq_add_device(), it should be replaced by:

	err = -EINVAL;
	goto err_dev;

>  	dev_set_name(&devfreq->dev, "devfreq%d",
>  				atomic_inc_return(&devfreq_no));
>  	err = device_register(&devfreq->dev);

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


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

* Re: [PATCH] PM / devfreq: Add new name attribute for sysfs
  2018-08-29 10:57   ` Greg KH
@ 2018-08-29 22:50     ` Chanwoo Choi
  0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2018-08-29 22:50 UTC (permalink / raw)
  To: Greg KH
  Cc: myungjoo.ham, kyungmin.park, rafael.j.wysocki, chanwoo, linux-pm,
	linux-kernel, stable

Dear Greg,

On 2018년 08월 29일 19:57, Greg KH wrote:
> On Wed, Aug 29, 2018 at 04:34:06PM +0900, Chanwoo Choi wrote:
>> commit 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for
>> sysfs") changed the node name to devfreq(x). After this commit, it is not
>> possible to get the device name through /sys/class/devfreq/devfreq(X)/*.
>>
>> Add new name attribute in order to get device name.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>>  drivers/devfreq/devfreq.c | 11 +++++++++++
>>  include/linux/devfreq.h   |  3 +++
>>  2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 4c49bb1330b5..2145563d5ee5 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -620,6 +620,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
>>  	}
>>  	devfreq->max_freq = devfreq->scaling_max_freq;
>>
>> +	devfreq->name = dev_name(devfreq->dev.parent);
>> +	if (IS_ERR_OR_NULL(devfreq->name))
>> +		return -EINVAL;
>>  	dev_set_name(&devfreq->dev, "devfreq%d",
>>  				atomic_inc_return(&devfreq_no));
>>  	err = device_register(&devfreq->dev);
>> @@ -1261,6 +1264,13 @@ static ssize_t trans_stat_show(struct device *dev,
>>  }
>>  static DEVICE_ATTR_RO(trans_stat);
>>
>> +static ssize_t name_show(struct device *dev,
>> +			struct device_attribute *attr, char *buf)
>> +{
>> +	return sprintf(buf, "%s\n", to_devfreq(dev)->name);
>> +}
>> +static DEVICE_ATTR_RO(name);
> 
> You need a new Documentation/ABI/ entry for this.

Thanks for comment. I'll.

Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH] PM / devfreq: Add new name attribute for sysfs
  2018-08-29 12:50   ` Bartlomiej Zolnierkiewicz
@ 2018-08-29 22:59     ` Chanwoo Choi
  0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2018-08-29 22:59 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: myungjoo.ham, kyungmin.park, rafael.j.wysocki, chanwoo, linux-pm,
	linux-kernel, stable

Hi Bartlomiej,

On 2018년 08월 29일 21:50, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi Chanwoo,
> 
> On Wednesday, August 29, 2018 04:34:06 PM Chanwoo Choi wrote:
>> commit 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for
>> sysfs") changed the node name to devfreq(x). After this commit, it is not
>> possible to get the device name through /sys/class/devfreq/devfreq(X)/*.
>>
>> Add new name attribute in order to get device name.
> 
> Could you please describe the issue encountered in more detail
> (what the old device name is needed for)?

You can check it on mail thread[1].
[1] https://lkml.org/lkml/2018/5/8/1042

>  
>> Cc: stable@vger.kernel.org
>> Fixes: 4585fbcb5331 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>>  drivers/devfreq/devfreq.c | 11 +++++++++++
>>  include/linux/devfreq.h   |  3 +++
>>  2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 4c49bb1330b5..2145563d5ee5 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -620,6 +620,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
>>  	}
>>  	devfreq->max_freq = devfreq->scaling_max_freq;
>>
>> +	devfreq->name = dev_name(devfreq->dev.parent);
> 
> It seems that 'dev' can be used instead of 'devfreq->dev.parent'.

devfreq->dev.parent is same with dev. it doesn't matter.

> 
>> +	if (IS_ERR_OR_NULL(devfreq->name))
> 
> Error values are not encoded into pointer returned by dev_name()
> (drivers/base/ code is only checking for pointer being NULL).

OK. I'll just check whether NULL or not.

> 
>> +		return -EINVAL;
> 
> This leaks 'devfreq' object and doesn't encode return value into
> pointer returned by devfreq_add_device(), it should be replaced by:

Right. I'll fix it.

> 
> 	err = -EINVAL;
> 	goto err_dev;
> 
>>  	dev_set_name(&devfreq->dev, "devfreq%d",
>>  				atomic_inc_return(&devfreq_no));
>>  	err = device_register(&devfreq->dev);
> 
> Best regards,
> --
> Bartlomiej Zolnierkiewicz
> Samsung R&D Institute Poland
> Samsung Electronics
> 
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

end of thread, other threads:[~2018-08-29 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180829073410epcas1p2f314e6c4c29eacfe3ebd5fb4f7f2f122@epcas1p2.samsung.com>
2018-08-29  7:34 ` [PATCH] PM / devfreq: Add new name attribute for sysfs Chanwoo Choi
2018-08-29 10:57   ` Greg KH
2018-08-29 22:50     ` Chanwoo Choi
2018-08-29 12:50   ` Bartlomiej Zolnierkiewicz
2018-08-29 22:59     ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).