linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
@ 2019-02-26  7:31 Wei Yang
  2019-02-26 16:10 ` Michael S. Tsirkin
  2019-02-26 18:45 ` [Qemu-devel] " Philippe Mathieu-Daudé
  0 siblings, 2 replies; 12+ messages in thread
From: Wei Yang @ 2019-02-26  7:31 UTC (permalink / raw)
  To: qemu-devel, linux-kernel; +Cc: somlo, mst, Wei Yang

Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
to define the attribute.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 039e0f91dba8..a1293cbd7adb 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
+static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
+			       char *buf)
 {
 	return sprintf(buf, "%u\n", fw_cfg_rev);
 }
-
-static const struct {
-	struct attribute attr;
-	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
-} fw_cfg_rev_attr = {
-	.attr = { .name = "rev", .mode = S_IRUSR },
-	.show = fw_cfg_showrev,
-};
+static const struct kobj_attribute fw_cfg_rev_attr =
+	__ATTR_RO_MODE(fw_cfg_rev, 0400);
 
 /* fw_cfg_sysfs_entry type */
 struct fw_cfg_sysfs_entry {
-- 
2.19.1


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

* Re: [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26  7:31 [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs Wei Yang
@ 2019-02-26 16:10 ` Michael S. Tsirkin
  2019-02-26 18:47   ` [Qemu-devel] " Philippe Mathieu-Daudé
  2019-02-27  5:33   ` Wei Yang
  2019-02-26 18:45 ` [Qemu-devel] " Philippe Mathieu-Daudé
  1 sibling, 2 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-02-26 16:10 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, linux-kernel, somlo

On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
> to define the attribute.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 039e0f91dba8..a1293cbd7adb 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
> +			       char *buf)
>  {
>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>  }
> -
> -static const struct {
> -	struct attribute attr;
> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
> -} fw_cfg_rev_attr = {
> -	.attr = { .name = "rev", .mode = S_IRUSR },
> -	.show = fw_cfg_showrev,
> -};
> +static const struct kobj_attribute fw_cfg_rev_attr =
> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>  
>  /* fw_cfg_sysfs_entry type */
>  struct fw_cfg_sysfs_entry {


Looks like this will change the name from "rev" to "fw_cfg_rev".
That's a userspace visible change which we should not do lightly.
> -- 
> 2.19.1

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26  7:31 [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs Wei Yang
  2019-02-26 16:10 ` Michael S. Tsirkin
@ 2019-02-26 18:45 ` Philippe Mathieu-Daudé
  2019-02-27  3:07   ` Wei Yang
  1 sibling, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-26 18:45 UTC (permalink / raw)
  To: Wei Yang, qemu-devel, linux-kernel; +Cc: somlo, mst

Hi Wei,

On 2/26/19 8:31 AM, Wei Yang wrote:
> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
> to define the attribute.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 039e0f91dba8..a1293cbd7adb 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
> +			       char *buf)
>  {
>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>  }
> -
> -static const struct {
> -	struct attribute attr;
> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
> -} fw_cfg_rev_attr = {
> -	.attr = { .name = "rev", .mode = S_IRUSR },
> -	.show = fw_cfg_showrev,
> -};
> +static const struct kobj_attribute fw_cfg_rev_attr =
> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);

Why not keep S_IRUSR?

>  
>  /* fw_cfg_sysfs_entry type */
>  struct fw_cfg_sysfs_entry {
> 

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26 16:10 ` Michael S. Tsirkin
@ 2019-02-26 18:47   ` Philippe Mathieu-Daudé
  2019-02-26 18:50     ` Michael S. Tsirkin
  2019-02-27  5:33   ` Wei Yang
  1 sibling, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-26 18:47 UTC (permalink / raw)
  To: Michael S. Tsirkin, Wei Yang; +Cc: somlo, qemu-devel, linux-kernel

On 2/26/19 5:10 PM, Michael S. Tsirkin wrote:
> On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
>> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> to define the attribute.
>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> index 039e0f91dba8..a1293cbd7adb 100644
>> --- a/drivers/firmware/qemu_fw_cfg.c
>> +++ b/drivers/firmware/qemu_fw_cfg.c
>> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> +			       char *buf)
>>  {
>>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>>  }
>> -
>> -static const struct {
>> -	struct attribute attr;
>> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> -} fw_cfg_rev_attr = {
>> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> -	.show = fw_cfg_showrev,
>> -};
>> +static const struct kobj_attribute fw_cfg_rev_attr =
>> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>>  
>>  /* fw_cfg_sysfs_entry type */
>>  struct fw_cfg_sysfs_entry {
> 
> 
> Looks like this will change the name from "rev" to "fw_cfg_rev".
> That's a userspace visible change which we should not do lightly.

We could name the function rev_show but this stay fragile, we'd also
need a comment "don't rename this".

>> -- 
>> 2.19.1
> 

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26 18:47   ` [Qemu-devel] " Philippe Mathieu-Daudé
@ 2019-02-26 18:50     ` Michael S. Tsirkin
  0 siblings, 0 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-02-26 18:50 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Wei Yang, somlo, qemu-devel, linux-kernel

On Tue, Feb 26, 2019 at 07:47:35PM +0100, Philippe Mathieu-Daudé wrote:
> On 2/26/19 5:10 PM, Michael S. Tsirkin wrote:
> > On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
> >> to define the attribute.
> >>
> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> >> ---
> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
> >>  1 file changed, 4 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> >> index 039e0f91dba8..a1293cbd7adb 100644
> >> --- a/drivers/firmware/qemu_fw_cfg.c
> >> +++ b/drivers/firmware/qemu_fw_cfg.c
> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
> >>  	return 0;
> >>  }
> >>  
> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
> >> +			       char *buf)
> >>  {
> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
> >>  }
> >> -
> >> -static const struct {
> >> -	struct attribute attr;
> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
> >> -} fw_cfg_rev_attr = {
> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
> >> -	.show = fw_cfg_showrev,
> >> -};
> >> +static const struct kobj_attribute fw_cfg_rev_attr =
> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
> >>  
> >>  /* fw_cfg_sysfs_entry type */
> >>  struct fw_cfg_sysfs_entry {
> > 
> > 
> > Looks like this will change the name from "rev" to "fw_cfg_rev".
> > That's a userspace visible change which we should not do lightly.
> 
> We could name the function rev_show but this stay fragile, we'd also
> need a comment "don't rename this".

It's a given that one must not rename attributes.

> >> -- 
> >> 2.19.1
> > 

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26 18:45 ` [Qemu-devel] " Philippe Mathieu-Daudé
@ 2019-02-27  3:07   ` Wei Yang
  2019-02-27 13:54     ` Michael S. Tsirkin
  0 siblings, 1 reply; 12+ messages in thread
From: Wei Yang @ 2019-02-27  3:07 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Wei Yang, qemu-devel, linux-kernel, somlo, mst

On Tue, Feb 26, 2019 at 07:45:46PM +0100, Philippe Mathieu-Daudé wrote:
>Hi Wei,
>
>On 2/26/19 8:31 AM, Wei Yang wrote:
>> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> to define the attribute.
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> index 039e0f91dba8..a1293cbd7adb 100644
>> --- a/drivers/firmware/qemu_fw_cfg.c
>> +++ b/drivers/firmware/qemu_fw_cfg.c
>> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> +			       char *buf)
>>  {
>>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>>  }
>> -
>> -static const struct {
>> -	struct attribute attr;
>> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> -} fw_cfg_rev_attr = {
>> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> -	.show = fw_cfg_showrev,
>> -};
>> +static const struct kobj_attribute fw_cfg_rev_attr =
>> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>
>Why not keep S_IRUSR?
>

Because scripts/checkpatch.pl suggest not use S_IRUSR :-)

I am not sure about the particular reason.

>>  
>>  /* fw_cfg_sysfs_entry type */
>>  struct fw_cfg_sysfs_entry {
>> 

-- 
Wei Yang
Help you, Help me

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

* Re: [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-26 16:10 ` Michael S. Tsirkin
  2019-02-26 18:47   ` [Qemu-devel] " Philippe Mathieu-Daudé
@ 2019-02-27  5:33   ` Wei Yang
  2019-02-27 13:51     ` Michael S. Tsirkin
  1 sibling, 1 reply; 12+ messages in thread
From: Wei Yang @ 2019-02-27  5:33 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Wei Yang, qemu-devel, linux-kernel, somlo

On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote:
>On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
>> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> to define the attribute.
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>>  1 file changed, 4 insertions(+), 9 deletions(-)
>> 
>> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> index 039e0f91dba8..a1293cbd7adb 100644
>> --- a/drivers/firmware/qemu_fw_cfg.c
>> +++ b/drivers/firmware/qemu_fw_cfg.c
>> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> +			       char *buf)
>>  {
>>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>>  }
>> -
>> -static const struct {
>> -	struct attribute attr;
>> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> -} fw_cfg_rev_attr = {
>> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> -	.show = fw_cfg_showrev,
>> -};
>> +static const struct kobj_attribute fw_cfg_rev_attr =
>> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>>  
>>  /* fw_cfg_sysfs_entry type */
>>  struct fw_cfg_sysfs_entry {
>
>
>Looks like this will change the name from "rev" to "fw_cfg_rev".
>That's a userspace visible change which we should not do lightly.

You are right, I should keep the interface untouched.

To keep it user un-visible, we could change like below:

-       __ATTR_RO(fw_cfg_rev);
+       __ATTR_RO(rev);

Is this better for you?

>> -- 
>> 2.19.1

-- 
Wei Yang
Help you, Help me

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

* Re: [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-27  5:33   ` Wei Yang
@ 2019-02-27 13:51     ` Michael S. Tsirkin
  2019-02-27 14:26       ` [Qemu-devel] " Wei Yang
  2019-02-28  0:49       ` Wei Yang
  0 siblings, 2 replies; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-02-27 13:51 UTC (permalink / raw)
  To: Wei Yang; +Cc: qemu-devel, linux-kernel, somlo

On Wed, Feb 27, 2019 at 01:33:19PM +0800, Wei Yang wrote:
> On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote:
> >On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
> >> to define the attribute.
> >> 
> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> >> ---
> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
> >>  1 file changed, 4 insertions(+), 9 deletions(-)
> >> 
> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> >> index 039e0f91dba8..a1293cbd7adb 100644
> >> --- a/drivers/firmware/qemu_fw_cfg.c
> >> +++ b/drivers/firmware/qemu_fw_cfg.c
> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
> >>  	return 0;
> >>  }
> >>  
> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
> >> +			       char *buf)
> >>  {
> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
> >>  }
> >> -
> >> -static const struct {
> >> -	struct attribute attr;
> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
> >> -} fw_cfg_rev_attr = {
> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
> >> -	.show = fw_cfg_showrev,
> >> -};
> >> +static const struct kobj_attribute fw_cfg_rev_attr =
> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
> >>  
> >>  /* fw_cfg_sysfs_entry type */
> >>  struct fw_cfg_sysfs_entry {
> >
> >
> >Looks like this will change the name from "rev" to "fw_cfg_rev".
> >That's a userspace visible change which we should not do lightly.
> 
> You are right, I should keep the interface untouched.
> 
> To keep it user un-visible, we could change like below:
> 
> -       __ATTR_RO(fw_cfg_rev);
> +       __ATTR_RO(rev);
> 
> Is this better for you?


Also why use 0400 and not S_IRUSR?

> >> -- 
> >> 2.19.1
> 
> -- 
> Wei Yang
> Help you, Help me

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-27  3:07   ` Wei Yang
@ 2019-02-27 13:54     ` Michael S. Tsirkin
  2019-02-27 14:29       ` Wei Yang
  0 siblings, 1 reply; 12+ messages in thread
From: Michael S. Tsirkin @ 2019-02-27 13:54 UTC (permalink / raw)
  To: Wei Yang; +Cc: Philippe Mathieu-Daudé, qemu-devel, linux-kernel, somlo

On Wed, Feb 27, 2019 at 11:07:16AM +0800, Wei Yang wrote:
> On Tue, Feb 26, 2019 at 07:45:46PM +0100, Philippe Mathieu-Daudé wrote:
> >Hi Wei,
> >
> >On 2/26/19 8:31 AM, Wei Yang wrote:
> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
> >> to define the attribute.
> >> 
> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> >> ---
> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
> >>  1 file changed, 4 insertions(+), 9 deletions(-)
> >> 
> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> >> index 039e0f91dba8..a1293cbd7adb 100644
> >> --- a/drivers/firmware/qemu_fw_cfg.c
> >> +++ b/drivers/firmware/qemu_fw_cfg.c
> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
> >>  	return 0;
> >>  }
> >>  
> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
> >> +			       char *buf)
> >>  {
> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
> >>  }
> >> -
> >> -static const struct {
> >> -	struct attribute attr;
> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
> >> -} fw_cfg_rev_attr = {
> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
> >> -	.show = fw_cfg_showrev,
> >> -};
> >> +static const struct kobj_attribute fw_cfg_rev_attr =
> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
> >
> >Why not keep S_IRUSR?
> >
> 
> Because scripts/checkpatch.pl suggest not use S_IRUSR :-)
> 
> I am not sure about the particular reason.

Oh yea.

http://lkml.kernel.org/r/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ@mail.gmail.com

maybe mention this in the commit log.

> >>  
> >>  /* fw_cfg_sysfs_entry type */
> >>  struct fw_cfg_sysfs_entry {
> >> 
> 
> -- 
> Wei Yang
> Help you, Help me

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-27 13:51     ` Michael S. Tsirkin
@ 2019-02-27 14:26       ` Wei Yang
  2019-02-28  0:49       ` Wei Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Wei Yang @ 2019-02-27 14:26 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Wei Yang, somlo, qemu-devel, linux-kernel

On Wed, Feb 27, 2019 at 08:51:11AM -0500, Michael S. Tsirkin wrote:
>On Wed, Feb 27, 2019 at 01:33:19PM +0800, Wei Yang wrote:
>> On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote:
>> >On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
>> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> >> to define the attribute.
>> >> 
>> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> >> ---
>> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>> >>  1 file changed, 4 insertions(+), 9 deletions(-)
>> >> 
>> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> >> index 039e0f91dba8..a1293cbd7adb 100644
>> >> --- a/drivers/firmware/qemu_fw_cfg.c
>> >> +++ b/drivers/firmware/qemu_fw_cfg.c
>> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>> >>  	return 0;
>> >>  }
>> >>  
>> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> >> +			       char *buf)
>> >>  {
>> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>> >>  }
>> >> -
>> >> -static const struct {
>> >> -	struct attribute attr;
>> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> >> -} fw_cfg_rev_attr = {
>> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> >> -	.show = fw_cfg_showrev,
>> >> -};
>> >> +static const struct kobj_attribute fw_cfg_rev_attr =
>> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>> >>  
>> >>  /* fw_cfg_sysfs_entry type */
>> >>  struct fw_cfg_sysfs_entry {
>> >
>> >
>> >Looks like this will change the name from "rev" to "fw_cfg_rev".
>> >That's a userspace visible change which we should not do lightly.
>> 
>> You are right, I should keep the interface untouched.
>> 
>> To keep it user un-visible, we could change like below:
>> 
>> -       __ATTR_RO(fw_cfg_rev);
>> +       __ATTR_RO(rev);
>> 
>> Is this better for you?
>
>
>Also why use 0400 and not S_IRUSR?
>

This is interesting. The scripts/checkpatch.pl suggest to use 0400.

I am not sure why the script give this suggestion. Maybe we need to fix
the script?

>> >> -- 
>> >> 2.19.1
>> 
>> -- 
>> Wei Yang
>> Help you, Help me

-- 
Wei Yang
Help you, Help me

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

* Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-27 13:54     ` Michael S. Tsirkin
@ 2019-02-27 14:29       ` Wei Yang
  0 siblings, 0 replies; 12+ messages in thread
From: Wei Yang @ 2019-02-27 14:29 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Wei Yang, somlo, Philippe Mathieu-Daudé, qemu-devel, linux-kernel

On Wed, Feb 27, 2019 at 08:54:58AM -0500, Michael S. Tsirkin wrote:
>On Wed, Feb 27, 2019 at 11:07:16AM +0800, Wei Yang wrote:
>> On Tue, Feb 26, 2019 at 07:45:46PM +0100, Philippe Mathieu-Daudé wrote:
>> >Hi Wei,
>> >
>> >On 2/26/19 8:31 AM, Wei Yang wrote:
>> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> >> to define the attribute.
>> >> 
>> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> >> ---
>> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>> >>  1 file changed, 4 insertions(+), 9 deletions(-)
>> >> 
>> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> >> index 039e0f91dba8..a1293cbd7adb 100644
>> >> --- a/drivers/firmware/qemu_fw_cfg.c
>> >> +++ b/drivers/firmware/qemu_fw_cfg.c
>> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>> >>  	return 0;
>> >>  }
>> >>  
>> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> >> +			       char *buf)
>> >>  {
>> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>> >>  }
>> >> -
>> >> -static const struct {
>> >> -	struct attribute attr;
>> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> >> -} fw_cfg_rev_attr = {
>> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> >> -	.show = fw_cfg_showrev,
>> >> -};
>> >> +static const struct kobj_attribute fw_cfg_rev_attr =
>> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>> >
>> >Why not keep S_IRUSR?
>> >
>> 
>> Because scripts/checkpatch.pl suggest not use S_IRUSR :-)
>> 
>> I am not sure about the particular reason.
>
>Oh yea.
>
>http://lkml.kernel.org/r/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ@mail.gmail.com
>
>maybe mention this in the commit log.
>

