Skip to content

Commit a979182

Browse files
Shixiong Ouhdeller
authored andcommitted
fbdev: lcdcfb: Register sysfs groups through driver core
[WHY] 1. The driver forgot to call device_remove_file() in sh_mobile_lcdc_overlay_fb_unregister(), and there was no error handling when calling device_create_file() failed. 2. This should probably use device_add_group() instead of individual files to simplify both creation and removal. [Arnd] 3. The driver core can register and cleanup sysfs groups already. as commit 95cdd53 ("fbdev: efifb: Register sysfs groups through driver core"). [HOW] Register sysfs groups through driver core. Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 5bbcc76 commit a979182

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

drivers/video/fbdev/sh_mobile_lcdcfb.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,16 +1338,19 @@ overlay_rop3_store(struct device *dev, struct device_attribute *attr,
13381338
return count;
13391339
}
13401340

1341-
static const struct device_attribute overlay_sysfs_attrs[] = {
1342-
__ATTR(ovl_alpha, S_IRUGO|S_IWUSR,
1343-
overlay_alpha_show, overlay_alpha_store),
1344-
__ATTR(ovl_mode, S_IRUGO|S_IWUSR,
1345-
overlay_mode_show, overlay_mode_store),
1346-
__ATTR(ovl_position, S_IRUGO|S_IWUSR,
1347-
overlay_position_show, overlay_position_store),
1348-
__ATTR(ovl_rop3, S_IRUGO|S_IWUSR,
1349-
overlay_rop3_show, overlay_rop3_store),
1341+
static DEVICE_ATTR_RW(overlay_alpha);
1342+
static DEVICE_ATTR_RW(overlay_mode);
1343+
static DEVICE_ATTR_RW(overlay_position);
1344+
static DEVICE_ATTR_RW(overlay_rop3);
1345+
1346+
static struct attribute *overlay_sysfs_attrs[] = {
1347+
&dev_attr_overlay_alpha.attr,
1348+
&dev_attr_overlay_mode.attr,
1349+
&dev_attr_overlay_position.attr,
1350+
&dev_attr_overlay_rop3.attr,
1351+
NULL,
13501352
};
1353+
ATTRIBUTE_GROUPS(overlay_sysfs);
13511354

13521355
static const struct fb_fix_screeninfo sh_mobile_lcdc_overlay_fix = {
13531356
.id = "SH Mobile LCDC",
@@ -1516,7 +1519,6 @@ sh_mobile_lcdc_overlay_fb_register(struct sh_mobile_lcdc_overlay *ovl)
15161519
{
15171520
struct sh_mobile_lcdc_priv *lcdc = ovl->channel->lcdc;
15181521
struct fb_info *info = ovl->info;
1519-
unsigned int i;
15201522
int ret;
15211523

15221524
if (info == NULL)
@@ -1530,12 +1532,6 @@ sh_mobile_lcdc_overlay_fb_register(struct sh_mobile_lcdc_overlay *ovl)
15301532
dev_name(lcdc->dev), ovl->index, info->var.xres,
15311533
info->var.yres, info->var.bits_per_pixel);
15321534

1533-
for (i = 0; i < ARRAY_SIZE(overlay_sysfs_attrs); ++i) {
1534-
ret = device_create_file(info->dev, &overlay_sysfs_attrs[i]);
1535-
if (ret < 0)
1536-
return ret;
1537-
}
1538-
15391535
return 0;
15401536
}
15411537

@@ -2641,6 +2637,7 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev)
26412637
static struct platform_driver sh_mobile_lcdc_driver = {
26422638
.driver = {
26432639
.name = "sh_mobile_lcdc_fb",
2640+
.dev_groups = overlay_sysfs_groups,
26442641
.pm = &sh_mobile_lcdc_dev_pm_ops,
26452642
},
26462643
.probe = sh_mobile_lcdc_probe,

0 commit comments

Comments
 (0)