Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp514448pxf; Thu, 8 Apr 2021 07:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYHvkOcRIZVCk80TXZACxk36f0DvkQ/ExLQOQuefmlGAyLDnetDPZOHV34ZzKc6MTaRosb X-Received: by 2002:a63:4d24:: with SMTP id a36mr1453001pgb.64.1617892911017; Thu, 08 Apr 2021 07:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617892911; cv=none; d=google.com; s=arc-20160816; b=u3Ks/yBwKmcCkCSPrQbMGQ7yhvyWQ24eDpCTaUU7oZkOZZltCXRIKCKbgBcDM9c3/9 GMRX09l6tluWfQn1wDIG2h77Q2DltE1JjKz+gOeYvxmyON3CUMqfCtWaM42EaBwBN+uW nSvtvs/zBpggdWmbf6rAYlmAINy1nnTkJMbVHYXzuoBthIAqJMBw/NOtjdFHoRA20wg5 p9D0pLdTvo1PAAt+knTNc7Ku61LxNIlcHZ1w1LQxGB/IYlD8UZifnR08rQ+zkZPzGG3f OewaNd6gylD+gTUdShvzN4Sy6BCnDKl0hcpA+qcJtstakJP9+j+uu6ISTnDFgDlEstIN jG6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=jgUjy+0dvhZup5xoC8Pl09DoyZqFtJjDoR5hGMlPPlM=; b=0ei0yQib9tDbP7ZSAhh0ibLVDCfr7B8j7SQZiyHkwtO/vMurtMgJvAhviLzbSsMdvD AMQ9OCtVC25g7CnwDeS9oSODe8tC0Wx/xmtDgZ1kzH9jY5It/a2SkbJTHLUdAzP9eNFv cr64JCo/kbbuXbeYZw/UfgFVT2bvc54j838RHtNLg2pbrWm5YbO8Gto+8pr17g+v7Uif 2AskRkumjs4bwXMXkMQLICZXNqAJ1OerVU/U68GO20u8jC9eAY1Mrys3pOxAEC3Wz36n B8EtmYG5UEUi+7pstYmzkLSXSe4OtVs8I/YNEacGY5J/MdGxOd9otBYSiqXwDXpiSqLF KqbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=nR5KXRCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si9579469pjq.38.2021.04.08.07.41.37; Thu, 08 Apr 2021 07:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=nR5KXRCm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbhDHOkI (ORCPT + 99 others); Thu, 8 Apr 2021 10:40:08 -0400 Received: from ned.t-8ch.de ([212.47.237.191]:41998 "EHLO ned.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbhDHOkF (ORCPT ); Thu, 8 Apr 2021 10:40:05 -0400 Date: Thu, 8 Apr 2021 16:39:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1617892789; bh=eawHhWnZrhj3EwvJjSXCOh9KssxWRfjXIYrC8hWM9Q4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nR5KXRCmNmogKrWvoW7jwDcIWxva0F0RH3oGPMuigRneVHQabY63jpFKpXtYHyvU4 9vTp/1XQpNVAlFjaBhX9CszJznbyHvqh/7gmCaZGP7hAOA0qPD3EZ0hHD9Q40J3Ib1 NBLnXD0r22F69ktd6qgYTQ4CntG/pPGuhrR8/2c4= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: "platform-driver-x86@vger.kernel.org" , Mark Gross , Hans de Goede , "linux-kernel@vger.kernel.org" , Matthew Garrett Subject: Re: [PATCH v2] platform/x86: add Gigabyte WMI temperature driver Message-ID: <0c3ef6d2-6e95-4dd9-b9d4-41f5e70bc574@t-8ch.de> References: <20210405204810.339763-1-linux@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 "); > > +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