Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3430503pxf; Mon, 22 Mar 2021 06:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEHW68DLwYbFqRK28oBeop/mUvpG3/ULPwUvNH6i7DNcTL/pL3iDiWU2HbT2s7TJZ7wpkR X-Received: by 2002:a17:906:c9c2:: with SMTP id hk2mr19515153ejb.244.1616419354764; Mon, 22 Mar 2021 06:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616419354; cv=none; d=google.com; s=arc-20160816; b=UkE/tEFjT+z25TtIFKQ53w5UZcu+ut70QxtwVpmJw8xiL1l+6OBwNdm2bdAVPWqBes 0FDfQdtn3tkyUBzXoQwIS9Sn+b10GmXb2OkzMopQ7KDpvCbHVZgQYHL5QG95jgKmoDWV 5/At/EwQDcRcoA0A8RaAL7jIymHSJpyW5fgKpgK+dkPIgZlKhBYyrE8XokomLPZb4NY+ AF2jWU7kCcT5Gic4HsNi3oz/vC2gDahGYIEqnxZ9WD8iQy3ivE6oFWox3sydtcK3BfOu lhwmX90+QAMInvYhBBtiZQ2tnbkFCTBPlbnc0IdGW9KZ9+Arn4vsexv9mGmaLcb5vq8m o+HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature:dkim-signature; bh=Q3lhQzUVNRpT0WVcy0osqEdXHCEuJqKRN3r8YPhYJwc=; b=rCNC0DkD7pQG9gX01Cfg1gJL0GGf377hLmwsq7DDggrnT4uIaM9jOF+4FrW+BcGTsS ip+5YGYYjcou8UBtHOL5BgmyKztv9Kk5nlrDAdZ7p4DpTe2GP4nyrYpK4owYdSf5vzVH OPluNStIsA5hKRmT+WpHG4wyQgY/B7m7mvdhShDAQ7exBmB/pVPDXl4yaQELUUeGL1H/ mALnoe0/CEFgfFY26ZoIqK7KL9fkrn7iW3djte32fPdG+HCwlMDUjJp3rWM/hPa+qsqR 6Xx2v57PNoa0xdfYKLOBNpEpuUxMb652khVG7jQwbkJ86/POch10ks1rlDhoZjHGmGYd gg5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm3 header.b=dy2RzWeA; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LRkKODN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si10463515edq.578.2021.03.22.06.22.12; Mon, 22 Mar 2021 06:22:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm3 header.b=dy2RzWeA; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LRkKODN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbhCVNTZ (ORCPT + 99 others); Mon, 22 Mar 2021 09:19:25 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47329 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhCVNQr (ORCPT ); Mon, 22 Mar 2021 09:16:47 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 29B1B5C013A; Mon, 22 Mar 2021 09:16:47 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute1.internal (MEProxy); Mon, 22 Mar 2021 09:16:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=mime-version:message-id:in-reply-to:references:date:from:to :cc:subject:content-type; s=fm3; bh=Q3lhQzUVNRpT0WVcy0osqEdXHCEu JqKRN3r8YPhYJwc=; b=dy2RzWeAsdsTMUAAyE0U2TQJGAPMmJ6EYS6gxLJje1ZN SGb0LZsJlhzlp3SUVYyKfMlkuj68Ku3hxlHE+LgShM9RihaZc0TJedgs3aeJmfzm imkx9Er02ypDqLOsUdorkZd81jDcomO+RLO0jqxRKp0iIUjxg8mFxWCUaoKkOVnY 34Uu3s4d2OoAKxUcxeSYIufaIAO01SBbR+wR6qhG90MBCTxogx5mKUejdpzAPpaU hzdErJ8fksUS9BQOs2JgvlHySkB6zAC3sY7N7jyLYyU0/3aDy6ZGyismYPf9R4Fc Hrsr35HojCg6YYe6AzKMb+7a6/GGfK4E6knM6usrGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Q3lhQz UVNRpT0WVcy0osqEdXHCEuJqKRN3r8YPhYJwc=; b=LRkKODN2PtIs7T5fZkLaTR UhcjcjjgvJzvF5LaKsFfz8uP6CLh5uQaGhjbztgkFhr2fJmg8R0/WUpD79Y8OTBd DDSR/YHL3GmNK9SsYlqY/BOsK3G+UgFQ9Bl+ZhThpilrPkxVRezPBzr0MtCf9NRC YIdwAEIQepcL2CartsR1hRlYw8cBmEbR5pwTIFnMGTe9vPxcan7rUfxBe0Vqt450 m0ZCafiZQ3ZUvMqGm0BgXOcCgXWiZPh6IrUGrBddwb0kUu7Rhk0/5WH5z0QFH4X4 n1ATk5XFKuUepeq+B3f9/z7kiUhhkqbqdHA8LK6u8GjFGYHq33z6eWtO0amAogtA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeggedggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomheptehlihhs thgrihhruceorghlihhsthgrihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrg htthgvrhhnpeeuffekveehjeeltdeuveeikeelkeejhfejheduhfdtgfdtgfejjeekvdev jeevueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grlhhishhtrghirhesrghlihhsthgrihhrvdefrdhmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 01DB13A0721; Mon, 22 Mar 2021 09:16:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-271-g88286cf463-fm-20210318.001-g88286cf4 Mime-Version: 1.0 Message-Id: In-Reply-To: <20210321220043.318239-2-dmitry.torokhov@gmail.com> References: <20210321220043.318239-1-dmitry.torokhov@gmail.com> <20210321220043.318239-2-dmitry.torokhov@gmail.com> Date: Mon, 22 Mar 2021 09:14:57 -0400 From: Alistair To: "Dmitry Torokhov" , linux-input@vger.kernel.org Cc: "Linux Kernel Mailing List" Subject: Re: [PATCH 2/2] Input: wacom_i2c - switch to using managed resources Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 21, 2021, at 6:00 PM, Dmitry Torokhov wrote: > This simplifies error unwinding path and allows us to get rid of > remove() method. > > Signed-off-by: Dmitry Torokhov > Reviewed-by: Alistair Francis Alistair > --- > drivers/input/touchscreen/wacom_i2c.c | 55 +++++++++------------------ > 1 file changed, 17 insertions(+), 38 deletions(-) > > diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c > index 609ff84e7693..22826c387da5 100644 > --- a/drivers/input/touchscreen/wacom_i2c.c > +++ b/drivers/input/touchscreen/wacom_i2c.c > @@ -145,15 +145,16 @@ static void wacom_i2c_close(struct input_dev *dev) > } > > static int wacom_i2c_probe(struct i2c_client *client, > - const struct i2c_device_id *id) > + const struct i2c_device_id *id) > { > + struct device *dev = &client->dev; > struct wacom_i2c *wac_i2c; > struct input_dev *input; > struct wacom_features features = { 0 }; > int error; > > if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { > - dev_err(&client->dev, "i2c_check_functionality error\n"); > + dev_err(dev, "i2c_check_functionality error\n"); > return -EIO; > } > > @@ -161,21 +162,22 @@ static int wacom_i2c_probe(struct i2c_client *client, > if (error) > return error; > > - wac_i2c = kzalloc(sizeof(*wac_i2c), GFP_KERNEL); > - input = input_allocate_device(); > - if (!wac_i2c || !input) { > - error = -ENOMEM; > - goto err_free_mem; > - } > + wac_i2c = devm_kzalloc(dev, sizeof(*wac_i2c), GFP_KERNEL); > + if (!wac_i2c) > + return -ENOMEM; > > wac_i2c->client = client; > + > + input = devm_input_allocate_device(dev); > + if (!input) > + return -ENOMEM; > + > wac_i2c->input = input; > > input->name = "Wacom I2C Digitizer"; > input->id.bustype = BUS_I2C; > input->id.vendor = 0x56a; > input->id.version = features.fw_version; > - input->dev.parent = &client->dev; > input->open = wacom_i2c_open; > input->close = wacom_i2c_close; > > @@ -194,12 +196,11 @@ static int wacom_i2c_probe(struct i2c_client *client, > > input_set_drvdata(input, wac_i2c); > > - error = request_threaded_irq(client->irq, NULL, wacom_i2c_irq, > - IRQF_ONESHOT, "wacom_i2c", wac_i2c); > + error = devm_request_threaded_irq(dev, client->irq, NULL, wacom_i2c_irq, > + IRQF_ONESHOT, "wacom_i2c", wac_i2c); > if (error) { > - dev_err(&client->dev, > - "Failed to enable IRQ, error: %d\n", error); > - goto err_free_mem; > + dev_err(dev, "Failed to request IRQ: %d\n", error); > + return error; > } > > /* Disable the IRQ, we'll enable it in wac_i2c_open() */ > @@ -207,31 +208,10 @@ static int wacom_i2c_probe(struct i2c_client *client, > > error = input_register_device(wac_i2c->input); > if (error) { > - dev_err(&client->dev, > - "Failed to register input device, error: %d\n", error); > - goto err_free_irq; > + dev_err(dev, "Failed to register input device: %d\n", error); > + return error; > } > > - i2c_set_clientdata(client, wac_i2c); > - return 0; > - > -err_free_irq: > - free_irq(client->irq, wac_i2c); > -err_free_mem: > - input_free_device(input); > - kfree(wac_i2c); > - > - return error; > -} > - > -static int wacom_i2c_remove(struct i2c_client *client) > -{ > - struct wacom_i2c *wac_i2c = i2c_get_clientdata(client); > - > - free_irq(client->irq, wac_i2c); > - input_unregister_device(wac_i2c->input); > - kfree(wac_i2c); > - > return 0; > } > > @@ -268,7 +248,6 @@ static struct i2c_driver wacom_i2c_driver = { > }, > > .probe = wacom_i2c_probe, > - .remove = wacom_i2c_remove, > .id_table = wacom_i2c_id, > }; > module_i2c_driver(wacom_i2c_driver); > -- > 2.31.0.rc2.261.g7f71774620-goog > >