From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Denis Pauk <pauk.denis@gmail.com>
Cc: "Bernhard Seibold" <mail@bernhard-seibold.de>,
"Pär Ekholm" <pehlm@pekholm.org>,
to.eivind@gmail.com, "Artem S . Tashkinov" <aros@gmx.com>,
"Vittorio Roberto Alfieri" <me@rebtoor.com>,
"Guenter Roeck" <linux@roeck-us.net>,
"Jean Delvare" <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] hwmon: (nct6775) Support access via Asus WMI (v2)
Date: Thu, 9 Sep 2021 20:01:36 +0300 [thread overview]
Message-ID: <YTo98BIZjtlHtGrH@smile.fi.intel.com> (raw)
In-Reply-To: <20210908213605.9929-3-pauk.denis@gmail.com>
On Thu, Sep 09, 2021 at 12:36:04AM +0300, Denis Pauk wrote:
> Support accessing the NCT677x via Asus WMI functions.
>
> On mainboards that support this way of accessing the chip,
> the driver will usually not work without this option since
> in these mainboards, ACPI will mark the I/O port as used.
...
> +static int asuswmi_evaluate_method(u32 method_id,
> + u8 bank, u8 reg, u8 val, u32 *retval)
Indentation can be better.
Ditto for many lines in this change.
> +{
> + u32 args = bank | (reg << 8) | (val << 16);
> + struct acpi_buffer input = { (acpi_size) sizeof(args), &args };
> + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> + acpi_status status;
> + union acpi_object *obj;
> + u32 tmp = 0;
> +
> + status = wmi_evaluate_method(ASUSWMI_MGMT2_GUID, 0, method_id,
> + &input, &output);
> +
> + if (ACPI_FAILURE(status))
> + return -EIO;
> + obj = (union acpi_object *)output.pointer;
Do you need casting?
> + if (obj && obj->type == ACPI_TYPE_INTEGER)
> + tmp = (u32) obj->integer.value;
Ditto.
> + if (retval)
> + *retval = tmp;
> +
> + kfree(obj);
> +
> + if (tmp == ASUSWMI_UNSUPPORTED_METHOD)
> + return -ENODEV;
> + return 0;
> +}
...
> +static inline int
> +nct6775_asuswmi_read(u8 bank, u8 reg, u8 *val)
One line.
> +{
> + u32 tmp;
> + int ret = asuswmi_evaluate_method(ASUSWMI_METHODID_RHWM, bank, reg, 0, &tmp);
> + *val = tmp & 0xff;
Do you need ' & 0xff' part?
> + return ret;
> +}
...
> + if (data->access == access_asuswmi) {
> + data->bank = bank;
> + return;
> + }
It means you have to introduce a new callback ->set_bank() (in a separate change).
...
> + if (data->access == access_asuswmi) {
> + nct6775_asuswmi_read(data->bank, reg, &tmp);
> + res = (tmp & 0xff);
> + if (word_sized) {
> + nct6775_asuswmi_read(data->bank,
> + (reg & 0xff) + 1, &tmp);
> + res = (res << 8) + (tmp & 0xff);
> + }
> + return res;
> + }
Similar.
...
> + if (data->access == access_asuswmi) {
> + if (word_sized) {
> + nct6775_asuswmi_write(data->bank, (reg & 0xff),
> + (value >> 8) & 0xff);
> + nct6775_asuswmi_write(data->bank, (reg & 0xff) + 1,
> + value & 0xff);
> + } else {
> + nct6775_asuswmi_write(data->bank, (reg & 0xff),
> + value);
> + }
> +
> + return 0;
> + }
Similar.
...
> + if (sio_data->access == access_direct) {
> + res = platform_get_resource(pdev, IORESOURCE_IO, 0);
> + if (!res)
> + return -EBUSY;
>
> - if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
> - DRVNAME))
> - return -EBUSY;
> + if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
> + DRVNAME))
> + return -EBUSY;
> + }
Maybe it should be part of some kind of ->setup()?
...
> +static const char * const asus_wmi_boards[] = {
> + "PRIME B460-PLUS",
> + "ROG CROSSHAIR VIII IMPACT",
> + "ROG STRIX B550-E GAMING",
> + "ROG STRIX B550-F GAMING (WI-FI)",
> + "ROG STRIX Z490-I GAMING",
> + "TUF GAMING B550M-PLUS",
> + "TUF GAMING B550M-PLUS (WI-FI)",
> + "TUF GAMING B550-PLUS",
> + "TUF GAMING X570-PLUS",
> + "TUF GAMING X570-PRO (WI-FI)"
+ comma at the end.
> +};
...
> + if (match_string(asus_wmi_boards,
> + ARRAY_SIZE(asus_wmi_boards), board_name) != -EINVAL) {
err = match_string(...);
if (err < 0) {
...
}
> + /* if reading chip id via WMI succeeds, use WMI */
> + if (!nct6775_asuswmi_read(0, NCT6775_REG_CHIPID, &tmp)) {
> + pr_info("Using Asus WMI to access chip\n");
> + access = access_asuswmi;
> + }
> + }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-09-09 17:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <08262b12-4345-76a9-87be-66d630af3a59@roeck-us.net>
2021-09-08 21:36 ` [PATCH 1/3] hwmon: (nct6775) Use sio_data in superio_* (v2) Denis Pauk
2021-09-08 21:36 ` [PATCH 2/3] hwmon: (nct6775) Use superio function pointers (v2) Denis Pauk
2021-09-09 16:53 ` Andy Shevchenko
2021-09-08 21:36 ` [PATCH 3/3] hwmon: (nct6775) Support access via Asus WMI (v2) Denis Pauk
2021-09-09 17:00 ` Guenter Roeck
2021-09-09 17:01 ` Andy Shevchenko [this message]
2021-09-09 16:50 ` [PATCH 1/3] hwmon: (nct6775) Use sio_data in superio_* (v2) Andy Shevchenko
2021-09-11 22:24 ` Denis Pauk
2021-09-12 14:43 ` Andy Shevchenko
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=YTo98BIZjtlHtGrH@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=aros@gmx.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mail@bernhard-seibold.de \
--cc=me@rebtoor.com \
--cc=pauk.denis@gmail.com \
--cc=pehlm@pekholm.org \
--cc=to.eivind@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).