From patchwork Fri Nov 5 12:42:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32AB4C433EF for ; Fri, 5 Nov 2021 12:44:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E788D61212 for ; Fri, 5 Nov 2021 12:44:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E788D61212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wx3Sc9me2HyJM90KqXesQHfzFVLloAck0rM4RlQAmPE=; b=qllEbMcX1rrJYG XtVBmALwLJjqP50zleA48sebH7q9E4UHOVHRkMQEOtXzLhO7P7cnLSwjYbwLeyojbBwzuEi4Ts8+z ZlP3+B9Muuyi4p0ZIo/YRSJa0zTjJVBrhdAsPZenA/af/VIcCdYecwiKOLAC2P7vLWFWovrQ84PGS SzOUtJBP6c8nzq9JkvRYFMv3sCIVaYpqxKwP4ll0E8EblDURSmIyrIR6m14Kt/IZTYhph/QEBNRjo Dg+enTmEk/RmafpBNrkl920rYQH8Li8+xX9akS0WrG3QLZaTtECaoND0Z+QTk4rc47Kg6dBGjqtVI f08BqunWdy48mqSoUBKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miya9-00BHFg-QY; Fri, 05 Nov 2021 12:44:33 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYn-00BGW6-Vw; Fri, 05 Nov 2021 12:43:11 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941076" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941076" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="730520446" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 05 Nov 2021 05:43:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 64BAB512; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 07/19] pinctrl/rockchip: Switch to use devm_kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:30 +0200 Message-Id: <20211105124242.27288-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054310_055280_7AA9D81C X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have a generic helper, switch the module to use it. As a side effect, add check for the memory allocation failures and cleanup it either in error case or when driver is unloading. Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 929c96ea621a..438808a867cf 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -33,6 +33,8 @@ #include #include #include +#include + #include #include "core.h" @@ -2452,6 +2454,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, struct pinctrl_pin_desc *pindesc, *pdesc; struct rockchip_pin_bank *pin_bank; struct device *dev = &pdev->dev; + char **pin_names; int pin, bank, ret; int k; @@ -2471,10 +2474,14 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, pdesc = pindesc; for (bank = 0, k = 0; bank < info->ctrl->nr_banks; bank++) { pin_bank = &info->ctrl->pin_banks[bank]; + + pin_names = devm_kasprintf_strarray(dev, pin_bank->name, pin_bank->nr_pins); + if (IS_ERR(pin_names)) + return PTR_ERR(pin_names); + for (pin = 0; pin < pin_bank->nr_pins; pin++, k++) { pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "%s-%d", - pin_bank->name, pin); + pdesc->name = pin_names[pin]; pdesc++; }