- Use blacklight_get_brightness() helper - Use devm_ variant to register backlight device and drop explicit unregister - Use macro for initialization Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx> Cc: Andrzej Hajda <a.hajda@xxxxxxxxxxx> Cc: Neil Armstrong <narmstrong@xxxxxxxxxxxx> Cc: Laurent Pinchart <Laurent.pinchart@xxxxxxxxxxxxxxxx> Cc: Jonas Karlman <jonas@xxxxxxxxx> Cc: Jernej Skrabec <jernej.skrabec@xxxxxxxx> --- drivers/gpu/drm/bridge/parade-ps8622.c | 43 +++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c b/drivers/gpu/drm/bridge/parade-ps8622.c index d789ea2a7fb9..a46a883e0b8c 100644 --- a/drivers/gpu/drm/bridge/parade-ps8622.c +++ b/drivers/gpu/drm/bridge/parade-ps8622.c @@ -284,8 +284,7 @@ static int ps8622_send_config(struct ps8622_bridge *ps8622) goto error; /* FFh for 100% brightness, 0h for 0% brightness */ - err = ps8622_set(cl, 0x01, 0xa7, - ps8622->bl->props.brightness); + err = ps8622_set(cl, 0x01, 0xa7, backlight_get_brightness(ps8622->bl)); if (err) goto error; } else { @@ -331,18 +330,11 @@ static int ps8622_send_config(struct ps8622_bridge *ps8622) static int ps8622_backlight_update(struct backlight_device *bl) { struct ps8622_bridge *ps8622 = dev_get_drvdata(&bl->dev); - int ret, brightness = bl->props.brightness; - - if (bl->props.power != FB_BLANK_UNBLANK || - bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK)) - brightness = 0; if (!ps8622->enabled) return -EINVAL; - ret = ps8622_set(ps8622->client, 0x01, 0xa7, brightness); - - return ret; + return ps8622_set(ps8622->client, 0x01, 0xa7, backlight_get_brightness(bl)); } static const struct backlight_ops ps8622_backlight_ops = { @@ -521,7 +513,23 @@ static const struct drm_bridge_funcs ps8622_bridge_funcs = { .attach = ps8622_attach, }; -static const struct of_device_id ps8622_devices[] = { +static int ps8622_register_blacklight(struct device *dev, struct ps8622_bridge *ps8622) +{ + DECLARE_BACKLIGHT_INIT_RAW(props, PS8622_MAX_BRIGHTNESS, PS8622_MAX_BRIGHTNESS); + struct backlight_device *bl; + + bl = devm_backlight_device_register(dev, dev_name(dev), dev, + ps8622, &ps8622_backlight_ops, &props); + if (IS_ERR(bl)) { + DRM_ERROR("failed to register backlight\n"); + return PTR_ERR(bl); + } + + ps8622->bl = bl; + return 0; +} + +const struct of_device_id ps8622_devices[] = { {.compatible = "parade,ps8622",}, {.compatible = "parade,ps8625",}, {} @@ -581,17 +589,9 @@ static int ps8622_probe(struct i2c_client *client, } if (!of_find_property(dev->of_node, "use-external-pwm", NULL)) { - ps8622->bl = backlight_device_register("ps8622-backlight", - dev, ps8622, &ps8622_backlight_ops, - NULL); - if (IS_ERR(ps8622->bl)) { - DRM_ERROR("failed to register backlight\n"); - ret = PTR_ERR(ps8622->bl); - ps8622->bl = NULL; + ret = ps8622_register_blacklight(dev, ps8622); + if (ret) return ret; - } - ps8622->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS; - ps8622->bl->props.brightness = PS8622_MAX_BRIGHTNESS; } ps8622->bridge.funcs = &ps8622_bridge_funcs; @@ -607,7 +607,6 @@ static int ps8622_remove(struct i2c_client *client) { struct ps8622_bridge *ps8622 = i2c_get_clientdata(client); - backlight_device_unregister(ps8622->bl); drm_bridge_remove(&ps8622->bridge); return 0; -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel