From patchwork Tue Sep 10 15:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827153 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30FEE193081; Tue, 10 Sep 2024 15:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982605; cv=none; b=MdRfVzfgxM9QtspEf3YYVNaGMXEWvwL0l6/voI4EOM4BLKgv+Od1Q2EcNypuhcllV98kkRrLvu1StJmDXhSRkZdRMmacIcjsLaHkMLnqfv9rzhEwToQMgKRd/5AKvE3d27cFhlMX23nruXbG6+HVqzz/UxjsR66E09Z/vLqjmQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982605; c=relaxed/simple; bh=BpxgEr0zyi4zGYHNCoSUiqjIKuCesB7lSW2wi3WskVU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hD5QIiN2HmDNavMdKK98qY1vJVci2ApGUCstlUhJSxX0EVgGmc/hY/MQ8esffSn6Uf0eU/fWKSEpY62+jm2qL97ygETPoCyJixCV8JZjqCHa0uGqYHSexnKnktrewOziy2CKlmBvb7zZ1YK/QD0SIhIgff0fJ1FCofB5GJmdp14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X378X4BDsz1j8KR; Tue, 10 Sep 2024 23:36:12 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id ADF4D1401F3; Tue, 10 Sep 2024 23:36:40 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:39 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 02/15] HID: cp2112: Use devm_hid_hw_start_and_open in cp2112_probe() Date: Tue, 10 Sep 2024 23:45:32 +0800 Message-ID: <20240910154545.736786-3-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the cp2112 module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the err_hid_close and err_hid_stop lables. Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-3-lizetao1@huawei.com/ v1 -> v2: Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-3-lizetao1@huawei.com/ drivers/hid/hid-cp2112.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 20a0d1315d90..6d65c65f1b83 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1215,22 +1215,14 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; } - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); - if (ret) { - hid_err(hdev, "hw start failed\n"); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); + if (ret) return ret; - } - - ret = hid_hw_open(hdev); - if (ret) { - hid_err(hdev, "hw open failed\n"); - goto err_hid_stop; - } ret = hid_hw_power(hdev, PM_HINT_FULLON); if (ret < 0) { hid_err(hdev, "power management error: %d\n", ret); - goto err_hid_close; + return ret; } ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf), @@ -1334,10 +1326,6 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) i2c_del_adapter(&dev->adap); err_power_normal: hid_hw_power(hdev, PM_HINT_NORMAL); -err_hid_close: - hid_hw_close(hdev); -err_hid_stop: - hid_hw_stop(hdev); return ret; } @@ -1354,14 +1342,6 @@ static void cp2112_remove(struct hid_device *hdev) } gpiochip_remove(&dev->gc); - /* i2c_del_adapter has finished removing all i2c devices from our - * adapter. Well behaved devices should no longer call our cp2112_xfer - * and should have waited for any pending calls to finish. It has also - * waited for device_unregister(&adap->dev) to complete. Therefore we - * can safely free our struct cp2112_device. - */ - hid_hw_close(hdev); - hid_hw_stop(hdev); } static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report, From patchwork Tue Sep 10 15:45:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827146 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA09B1A00F4; Tue, 10 Sep 2024 15:37:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982627; cv=none; b=cpGAHTEFWBVUtojNdqBCijdhUgfnzO34ZFBSOlhMZRlC0VvpojezN6XE3rIlEbPCFF1azAVlkniIlSYNUxM5Wv3nn4cwk7ER6h/R/bB9Uc8kyiVItYrvPW+x6zIkTkcHBu82KcgHBoiRydZVQ46cx+EPcIrDniYO8ACGWxxzL9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982627; c=relaxed/simple; bh=7qi4mBYuK0ZnEPIUgHeNiz19kDlMvrLoPLzh2Iqhiy0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JTdeX6kkeKqdmR0HHUMFpORUeDo/wcmwH9o+cUgHSBLGJ6wkF8PccrlEiNOuGYuuRCapHkXr0dtYpenECinlnUEakFc5bDdoCunEvFxltVteDbMLrYV1S6E8TGOrp2YNAukWjbO5yAk9Wy2tV9VJzA3vmYr8xDS6QEAfCAlEeDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4X379M2z5Cz1xxDH; Tue, 10 Sep 2024 23:36:55 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id C28E01A0191; Tue, 10 Sep 2024 23:36:56 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:41 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 05/15] HID: mcp2221: Use devm_hid_hw_start_and_open in mcp2221_probe() Date: Tue, 10 Sep 2024 23:45:35 +0800 Message-ID: <20240910154545.736786-6-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the mcp2221 module use devm_add_action_or_reset() to manage device resource for HID unregistration, now that a universal interface has been provided, use a universal interface to replace it. Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-6-lizetao1@huawei.com/ v1 -> v2: None v1: https://lore.kernel.org/all/20240904123607.3407364-6-lizetao1@huawei.com/ drivers/hid/hid-mcp2221.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c index 0f93c22a479f..3b8269f7e923 100644 --- a/drivers/hid/hid-mcp2221.c +++ b/drivers/hid/hid-mcp2221.c @@ -932,15 +932,6 @@ static int mcp2221_raw_event(struct hid_device *hdev, return 1; } -/* Device resource managed function for HID unregistration */ -static void mcp2221_hid_unregister(void *ptr) -{ - struct hid_device *hdev = ptr; - - hid_hw_close(hdev); - hid_hw_stop(hdev); -} - /* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */ static void mcp2221_remove(struct hid_device *hdev) { @@ -1141,31 +1132,18 @@ static int mcp2221_probe(struct hid_device *hdev, * This driver uses the .raw_event callback and therefore does not need any * HID_CONNECT_xxx flags. */ - ret = hid_hw_start(hdev, 0); - if (ret) { - hid_err(hdev, "can't start hardware\n"); + ret = devm_hid_hw_start_and_open(hdev, 0); + if (ret) return ret; - } hid_info(hdev, "USB HID v%x.%02x Device [%s] on %s\n", hdev->version >> 8, hdev->version & 0xff, hdev->name, hdev->phys); - ret = hid_hw_open(hdev); - if (ret) { - hid_err(hdev, "can't open device\n"); - hid_hw_stop(hdev); - return ret; - } - mutex_init(&mcp->lock); init_completion(&mcp->wait_in_report); hid_set_drvdata(hdev, mcp); mcp->hdev = hdev; - ret = devm_add_action_or_reset(&hdev->dev, mcp2221_hid_unregister, hdev); - if (ret) - return ret; - hid_device_io_start(hdev); /* Set I2C bus clock diviser */ From patchwork Tue Sep 10 15:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827151 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16418191476; Tue, 10 Sep 2024 15:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982620; cv=none; b=Gh8PzLwSTOzfYX4TCSz+MVD0DPkuPH//1rJBUPaeLdIDVfGpycsT3zIkjI4aXBpcYY09C9JV0kq2jIzU55Kf07X29hvQXDZBfdszk82he/Bc/8eScqXKfopY687/EosMNf4c2UF6HyfkidtdJhUAKbT192xxHNHtlGhl8/lnOo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982620; c=relaxed/simple; bh=25i+UONXCDs5rFYVr2iA7Gp3T0NOZ2v/NTfArg/wAh4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=foumtPQ+afNdejrJX80qqMXLH1PW6nvJrrIr44NRSxdxLvY/8p0qTiqwhUdkcFpw1y/tFm3fREwgdl7+no7NmMxJcyhC1hbkrcM/vlGwXRqWaFGJTbR7cVhS7vt3Wcj24/CZf+jIqEmHv2AgytKgMK7740lCei5FYKaqv19p9Hg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X378r5sfzz1j8MK; Tue, 10 Sep 2024 23:36:28 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id EC42E1A0191; Tue, 10 Sep 2024 23:36:56 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:43 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 08/15] hwmon: (aquacomputer_d5next) Use devm_hid_hw_start_and_open in aqc_probe() Date: Tue, 10 Sep 2024 23:45:38 +0800 Message-ID: <20240910154545.736786-9-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the aquacomputer_d5next module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the fail_and_close and fail_and_stop lables, and directly return the error code when an error occurs. Reviewed-by: Aleksa Savic Acked-by: Guenter Roeck Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-9-lizetao1@huawei.com/ v1 -> v2: Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-13-lizetao1@huawei.com/ drivers/hwmon/aquacomputer_d5next.c | 39 +++++++---------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c index 8e55cd2f46f5..9b66ff0fe6e1 100644 --- a/drivers/hwmon/aquacomputer_d5next.c +++ b/drivers/hwmon/aquacomputer_d5next.c @@ -1556,14 +1556,10 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) if (ret) return ret; - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); if (ret) return ret; - ret = hid_hw_open(hdev); - if (ret) - goto fail_and_stop; - switch (hdev->product) { case USB_PRODUCT_ID_AQUAERO: /* @@ -1577,10 +1573,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) * they present. The two other devices have the type of the second element in * their respective collections set to 1, while the real device has it set to 0. */ - if (hdev->collection[1].type != 0) { - ret = -ENODEV; - goto fail_and_close; - } + if (hdev->collection[1].type != 0) + return -ENODEV; priv->kind = aquaero; @@ -1740,10 +1734,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) * Choose the right Leakshield device, because * the other one acts as a keyboard */ - if (hdev->type != 2) { - ret = -ENODEV; - goto fail_and_close; - } + if (hdev->type != 2) + return -ENODEV; priv->kind = leakshield; @@ -1865,30 +1857,20 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id) priv->name = aqc_device_names[priv->kind]; priv->buffer = devm_kzalloc(&hdev->dev, priv->buffer_size, GFP_KERNEL); - if (!priv->buffer) { - ret = -ENOMEM; - goto fail_and_close; - } + if (!priv->buffer) + return -ENOMEM; mutex_init(&priv->mutex); priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, priv->name, priv, &aqc_chip_info, NULL); - if (IS_ERR(priv->hwmon_dev)) { - ret = PTR_ERR(priv->hwmon_dev); - goto fail_and_close; - } + if (IS_ERR(priv->hwmon_dev)) + return PTR_ERR(priv->hwmon_dev); aqc_debugfs_init(priv); return 0; - -fail_and_close: - hid_hw_close(hdev); -fail_and_stop: - hid_hw_stop(hdev); - return ret; } static void aqc_remove(struct hid_device *hdev) @@ -1897,9 +1879,6 @@ static void aqc_remove(struct hid_device *hdev) debugfs_remove_recursive(priv->debugfs); hwmon_device_unregister(priv->hwmon_dev); - - hid_hw_close(hdev); - hid_hw_stop(hdev); } static const struct hid_device_id aqc_table[] = { From patchwork Tue Sep 10 15:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827150 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D48199FD7; Tue, 10 Sep 2024 15:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982621; cv=none; b=nhkGec81OsVdjbPirkOKitIVZyuZDO7NbBGTOZFJpJ3KQ3qnjNC595Tk4OD5QIg7AACPPSLnGvRM3OUneLUROwmOLKjcdFD9nxXfoi24TdoisPD2WhUzib78umRw/8V0FdX4DaqHwhgHp9wHW/kMPTbCOHeJ6XH0/fkUIoC3YEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982621; c=relaxed/simple; bh=/3SfGZur229jt8c6RIivd+a0zOHoE6Aq9wRdyxlUDxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h0XPs2XkH76wglZopfoDVzWonvUMNk7FMWUlWHI81Nq2xypSd7McX6Gwp4YkqXfKHU5lAgs5RUNoteIGQRR9KCzhbSQVjXhzzR8qgfAjbb4blqOCH90AyeD+wE1Wc7noowDW6I31pNzExqdaFgdiOnLWQ6cEoqA2SayLZ8XWWcU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X378r6g4Hz1j8Ms; Tue, 10 Sep 2024 23:36:28 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 138A91A0190; Tue, 10 Sep 2024 23:36:57 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:44 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 10/15] hwmon: (corsair-cpro) Use devm_hid_hw_start_and_open in ccp_probe() Date: Tue, 10 Sep 2024 23:45:40 +0800 Message-ID: <20240910154545.736786-11-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the corsair-cpro module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the out_hw_close and hid_hw_stop lables, and directly return the error code when an error occurs. Acked-by: Marius Zachmann Acked-by: Guenter Roeck Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-11-lizetao1@huawei.com/ v1 -> v2: Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-15-lizetao1@huawei.com/ drivers/hwmon/corsair-cpro.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/corsair-cpro.c b/drivers/hwmon/corsair-cpro.c index e1a7f7aa7f80..7bba30840f32 100644 --- a/drivers/hwmon/corsair-cpro.c +++ b/drivers/hwmon/corsair-cpro.c @@ -601,14 +601,10 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) if (ret) return ret; - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); if (ret) return ret; - ret = hid_hw_open(hdev); - if (ret) - goto out_hw_stop; - ccp->hdev = hdev; hid_set_drvdata(hdev, ccp); @@ -621,28 +617,20 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) /* temp and fan connection status only updates when device is powered on */ ret = get_temp_cnct(ccp); if (ret) - goto out_hw_close; + return ret; ret = get_fan_cnct(ccp); if (ret) - goto out_hw_close; + return ret; ccp_debugfs_init(ccp); ccp->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsaircpro", ccp, &ccp_chip_info, NULL); - if (IS_ERR(ccp->hwmon_dev)) { - ret = PTR_ERR(ccp->hwmon_dev); - goto out_hw_close; - } + if (IS_ERR(ccp->hwmon_dev)) + return PTR_ERR(ccp->hwmon_dev); return 0; - -out_hw_close: - hid_hw_close(hdev); -out_hw_stop: - hid_hw_stop(hdev); - return ret; } static void ccp_remove(struct hid_device *hdev) @@ -651,8 +639,6 @@ static void ccp_remove(struct hid_device *hdev) debugfs_remove_recursive(ccp->debugfs); hwmon_device_unregister(ccp->hwmon_dev); - hid_hw_close(hdev); - hid_hw_stop(hdev); } static const struct hid_device_id ccp_devices[] = { From patchwork Tue Sep 10 15:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827148 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701EF19A28B; Tue, 10 Sep 2024 15:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982622; cv=none; b=A0n2R04CvR6WN4d99FzcV+QNQdx6sENXOmvKHUQl4PAXrCtQgjsdP71kIl5gmu6u6eOwukZtsbHdW7h+9Dc2jnaOSchgqnR9ZLyjp1hXIyQACorZRYzDsztZJtZi6geqauLbxYbp3MF57FhDCtl56YUEAHJAyHlNMyE3KCiKoyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982622; c=relaxed/simple; bh=uc7u5wB4LeMQ5k5CzWuYbkW0/7xI8rraHHxJe0euFvU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nO/Sy78z4dozMmgtj+ZnlSiPgpy6qPJPGtmImLr7z9T5cx/KfHkf3eMhNxY1jrJNM2COZk+qcWnNU6cXISxeNlIWzvAaT4SxO0uPx9RcaqFu5OXLNTNTD4HY6bhX5nCclCAmcAoUZkIgiojN63ULKpL9Sf4WIBt2gmV+QPzxkM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X378r5kzLz2Dc4j; Tue, 10 Sep 2024 23:36:28 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 20FE71A0191; Tue, 10 Sep 2024 23:36:57 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:45 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 11/15] hwmon: (corsair-psu) Use devm_hid_hw_start_and_open in corsairpsu_probe() Date: Tue, 10 Sep 2024 23:45:41 +0800 Message-ID: <20240910154545.736786-12-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the corsair-psu module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the fail_and_close and fail_and_stop lables, and directly return the error code when an error occurs. Reviewed-by: Wilken Gottwalt Acked-by: Guenter Roeck Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-12-lizetao1@huawei.com/ v1 -> v2: Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-15-lizetao1@huawei.com/ drivers/hwmon/corsair-psu.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c index f8f22b8a67cd..b574ec9cd00f 100644 --- a/drivers/hwmon/corsair-psu.c +++ b/drivers/hwmon/corsair-psu.c @@ -787,14 +787,10 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id if (ret) return ret; - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); if (ret) return ret; - ret = hid_hw_open(hdev); - if (ret) - goto fail_and_stop; - priv->hdev = hdev; hid_set_drvdata(hdev, priv); mutex_init(&priv->lock); @@ -805,13 +801,13 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id ret = corsairpsu_init(priv); if (ret < 0) { dev_err(&hdev->dev, "unable to initialize device (%d)\n", ret); - goto fail_and_stop; + return ret; } ret = corsairpsu_fwinfo(priv); if (ret < 0) { dev_err(&hdev->dev, "unable to query firmware (%d)\n", ret); - goto fail_and_stop; + return ret; } corsairpsu_get_criticals(priv); @@ -820,20 +816,12 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsairpsu", priv, &corsairpsu_chip_info, NULL); - if (IS_ERR(priv->hwmon_dev)) { - ret = PTR_ERR(priv->hwmon_dev); - goto fail_and_close; - } + if (IS_ERR(priv->hwmon_dev)) + return PTR_ERR(priv->hwmon_dev); corsairpsu_debugfs_init(priv); return 0; - -fail_and_close: - hid_hw_close(hdev); -fail_and_stop: - hid_hw_stop(hdev); - return ret; } static void corsairpsu_remove(struct hid_device *hdev) @@ -842,8 +830,6 @@ static void corsairpsu_remove(struct hid_device *hdev) debugfs_remove_recursive(priv->debugfs); hwmon_device_unregister(priv->hwmon_dev); - hid_hw_close(hdev); - hid_hw_stop(hdev); } static int corsairpsu_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, From patchwork Tue Sep 10 15:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827147 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DA99199FDB; Tue, 10 Sep 2024 15:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982623; cv=none; b=m1IVMpX1xdb/dxfhN/v/42P3PLvBK7Ll3Ed1tvfz98aEQFZfij+sVMyzax7UExcCK4+KT07WZoc8OnwLx0/yylJV7ICXwss8GEjJNrFd7oiFBwEbX1CszhuYVdvw7FaOXpq1oFf2k34u+81BnZRqkvOdigJhOjUz0z+fktw7D38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982623; c=relaxed/simple; bh=iTFC6Tib+y7aOz4hW2DQiNvumbaug4wygRwoOqlsx3A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nK28td37g2c88+D86b3PfaduHh6K2wuBzolczs7ygrPVXzBKlKBmg2kaBJuTrTdoCOymhg0gNQIGh1J8t5O21GLQLJDZx01gyznnLxDVS8DW72NdwTw9n5bfsxBDLEVXIFW1oDPVWJiw+cF7q6PbSi5Fz+9MMbUdFanI1ZcHcNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X378s0LRyz1j8Md; Tue, 10 Sep 2024 23:36:29 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 2E95A1A0188; Tue, 10 Sep 2024 23:36:57 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:46 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 12/15] hwmon: (gigabyte_waterforce) Use devm_hid_hw_start_and_open in waterforce_probe() Date: Tue, 10 Sep 2024 23:45:42 +0800 Message-ID: <20240910154545.736786-13-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the waterforce module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the fail_and_close and fail_and_stop lables, and directly return the error code when an error occurs. Reviewed-by: Aleksa Savic Acked-by: Guenter Roeck Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-13-lizetao1@huawei.com/ v1 -> v2: Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-16-lizetao1@huawei.com/ drivers/hwmon/gigabyte_waterforce.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/hwmon/gigabyte_waterforce.c b/drivers/hwmon/gigabyte_waterforce.c index 8129d7b3ceaf..9052d1c3d5aa 100644 --- a/drivers/hwmon/gigabyte_waterforce.c +++ b/drivers/hwmon/gigabyte_waterforce.c @@ -337,23 +337,13 @@ static int waterforce_probe(struct hid_device *hdev, const struct hid_device_id /* * Enable hidraw so existing user-space tools can continue to work. */ - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); - if (ret) { - hid_err(hdev, "hid hw start failed with %d\n", ret); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); + if (ret) return ret; - } - - ret = hid_hw_open(hdev); - if (ret) { - hid_err(hdev, "hid hw open failed with %d\n", ret); - goto fail_and_stop; - } priv->buffer = devm_kzalloc(&hdev->dev, MAX_REPORT_LENGTH, GFP_KERNEL); - if (!priv->buffer) { - ret = -ENOMEM; - goto fail_and_close; - } + if (!priv->buffer) + return -ENOMEM; mutex_init(&priv->status_report_request_mutex); mutex_init(&priv->buffer_lock); @@ -371,18 +361,12 @@ static int waterforce_probe(struct hid_device *hdev, const struct hid_device_id if (IS_ERR(priv->hwmon_dev)) { ret = PTR_ERR(priv->hwmon_dev); hid_err(hdev, "hwmon registration failed with %d\n", ret); - goto fail_and_close; + return ret; } waterforce_debugfs_init(priv); return 0; - -fail_and_close: - hid_hw_close(hdev); -fail_and_stop: - hid_hw_stop(hdev); - return ret; } static void waterforce_remove(struct hid_device *hdev) @@ -391,9 +375,6 @@ static void waterforce_remove(struct hid_device *hdev) debugfs_remove_recursive(priv->debugfs); hwmon_device_unregister(priv->hwmon_dev); - - hid_hw_close(hdev); - hid_hw_stop(hdev); } static const struct hid_device_id waterforce_table[] = { From patchwork Tue Sep 10 15:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 827149 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87A3819AA75; Tue, 10 Sep 2024 15:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982621; cv=none; b=QjHV3qPzQyzuUF4n2Ahhd4ZcmokdXRqp3Ht9U3srI5+sso/Q3DemmC/E+8ISWej/MgAiQOWzMKs4oOohXKUV4U45pmR+5OoIcoWaRtaWJhRF8brT40gwtGudE/pnxXq7es3/8PiJXhP4mvmLy2AWQ+8h0iYhcs1r/68EICJdims= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725982621; c=relaxed/simple; bh=fPodBcRmooQc412mo89NDHrao5EJWLAEnyMWs+S2xpE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hkBV3r59Lfnijmbrad2fJglvLJlqDIBB5AXSL9iUII4Kqql4UrZglOxiOyGqvC6NYTtr4169jjZXjr8kxB3r05lP1DhRMAm6KUPbAdyOzITJt09qXmxv9YOZUTY4K5DnrFBaNyiIhP7Rxou1dk18uUcBSansKCGn6BaAsuXG6yI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X378s0DjHz2Dc4l; Tue, 10 Sep 2024 23:36:29 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 57FB31A0188; Tue, 10 Sep 2024 23:36:57 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 10 Sep 2024 23:36:47 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH -next v3 15/15] hwmon: (nzxt-smart2) Use devm_hid_hw_start_and_open in nzxt_smart2_hid_probe() Date: Tue, 10 Sep 2024 23:45:45 +0800 Message-ID: <20240910154545.736786-16-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910154545.736786-1-lizetao1@huawei.com> References: <20240910154545.736786-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd500012.china.huawei.com (7.221.188.25) Currently, the nzxt-smart2 module needs to maintain hid resources by itself. Use devm_hid_hw_start_and_open helper to ensure that hid resources are consistent with the device life cycle, and release hid resources before device is released. At the same time, it can avoid the goto-release encoding, drop the out_hw_close and out_hw_stop lables, and directly return the error code when an error occurs. Further optimization, use devm_hwmon_device_register_with_info to replace hwmon_device_register_with_info, the remote operation can be completely deleted, and the drvdata no longer needs to hold hwmon device Acked-by: Guenter Roeck Signed-off-by: Li Zetao --- v2 -> v3: None v2: https://lore.kernel.org/all/20240909012313.500341-16-lizetao1@huawei.com/ v1 -> v2: 1) Further optimize using devm_hwmon_device_register_with_info and remove the .remove operation 2) Adjust commit information v1: https://lore.kernel.org/all/20240904123607.3407364-20-lizetao1@huawei.com/ drivers/hwmon/nzxt-smart2.c | 38 +++++-------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c index df6fa72a6b59..9c6d020ac896 100644 --- a/drivers/hwmon/nzxt-smart2.c +++ b/drivers/hwmon/nzxt-smart2.c @@ -172,7 +172,6 @@ struct set_fan_speed_report { struct drvdata { struct hid_device *hid; - struct device *hwmon; u8 fan_duty_percent[FAN_CHANNELS]; u16 fan_rpm[FAN_CHANNELS]; @@ -730,6 +729,7 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct drvdata *drvdata; + struct device *hwmon; int ret; drvdata = devm_kzalloc(&hdev->dev, sizeof(struct drvdata), GFP_KERNEL); @@ -750,44 +750,17 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev, if (ret) return ret; - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); + ret = devm_hid_hw_start_and_open(hdev, HID_CONNECT_HIDRAW); if (ret) return ret; - ret = hid_hw_open(hdev); - if (ret) - goto out_hw_stop; - hid_device_io_start(hdev); init_device(drvdata, UPDATE_INTERVAL_DEFAULT_MS); - drvdata->hwmon = - hwmon_device_register_with_info(&hdev->dev, "nzxtsmart2", drvdata, - &nzxt_smart2_chip_info, NULL); - if (IS_ERR(drvdata->hwmon)) { - ret = PTR_ERR(drvdata->hwmon); - goto out_hw_close; - } - - return 0; - -out_hw_close: - hid_hw_close(hdev); - -out_hw_stop: - hid_hw_stop(hdev); - return ret; -} - -static void nzxt_smart2_hid_remove(struct hid_device *hdev) -{ - struct drvdata *drvdata = hid_get_drvdata(hdev); - - hwmon_device_unregister(drvdata->hwmon); - - hid_hw_close(hdev); - hid_hw_stop(hdev); + hwmon = devm_hwmon_device_register_with_info(&hdev->dev, "nzxtsmart2", drvdata, + &nzxt_smart2_chip_info, NULL); + return PTR_ERR_OR_ZERO(hwmon); } static const struct hid_device_id nzxt_smart2_hid_id_table[] = { @@ -807,7 +780,6 @@ static struct hid_driver nzxt_smart2_hid_driver = { .name = "nzxt-smart2", .id_table = nzxt_smart2_hid_id_table, .probe = nzxt_smart2_hid_probe, - .remove = nzxt_smart2_hid_remove, .raw_event = nzxt_smart2_hid_raw_event, #ifdef CONFIG_PM .reset_resume = nzxt_smart2_hid_reset_resume,