All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR()
@ 2017-12-11  9:54 Aishwarya Pant
  2017-12-13 11:50 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Aishwarya Pant @ 2017-12-11  9:54 UTC (permalink / raw)
  To: Thomas Petazzoni, Greg Kroah-Hartman, devel, linux-kernel; +Cc: julia.lawall

This is a clean-up patch which replaces the uses of raw __ATTR(...)
macro with the more conventional DEVICE_ATTR(...) for defining device
attributes.

Done using coccinelle-

@r@
identifier foo, n;
@@

struct device_attribute foo =  __ATTR(n, ...);

@script:python p@
id;
foo << r.foo;
n << r.n;
@@

// standardise the variable name to dev_attr_{name}
coccinelle.id = "dev_attr_" + n

@@
identifier r.foo;
declarer name DEVICE_ATTR;
@@

//change definition
- struct device_attribute foo = __ATTR
+ DEVICE_ATTR
	(...);

@depends on r@
identifier r.foo, p.id;
@@

// replace usages everywhere
- foo
+ id

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
---
 drivers/staging/fbtft/fbtft-sysfs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
index 712096659aa0..506d604d01bb 100644
--- a/drivers/staging/fbtft/fbtft-sysfs.c
+++ b/drivers/staging/fbtft/fbtft-sysfs.c
@@ -197,19 +197,18 @@ static ssize_t show_debug(struct device *device,
 	return snprintf(buf, PAGE_SIZE, "%lu\n", par->debug);
 }
 
-static struct device_attribute debug_device_attr =
-	__ATTR(debug, 0660, show_debug, store_debug);
+static DEVICE_ATTR(debug, 0660, show_debug, store_debug);
 
 void fbtft_sysfs_init(struct fbtft_par *par)
 {
-	device_create_file(par->info->dev, &debug_device_attr);
+	device_create_file(par->info->dev, &dev_attr_debug);
 	if (par->gamma.curves && par->fbtftops.set_gamma)
 		device_create_file(par->info->dev, &gamma_device_attrs[0]);
 }
 
 void fbtft_sysfs_exit(struct fbtft_par *par)
 {
-	device_remove_file(par->info->dev, &debug_device_attr);
+	device_remove_file(par->info->dev, &dev_attr_debug);
 	if (par->gamma.curves && par->fbtftops.set_gamma)
 		device_remove_file(par->info->dev, &gamma_device_attrs[0]);
 }
-- 
2.15.1

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

