From: jsg Date: Fri, 9 Sep 2022 04:36:03 +0000 (+0000) Subject: drm/i915/display: avoid warnings when registering dual panel backlight X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a939c9caa94a8e07fd0858b16ba9b91bdc45904a;p=openbsd drm/i915/display: avoid warnings when registering dual panel backlight From Arun R Murthy 7828b5d0080a4621973ab5c680c4df0bc6d96437 in linux 5.15.y/5.15.66 868e8e5156a1f8d92ca83fdbac6fd52798650792 in mainline linux --- diff --git a/sys/dev/pci/drm/i915/display/intel_backlight.c b/sys/dev/pci/drm/i915/display/intel_backlight.c index 7d9415f064c..26e38894171 100644 --- a/sys/dev/pci/drm/i915/display/intel_backlight.c +++ b/sys/dev/pci/drm/i915/display/intel_backlight.c @@ -979,26 +979,26 @@ int intel_backlight_device_register(struct intel_connector *connector) if (!name) return -ENOMEM; - bd = backlight_device_register(name, connector->base.kdev, connector, - &intel_backlight_device_ops, &props); - - /* - * Using the same name independent of the drm device or connector - * prevents registration of multiple backlight devices in the - * driver. However, we need to use the default name for backward - * compatibility. Use unique names for subsequent backlight devices as a - * fallback when the default name already exists. - */ - if (IS_ERR(bd) && PTR_ERR(bd) == -EEXIST) { + bd = backlight_device_get_by_name(name); + if (bd) { +#ifdef __linux__ + put_device(&bd->dev); +#endif + /* + * Using the same name independent of the drm device or connector + * prevents registration of multiple backlight devices in the + * driver. However, we need to use the default name for backward + * compatibility. Use unique names for subsequent backlight devices as a + * fallback when the default name already exists. + */ kfree(name); name = kasprintf(GFP_KERNEL, "card%d-%s-backlight", i915->drm.primary->index, connector->base.name); if (!name) return -ENOMEM; - - bd = backlight_device_register(name, connector->base.kdev, connector, - &intel_backlight_device_ops, &props); } + bd = backlight_device_register(name, connector->base.kdev, connector, + &intel_backlight_device_ops, &props); if (IS_ERR(bd)) { drm_err(&i915->drm,