linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: hid-cmedia: use device managed resources
Date: Tue, 27 Sep 2022 11:42:33 +0200	[thread overview]
Message-ID: <YzLFieUC3UmJolvn@gmail.com> (raw)
In-Reply-To: <20220915123422.520721-1-marcus.folkesson@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

Hi,

Do you pick up this (and the similiar
[PATCH] HID: hid-alps: use default remove for hid device
[PATCH] HID: hid-elan: use default remove for hid device
)
patch as well?


On Thu, Sep 15, 2022 at 02:34:22PM +0200, Marcus Folkesson wrote:
> When we do not need to free() any memory in .remove, we can remove
> cmhid_remove as well.
> hid_device_remove() will call hid_hw_stop() as default .remove function
> if no function is specified.
> 
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
>  drivers/hid/hid-cmedia.c | 25 +++++--------------------
>  1 file changed, 5 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/hid/hid-cmedia.c b/drivers/hid/hid-cmedia.c
> index cab42047bc99..87786a88b119 100644
> --- a/drivers/hid/hid-cmedia.c
> +++ b/drivers/hid/hid-cmedia.c
> @@ -145,11 +145,9 @@ static int cmhid_probe(struct hid_device *hid, const struct hid_device_id *id)
>  	int ret;
>  	struct cmhid *cm;
>  
> -	cm = kzalloc(sizeof(struct cmhid), GFP_KERNEL);
> -	if (!cm) {
> -		ret = -ENOMEM;
> -		goto allocfail;
> -	}
> +	cm = devm_kzalloc(&hid->dev, sizeof(struct cmhid), GFP_KERNEL);
> +	if (!cm)
> +		return -ENOMEM;
>  
>  	cm->hid = hid;
>  
> @@ -159,28 +157,16 @@ static int cmhid_probe(struct hid_device *hid, const struct hid_device_id *id)
>  	ret = hid_parse(hid);
>  	if (ret) {
>  		hid_err(hid, "parse failed\n");
> -		goto fail;
> +		return ret;
>  	}
>  
>  	ret = hid_hw_start(hid, HID_CONNECT_DEFAULT | HID_CONNECT_HIDDEV_FORCE);
>  	if (ret) {
>  		hid_err(hid, "hw start failed\n");
> -		goto fail;
> +		return ret;
>  	}
>  
>  	return 0;

Outch, I just saw that we should just return ret here. IOW

  	if (ret)
  		hid_err(hid, "hw start failed\n");

    return ret;

Do you want me to send v2 or do you fix that when applying?

Thanks,
Marcus Folkesson


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2022-09-27  9:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 12:34 [PATCH] HID: hid-cmedia: use device managed resources Marcus Folkesson
2022-09-27  9:42 ` Marcus Folkesson [this message]

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=YzLFieUC3UmJolvn@gmail.com \
    --to=marcus.folkesson@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).