From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742AbdKHPcL (ORCPT ); Wed, 8 Nov 2017 10:32:11 -0500 Received: from www381.your-server.de ([78.46.137.84]:40451 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbdKHPcJ (ORCPT ); Wed, 8 Nov 2017 10:32:09 -0500 Subject: Re: [PATCH v2 1/3] Input: ad7897 - use managed allocated resources To: Andi Shyti , Dmitry Torokhov Cc: Michael Hennerich , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti References: <20171108140403.727-1-andi@etezian.org> <20171108140403.727-2-andi@etezian.org> From: Lars-Peter Clausen Message-ID: Date: Wed, 8 Nov 2017 16:31:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171108140403.727-2-andi@etezian.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: lars@metafoo.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/08/2017 03:04 PM, Andi Shyti wrote: > Use managed allocated resources to simplify error handling during > probing failure and module exiting. > > With this all the goto labels in the probe function together with > the cleanups in the remove function are unnecessary, therefore > removed. > > CC: Michael Hennerich > Signed-off-by: Andi Shyti > --- > drivers/input/touchscreen/ad7877.c | 42 +++++++++----------------------------- > 1 file changed, 10 insertions(+), 32 deletions(-) > > diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c > index 0381c7809d1b..c8a143db8681 100644 > --- a/drivers/input/touchscreen/ad7877.c > +++ b/drivers/input/touchscreen/ad7877.c > @@ -707,12 +707,10 @@ static int ad7877_probe(struct spi_device *spi) > return err; > } > > - ts = kzalloc(sizeof(struct ad7877), GFP_KERNEL); > - input_dev = input_allocate_device(); > - if (!ts || !input_dev) { > - err = -ENOMEM; > - goto err_free_mem; > - } > + ts = devm_kzalloc(&spi->dev, sizeof(struct ad7877), GFP_KERNEL); > + input_dev = devm_input_allocate_device(&spi->dev); > + if (!input_dev) You removed the check for 'ts' here and only added it back in patch 3. > + return -ENOMEM; > > spi_set_drvdata(spi, ts); > ts->spi = spi; [...]