[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c3ef6d2-6e95-4dd9-b9d4-41f5e70bc574@t-8ch.de>
Date: Thu, 8 Apr 2021 16:39:47 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Barnabás Pőcze <pobrn@...tonmail.com>
Cc: "platform-driver-x86@...r.kernel.org"
<platform-driver-x86@...r.kernel.org>,
Mark Gross <mgross@...ux.intel.com>,
Hans de Goede <hdegoede@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Matthew Garrett <mjg59@...f.ucam.org>
Subject: Re: [PATCH v2] platform/x86: add Gigabyte WMI temperature driver
Hi,
On Mi, 2021-04-07T18:27+0000, Barnabás Pőcze wrote:
> 2021. április 5., hétfő 22:48 keltezéssel, Thomas Weißschuh írta:
> > Tested with a X570 I Aorus Pro Wifi.
> > The mainboard contains an ITE IT8688E chip for management.
> > This chips is also handled by drivers/hwmon/i87.c but as it is also used
> > by the firmware itself it needs an ACPI driver.
>
> I gather this means you're getting the
>
> ACPI Warning: SystemIO range ... conflicts with ...
> ACPI: If an ACPI driver is available for this device, you should use it instead of the native driver
>
> warning?
Exactly.
> > +struct gigabyte_wmi_args {
> > + u32 arg1;
> > +};
> > +
> > +static int gigabyte_wmi_perform_query(enum gigabyte_wmi_commandtype command,
> > + struct gigabyte_wmi_args *args, struct acpi_buffer *out)
> > +{
> > + const struct acpi_buffer in = {
> > + .length = sizeof(*args),
> > + .pointer = args,
> > + };
> > +
> > + acpi_status ret = wmi_evaluate_method(GIGABYTE_WMI_GUID, 0x0, command, &in, out);
>
> Ideally, you'd use the WMI device that was passed to the probe method to do the query
> using `wmidev_evaluate_method()`. You can pass the WMI device pointer
> to `devm_hwmon_device_register_with_info()` in the `drvdata` argument,
> then in the ->read() callback you can retrieve it:
>
> static int gigabyte_wmi_hwmon_read(struct device *dev, ...)
> {
> struct wmi_device *wdev = dev_get_drvdata(dev);
>
> and then you can pass that to the other functions.
Done.
> > + if (ret == AE_OK) {
> > + return 0;
> > + } else {
> > + return -EIO;
> > + };
>
> The `;` is not needed. And please use `ACPI_FAILURE()` or `ACPI_SUCCESS()`
> to check the returned value. For example:
>
> acpi_status ret = ...;
> if (ACPI_FAILURE(ret))
> return -EIO;
>
> return 0;
Done.
> > +}
> > +
> > +static int gigabyte_wmi_query_integer(enum gigabyte_wmi_commandtype command,
> > + struct gigabyte_wmi_args *args, u64 *res)
> > +{
> > + union acpi_object *obj;
> > + struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
> > + int ret;
> > +
> > + ret = gigabyte_wmi_perform_query(command, args, &result);
> > + if (ret) {
> > + goto out;
>
> I believe if this branch is taken, no buffer is allocated (due to the failure),
> so you can just `return ret;` here and do away with the goto completely - if I'm not mistaken.
Done.
> > +static const struct hwmon_channel_info *gigabyte_wmi_hwmon_info[] = {
> > + HWMON_CHANNEL_INFO(temp,
> > + HWMON_T_INPUT,
> > + HWMON_T_INPUT,
> > + HWMON_T_INPUT,
> > + HWMON_T_INPUT,
> > + HWMON_T_INPUT,
> > + HWMON_T_INPUT),
> > + NULL,
> ^
> Minor thing: usually commas after sentinel values are omitted.
Done.
> > +static const struct wmi_device_id gigabyte_wmi_id_table[] = {
> > + { GIGABYTE_WMI_GUID, NULL },
> > + { },
> ^
> Same here.
Done.
>
> > +};
> > +
> > +static struct wmi_driver gigabyte_wmi_driver = {
> > + .driver = {
> > + .name = "gigabyte-wmi",
> > + },
> > + .id_table = gigabyte_wmi_id_table,
> > + .probe = gigabyte_wmi_probe,
> > +};
> > +module_wmi_driver(gigabyte_wmi_driver);
> > +
> > +MODULE_DEVICE_TABLE(wmi, gigabyte_wmi_id_table);
> > +MODULE_AUTHOR("Thomas Weißschuh <thomas@...ssschuh.net>");
> > +MODULE_DESCRIPTION("Gigabyte Temperature WMI Driver");
>
> It's a very minor thing, but could you please
> synchronize this description with the Kconfig?
Of course.
Thanks again for the review!
Thomas
Powered by blists - more mailing lists