Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3985472ybl; Mon, 12 Aug 2019 09:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgO0awgtF6Lh0A90fl+J6zKxdG7sKEFdzjAuaV/1RkIqcigccvwZOBnjwbWuYtA+ofk6wc X-Received: by 2002:a17:90a:b016:: with SMTP id x22mr131511pjq.116.1565627386041; Mon, 12 Aug 2019 09:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565627386; cv=none; d=google.com; s=arc-20160816; b=WBor6fDYK9/GbkkV3HXt+FIXycOEv9UIK1J9BZslTCrDG/THnZIArjCsMHZbmjPF1H d8UZc4LdXQAT9cwLGgMKWAn+6RUjGlAbbxpTl0KGfbnoNZop61iIyEregVFNyx6niu91 vce9ssD0GGiDnvq6sRBYxvr5HWEBDxPeDeBxj/5TPzxIyPbhr13FvLZDSp9Y91c9oRIq jHK2bqU4nFB7xCdcqg/mnUohFtUVx1Ih2pQOGwq0H24aHRfTAc6hzQkLhC4WIgWixsXw xI/nAfxTfPH58r4l+OABhHigAQKn0GmGPi+v13KgYHQMKS293hoRLIqoY3C6ZjQSOOup x5Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bVs+9HXQe8tYXpkOLTOCf2gwpyoN614wTh+XDMq1CNE=; b=GvRJgiyn8tw5VHKaIbNofztNHBvjAtem/JJZdnhS+tHKfGUxEhkRrByuDQ0pMFw3GP /FV0sqNVvspNymYH6qC1XhDL7qwO90xech5ygln6GzA/WUd+CPOTsY+WJkGM0jH9CG/K pmey41MClEN1qGoLeikIybn5wUZZNjL17Hc4smKh8GlsTsStwwSWKgOdeuQCmQ/P4mgU 5/2BnftKeY2D+412Ip8+satwVgeA8vtVrOBXH2gQTsLrnwKOLECrMicQ0GiWiyiiB5D7 M4EObi58sOzQGaW5yvR+Bo3cl9KxlKfoMypiUfepSpanokhltCbmf4bqQ8npV/ly3tA0 UUeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si63077950pgj.239.2019.08.12.09.29.30; Mon, 12 Aug 2019 09:29:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbfHLQ1x (ORCPT + 99 others); Mon, 12 Aug 2019 12:27:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30569 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbfHLQ1w (ORCPT ); Mon, 12 Aug 2019 12:27:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CE1689AC5; Mon, 12 Aug 2019 16:27:51 +0000 (UTC) Received: from plouf.redhat.com (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 906F55C1B5; Mon, 12 Aug 2019 16:27:49 +0000 (UTC) From: Benjamin Tissoires To: =?UTF-8?q?Bruno=20Pr=C3=A9mont?= , Jonathan Cameron , Srinivas Pandruvada , Ping Cheng , Jason Gerecke , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 1/2] HID: do not call hid_set_drvdata(hdev, NULL) in drivers Date: Mon, 12 Aug 2019 18:27:39 +0200 Message-Id: <20190812162740.15898-2-benjamin.tissoires@redhat.com> In-Reply-To: <20190812162740.15898-1-benjamin.tissoires@redhat.com> References: <20190812162740.15898-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 12 Aug 2019 16:27:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a common pattern in the HID drivers to reset the drvdata. Some do it properly, some do it only in case of failure. But, this is actually already handled by driver core, so there is no need to do it manually. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-cougar.c | 6 ++---- drivers/hid/hid-gfrm.c | 7 ------- drivers/hid/hid-lenovo.c | 2 -- drivers/hid/hid-picolcd_core.c | 7 +------ drivers/hid/hid-sensor-hub.c | 1 - 5 files changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/hid/hid-cougar.c b/drivers/hid/hid-cougar.c index e0bb7b34f3a4..4ff3bc1d25e2 100644 --- a/drivers/hid/hid-cougar.c +++ b/drivers/hid/hid-cougar.c @@ -207,7 +207,7 @@ static int cougar_probe(struct hid_device *hdev, error = hid_parse(hdev); if (error) { hid_err(hdev, "parse failed\n"); - goto fail; + return error; } if (hdev->collection->usage == COUGAR_VENDOR_USAGE) { @@ -219,7 +219,7 @@ static int cougar_probe(struct hid_device *hdev, error = hid_hw_start(hdev, connect_mask); if (error) { hid_err(hdev, "hw start failed\n"); - goto fail; + return error; } error = cougar_bind_shared_data(hdev, cougar); @@ -249,8 +249,6 @@ static int cougar_probe(struct hid_device *hdev, fail_stop_and_cleanup: hid_hw_stop(hdev); -fail: - hid_set_drvdata(hdev, NULL); return error; } diff --git a/drivers/hid/hid-gfrm.c b/drivers/hid/hid-gfrm.c index 86c317320bf2..699186ff2349 100644 --- a/drivers/hid/hid-gfrm.c +++ b/drivers/hid/hid-gfrm.c @@ -123,12 +123,6 @@ static int gfrm_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; } -static void gfrm_remove(struct hid_device *hdev) -{ - hid_hw_stop(hdev); - hid_set_drvdata(hdev, NULL); -} - static const struct hid_device_id gfrm_devices[] = { { HID_BLUETOOTH_DEVICE(0x58, 0x2000), .driver_data = GFRM100 }, @@ -142,7 +136,6 @@ static struct hid_driver gfrm_driver = { .name = "gfrm", .id_table = gfrm_devices, .probe = gfrm_probe, - .remove = gfrm_remove, .input_mapping = gfrm_input_mapping, .raw_event = gfrm_raw_event, .input_configured = gfrm_input_configured, diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 364bc7f11d9d..96fa2a2c2cd3 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -866,8 +866,6 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev) led_classdev_unregister(&data_pointer->led_micmute); led_classdev_unregister(&data_pointer->led_mute); - - hid_set_drvdata(hdev, NULL); } static void lenovo_remove_cptkbd(struct hid_device *hdev) diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c index 5f7a39a5d4af..1b5c63241af0 100644 --- a/drivers/hid/hid-picolcd_core.c +++ b/drivers/hid/hid-picolcd_core.c @@ -534,8 +534,7 @@ static int picolcd_probe(struct hid_device *hdev, data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL); if (data == NULL) { hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n"); - error = -ENOMEM; - goto err_no_cleanup; + return -ENOMEM; } spin_lock_init(&data->lock); @@ -597,9 +596,6 @@ static int picolcd_probe(struct hid_device *hdev, hid_hw_stop(hdev); err_cleanup_data: kfree(data); -err_no_cleanup: - hid_set_drvdata(hdev, NULL); - return error; } @@ -635,7 +631,6 @@ static void picolcd_remove(struct hid_device *hdev) picolcd_exit_cir(data); picolcd_exit_keys(data); - hid_set_drvdata(hdev, NULL); mutex_destroy(&data->mutex); /* Finally, clean up the picolcd data itself */ kfree(data); diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index be92a6f79687..94c7398b5c27 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -742,7 +742,6 @@ static void sensor_hub_remove(struct hid_device *hdev) } spin_unlock_irqrestore(&data->lock, flags); mfd_remove_devices(&hdev->dev); - hid_set_drvdata(hdev, NULL); mutex_destroy(&data->mutex); } -- 2.19.2