From patchwork Fri Feb 10 14:56:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13135872 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CAAB6C636CD for ; Fri, 10 Feb 2023 14:57:35 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H7y1ewJwH5HDKVFJHbTa7f/NjGFiJRcWOhk2+1Tq4sY=; b=T0L7JZz2Q2QFhs gfR+kTiuPxfJQkFKRq9VOW+TaQokNExrHqnQhaqzEV9CuXfltdgkUezXx2X2JfkleroZ9r6x0rysf zuBH9ULBpznO+vWxJZP4T8dY3APuezeH4qeLk8uSQETy9AjhvmKo6bfI6glAstKq1ypML8WFMnxrx 6Uf8Wg7XN27miVoxE25X9jhqX7iT7HCGAawUR2ZQIVKE6fY/NRoRM4Ww81DNUZM4u12/faIYEh5o2 k5RZWSaHBAv6Ib4dFPsUs1wmuDLW1KfoPMbvnY8sfTU3y4BgkEcGu0Qq+cnFk3315hJHNWS7xvLKN RshL/2vLa6QDtfq0psfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUpJ-00687S-SB; Fri, 10 Feb 2023 14:56:37 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUp7-0067yU-Kn for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2023 14:56:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040985; x=1707576985; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yF1vTEf/Cj8uQR7zMwL8EK6cJrGK3YEQj9wTzr3teZY=; b=ghRCGV8eFnzclIJrQhB2Ihkjeeg/+VLBV5UDnegwvS5jT4/HO9lXJYY9 Jym4hbnLEdWZ5a6Y/IPeZHZCd8/crD1gkB2x3p7JsuvasqEcXZJXLH9uf x8fiEErroHva2A1DEZXeKF4MqevY/Ok1A+SJZ5bqVaTTNF0tQXA9oh0nV 2GN1cvEsPJXVGk9sZtSd8gzSitj1IYnO6F+xxVzElMZQPQ/TmQUoSBnK0 lXAcxOZ1UEq+l5XdX/0UA8jowwzXb2/7Z389CStXboIUJ49ea7Hjs8Pxr H3VW4RZW4RPM1xdFWzY5lz47XoTwemjEAwuXVqQ0c8y5iPDG3c+LPpH2h g==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836317" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836317" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 06:56:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="668079982" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="668079982" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 10 Feb 2023 06:56:18 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DD30F1A6; Fri, 10 Feb 2023 16:56:57 +0200 (EET) From: Andy Shevchenko To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2) Date: Fri, 10 Feb 2023 16:56:52 +0200 Message-Id: <20230210145656.71838-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210145656.71838-1-andriy.shevchenko@linux.intel.com> References: <20230210145656.71838-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-20230210_065625_721155_032FE549 X-CRM114-Status: GOOD ( 18.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , Ludovic Desroches , Andy Shevchenko , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_kasprintf() instead of kasprintf() to avoid any potential leaks. At the moment drivers have no remove functionality hence there is no need for fixes tag. While at it, switch to use devm_kasprintf_strarray(). Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 735c501e7a06..bb93d8bcfd08 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Since we request GPIOs from ourself */ #include @@ -1371,6 +1372,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, static int at91_pinctrl_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct at91_pinctrl *info; struct pinctrl_pin_desc *pdesc; int ret, i, j, k; @@ -1394,9 +1396,19 @@ static int at91_pinctrl_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0, k = 0; i < gpio_banks; i++) { + char **pin_names; + + pin_names = devm_kasprintf_strarray(dev, "pio", MAX_NB_GPIO_PER_BANK); + if (!names) + return -ENOMEM; + for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) { + char *pin_name = pin_names[j]; + + strreplace(pin_name, '-', i + 'A'); + pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "pio%c%d", i + 'A', j); + pdesc->name = pin_name; pdesc++; } } @@ -1797,7 +1809,8 @@ static const struct of_device_id at91_gpio_of_match[] = { static int at91_gpio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct at91_gpio_chip *at91_chip = NULL; struct gpio_chip *chip; struct pinctrl_gpio_range *range; @@ -1866,16 +1879,14 @@ static int at91_gpio_probe(struct platform_device *pdev) chip->ngpio = ngpio; } - names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *), - GFP_KERNEL); - + names = devm_kasprintf_strarray(dev, "pio", chip->ngpio); if (!names) { ret = -ENOMEM; goto clk_enable_err; } for (i = 0; i < chip->ngpio; i++) - names[i] = devm_kasprintf(&pdev->dev, GFP_KERNEL, "pio%c%d", alias_idx + 'A', i); + strreplace('-', alias_idx + 'A'); chip->names = (const char *const *)names; From patchwork Fri Feb 10 14:56:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13135874 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EB674C05027 for ; Fri, 10 Feb 2023 14:57:53 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+Z3P0QwCUM94PJAO5+Hlfvu0PfJ+bxjgHP8Ek0CyBD8=; b=As7MqRA6cBbVay k3uwWa4RdiRFXcTdKAVafY0r5H9kcx7gWF/NeDCBgSMe064aahr952VA2liBUzrav48yHlvZlesRD f5UjVCaTCnkwG1dGPpKbGKEbJOuAH6rSqq+O4HewNcTAvaNURAr9qDQhMyC7pfQmTb1+SQFsQBKNX eqHBNq3LMAFeGUnW+cZ3vAip+LCsrxtHqcLdWF2JHw7YHMyLHTXzYxfsPgDagSMcvAUPlyzxlCpn/ P/nb+o1PKSCJhqw4Fq3LWutrofBHvCMsWDkY60ndzhvopl/1+Js61tBpkeSfRngNGLNQu16Ar9y9a yQmIogmWVxs+3/bXctjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUpb-0068Fp-2W; Fri, 10 Feb 2023 14:56:55 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUp9-0067zU-3N for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2023 14:56:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040987; x=1707576987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jUL6wp0NTeLmMM6UL4qWTlmx/HlyA4RONhL6c9GtXJ4=; b=BKCTUftfkkT5b8vrPsPpChgcQpH/tmHCD6G+kEAHZrTyfs9imR3JuUfY hksApdlud9iU7ic68BdRRjZ+S1HcL5O54GIHVFsjuPZ2g5/wAVQ2yU6Z7 QHbgA0lf4zl2e52dVe6fys0r1lv0XJdUWBWnmIsqHH7yxwC00SpJDdfug XlX1mAYZtewdqr90nnSw/10xJmrqkpBqdBl/wplo8nl1qvsE8khWcScvm VisSiomG+Rr136InxiRa7F1F4qylwsXIlxoAwxa4tL7jqfqounF/WCrjh rboVikgpJzzm5JxYCDq/Wge9eRv66w55QCHcHTAwE8JKqVk0J188nZAIr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836324" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836324" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 06:56:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="668079984" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="668079984" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 10 Feb 2023 06:56:18 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EAE95210; Fri, 10 Feb 2023 16:56:57 +0200 (EET) From: Andy Shevchenko To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] pinctrl: at91: Don't mix non-devm calls with devm ones Date: Fri, 10 Feb 2023 16:56:53 +0200 Message-Id: <20230210145656.71838-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210145656.71838-1-andriy.shevchenko@linux.intel.com> References: <20230210145656.71838-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-20230210_065627_202729_5C27D634 X-CRM114-Status: GOOD ( 16.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , Ludovic Desroches , Andy Shevchenko , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace devm_clk_get() by devm_clk_get_enabled() and drop unneeded code pieces. This will make sure we keep the ordering of the resource allocation correct. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index bb93d8bcfd08..6d5ebdae0bf9 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1849,19 +1849,13 @@ static int at91_gpio_probe(struct platform_device *pdev) at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; - at91_chip->clock = devm_clk_get(&pdev->dev, NULL); + at91_chip->clock = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(at91_chip->clock)) { dev_err(&pdev->dev, "failed to get clock, ignoring.\n"); ret = PTR_ERR(at91_chip->clock); goto err; } - ret = clk_prepare_enable(at91_chip->clock); - if (ret) { - dev_err(&pdev->dev, "failed to prepare and enable clock, ignoring.\n"); - goto clk_enable_err; - } - at91_chip->chip = at91_gpio_template; at91_chip->id = alias_idx; @@ -1882,7 +1876,7 @@ static int at91_gpio_probe(struct platform_device *pdev) names = devm_kasprintf_strarray(dev, "pio", chip->ngpio); if (!names) { ret = -ENOMEM; - goto clk_enable_err; + goto err; } for (i = 0; i < chip->ngpio; i++) @@ -1915,8 +1909,6 @@ static int at91_gpio_probe(struct platform_device *pdev) return 0; gpiochip_add_err: -clk_enable_err: - clk_disable_unprepare(at91_chip->clock); err: dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); From patchwork Fri Feb 10 14:56:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13135873 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 92CE9C05027 for ; Fri, 10 Feb 2023 14:57:48 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H2xKQZEKnT5x/uswCi0s/+YeYgfqSI1eapKN9IGcI18=; b=uEHRHzIi6j6Olf 4oGP/zNP8zjTxiyHrxUahlm7Q1XWJB1SEos0FgMUFeaHB6z66bihPlfpY9ZCtWHEgcAnEk3cUkU+Z EwhjzY1FD6+LvmOz0x+HZP4G3pmdvY4oa1hDhtOBRi5lQEhyRtYibn5mFUca8lonwz+08O2S8OLVk uEv4f5pREqGK9Wue1BcBfk/N/Tp5+KRsZ2DyWmdm4+cEWbHYVshT7B9IEUNM1vLvRJNPmMlVmmd+4 UjVygqj+GZoDKOQZZadJl4HqiJLxpx8Gk3+EZjkhqYQm913eMQUY8/EagzyFfwpgOtWbOoz4KlzUZ LAQ3y+BTgCf9ZXHh/GSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUpT-0068Be-12; Fri, 10 Feb 2023 14:56:47 +0000 Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUp8-0067yY-Af for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2023 14:56:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040986; x=1707576986; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o+AkmZ/j0Ltm2vhm8z9qz/CNnGgU1gRksq4fGSdRq2A=; b=Attpm4ZUTgA3Kqu5INd6r2Xl08mRQlZpCmqSDtTkuGAcEHPQxgrzzvfr rrd+EOsxNqNCtJjlkjh4rAVI7Z535eVWfH3wZhxFcRWh2dyrcPRcx1tsp oH488/+Uf6RjYL2cculAcACf7q4pDHjyuYHLebTV6clomy+1lIy5gnnMj B9iHrXl3r5ilWJLDOkVj/teoQtNSZst4tgfarmr5bVwPSXZ/HIC5qbLbb CCyvRmDNRfX1F5W/i9EmgRvMxKPSb6sgJlg2JGqUjxqLVjGhO2lX3a4Ei 1ydeKFKsay+0vj8qgCpZ2obm3RJDfnwHfZtWe0VREDgSTQAY7kPWekxKd A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="395041592" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="395041592" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 06:56:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="776953052" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="776953052" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 10 Feb 2023 06:56:19 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EFF961F8; Fri, 10 Feb 2023 16:56:57 +0200 (EET) From: Andy Shevchenko To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] pinctrl: at91: Use of_device_get_match_data() Date: Fri, 10 Feb 2023 16:56:54 +0200 Message-Id: <20230210145656.71838-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210145656.71838-1-andriy.shevchenko@linux.intel.com> References: <20230210145656.71838-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-20230210_065626_492797_AB880FA3 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , Ludovic Desroches , Andy Shevchenko , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use of_device_get_match_data() to simplify the code. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 6d5ebdae0bf9..203a29ad9344 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1304,8 +1304,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, return -ENODEV; info->dev = &pdev->dev; - info->ops = (const struct at91_pinctrl_mux_ops *) - of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; + info->ops = of_device_get_match_data(dev); at91_pinctrl_child_count(info, np); /* @@ -1844,8 +1843,7 @@ static int at91_gpio_probe(struct platform_device *pdev) goto err; } - at91_chip->ops = (const struct at91_pinctrl_mux_ops *) - of_match_device(at91_gpio_of_match, &pdev->dev)->data; + at91_chip->ops = of_device_get_match_data(dev); at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; From patchwork Fri Feb 10 14:56:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13135876 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 25231C05027 for ; Fri, 10 Feb 2023 14:58:20 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kMZhqJDvryuoQdLT003tj4RkC0FMwReb2+mwDNG8O1Q=; b=mAFijJLqwsLoJt 3Kg24mcxY2YKZjjEhp1lvQvgUy/zfA5LcsB/mwjqU6Lckq4+a8iqBzkYKVhUA/X7WnogHRyEea9tp JcafvUt6M8G2pOY14AraZ+y9sZXzvaxOj4lrkoc9pE56tXtY/LAkucm1q/GStsYwYsSFT7PUZ45Ly gC1qlPZFl95sUKNzkgilJ9yG1sHhB8ePbCOcfKGhGA2RduMsCXBP1SCRAPsBh6xu4+E3lhykN9T39 tTdyc8WwMCVyeJ2l0RB8d7f4pIMpavF2mbjj8oht6UaFCUWJ3A03GwSz6lNJBRWwjRVunT28EXvCe 9K2KfA8p18AQiIfzOkxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUq2-0068Ux-CU; Fri, 10 Feb 2023 14:57:22 +0000 Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUpA-0067yY-Ed for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2023 14:56:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040988; x=1707576988; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S5CRSmT8K9GvBmi5rjBq6cSRiB9PaGnL3gOxhpG0i+4=; b=YZRe+KvjV2gzE7kg2vXt0zWh1LdBh6fWcZ1AQkNw7lAfRbSH54bAL8fb 2ofecZqEZ3Kp2jFeUU7uc3Ym8F/zl3G5AEFHli2FZCqdVdundFNS1O+cm N7xgyxAzWS1bTvw0DO+wVnLs80NqdEgc4dSyYy3U20OSURaZMigPj8ECG YbuhMMHIJWY9k6f3eQUiYcF88a0Qm/ftT8Vbt/sKlF5yI2/MDiXUYR9g2 SF2N0f2qQxT+4NN+VmbZ9LpP8M/YhDnBEnR+dXOOag18EsLBhB8joNh9e /1eEalDM5OiyaQ984U0q4vHwdIXA1AoBZ3RffVUSAtW/exfWKAJJbRQ1y A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="395041595" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="395041595" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 06:56:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="776953053" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="776953053" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 10 Feb 2023 06:56:19 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0FD05269; Fri, 10 Feb 2023 16:56:58 +0200 (EET) From: Andy Shevchenko To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] pinctrl: at91: Use dev_err_probe() instead of custom messaging Date: Fri, 10 Feb 2023 16:56:55 +0200 Message-Id: <20230210145656.71838-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210145656.71838-1-andriy.shevchenko@linux.intel.com> References: <20230210145656.71838-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-20230210_065628_660830_397FAA23 X-CRM114-Status: GOOD ( 18.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , Ludovic Desroches , Andy Shevchenko , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The custom message has no value except printing the error code, the same does dev_err_probe(). Let's use the latter for the sake of unification. Note that some APIs already have messaging in them and some simply do not require the current noise. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91.c | 64 +++++++++++----------------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 203a29ad9344..797382a237e8 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1294,10 +1294,11 @@ static const struct of_device_id at91_pinctrl_of_match[] = { static int at91_pinctrl_probe_dt(struct platform_device *pdev, struct at91_pinctrl *info) { + struct device *dev = &pdev->dev; int ret = 0; int i, j, ngpio_chips_enabled = 0; uint32_t *tmp; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; struct device_node *child; if (!np) @@ -1360,9 +1361,8 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, continue; ret = at91_pinctrl_parse_functions(child, info, i++); if (ret) { - dev_err(&pdev->dev, "failed to parse function\n"); of_node_put(child); - return ret; + return dev_err_probe(dev, ret, "failed to parse function\n"); } } @@ -1415,11 +1415,8 @@ static int at91_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); info->pctl = devm_pinctrl_register(&pdev->dev, &at91_pinctrl_desc, info); - - if (IS_ERR(info->pctl)) { - dev_err(&pdev->dev, "could not register AT91 pinctrl driver\n"); - return PTR_ERR(info->pctl); - } + if (IS_ERR(info->pctl)) + return dev_err_probe(dev, PTR_ERR(info->pctl), "could not register AT91 pinctrl driver\n"); /* We will handle a range of GPIO pins */ for (i = 0; i < gpio_banks; i++) @@ -1820,39 +1817,28 @@ static int at91_gpio_probe(struct platform_device *pdev) char **names; BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips)); - if (gpio_chips[alias_idx]) { - ret = -EBUSY; - goto err; - } + if (gpio_chips[alias_idx]) + return dev_err_probe(dev, -EBUSY, "%d slot is occupied.\n", alias_idx); irq = platform_get_irq(pdev, 0); - if (irq < 0) { - ret = irq; - goto err; - } + if (irq < 0) + return irq; at91_chip = devm_kzalloc(&pdev->dev, sizeof(*at91_chip), GFP_KERNEL); - if (!at91_chip) { - ret = -ENOMEM; - goto err; - } + if (!at91_chip) + return -ENOMEM; at91_chip->regbase = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(at91_chip->regbase)) { - ret = PTR_ERR(at91_chip->regbase); - goto err; - } + if (IS_ERR(at91_chip->regbase)) + return PTR_ERR(at91_chip->regbase); at91_chip->ops = of_device_get_match_data(dev); at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; at91_chip->clock = devm_clk_get_enabled(&pdev->dev, NULL); - if (IS_ERR(at91_chip->clock)) { - dev_err(&pdev->dev, "failed to get clock, ignoring.\n"); - ret = PTR_ERR(at91_chip->clock); - goto err; - } + if (IS_ERR(at91_chip->clock)) + return dev_err_probe(dev, PTR_ERR(at91_chip->clock), "failed to get clock, ignoring.\n"); at91_chip->chip = at91_gpio_template; at91_chip->id = alias_idx; @@ -1865,17 +1851,15 @@ static int at91_gpio_probe(struct platform_device *pdev) if (!of_property_read_u32(np, "#gpio-lines", &ngpio)) { if (ngpio >= MAX_NB_GPIO_PER_BANK) - pr_err("at91_gpio.%d, gpio-nb >= %d failback to %d\n", - alias_idx, MAX_NB_GPIO_PER_BANK, MAX_NB_GPIO_PER_BANK); + dev_err(dev, "at91_gpio.%d, gpio-nb >= %d failback to %d\n", + alias_idx, MAX_NB_GPIO_PER_BANK, MAX_NB_GPIO_PER_BANK); else chip->ngpio = ngpio; } names = devm_kasprintf_strarray(dev, "pio", chip->ngpio); - if (!names) { - ret = -ENOMEM; - goto err; - } + if (!names) + return -ENOMEM; for (i = 0; i < chip->ngpio; i++) strreplace('-', alias_idx + 'A'); @@ -1892,11 +1876,11 @@ static int at91_gpio_probe(struct platform_device *pdev) ret = at91_gpio_of_irq_setup(pdev, at91_chip); if (ret) - goto gpiochip_add_err; + return ret; ret = gpiochip_add_data(chip, at91_chip); if (ret) - goto gpiochip_add_err; + return ret; gpio_chips[alias_idx] = at91_chip; platform_set_drvdata(pdev, at91_chip); @@ -1905,12 +1889,6 @@ static int at91_gpio_probe(struct platform_device *pdev) dev_info(&pdev->dev, "at address %p\n", at91_chip->regbase); return 0; - -gpiochip_add_err: -err: - dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); - - return ret; } static const struct dev_pm_ops at91_gpio_pm_ops = { From patchwork Fri Feb 10 14:56:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13135875 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E35EFC636CD for ; Fri, 10 Feb 2023 14:58:09 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fzshNYu4dhnaYMBP41D/MlIHzi+r7TDdQLugZq9ge9E=; b=UjYzNYvV6eGBJm oDwrGsMYMJma79uH5m+Gcu9QrXwPWSduxFgyLkFxZGZGuS1lEsuKJeKsjNm/R2Jx+OSseum1IOoM4 7giXCgKGIAR1xQZq8Ym83x4PSxfVpUWWGUL75cYuxaMgNozAGkLMLoJLv5JlmnoCJz678k2IzUHVR Fki2pGevpE/epRE3BKMiY92y80wiYaz2gQUpCV5m50BQPQtSt42KZEQLCcTs5899dd1Dfn4988mmj 8f9vj47RPrC4X8diRc4DXWEdeClHs99D1Pp6/HIMP8uGzvG2vBl4Jli16/eusupJnPhrXqAKj8d5b ECnuSiepK4vMFcWqpxWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUpo-0068Mr-8E; Fri, 10 Feb 2023 14:57:08 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQUp9-0067yU-3c for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2023 14:56:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040987; x=1707576987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zd5Esd2sOCM8trmFSB0vVSIXyOZ3q8JrPvYqADwoYnE=; b=FJlB4qvjb7bpT6VMNMWh38g9XvmKOcT1ikxMHe3JhUzYjN780eSKhmWz FFcJ7fZW1rXhLuNagTHAt5aZhlxL0zI1QSbXbsZJGzQCQ25I9K5KVjjCO A1NJLUrD1hzqg0X2YesF0hSiS+zmYCTAvYmDbW0MPvI9F/sgSGehqZiJ8 Ch39htRcZcuq+m3CBHCqaQvr+IEEM8v94WDfHkEAHk/r8zP7gDNqYjqFT o8grpl2PXE4VWGkNp9wh0qf9yeGKB5S9fDQ6StXEKNph9uk1wXxamc49P 7CTF9NE2LAIiDKJAu57y8fBl2u7wDULHcW47hKjiAeOQdkN37CE01fIWe A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836335" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836335" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 06:56:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="668079990" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="668079990" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 10 Feb 2023 06:56:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 210C0252; Fri, 10 Feb 2023 16:56:58 +0200 (EET) From: Andy Shevchenko To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] pinctrl: at91: Utilise temporary variable for struct device Date: Fri, 10 Feb 2023 16:56:56 +0200 Message-Id: <20230210145656.71838-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210145656.71838-1-andriy.shevchenko@linux.intel.com> References: <20230210145656.71838-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-20230210_065627_235121_CD0778D6 X-CRM114-Status: GOOD ( 17.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , Ludovic Desroches , Andy Shevchenko , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have a temporary variable to keep pointer to struct device. Utilise it inside the ->probe() implementation. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91.c | 63 +++++++++++++++------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 797382a237e8..f57781c2786a 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1304,7 +1304,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, if (!np) return -ENODEV; - info->dev = &pdev->dev; + info->dev = dev; info->ops = of_device_get_match_data(dev); at91_pinctrl_child_count(info, np); @@ -1324,35 +1324,30 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, if (ret) return ret; - dev_dbg(&pdev->dev, "nmux = %d\n", info->nmux); + dev_dbg(dev, "nmux = %d\n", info->nmux); - dev_dbg(&pdev->dev, "mux-mask\n"); + dev_dbg(dev, "mux-mask\n"); tmp = info->mux_mask; for (i = 0; i < gpio_banks; i++) { - for (j = 0; j < info->nmux; j++, tmp++) { - dev_dbg(&pdev->dev, "%d:%d\t0x%x\n", i, j, tmp[0]); - } + for (j = 0; j < info->nmux; j++, tmp++) + dev_dbg(dev, "%d:%d\t0x%x\n", i, j, tmp[0]); } - dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); - dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kcalloc(&pdev->dev, - info->nfunctions, - sizeof(struct at91_pmx_func), - GFP_KERNEL); + dev_dbg(dev, "nfunctions = %d\n", info->nfunctions); + dev_dbg(dev, "ngroups = %d\n", info->ngroups); + info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), + GFP_KERNEL); if (!info->functions) return -ENOMEM; - info->groups = devm_kcalloc(&pdev->dev, - info->ngroups, - sizeof(struct at91_pin_group), - GFP_KERNEL); + info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), + GFP_KERNEL); if (!info->groups) return -ENOMEM; - dev_dbg(&pdev->dev, "nbanks = %d\n", gpio_banks); - dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); - dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); + dev_dbg(dev, "nbanks = %d\n", gpio_banks); + dev_dbg(dev, "nfunctions = %d\n", info->nfunctions); + dev_dbg(dev, "ngroups = %d\n", info->ngroups); i = 0; @@ -1376,7 +1371,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev) struct pinctrl_pin_desc *pdesc; int ret, i, j, k; - info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -1384,13 +1379,10 @@ static int at91_pinctrl_probe(struct platform_device *pdev) if (ret) return ret; - at91_pinctrl_desc.name = dev_name(&pdev->dev); + at91_pinctrl_desc.name = dev_name(dev); at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; at91_pinctrl_desc.pins = pdesc = - devm_kcalloc(&pdev->dev, - at91_pinctrl_desc.npins, sizeof(*pdesc), - GFP_KERNEL); - + devm_kcalloc(dev, at91_pinctrl_desc.npins, sizeof(*pdesc), GFP_KERNEL); if (!at91_pinctrl_desc.pins) return -ENOMEM; @@ -1413,8 +1405,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, info); - info->pctl = devm_pinctrl_register(&pdev->dev, &at91_pinctrl_desc, - info); + info->pctl = devm_pinctrl_register(dev, &at91_pinctrl_desc, info); if (IS_ERR(info->pctl)) return dev_err_probe(dev, PTR_ERR(info->pctl), "could not register AT91 pinctrl driver\n"); @@ -1423,7 +1414,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev) if (gpio_chips[i]) pinctrl_add_gpio_range(info->pctl, &gpio_chips[i]->range); - dev_info(&pdev->dev, "initialized AT91 pinctrl driver\n"); + dev_info(dev, "initialized AT91 pinctrl driver\n"); return 0; } @@ -1714,6 +1705,7 @@ static void gpio_irq_handler(struct irq_desc *desc) static int at91_gpio_of_irq_setup(struct platform_device *pdev, struct at91_gpio_chip *at91_gpio) { + struct device *dev = &pdev->dev; struct gpio_chip *gpiochip_prev = NULL; struct at91_gpio_chip *prev = NULL; struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); @@ -1721,8 +1713,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, struct gpio_irq_chip *girq; int i; - gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), - GFP_KERNEL); + gpio_irqchip = devm_kzalloc(dev, sizeof(*gpio_irqchip), GFP_KERNEL); if (!gpio_irqchip) return -ENOMEM; @@ -1758,7 +1749,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, if (!gpiochip_prev) { girq->parent_handler = gpio_irq_handler; girq->num_parents = 1; - girq->parents = devm_kcalloc(&pdev->dev, 1, + girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) @@ -1824,7 +1815,7 @@ static int at91_gpio_probe(struct platform_device *pdev) if (irq < 0) return irq; - at91_chip = devm_kzalloc(&pdev->dev, sizeof(*at91_chip), GFP_KERNEL); + at91_chip = devm_kzalloc(dev, sizeof(*at91_chip), GFP_KERNEL); if (!at91_chip) return -ENOMEM; @@ -1836,7 +1827,7 @@ static int at91_gpio_probe(struct platform_device *pdev) at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; - at91_chip->clock = devm_clk_get_enabled(&pdev->dev, NULL); + at91_chip->clock = devm_clk_get_enabled(dev, NULL); if (IS_ERR(at91_chip->clock)) return dev_err_probe(dev, PTR_ERR(at91_chip->clock), "failed to get clock, ignoring.\n"); @@ -1844,8 +1835,8 @@ static int at91_gpio_probe(struct platform_device *pdev) at91_chip->id = alias_idx; chip = &at91_chip->chip; - chip->label = dev_name(&pdev->dev); - chip->parent = &pdev->dev; + chip->label = dev_name(dev); + chip->parent = dev; chip->owner = THIS_MODULE; chip->base = alias_idx * MAX_NB_GPIO_PER_BANK; @@ -1886,7 +1877,7 @@ static int at91_gpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, at91_chip); gpio_banks = max(gpio_banks, alias_idx + 1); - dev_info(&pdev->dev, "at address %p\n", at91_chip->regbase); + dev_info(dev, "at address %p\n", at91_chip->regbase); return 0; }