From nobody Tue Apr 7 14:04:30 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81CB22F12C1; Wed, 25 Feb 2026 20:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772053059; cv=none; b=NafSh7eBCdWYTPyN2xYMfVjtUqQZg5reyKKnG9+7ZJ84C+HGdK8KCUKiGX7Adzfb313GWsOXK43vtB/QZueX4EWkNn7MCEfXy0Eg/vjZBHVCUK327DU4/nFTOqKdgJIg44my0swo8y++fgMNtC1cV/8+NAX1W7sGxK0CkgFkf6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772053059; c=relaxed/simple; bh=os8p/7f07bfNvKhOQbtBqfHHFLUH8MjabQ3v6ti7ReI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cglOav6InQ2tR7OzVR4Y3YWpYuU5NI7L191IHXYVMp7zEuR4WXqEu08/dlffl+aIRu/YR9VA/0rte1FJH4dW6sKG95KU01EHJOiewOXgU+beiCXhKUNxs4ZDFBI9D882gSRSwk9fFtRTCOyAAvLwls57voutm/EWPJiklaUDExw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UavcFhbY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UavcFhbY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A299DC19423; Wed, 25 Feb 2026 20:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772053059; bh=os8p/7f07bfNvKhOQbtBqfHHFLUH8MjabQ3v6ti7ReI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UavcFhbYvarlp4E6obqGNwDGqm4Rn6zt1hbCUFssPSdlcUIUfg4ga0ePsUX7ma2l7 3I9dgeCa2Ua6VJdk6vFIQtrJVE/i4UdFlW2JuLhMZKgGQwvLpx6sEDo+Zoc63JEyyY yb+15XSODoSB7wyS6WZXRCm0E/1G9MWc0gKbnjSQcl6PHGHcYyWvBGbH9rurJHoL8L 7B5oHL1llB7h7sg2R5UzL2I2xJZ4Tx4QCAi5Z2/3xanK2oFj/5Bl9xEEOPj7olUdVM NmLBnBRkRms8bzQcjFFdXeJ0q5ny2GgnA9dVVCIMHwTc6+e89PjcWZh/MAUPpBjJNO BJgr8+dKlOJsg== From: "Rafael J. Wysocki" To: Ilpo =?ISO-8859-1?Q?J=E4rvinen?= Cc: Robert Gerlach , Hans de Goede , LKML , Linux ACPI , platform-driver-x86@vger.kernel.org, Jonathan Woithe Subject: [PATCH v1 4/5] platform/x86: fujitsu: Convert backlight driver to a platform one Date: Wed, 25 Feb 2026 21:52:09 +0100 Message-ID: <23036941.EfDdHjke4D@rafael.j.wysocki> Organization: Linux Kernel Development In-Reply-To: <1968442.tdWV9SEqCh@rafael.j.wysocki> References: <1968442.tdWV9SEqCh@rafael.j.wysocki> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Rafael J. Wysocki" In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1]. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the backlight part of the Fujitsu laptop driver from an ACPI driver to a platform one. After this change, the backlight and input subordinate devices will be registered under the platform device used for driver binding instead of its ACPI companion. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] Signed-off-by: Rafael J. Wysocki --- drivers/platform/x86/fujitsu-laptop.c | 117 +++++++++++++------------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/f= ujitsu-laptop.c index cb13c06b8f35..d4550309ac13 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -284,15 +284,16 @@ static void fujitsu_battery_charge_control_remove(str= uct acpi_device *device) =20 /* Hardware access for LCD brightness control */ =20 -static int set_lcd_level(struct acpi_device *device, int level) +static int set_lcd_level(struct device *dev, int level) { - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); + acpi_handle handle =3D ACPI_HANDLE(dev); acpi_status status; char *method; =20 switch (use_alt_lcd_levels) { case -1: - if (acpi_has_method(device->handle, "SBL2")) + if (acpi_has_method(handle, "SBL2")) method =3D "SBL2"; else method =3D "SBLL"; @@ -305,16 +306,14 @@ static int set_lcd_level(struct acpi_device *device, = int level) break; } =20 - acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method, - level); + acpi_handle_debug(handle, "set lcd level via %s [%d]\n", method, level); =20 if (level < 0 || level >=3D priv->max_brightness) return -EINVAL; =20 - status =3D acpi_execute_simple_method(device->handle, method, level); + status =3D acpi_execute_simple_method(handle, method, level); if (ACPI_FAILURE(status)) { - acpi_handle_err(device->handle, "Failed to evaluate %s\n", - method); + acpi_handle_err(handle, "Failed to evaluate %s\n", method); return -ENODEV; } =20 @@ -323,15 +322,16 @@ static int set_lcd_level(struct acpi_device *device, = int level) return 0; } =20 -static int get_lcd_level(struct acpi_device *device) +static int get_lcd_level(struct device *dev) { - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); + acpi_handle handle =3D ACPI_HANDLE(dev); unsigned long long state =3D 0; acpi_status status =3D AE_OK; =20 - acpi_handle_debug(device->handle, "get lcd level via GBLL\n"); + acpi_handle_debug(handle, "get lcd level via GBLL\n"); =20 - status =3D acpi_evaluate_integer(device->handle, "GBLL", NULL, &state); + status =3D acpi_evaluate_integer(handle, "GBLL", NULL, &state); if (ACPI_FAILURE(status)) return 0; =20 @@ -340,15 +340,16 @@ static int get_lcd_level(struct acpi_device *device) return priv->brightness_level; } =20 -static int get_max_brightness(struct acpi_device *device) +static int get_max_brightness(struct device *dev) { - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); + acpi_handle handle =3D ACPI_HANDLE(dev); unsigned long long state =3D 0; acpi_status status =3D AE_OK; =20 - acpi_handle_debug(device->handle, "get max lcd level via RBLL\n"); + acpi_handle_debug(handle, "get max lcd level via RBLL\n"); =20 - status =3D acpi_evaluate_integer(device->handle, "RBLL", NULL, &state); + status =3D acpi_evaluate_integer(handle, "RBLL", NULL, &state); if (ACPI_FAILURE(status)) return -1; =20 @@ -361,15 +362,13 @@ static int get_max_brightness(struct acpi_device *dev= ice) =20 static int bl_get_brightness(struct backlight_device *b) { - struct acpi_device *device =3D bl_get_data(b); + struct device *dev =3D bl_get_data(b); =20 - return b->props.power =3D=3D BACKLIGHT_POWER_OFF ? 0 : get_lcd_level(devi= ce); + return b->props.power =3D=3D BACKLIGHT_POWER_OFF ? 0 : get_lcd_level(dev); } =20 static int bl_update_status(struct backlight_device *b) { - struct acpi_device *device =3D bl_get_data(b); - if (fext) { if (b->props.power =3D=3D BACKLIGHT_POWER_OFF) call_fext_func(fext, FUNC_BACKLIGHT, 0x1, @@ -379,7 +378,7 @@ static int bl_update_status(struct backlight_device *b) BACKLIGHT_PARAM_POWER, BACKLIGHT_ON); } =20 - return set_lcd_level(device, b->props.brightness); + return set_lcd_level(bl_get_data(b), b->props.brightness); } =20 static const struct backlight_ops fujitsu_bl_ops =3D { @@ -455,12 +454,13 @@ static const struct key_entry keymap_backlight[] =3D { { KE_END, 0 } }; =20 -static int acpi_fujitsu_bl_input_setup(struct acpi_device *device) +static int acpi_fujitsu_bl_input_setup(struct device *dev) { - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); + struct acpi_device *device =3D ACPI_COMPANION(dev); int ret; =20 - priv->input =3D devm_input_allocate_device(&device->dev); + priv->input =3D devm_input_allocate_device(dev); if (!priv->input) return -ENOMEM; =20 @@ -479,9 +479,9 @@ static int acpi_fujitsu_bl_input_setup(struct acpi_devi= ce *device) return input_register_device(priv->input); } =20 -static int fujitsu_backlight_register(struct acpi_device *device) +static int fujitsu_backlight_register(struct device *dev) { - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); const struct backlight_properties props =3D { .brightness =3D priv->brightness_level, .max_brightness =3D priv->max_brightness - 1, @@ -489,9 +489,8 @@ static int fujitsu_backlight_register(struct acpi_devic= e *device) }; struct backlight_device *bd; =20 - bd =3D devm_backlight_device_register(&device->dev, "fujitsu-laptop", - &device->dev, device, - &fujitsu_bl_ops, &props); + bd =3D devm_backlight_device_register(dev, "fujitsu-laptop", + dev, dev, &fujitsu_bl_ops, &props); if (IS_ERR(bd)) return PTR_ERR(bd); =20 @@ -504,73 +503,74 @@ static int fujitsu_backlight_register(struct acpi_dev= ice *device) =20 static void acpi_fujitsu_bl_notify(acpi_handle handle, u32 event, void *da= ta) { - struct acpi_device *device =3D data; - struct fujitsu_bl *priv =3D acpi_driver_data(device); + struct device *dev =3D data; + struct fujitsu_bl *priv =3D dev_get_drvdata(dev); int oldb, newb; =20 if (event !=3D ACPI_FUJITSU_NOTIFY_CODE) { - acpi_handle_info(device->handle, "unsupported event [0x%x]\n", - event); + acpi_handle_info(handle, "unsupported event [0x%x]\n", event); sparse_keymap_report_event(priv->input, -1, 1, true); return; } =20 oldb =3D priv->brightness_level; - get_lcd_level(device); + get_lcd_level(dev); newb =3D priv->brightness_level; =20 - acpi_handle_debug(device->handle, - "brightness button event [%i -> %i]\n", oldb, newb); + acpi_handle_debug(handle, "brightness button event [%i -> %i]\n", + oldb, newb); =20 if (oldb =3D=3D newb) return; =20 if (!disable_brightness_adjust) - set_lcd_level(device, newb); + set_lcd_level(dev, newb); =20 sparse_keymap_report_event(priv->input, oldb < newb, 1, true); } =20 -static int acpi_fujitsu_bl_add(struct acpi_device *device) +static int acpi_fujitsu_bl_probe(struct platform_device *pdev) { + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); struct fujitsu_bl *priv; int ret; =20 if (acpi_video_get_backlight_type() !=3D acpi_backlight_vendor) return -ENODEV; =20 - priv =3D devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); + priv =3D devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 fujitsu_bl =3D priv; strscpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME); strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS); - device->driver_data =3D priv; + + platform_set_drvdata(pdev, priv); =20 pr_info("ACPI: %s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); =20 - if (get_max_brightness(device) <=3D 0) + if (get_max_brightness(&pdev->dev) <=3D 0) priv->max_brightness =3D FUJITSU_LCD_N_LEVELS; - get_lcd_level(device); + get_lcd_level(&pdev->dev); =20 - ret =3D acpi_fujitsu_bl_input_setup(device); + ret =3D acpi_fujitsu_bl_input_setup(&pdev->dev); if (ret) return ret; =20 - ret =3D fujitsu_backlight_register(device); + ret =3D fujitsu_backlight_register(&pdev->dev); if (ret) return ret; =20 return acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY, - acpi_fujitsu_bl_notify, device); + acpi_fujitsu_bl_notify, &pdev->dev); } =20 -static void acpi_fujitsu_bl_remove(struct acpi_device *device) +static void acpi_fujitsu_bl_remove(struct platform_device *pdev) { - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, - acpi_fujitsu_bl_notify); + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), + ACPI_DEVICE_NOTIFY, acpi_fujitsu_bl_notify); } =20 /* ACPI device for hotkey handling */ @@ -1107,14 +1107,13 @@ static const struct acpi_device_id fujitsu_bl_devic= e_ids[] =3D { {"", 0}, }; =20 -static struct acpi_driver acpi_fujitsu_bl_driver =3D { - .name =3D ACPI_FUJITSU_BL_DRIVER_NAME, - .class =3D ACPI_FUJITSU_CLASS, - .ids =3D fujitsu_bl_device_ids, - .ops =3D { - .add =3D acpi_fujitsu_bl_add, - .remove =3D acpi_fujitsu_bl_remove, - }, +static struct platform_driver acpi_fujitsu_bl_driver =3D { + .probe =3D acpi_fujitsu_bl_probe, + .remove =3D acpi_fujitsu_bl_remove, + .driver =3D { + .name =3D ACPI_FUJITSU_BL_DRIVER_NAME, + .acpi_match_table =3D fujitsu_bl_device_ids, + }, }; =20 static const struct acpi_device_id fujitsu_laptop_device_ids[] =3D { @@ -1143,7 +1142,7 @@ static int __init fujitsu_init(void) { int ret; =20 - ret =3D acpi_bus_register_driver(&acpi_fujitsu_bl_driver); + ret =3D platform_driver_register(&acpi_fujitsu_bl_driver); if (ret) return ret; =20 @@ -1166,7 +1165,7 @@ static int __init fujitsu_init(void) err_unregister_platform_driver: platform_driver_unregister(&fujitsu_pf_driver); err_unregister_acpi: - acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); + platform_driver_unregister(&acpi_fujitsu_bl_driver); =20 return ret; } @@ -1177,7 +1176,7 @@ static void __exit fujitsu_cleanup(void) =20 platform_driver_unregister(&fujitsu_pf_driver); =20 - acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); + platform_driver_unregister(&acpi_fujitsu_bl_driver); =20 pr_info("driver unloaded\n"); } --=20 2.51.0