staging: fbtft: convert sysfs attributes to use ATTRIBUTE_GROUPS
Subsystems (2)
PATCH v4 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.
---
v4: Fix build error - add extern declaration of fbtft_groups in
fbtft.h so all drivers using FBTFT_REGISTER_DRIVER macro can see the symbol
v3: Remove stray blank line in fbtft_attrs[] array
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
- 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 | 81 +++++++++++------------------ drivers/staging/fbtft/fbtft.h | 6 +++ drivers/staging/fbtft/internal.h | 2 - 4 files changed, 36 insertions(+), 56 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 -51
104 lines not on this page · raw message
drivers/staging/fbtft/fbtft.h +6 -0
@@ -8,6 +8,7 @@#include <linux/spinlock.h> #include <linux/spi/spi.h> #include <linux/platform_device.h> +#include <linux/sysfs.h> #define FBTFT_ONBOARD_BACKLIGHT 2
@@ -274,6 +275,9 @@ void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...);void fbtft_write_reg16_bus8 (struct fbtft_par *par,int len, ...);void fbtft_write_reg16_bus16 (struct fbtft_par *par,int len, ...); +/* fbtft-sysfs.c */ +extern const struct attribute_group *fbtft_groups[]; +#define FBTFT_DT_TABLE (_compatible) \ static const struct of_device_id dt_ids[] = { \ { .compatible = _compatible }, \
@@ -299,6 +303,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 +333,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
Greg KH
maintainerQuoted 7 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]>Reported-by kernel test robot <[email protected]>
No, the robot did not report this problem :(
Quoted 4 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.
...
Quoted 1 line
Reviewed-by Andy Shevchenko <[email protected]>
I need to withdraw this tag. Please, compile the code before sending.
You may not use ATTRIBUTE_GROUPS() in conjunction with extern.
Signature · 2 lines
With Best Regards, Andy Shevchenko