* Re: [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR()
  2017-12-11  9:54 [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR() Aishwarya Pant
@ 2017-12-13 11:50 ` Greg Kroah-Hartman
  2017-12-14  6:21   ` Aishwarya Pant
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2017-12-13 11:50 UTC (permalink / raw)
  To: Aishwarya Pant; +Cc: Thomas Petazzoni, devel, linux-kernel, julia.lawall

On Mon, Dec 11, 2017 at 03:24:30PM +0530, Aishwarya Pant wrote:
> This is a clean-up patch which replaces the uses of raw __ATTR(...)
> macro with the more conventional DEVICE_ATTR(...) for defining device
> attributes.
> 
> Done using coccinelle-
> 
> @r@
> identifier foo, n;
> @@
> 
> struct device_attribute foo =  __ATTR(n, ...);
> 
> @script:python p@
> id;
> foo << r.foo;
> n << r.n;
> @@
> 
> // standardise the variable name to dev_attr_{name}
> coccinelle.id = "dev_attr_" + n
> 
> @@
> identifier r.foo;
> declarer name DEVICE_ATTR;
> @@
> 
> //change definition
> - struct device_attribute foo = __ATTR
> + DEVICE_ATTR
> 	(...);
> 
> @depends on r@
> identifier r.foo, p.id;
> @@
> 
> // replace usages everywhere
> - foo
> + id
> 
> Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
> ---
>  drivers/staging/fbtft/fbtft-sysfs.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
> index 712096659aa0..506d604d01bb 100644
> --- a/drivers/staging/fbtft/fbtft-sysfs.c
> +++ b/drivers/staging/fbtft/fbtft-sysfs.c
> @@ -197,19 +197,18 @@ static ssize_t show_debug(struct device *device,
>  	return snprintf(buf, PAGE_SIZE, "%lu\n", par->debug);
>  }
>  
> -static struct device_attribute debug_device_attr =
> -	__ATTR(debug, 0660, show_debug, store_debug);
> +static DEVICE_ATTR(debug, 0660, show_debug, store_debug);

This should be DEVICE_ATTR_RW(), right?  0660 makes no sense...

thanks,

greg k-h

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

* Re: [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR()
  2017-12-13 11:50 ` Greg Kroah-Hartman
@ 2017-12-14  6:21   ` Aishwarya Pant
  2017-12-14  7:27     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Aishwarya Pant @ 2017-12-14  6:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Thomas Petazzoni, devel, linux-kernel, julia.lawall

On Wed, Dec 13, 2017 at 12:50:00PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Dec 11, 2017 at 03:24:30PM +0530, Aishwarya Pant wrote:
> > This is a clean-up patch which replaces the uses of raw __ATTR(...)
> > macro with the more conventional DEVICE_ATTR(...) for defining device
> > attributes.
> > 
> > Done using coccinelle-
> > 
> > @r@
> > identifier foo, n;
> > @@
> > 
> > struct device_attribute foo =  __ATTR(n, ...);
> > 
> > @script:python p@
> > id;
> > foo << r.foo;
> > n << r.n;
> > @@
> > 
> > // standardise the variable name to dev_attr_{name}
> > coccinelle.id = "dev_attr_" + n
> > 
> > @@
> > identifier r.foo;
> > declarer name DEVICE_ATTR;
> > @@
> > 
> > //change definition
> > - struct device_attribute foo = __ATTR
> > + DEVICE_ATTR
> > 	(...);
> > 
> > @depends on r@
> > identifier r.foo, p.id;
> > @@
> > 
> > // replace usages everywhere
> > - foo
> > + id
> > 
> > Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
> > ---
> >  drivers/staging/fbtft/fbtft-sysfs.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
> > index 712096659aa0..506d604d01bb 100644
> > --- a/drivers/staging/fbtft/fbtft-sysfs.c
> > +++ b/drivers/staging/fbtft/fbtft-sysfs.c
> > @@ -197,19 +197,18 @@ static ssize_t show_debug(struct device *device,
> >  	return snprintf(buf, PAGE_SIZE, "%lu\n", par->debug);
> >  }
> >  
> > -static struct device_attribute debug_device_attr =
> > -	__ATTR(debug, 0660, show_debug, store_debug);
> > +static DEVICE_ATTR(debug, 0660, show_debug, store_debug);
> 
> This should be DEVICE_ATTR_RW(), right?  0660 makes no sense...

If it doesn't make sense here, I can replace it with DEVICE_ATTR_RW.
Though, 0660 has more open permissions than 0644.

> 
> thanks,
> 
> greg k-h

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

* Re: [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR()
  2017-12-14  6:21   ` Aishwarya Pant
@ 2017-12-14  7:27     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2017-12-14  7:27 UTC (permalink / raw)
  To: Aishwarya Pant; +Cc: devel, linux-kernel, julia.lawall

On Thu, Dec 14, 2017 at 11:51:17AM +0530, Aishwarya Pant wrote:
> On Wed, Dec 13, 2017 at 12:50:00PM +0100, Greg Kroah-Hartman wrote:
> > On Mon, Dec 11, 2017 at 03:24:30PM +0530, Aishwarya Pant wrote:
> > > This is a clean-up patch which replaces the uses of raw __ATTR(...)
> > > macro with the more conventional DEVICE_ATTR(...) for defining device
> > > attributes.
> > > 
> > > Done using coccinelle-
> > > 
> > > @r@
> > > identifier foo, n;
> > > @@
> > > 
> > > struct device_attribute foo =  __ATTR(n, ...);
> > > 
> > > @script:python p@
> > > id;
> > > foo << r.foo;
> > > n << r.n;
> > > @@
> > > 
> > > // standardise the variable name to dev_attr_{name}
> > > coccinelle.id = "dev_attr_" + n
> > > 
> > > @@
> > > identifier r.foo;
> > > declarer name DEVICE_ATTR;
> > > @@
> > > 
> > > //change definition
> > > - struct device_attribute foo = __ATTR
> > > + DEVICE_ATTR
> > > 	(...);
> > > 
> > > @depends on r@
> > > identifier r.foo, p.id;
> > > @@
> > > 
> > > // replace usages everywhere
> > > - foo
> > > + id
> > > 
> > > Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
> > > ---
> > >  drivers/staging/fbtft/fbtft-sysfs.c | 7 +++----
> > >  1 file changed, 3 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
> > > index 712096659aa0..506d604d01bb 100644
> > > --- a/drivers/staging/fbtft/fbtft-sysfs.c
> > > +++ b/drivers/staging/fbtft/fbtft-sysfs.c
> > > @@ -197,19 +197,18 @@ static ssize_t show_debug(struct device *device,
> > >  	return snprintf(buf, PAGE_SIZE, "%lu\n", par->debug);
> > >  }
> > >  
> > > -static struct device_attribute debug_device_attr =
> > > -	__ATTR(debug, 0660, show_debug, store_debug);
> > > +static DEVICE_ATTR(debug, 0660, show_debug, store_debug);
> > 
> > This should be DEVICE_ATTR_RW(), right?  0660 makes no sense...
> 
> If it doesn't make sense here, I can replace it with DEVICE_ATTR_RW.
> Though, 0660 has more open permissions than 0644.

Unless there is a really good reason for keeping an "odd" sysfs file
mode, use the default permissions.  As this is just a debug flag, 0644
makes a lot more sense, don't you think?

Actually, just drop this whole attribute.  Random "turn on debugging"
config files do not even belong in sysfs.  We have a kernel-wide
infrastructure for all of that already, no single driver, or tiny
subsystem, should have their own custom way of doing this.

thanks,

greg k-h

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

end of thread, other threads:[~2017-12-14  7:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-11  9:54 [PATCH] staging: fbtft: replace __ATTR() with DEVICE_ATTR() Aishwarya Pant
2017-12-13 11:50 ` Greg Kroah-Hartman
2017-12-14  6:21   ` Aishwarya Pant
2017-12-14  7:27     ` Greg Kroah-Hartman

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.