From nobody Tue Dec 16 16:37:09 2025 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 2406C2727F5; Thu, 11 Dec 2025 14:22:18 +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=1765462939; cv=none; b=thy6ngR0UQnSIql6uTff87oVb64wc//MxnB0CU+SeIqWUyMm0Q9JPXVJC1UF89Yd0yHxNukABY3D5eZBjhq/n3DPUkeetPQtwKEH8JaRSNin9WEi4szqWIHvAyWHek55bt4rSO0rAWpBHq0n+4iwdFFXmyBFz3SDOc6CR/EaX3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765462939; c=relaxed/simple; bh=lwmdgimdxLKUafRbbMz1KWXXUFLSaf7P7PJIeIKBRrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Rby0aKfQKiFbktu70Jl+MDY9O2boENQi76cOT/SZ5dmFBesRgMIWBVl94N9G3ywxnBYvGI+Yt3Ns4polMF42PtDZhcW46kp9/YCwMwNnx7FrTeBrUeIoXL/9lfEQohvlFvirWHxxY+e5TQJti36YIBAf2USTAM7QcyRVEMhnohQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ts9qwkmC; 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="Ts9qwkmC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA709C113D0; Thu, 11 Dec 2025 14:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765462938; bh=lwmdgimdxLKUafRbbMz1KWXXUFLSaf7P7PJIeIKBRrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts9qwkmCPni7zX64fIF6Mx/CRp9BO1n3C7KwkJ9sLoIgLjmtJjH7My8ftvE9YbqA1 fPgnz0kcgE2V6ayfRdUpOnjSphybhg1vRloVJxvUoEZsQfVEGMv4y6zJtxEqhQuHDn XsufzZsh5c/1i/ulDe0nDJaJqNgVj7YZh3sF/NwOJ1h0Y/jnAUWae+OBwsptPtuZun aMlyGsRLwhG5b80G0VDrlTNqqHJpSQQlwlO8YzBNqISuCkO8nTV56hragQr6aKyiIJ lx5939GqVSbASzOPo6vJ2b9dIWBUddH5JIftmj4GoPCPlPkkx7YXt9LfWABT9k2sC4 mhqAriRDbeB9g== From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Armin Wolf , Hans de Goede Subject: [RFT][PATCH v1 3/6] ACPI: SMBUS HC: Convert the driver to a platform one Date: Thu, 11 Dec 2025 15:17:58 +0100 Message-ID: <13909645.uLZWGnKmhe@rafael.j.wysocki> Organization: Linux Kernel Development In-Reply-To: <5066996.31r3eYUQgx@rafael.j.wysocki> References: <5066996.31r3eYUQgx@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 While binding drivers directly to struct acpi_device objects allows basic functionality to be provided, at least in the majority of cases, there are some problems with it, related to general consistency, sysfs layout, power management operation ordering, and code cleanliness. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the ACPI SMBUS HC driver to a platform one. After this conversion, acpi_ec_probe() does not need to populate the driver_data pointer of the EC platform device's ACPI companion any more, so update it accordingly. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/ec.c | 2 -- drivers/acpi/sbshc.c | 43 +++++++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 24 deletions(-) --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1733,8 +1733,6 @@ static int acpi_ec_probe(struct platform "EC: Used to handle transactions and events\n"); =20 platform_set_drvdata(pdev, ec); - /* This is needed for the SMBUS HC driver to work. */ - device->driver_data =3D ec; =20 ret =3D !!request_region(ec->data_addr, 1, "EC data"); WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr); --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -13,6 +13,8 @@ #include #include #include +#include + #include "sbshc.h" #include "internal.h" =20 @@ -30,8 +32,8 @@ struct acpi_smb_hc { bool done; }; =20 -static int acpi_smbus_hc_add(struct acpi_device *device); -static void acpi_smbus_hc_remove(struct acpi_device *device); +static int acpi_smbus_hc_probe(struct platform_device *pdev); +static void acpi_smbus_hc_remove(struct platform_device *pdev); =20 static const struct acpi_device_id sbs_device_ids[] =3D { {"ACPI0001", 0}, @@ -41,14 +43,13 @@ static const struct acpi_device_id sbs_d =20 MODULE_DEVICE_TABLE(acpi, sbs_device_ids); =20 -static struct acpi_driver acpi_smb_hc_driver =3D { - .name =3D "smbus_hc", - .class =3D ACPI_SMB_HC_CLASS, - .ids =3D sbs_device_ids, - .ops =3D { - .add =3D acpi_smbus_hc_add, - .remove =3D acpi_smbus_hc_remove, - }, +static struct platform_driver acpi_smb_hc_driver =3D { + .probe =3D acpi_smbus_hc_probe, + .remove =3D acpi_smbus_hc_remove, + .driver =3D { + .name =3D "acpi-smbus-hc", + .acpi_match_table =3D sbs_device_ids, + }, }; =20 union acpi_smb_status { @@ -237,15 +238,13 @@ static int smbus_alarm(void *context) return 0; } =20 -static int acpi_smbus_hc_add(struct acpi_device *device) +static int acpi_smbus_hc_probe(struct platform_device *pdev) { + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); int status; unsigned long long val; struct acpi_smb_hc *hc; =20 - if (!device) - return -EINVAL; - status =3D acpi_evaluate_integer(device->handle, "_EC", NULL, &val); if (ACPI_FAILURE(status)) { pr_err("error obtaining _EC.\n"); @@ -261,9 +260,12 @@ static int acpi_smbus_hc_add(struct acpi mutex_init(&hc->lock); init_waitqueue_head(&hc->wait); =20 - hc->ec =3D acpi_driver_data(acpi_dev_parent(device)); + platform_set_drvdata(pdev, hc); + + hc->ec =3D dev_get_drvdata(pdev->dev.parent); hc->offset =3D (val >> 8) & 0xff; hc->query_bit =3D val & 0xff; + /* This is needed for the SBS driver to work. */ device->driver_data =3D hc; =20 acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); @@ -273,21 +275,18 @@ static int acpi_smbus_hc_add(struct acpi return 0; } =20 -static void acpi_smbus_hc_remove(struct acpi_device *device) +static void acpi_smbus_hc_remove(struct platform_device *pdev) { - struct acpi_smb_hc *hc; - - if (!device) - return; + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); + struct acpi_smb_hc *hc =3D platform_get_drvdata(pdev); =20 - hc =3D acpi_driver_data(device); acpi_ec_remove_query_handler(hc->ec, hc->query_bit); acpi_os_wait_events_complete(); kfree(hc); device->driver_data =3D NULL; } =20 -module_acpi_driver(acpi_smb_hc_driver); +module_platform_driver(acpi_smb_hc_driver); =20 MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alexey Starikovskiy");