From patchwork Thu Nov 2 15:01:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 10038879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4083E603B5 for ; Thu, 2 Nov 2017 15:18:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 332632903E for ; Thu, 2 Nov 2017 15:18:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 282C52913F; Thu, 2 Nov 2017 15:18:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4A6929145 for ; Thu, 2 Nov 2017 15:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933796AbdKBPSP (ORCPT ); Thu, 2 Nov 2017 11:18:15 -0400 Received: from 9.mo68.mail-out.ovh.net ([46.105.78.111]:35292 "EHLO 9.mo68.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933763AbdKBPSG (ORCPT ); Thu, 2 Nov 2017 11:18:06 -0400 X-Greylist: delayed 604 seconds by postgrey-1.27 at vger.kernel.org; Thu, 02 Nov 2017 11:18:06 EDT Received: from player763.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 36D5D9A674 for ; Thu, 2 Nov 2017 16:02:06 +0100 (CET) Received: from etezian.org (unknown [211.196.237.107]) (Authenticated sender: andi@etezian.org) by player763.ha.ovh.net (Postfix) with ESMTPSA id 74AC53C008D; Thu, 2 Nov 2017 16:01:58 +0100 (CET) From: Andi Shyti To: Dmitry Torokhov Cc: Michael Hennerich , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 1/5] Input: ad7897 - use managed devm_kzalloc Date: Thu, 2 Nov 2017 17:01:32 +0200 Message-Id: <20171102150136.1476-2-andi@etezian.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171102150136.1476-1-andi@etezian.org> References: <20171102150136.1476-1-andi@etezian.org> X-Ovh-Tracer-Id: 3705899544571069082 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrgeeigdeilecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allocate the driver's structure by using devm_kzalloc instead of simple kzalloc and remove all the related kfree calls. CC: Michael Hennerich Signed-off-by: Andi Shyti --- drivers/input/touchscreen/ad7877.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index 0381c7809d1b..68941b72ed8a 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c @@ -707,9 +707,9 @@ static int ad7877_probe(struct spi_device *spi) return err; } - ts = kzalloc(sizeof(struct ad7877), GFP_KERNEL); + ts = devm_kzalloc(&spi->dev, sizeof(struct ad7877), GFP_KERNEL); input_dev = input_allocate_device(); - if (!ts || !input_dev) { + if (!input_dev) { err = -ENOMEM; goto err_free_mem; } @@ -799,7 +799,6 @@ static int ad7877_probe(struct spi_device *spi) free_irq(spi->irq, ts); err_free_mem: input_free_device(input_dev); - kfree(ts); return err; } @@ -813,7 +812,6 @@ static int ad7877_remove(struct spi_device *spi) free_irq(ts->spi->irq, ts); input_unregister_device(ts->input); - kfree(ts); dev_dbg(&spi->dev, "unregistered touchscreen\n");