All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jackie Liu <liu.yun@linux.dev>
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 1/5] hwmon: (corsair-cpro) Use devres function
Date: Tue, 21 Dec 2021 18:58:35 -0800	[thread overview]
Message-ID: <b2797eb5-e87a-918a-2232-8be943bcac69@roeck-us.net> (raw)
In-Reply-To: <20211222020114.3524736-1-liu.yun@linux.dev>

On 12/21/21 6:01 PM, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> Use devm_hwmon_device_register_with_info() and remove hwmon_dev
> from ccp_device struct as it is not needed anymore.
> 
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>   drivers/hwmon/corsair-cpro.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c
> index fa6aa4fc8b52..f476367ba6cf 100644
> --- a/drivers/hwmon/corsair-cpro.c
> +++ b/drivers/hwmon/corsair-cpro.c
> @@ -76,7 +76,6 @@
>   
>   struct ccp_device {
>   	struct hid_device *hdev;
> -	struct device *hwmon_dev;
>   	struct completion wait_input_report;
>   	struct mutex mutex; /* whenever buffer is used, lock before send_usb_cmd */
>   	u8 *buffer;
> @@ -486,6 +485,7 @@ static int get_temp_cnct(struct ccp_device *ccp)
>   static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id)
>   {
>   	struct ccp_device *ccp;
> +	struct device *hwmon_dev;
>   	int ret;
>   
>   	ccp = devm_kzalloc(&hdev->dev, sizeof(*ccp), GFP_KERNEL);
> @@ -523,12 +523,12 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id)
>   	ret = get_fan_cnct(ccp);
>   	if (ret)
>   		goto out_hw_close;
> -	ccp->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsaircpro",
> -							 ccp, &ccp_chip_info, 0);
> -	if (IS_ERR(ccp->hwmon_dev)) {
> -		ret = PTR_ERR(ccp->hwmon_dev);
> +	hwmon_dev =
> +		devm_hwmon_device_register_with_info(&hdev->dev, "corsaircpro",
> +						     ccp, &ccp_chip_info, 0);
> +	ret = PTR_ERR_OR_ZERO(hwmon_dev);
> +	if (ret)
>   		goto out_hw_close;
> -	}
>   
>   	return 0;
>   
> @@ -541,9 +541,6 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id)
>   
>   static void ccp_remove(struct hid_device *hdev)
>   {
> -	struct ccp_device *ccp = hid_get_drvdata(hdev);
> -
> -	hwmon_device_unregister(ccp->hwmon_dev);
>   	hid_hw_close(hdev);
>   	hid_hw_stop(hdev);

The point is that the above two functions need to be called _after_ the hwmon device
was removed. This patch changes the order and removes the hwmon device after the hid
functions have been removed.

If you think this is valid you'll need to explain in detail why removal order
does not matter. Otherwise this patch deserves a NACK.

Guenter



  parent reply	other threads:[~2021-12-22  2:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22  2:01 [PATCH 1/5] hwmon: (corsair-cpro) Use devres function Jackie Liu
2021-12-22  2:01 ` [PATCH 2/5] hwmon: (nzxt-kraken2) " Jackie Liu
2021-12-22  2:01 ` [PATCH 3/5] hwmon: (corsair-psu) " Jackie Liu
2021-12-22  2:01 ` [PATCH 4/5] hwmon: (d5next) " Jackie Liu
2021-12-22  2:01 ` [PATCH 5/5] hwmon: (drivetemp) " Jackie Liu
2021-12-22  3:03   ` Guenter Roeck
2021-12-22  5:43     ` Jackie Liu
2021-12-22  2:58 ` Guenter Roeck [this message]
2021-12-22  6:13   ` [PATCH 1/5] hwmon: (corsair-cpro) " Jackie Liu
2021-12-22 16:10     ` Guenter Roeck

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=b2797eb5-e87a-918a-2232-8be943bcac69@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=liu.yun@linux.dev \
    /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.