[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250219064808.170517-1-oushixiong1025@163.com>
Date: Wed, 19 Feb 2025 14:48:08 +0800
From: oushixiong1025@....com
To: Helge Deller <deller@....de>
Cc: Thomas Zimmermann <tzimmermann@...e.de>,
Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
Lee Jones <lee@...nel.org>,
Uwe Kleine-König <u.kleine-koenig@...libre.com>,
Arnd Bergmann <arnd@...db.de>,
linux-fbdev@...r.kernel.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
Shixiong Ou <oushixiong@...inos.cn>
Subject: [PATCH v3] fbdev: lcdcfb: add missing device_remove_file()
From: Shixiong Ou <oushixiong@...inos.cn>
1. The device_remove_file() need to be called when driver is removing.
2. The device_remove_file() need to be called if the call to
device_create_file() fails.
Signed-off-by: Shixiong Ou <oushixiong@...inos.cn>
---
v1->v2:
add missing 'return error'.
call device_remove_file() in sh_mobile_lcdc_overlay_fb_unregister().
v2->v3:
change the type of 'i' to int.
add overlay_sysfs_attrs_enabled flag.
drivers/video/fbdev/sh_mobile_lcdcfb.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index 4715dcb59811..eaf782133542 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -200,6 +200,8 @@ struct sh_mobile_lcdc_overlay {
unsigned int pitch;
int pos_x;
int pos_y;
+
+ bool overlay_sysfs_attrs_enabled;
};
struct sh_mobile_lcdc_priv {
@@ -1504,10 +1506,16 @@ static void
sh_mobile_lcdc_overlay_fb_unregister(struct sh_mobile_lcdc_overlay *ovl)
{
struct fb_info *info = ovl->info;
+ unsigned int i;
if (info == NULL || info->dev == NULL)
return;
+ if (ovl->overlay_sysfs_attrs_enabled) {
+ for (i = 0; i < ARRAY_SIZE(overlay_sysfs_attrs); ++i)
+ device_remove_file(info->dev, &overlay_sysfs_attrs[i]);
+ ovl->overlay_sysfs_attrs_enabled = false;
+ }
unregister_framebuffer(ovl->info);
}
@@ -1516,7 +1524,7 @@ sh_mobile_lcdc_overlay_fb_register(struct sh_mobile_lcdc_overlay *ovl)
{
struct sh_mobile_lcdc_priv *lcdc = ovl->channel->lcdc;
struct fb_info *info = ovl->info;
- unsigned int i;
+ int i, error = 0;
int ret;
if (info == NULL)
@@ -1530,10 +1538,19 @@ sh_mobile_lcdc_overlay_fb_register(struct sh_mobile_lcdc_overlay *ovl)
dev_name(lcdc->dev), ovl->index, info->var.xres,
info->var.yres, info->var.bits_per_pixel);
+ ovl->overlay_sysfs_attrs_enabled = true;
+
for (i = 0; i < ARRAY_SIZE(overlay_sysfs_attrs); ++i) {
- ret = device_create_file(info->dev, &overlay_sysfs_attrs[i]);
- if (ret < 0)
- return ret;
+ error = device_create_file(info->dev, &overlay_sysfs_attrs[i]);
+ if (error)
+ break;
+ }
+
+ if (error) {
+ while (--i >= 0)
+ device_remove_file(info->dev, &overlay_sysfs_attrs[i]);
+ ovl->overlay_sysfs_attrs_enabled = false;
+ return error;
}
return 0;
--
2.25.1
Powered by blists - more mailing lists