From patchwork Mon May 15 09:24:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 762336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wRFb551hYz9s4s for ; Mon, 15 May 2017 19:26:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760534AbdEOJZS (ORCPT ); Mon, 15 May 2017 05:25:18 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59853 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760587AbdEOJZR (ORCPT ); Mon, 15 May 2017 05:25:17 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id B77E326128C From: Sebastian Reichel To: Sebastian Reichel , Linus Walleij , Steven Miao , Vladimir Zapolskiy , Sylvain Lemieux Cc: Enric Balletbo i Serra , linux-gpio@vger.kernel.org, adi-buildroot-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCHv3 07/14] pinctrl: mcp23s08: use managed kzalloc for mcp Date: Mon, 15 May 2017 11:24:31 +0200 Message-Id: <20170515092438.13076-8-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170515092438.13076-1-sebastian.reichel@collabora.co.uk> References: <20170515092438.13076-1-sebastian.reichel@collabora.co.uk> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Let's remove a few lines of code by using managed memory for mcp variable. Signed-off-by: Sebastian Reichel --- drivers/pinctrl/pinctrl-mcp23s08.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index 94d2c19a6989..4d2e1c3c0e87 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -1019,7 +1019,7 @@ static int mcp230xx_probe(struct i2c_client *client, } } - mcp = kzalloc(sizeof(*mcp), GFP_KERNEL); + mcp = devm_kzalloc(&client->dev, sizeof(*mcp), GFP_KERNEL); if (!mcp) return -ENOMEM; @@ -1027,16 +1027,11 @@ static int mcp230xx_probe(struct i2c_client *client, status = mcp23s08_probe_one(mcp, &client->dev, client, client->addr, id->driver_data, pdata, 0); if (status) - goto fail; + return status; i2c_set_clientdata(client, mcp); return 0; - -fail: - kfree(mcp); - - return status; } static int mcp230xx_remove(struct i2c_client *client) @@ -1044,7 +1039,6 @@ static int mcp230xx_remove(struct i2c_client *client) struct mcp23s08 *mcp = i2c_get_clientdata(client); gpiochip_remove(&mcp->chip); - kfree(mcp); return 0; }