Skip to contentSkip to conversation

staging: fbtft: convert sysfs attributes to use ATTRIBUTE_GROUPS

PATCH Superseded Harshit Shaw 2 participants 2 messages May 12

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 ATTRIBUTE_GROUPS() macro and add dev_groups to driver
structure instead of using sysfs_create_group() directly, as suggested by Greg KH.

 drivers/staging/fbtft/fbtft-core.c  |  3 -
 drivers/staging/fbtft/fbtft-sysfs.c | 86 +++++++++++------------------
 drivers/staging/fbtft/fbtft.h       |  2 +
 drivers/staging/fbtft/internal.h    |  3 +-
 4 files changed, 35 insertions(+), 59 deletions(-)
drivers/staging/fbtft/fbtft-core.c +0 -3
index 3da42c8ca6e3..e6d33127cecc 100644
@@ -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 +32 -54

100 lines not on this page · raw message

drivers/staging/fbtft/fbtft.h +2 -0
index 317be17b95c1..ab71db017d05 100644
@@ -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 +1 -2
index ae2ff4a4a472..39fd1e167b41 100644
@@ -4,8 +4,7 @@
 #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);
+extern const struct attribute_group *fbtft_groups[];
 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
#1 lore raw
Quoted 7 lines · Harshit Shaw

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.

---

This is not a v2 as you read the Subject.

Quoted 3 lines

v2: Use ATTRIBUTE_GROUPS() macro and add dev_groups to driver
structure instead of using sysfs_create_group() directly, as suggested by Greg KH.

I gave you the comments in previous version, and at least some of them were ignored. Why?

...

Quoted 1 line

+extern const struct attribute_group *fbtft_groups[];

You haven't compiled that?

Signature · 2 lines
With Best Regards,
Andy Shevchenko