All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <markgross@kernel.org>,
	Andy Shevchenko <andy@infradead.org>,
	Mark Pearson <markpearson@lenovo.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Len Baker <len.baker@gmx.com>,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH 4/6] platform/x86: thinkpad_acpi: Fix the hwmon sysfs-attr showing up in the wrong place
Date: Tue, 23 Nov 2021 22:04:22 +0100	[thread overview]
Message-ID: <20211123210424.266607-5-hdegoede@redhat.com> (raw)
In-Reply-To: <20211123210424.266607-1-hdegoede@redhat.com>

The hwmon sysfs-attr should show up under the hwmon-classdev, not under
the tpacpi_sensors_pdev. Pass the tpacpi_hwmon_groups attr-groups array
to hwmon_device_register_with_groups() instead of setting
tpacpi_hwmon_pdriver.driver.dev_groups to it to fix this.

This also requires moving the hwmon_device_register_with_groups() call to
after the subdriver init functions have run so that the is_visible()
calls will work properly.

Fixes: 79f960e29cfc ("platform/x86: thinkpad_acpi: Convert platform driver to use dev_groups")
Cc: Len Baker <len.baker@gmx.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 7680bb0ee2d5..2f290ed59d92 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10537,7 +10537,6 @@ static struct platform_driver tpacpi_hwmon_pdriver = {
 	.driver = {
 		.name = TPACPI_HWMON_DRVR_NAME,
 		.groups = tpacpi_hwmon_driver_groups,
-		.dev_groups = tpacpi_hwmon_groups,
 	},
 };
 
@@ -11186,6 +11185,8 @@ static void thinkpad_acpi_module_exit(void)
 
 	tpacpi_lifecycle = TPACPI_LIFE_EXITING;
 
+	if (tpacpi_hwmon)
+		hwmon_device_unregister(tpacpi_hwmon);
 	if (tp_features.sensors_pdrv_registered)
 		platform_driver_unregister(&tpacpi_hwmon_pdriver);
 	if (tp_features.platform_drv_registered)
@@ -11207,8 +11208,6 @@ static void thinkpad_acpi_module_exit(void)
 		kfree(hotkey_keycode_map);
 	}
 
-	if (tpacpi_hwmon)
-		hwmon_device_unregister(tpacpi_hwmon);
 	if (tpacpi_sensors_pdev)
 		platform_device_unregister(tpacpi_sensors_pdev);
 	if (tpacpi_pdev)
@@ -11287,16 +11286,7 @@ static int __init thinkpad_acpi_module_init(void)
 		return ret;
 	}
 	tp_features.sensors_pdev_attrs_registered = 1;
-	tpacpi_hwmon = hwmon_device_register_with_groups(
-		&tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, NULL);
 
-	if (IS_ERR(tpacpi_hwmon)) {
-		ret = PTR_ERR(tpacpi_hwmon);
-		tpacpi_hwmon = NULL;
-		pr_err("unable to register hwmon device\n");
-		thinkpad_acpi_module_exit();
-		return ret;
-	}
 	mutex_init(&tpacpi_inputdev_send_mutex);
 	tpacpi_inputdev = input_allocate_device();
 	if (!tpacpi_inputdev) {
@@ -11345,6 +11335,16 @@ static int __init thinkpad_acpi_module_init(void)
 	}
 	tp_features.sensors_pdrv_registered = 1;
 
+	tpacpi_hwmon = hwmon_device_register_with_groups(
+		&tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups);
+	if (IS_ERR(tpacpi_hwmon)) {
+		ret = PTR_ERR(tpacpi_hwmon);
+		tpacpi_hwmon = NULL;
+		pr_err("unable to register hwmon device\n");
+		thinkpad_acpi_module_exit();
+		return ret;
+	}
+
 	ret = input_register_device(tpacpi_inputdev);
 	if (ret < 0) {
 		pr_err("unable to register input device\n");
-- 
2.33.1


  parent reply	other threads:[~2021-11-23 21:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 21:04 [PATCH 0/6] platform/x86: thinkpad_acpi: 4 bug-fixes + 2 cleanups Hans de Goede
2021-11-23 21:04 ` [PATCH 1/6] platform/x86: thinkpad_acpi: Restore missing hotkey_tablet_mode and hotkey_radio_sw sysfs-attr Hans de Goede
2021-11-23 21:04 ` [PATCH 2/6] platform/x86: thinkpad_acpi: Register tpacpi_pdriver after subdriver init Hans de Goede
2021-11-23 21:04 ` [PATCH 3/6] platform/x86: thinkpad_acpi: tpacpi_attr_group contains driver attributes not device attrs Hans de Goede
2021-11-23 21:04 ` Hans de Goede [this message]
2021-11-23 21:04 ` [PATCH 5/6] platform/x86: thinkpad_acpi: Remove unused sensors_pdev_attrs_registered flag Hans de Goede
2021-11-23 21:04 ` [PATCH 6/6] platform/x86: thinkpad_acpi: Move input_unregister_device() to the top of thinkpad_acpi_module_exit() Hans de Goede
2021-11-25 15:35 ` [PATCH 0/6] platform/x86: thinkpad_acpi: 4 bug-fixes + 2 cleanups Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211123210424.266607-5-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@infradead.org \
    --cc=len.baker@gmx.com \
    --cc=markgross@kernel.org \
    --cc=markpearson@lenovo.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.