diff mbox series

[1/2] video: fbdev: gbefb: Convert to use dev_groups

Message ID 20220902025555.3833920-1-jiasheng@iscas.ac.cn
State New
Headers show
Series [1/2] video: fbdev: gbefb: Convert to use dev_groups | expand

Commit Message

Jiasheng Jiang Sept. 2, 2022, 2:55 a.m. UTC
The driver core supports the ability to handle the creation and removal
of device-specific sysfs files in a race-free manner. Moreover, it can
guarantee the success of creation. Therefore, it should be better to
convert to use dev_groups.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/video/fbdev/gbefb.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

Comments

Helge Deller Sept. 25, 2022, 11:26 a.m. UTC | #1
On 9/2/22 04:55, Jiasheng Jiang wrote:
> The driver core supports the ability to handle the creation and removal
> of device-specific sysfs files in a race-free manner. Moreover, it can
> guarantee the success of creation. Therefore, it should be better to
> convert to use dev_groups.

applied. Thanks!

> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

This Fixes: lines doesn't make sense.
I dropped it.

Helge


> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/video/fbdev/gbefb.c | 20 +++++++-------------
>   1 file changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c
> index 6b4d5a7f3e15..1582c718329c 100644
> --- a/drivers/video/fbdev/gbefb.c
> +++ b/drivers/video/fbdev/gbefb.c
> @@ -1072,17 +1072,12 @@ static ssize_t gbefb_show_rev(struct device *device, struct device_attribute *at
>
>   static DEVICE_ATTR(revision, S_IRUGO, gbefb_show_rev, NULL);
>
> -static void gbefb_remove_sysfs(struct device *dev)
> -{
> -	device_remove_file(dev, &dev_attr_size);
> -	device_remove_file(dev, &dev_attr_revision);
> -}
> -
> -static void gbefb_create_sysfs(struct device *dev)
> -{
> -	device_create_file(dev, &dev_attr_size);
> -	device_create_file(dev, &dev_attr_revision);
> -}
> +static struct attribute *gbefb_attrs[] = {
> +	&dev_attr_size.attr,
> +	&dev_attr_revision.attr,
> +	NULL,
> +};
> +ATTRIBUTE_GROUPS(gbefb);
>
>   /*
>    * Initialization
> @@ -1221,7 +1216,6 @@ static int gbefb_probe(struct platform_device *p_dev)
>   	}
>
>   	platform_set_drvdata(p_dev, info);
> -	gbefb_create_sysfs(&p_dev->dev);
>
>   	fb_info(info, "%s rev %d @ 0x%08x using %dkB memory\n",
>   		info->fix.id, gbe_revision, (unsigned)GBE_BASE,
> @@ -1248,7 +1242,6 @@ static int gbefb_remove(struct platform_device* p_dev)
>   	gbe_turn_off();
>   	arch_phys_wc_del(par->wc_cookie);
>   	release_mem_region(GBE_BASE, sizeof(struct sgi_gbe));
> -	gbefb_remove_sysfs(&p_dev->dev);
>   	framebuffer_release(info);
>
>   	return 0;
> @@ -1259,6 +1252,7 @@ static struct platform_driver gbefb_driver = {
>   	.remove = gbefb_remove,
>   	.driver	= {
>   		.name = "gbefb",
> +		.dev_groups	= gbefb_groups,
>   	},
>   };
>
diff mbox series

Patch

diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c
index 6b4d5a7f3e15..1582c718329c 100644
--- a/drivers/video/fbdev/gbefb.c
+++ b/drivers/video/fbdev/gbefb.c
@@ -1072,17 +1072,12 @@  static ssize_t gbefb_show_rev(struct device *device, struct device_attribute *at
 
 static DEVICE_ATTR(revision, S_IRUGO, gbefb_show_rev, NULL);
 
-static void gbefb_remove_sysfs(struct device *dev)
-{
-	device_remove_file(dev, &dev_attr_size);
-	device_remove_file(dev, &dev_attr_revision);
-}
-
-static void gbefb_create_sysfs(struct device *dev)
-{
-	device_create_file(dev, &dev_attr_size);
-	device_create_file(dev, &dev_attr_revision);
-}
+static struct attribute *gbefb_attrs[] = {
+	&dev_attr_size.attr,
+	&dev_attr_revision.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(gbefb);
 
 /*
  * Initialization
@@ -1221,7 +1216,6 @@  static int gbefb_probe(struct platform_device *p_dev)
 	}
 
 	platform_set_drvdata(p_dev, info);
-	gbefb_create_sysfs(&p_dev->dev);
 
 	fb_info(info, "%s rev %d @ 0x%08x using %dkB memory\n",
 		info->fix.id, gbe_revision, (unsigned)GBE_BASE,
@@ -1248,7 +1242,6 @@  static int gbefb_remove(struct platform_device* p_dev)
 	gbe_turn_off();
 	arch_phys_wc_del(par->wc_cookie);
 	release_mem_region(GBE_BASE, sizeof(struct sgi_gbe));
-	gbefb_remove_sysfs(&p_dev->dev);
 	framebuffer_release(info);
 
 	return 0;
@@ -1259,6 +1252,7 @@  static struct platform_driver gbefb_driver = {
 	.remove = gbefb_remove,
 	.driver	= {
 		.name = "gbefb",
+		.dev_groups	= gbefb_groups,
 	},
 };