Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1388536ybl; Thu, 22 Aug 2019 13:46:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNTpO8/ct7fXBz7WbRUkozk4osmX+KUkyr3jzZr3cGg9oKKoiR6WaEOwRXT9Y5cXjHWIlH X-Received: by 2002:a17:90a:d593:: with SMTP id v19mr1621160pju.1.1566506819628; Thu, 22 Aug 2019 13:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566506819; cv=none; d=google.com; s=arc-20160816; b=zgQi1BEuYqLqMQRy7bmKPR8ckELG/PyUQunaY4NvVsLuVBgrI+dNQz8fcHQavZ5nUo ytzExuada45B7JbzpPYup4c4HUBxE5QLFeMm5sDMIs+7+U7jNpyfT7eSZiYRe6pZHXix 9qijBPLdBdLuuTKOvd1t+FOEpIY5xTmMG6KD4Bc6qf83OuPPCVf399CRFa5Ao2jzD9gR L5ZMpneHo76Mcj60Qov2rICgUnhETB5lIBijaB/sILhar+qND0ica4JJ9XdYcdAfoVNM cPqa4NjzFpnADC6LcJ411VcjtLvLRzBto6RVh/RYvOTUfb8FiCPTcjRrVxG1Mn8Cmk3A H4Rw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=x6JnB+fE1xlx/RNlzJPB1K7623ifOrdUVNFthkDrE1M=; b=MZwFzxvhB6S+KyLCYAg5FiTcMkB/T9bmtnzHFb79KLY4UnsIKDHGymZewhJPXc+Ug/ /xvxAkmQ6r1wJYgRecR9J+V20Jj+SbuVyPXAJhn1yD1l9vAkDNREaTzQLv6fLuTA8CUJ Y4S7J38Swc6X5pmuO/Xy3uc73mdx3xgoiaDaQLVnboAe4shOnNsGCfY04W89th+edpRD 5V4nwSlt26sE2yIBWqlC3B03qxJBeEdN8WQ/ZFDxe4S4422P0mfAy+86pirQTKPeadzF xtvFOcFOx/Rp2v0AdeAnEL+fv2X7jwQLzL33dGgzFIDfYBGb8WOn+GFcFlbCbjaC26EO Ddgw== 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 d27si283054pgd.328.2019.08.22.13.46.43; Thu, 22 Aug 2019 13:46:59 -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 S2389614AbfHVPuW convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Aug 2019 11:50:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49358 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731069AbfHVPuW (ORCPT ); Thu, 22 Aug 2019 11:50:22 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8586B85550 for ; Thu, 22 Aug 2019 15:50:21 +0000 (UTC) Received: by mail-qk1-f199.google.com with SMTP id d203so6268009qke.4 for ; Thu, 22 Aug 2019 08:50:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=e33KgK5g3O2XLfmnWFACPhTCEze1U4J8Z33SDjP74cg=; b=jTN9ncA6y6i1a+3iZCLwoWPQ/PrkMcBQEqJM/QHJmdvq+iftCq01dXY5fYeZdpX8r+ SmF8RfxlYEQ0QsZ8TVskuunmzuZRadUaXCB0RdVNueFWaXm789v+CKsr+TVFDLCCT9xp 5CFw+t2RH8HF1mHez4a+8R1trIwbktzEgMpUeKu9zn2dKtMnSvsV8jwhV3M71meqmGVv aZIGNC2oNpY0vEeT3c5A2ZUFRbhvo3BMym2JqTBot8t111E3FIURPoUZD48YL/HE/7jJ 2y/PlQqhOAzBzLtte8L9tSZeRq6sD6+45+3Z73m7SHziDposZpHaEns8CKLLDuOdYqjY +TqA== X-Gm-Message-State: APjAAAXyJf6lXw/WwZcTr87+fY1wgFaVWhq4pSe+fBYmpX3Wj99JS4mn 6IITaYBrM4mVj//4L1NgH2x4EUPCCjvLoUaZ5cZ1jurATsQLWRIblX7tFzSOopTfhHxj5px7ZL+ xCBLi7X5fi07LuYIPZtFAmGEpy3wwrEiqaKxKiSZ7 X-Received: by 2002:ac8:c86:: with SMTP id n6mr199540qti.345.1566489020852; Thu, 22 Aug 2019 08:50:20 -0700 (PDT) X-Received: by 2002:ac8:c86:: with SMTP id n6mr199526qti.345.1566489020648; Thu, 22 Aug 2019 08:50:20 -0700 (PDT) MIME-Version: 1.0 References: <20190812162740.15898-1-benjamin.tissoires@redhat.com> <20190812162740.15898-2-benjamin.tissoires@redhat.com> <20190813075358.2a3cbfbd@pluto.restena.lu> In-Reply-To: <20190813075358.2a3cbfbd@pluto.restena.lu> From: Benjamin Tissoires Date: Thu, 22 Aug 2019 17:50:08 +0200 Message-ID: Subject: Re: [PATCH 1/2] HID: do not call hid_set_drvdata(hdev, NULL) in drivers To: =?UTF-8?Q?Bruno_Pr=C3=A9mont?= Cc: Jonathan Cameron , Srinivas Pandruvada , Ping Cheng , Jason Gerecke , Jiri Kosina , "open list:HID CORE LAYER" , lkml Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 13, 2019 at 7:54 AM Bruno Prémont wrote: > > On Mon, 12 Aug 2019 18:27:39 +0200 Benjamin Tissoires wrote: > > 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 > > For hid-picolcd_core.c: > Acked-by: Bruno Prémont Thanks for the acks. Applied to for-5.4/cleanup Cheers, Benjamin > > > --- > > 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); > > } > >