Thanks :-)

>> >>  
>> >>  /* fw_cfg_sysfs_entry type */
>> >>  struct fw_cfg_sysfs_entry {
>> >> 
>> 
>> -- 
>> Wei Yang
>> Help you, Help me

-- 
Wei Yang
Help you, Help me

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

* Re: [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs
  2019-02-27 13:51     ` Michael S. Tsirkin
  2019-02-27 14:26       ` [Qemu-devel] " Wei Yang
@ 2019-02-28  0:49       ` Wei Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Wei Yang @ 2019-02-28  0:49 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Wei Yang, qemu-devel, linux-kernel, somlo

On Wed, Feb 27, 2019 at 08:51:11AM -0500, Michael S. Tsirkin wrote:
>On Wed, Feb 27, 2019 at 01:33:19PM +0800, Wei Yang wrote:
>> On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote:
>> >On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote:
>> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code
>> >> to define the attribute.
>> >> 
>> >> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> >> ---
>> >>  drivers/firmware/qemu_fw_cfg.c | 13 ++++---------
>> >>  1 file changed, 4 insertions(+), 9 deletions(-)
>> >> 
>> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
>> >> index 039e0f91dba8..a1293cbd7adb 100644
>> >> --- a/drivers/firmware/qemu_fw_cfg.c
>> >> +++ b/drivers/firmware/qemu_fw_cfg.c
>> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
>> >>  	return 0;
>> >>  }
>> >>  
>> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
>> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a,
>> >> +			       char *buf)
>> >>  {
>> >>  	return sprintf(buf, "%u\n", fw_cfg_rev);
>> >>  }
>> >> -
>> >> -static const struct {
>> >> -	struct attribute attr;
>> >> -	ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
>> >> -} fw_cfg_rev_attr = {
>> >> -	.attr = { .name = "rev", .mode = S_IRUSR },
>> >> -	.show = fw_cfg_showrev,
>> >> -};
>> >> +static const struct kobj_attribute fw_cfg_rev_attr =
>> >> +	__ATTR_RO_MODE(fw_cfg_rev, 0400);
>> >>  
>> >>  /* fw_cfg_sysfs_entry type */
>> >>  struct fw_cfg_sysfs_entry {
>> >
>> >
>> >Looks like this will change the name from "rev" to "fw_cfg_rev".
>> >That's a userspace visible change which we should not do lightly.
>> 
>> You are right, I should keep the interface untouched.
>> 
>> To keep it user un-visible, we could change like below:
>> 
>> -       __ATTR_RO(fw_cfg_rev);
>> +       __ATTR_RO(rev);
>> 
>> Is this better for you?
>
>
>Also why use 0400 and not S_IRUSR?
>

In case this is the proper way to use 0400 and after keeping the name
un-changed, would you mind I sending v2 for this?

>> >> -- 
>> >> 2.19.1
>> 
>> -- 
>> Wei Yang
>> Help you, Help me

-- 
Wei Yang
Help you, Help me

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

end of thread, other threads:[~2019-02-28  0:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26  7:31 [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs Wei Yang
2019-02-26 16:10 ` Michael S. Tsirkin
2019-02-26 18:47   ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-02-26 18:50     ` Michael S. Tsirkin
2019-02-27  5:33   ` Wei Yang
2019-02-27 13:51     ` Michael S. Tsirkin
2019-02-27 14:26       ` [Qemu-devel] " Wei Yang
2019-02-28  0:49       ` Wei Yang
2019-02-26 18:45 ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-02-27  3:07   ` Wei Yang
2019-02-27 13:54     ` Michael S. Tsirkin
2019-02-27 14:29       ` Wei Yang

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).