staging: fbtft: convert sysfs attributes to use ATTRIBUTE_GROUPS
Subsystems (2)
PATCH v2 1/1 staging: fbtft: convert sysfs attributes to use ATTRIBUTE_GROUPS
Replace direct device_create_file() calls with the correct ATTRIBUTE_GROUPS() macro. Add fbtft_groups as dev_groups in the driver structure so the driver core automatically adds and removes the sysfs attributes when a device is bound or unbound.
---
v2: - Use DEVICE_ATTR_RW() macro instead of DEVICE_ATTR()
- Move DEVICE_ATTR_RW() definitions closer to their callbacks
- Remove trailing comma after NULL in attribute array
- Remove extern declaration from internal.h, not needed
- Use ATTRIBUTE_GROUPS() macro and add dev_groups to driver structure as suggested by Greg KH and Andy Shevchenko
- Compile tested with: make M=drivers/staging/fbtft modules
drivers/staging/fbtft/fbtft-core.c | 3 -- drivers/staging/fbtft/fbtft-sysfs.c | 80 +++++++++++------------------ drivers/staging/fbtft/fbtft.h | 2 + drivers/staging/fbtft/internal.h | 2 - 4 files changed, 32 insertions(+), 55 deletions(-)
drivers/staging/fbtft/fbtft-core.c +0 -3
@@ -782,8 +782,6 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)if (ret <0 ) goto reg_fail; -fbtft_sysfs_init (par); -if (par->txbuf.buf && par->txbuf.len >=1024 )sprintf (text1,", %zu KiB buffer memory" , par->txbuf.len >>10 );if (spi)
@@ -826,7 +824,6 @@ int fbtft_unregister_framebuffer(struct fb_info *fb_info)if (par->fbtftops.unregister_backlight) par->fbtftops.unregister_backlight (par); -fbtft_sysfs_exit (par);unregister_framebuffer (fb_info);return 0 ;
drivers/staging/fbtft/fbtft-sysfs.c +30 -50
104 lines not on this page · raw message
drivers/staging/fbtft/fbtft.h +2 -0
@@ -299,6 +299,7 @@ static struct spi_driver fbtft_driver_spi_driver = { \ .driver = { \ .name = _name, \ .of_match_table = dt_ids, \ + .dev_groups = fbtft_groups, \ }, \ .id_table = _spi_ids, \ .probe = fbtft_driver_probe_spi, \
@@ -328,6 +329,7 @@ static struct platform_driver fbtft_driver_platform_driver = { \ .name = _name, \ .owner = THIS_MODULE, \ .of_match_table = dt_ids, \ + .dev_groups = fbtft_groups, \ }, \ .probe = fbtft_driver_probe_pdev, \ .remove = fbtft_driver_remove_pdev, \
drivers/staging/fbtft/internal.h +0 -2
@@ -4,8 +4,6 @@#ifndef __LINUX_FBTFT_INTERNAL_H#define __LINUX_FBTFT_INTERNAL_H -void fbtft_sysfs_init (struct fbtft_par *par); -void fbtft_sysfs_exit (struct fbtft_par *par);void fbtft_expand_debug_value (unsigned long *debug);int fbtft_gamma_parse_str (struct fbtft_par *par,u32 *curves,const char *str,int size);
Signature · 1 line
2.53.0
Quoted 6 lines · Harshit Shaw
Replace direct
device_create_file()calls with the correctATTRIBUTE_GROUPS()macro. Addfbtft_groupsasdev_groupsin the driver structure so the driver core automatically adds and removes the sysfs attributes when a device is bound or unbound.Signed-off-by Harshit Shaw <[email protected]>
Quoted 8 lines
---
v2: - UseDEVICE_ATTR_RW()macro instead ofDEVICE_ATTR()
- MoveDEVICE_ATTR_RW()definitions closer to their callbacks
- Remove trailing comma after NULL in attribute array
- Remove extern declaration frominternal.h, not needed
- UseATTRIBUTE_GROUPS()macro and adddev_groupsto driver structure as suggested by Greg KH and Andy Shevchenko
- Compile tested with: make M=drivers/staging/fbtft modules
Thanks for the update!
...
Quoted 2 lines
+static struct attribute *fbtft_attrs[] = {
Now it has stray blank line here.
drivers/staging/fbtft/fbtft-sysfs.c static ssize_t store_debug(struct device *device, · line 206
Quoted 4 lines
drivers/staging/fbtft/fbtft-sysfs.c +4
-0+ &dev_attr_debug.attr, + &dev_attr_gamma.attr, + NULL +};
...
Otherwise LGTM, and if Sashiko and others are happy with it
Signature · 2 lines
With Best Regards, Andy Shevchenko