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: 55430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp998957wrn; Fri, 10 Feb 2023 07:00:19 -0800 (PST) X-Google-Smtp-Source: AK7set/v+h+nz8wQHrxlWJuIBgxHhpYckkqGz0dWufvuIpLElYbBgQjZOs4U0GMz2E3krUT9CU9G X-Received: by 2002:a50:f697:0:b0:4a2:7579:1d9c with SMTP id d23-20020a50f697000000b004a275791d9cmr17158666edn.1.1676041219625; Fri, 10 Feb 2023 07:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676041219; cv=none; d=google.com; s=arc-20160816; b=XDANMyQz9cd04HXY61a+ctXCp0G5N8p+jLdYdBqgFkAbNvjTg7MDKMs0TPpxwYRrOW v6WsF1e6zmZm8mmrwHLfksnhnrvAlHaWngSjjxXDJ3J5PBIdSEFr7TvWZidL+cFu0n3X Cd6xHMOx+/7fMP8ZgEiWTZW6t9rwrRWjd644prcnyJ1h/uVeXE0IFNtZTjK83VRrUQQz nFkMoXGow2nddYkJR0vFMi6OuEVGHRYmkRxqbjjlkexxTTGMBR/5Ra5wA7FNgCxONnIA pNms1qK3ZacpfxXu4wo5im9Bxe5v/vacIL7bs9MFDt9Qn4kX+O03tf+EObgBmOikyypv DOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+8NkayhPIKci0o7h0bnKBAGL6iD7hK/TW+2szdOdBnc=; b=suj/6QQPMVxzsnhu1joXUkD4eqUdSuA7ipunh7mPxethVyTC0iHyJV+leCpw3jm08P YdyK4Ibo1Si65ifyyxhjlJChPuzKsLc1Pamj4dtfmCKezumlVTsEMVjz1I10c2H2QYYa /DMakCYVfJACc7Nb0q9z/N+biW0ZqJSBzEO7j/bqJaFEca+/OZtRkw5Dv+6krWOjBDi8 3arp4IJgxit+c0RNrcbNCuQ1iyfD6RBEoVvbvHYbL6ZPNbq/1HeveE00c6oNFoXdb6Xi 8bQza/HGBWZvJsDrW9YSzBiX47vhndWMEzhyaxn5mt5u1y7nuW33ovTKvvWc0ajqY8eX bJIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jMwb+tGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a05640202da00b004a0b6e6f506si5719041edx.431.2023.02.10.06.59.55; Fri, 10 Feb 2023 07:00:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jMwb+tGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232509AbjBJO4X (ORCPT + 99 others); Fri, 10 Feb 2023 09:56:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbjBJO4W (ORCPT ); Fri, 10 Feb 2023 09:56:22 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91E16C7E0; Fri, 10 Feb 2023 06:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040981; x=1707576981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yF1vTEf/Cj8uQR7zMwL8EK6cJrGK3YEQj9wTzr3teZY=; b=jMwb+tGZAL8NsfFwug+rpel8CS6Z/fq183wcwW9Q+bI4zV8qjnHydieQ VJmg1dxtO5dnqvX6226AkrbpLAUPqaAB0vDuI9OfjD+IQGxAV3VJG3B/k PxXj+m/9CPt4I+r1zIx2CB1Q+ZlvGFAcHAtSR4BIYNMFvd7quJk6lzzIz e6RtdrFkK438ldF1H1lKnEevW0CkEmmTBhDqX5odmrRnu0dJtn5YLQGzg ffDJvUylJtaM9ovTsnbIxTJ1dI2y2KdVPmSB/4Py5yPGr26GyhfkFesWW 79VhunVPLAM1OlTK1S3TXU117GLDnON5Aq84U9e+A6bL+oY37AxA+fkby A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836316" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836316" 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 Cc: Ludovic Desroches , Linus Walleij , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Andy Shevchenko 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757456598102590370?= X-GMAIL-MSGID: =?utf-8?q?1757456598102590370?= 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: 55429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp998870wrn; Fri, 10 Feb 2023 07:00:12 -0800 (PST) X-Google-Smtp-Source: AK7set/GveVFqXcR7Mv8rehxRIDXfMv7lrcsi7dCm1TSMWRqPGlPrMR6x245riUO9iuhNg4Rgfv6 X-Received: by 2002:a50:cd9d:0:b0:4ab:16a8:bc64 with SMTP id p29-20020a50cd9d000000b004ab16a8bc64mr8328731edi.24.1676041211915; Fri, 10 Feb 2023 07:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676041211; cv=none; d=google.com; s=arc-20160816; b=KqdP7PZN+OMYR54RHMrincgujNxtk7VElxcSgwLO79vecKbf6nMKCVfwqfJq+x7vuv V9FTekBe6hgYuC62ZfFjHndCs62CPV8x0MSnnsbksooMtPOznqc5R5TexzqvThYmFqwA D+gqJ8cfpGxxT90hazPgGCFZFm6mOorHdaqMipguSFyDmA0PrMjy4wxkMr5CUJjKtnij ZS/xjyBwa2fwYJ+P180yVr3cyGRXYUyQpqCRK0xCtdtes5xdVf6lGgpgKGNxeJWcAhW1 tvdQXzEF/pTzGvD9tOYrg0zW+2u6qq6pvyr4o3JECaz9fa5Lfiv/wSUAUSlI0w93kkGd P/qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kNrI+4y1TUF36Ck00qrlOwXeUvg/9cn9GDvjTfkcwqo=; b=uzoN2ZW1YuyTT6/4OVB81+YnNbQFd2z4iKfTS8XLn63t9fYiKXL3jvehz0MnVPRB9c ps4FfndQ74zAIY8X9rC144WcY6DzG5fVWoTZAa7WMXSM261xhnYudM/XFREpZ9dFYlU5 Ld1ptBbac1mTfc3YewlbQGXCmoNpzTHSAZkMkW31Xkll7mKRV91rrPdNEo0OnTAw3M8d GmEwBrHOuWguUt/yIGtqsCX7t5fEYcswMlQtXeXHp2p3dgbwgCv8GAC0+/QrzeWOzxUm 202ppHC3dcOkZhca72fr2kDXpccij9Lg9FFGcG+1gkuqxS41uE+0kzOtOPEDnSvP6uoI b6ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WCr19W7W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020aa7de09000000b004ab1f2867b2si5064626edv.28.2023.02.10.06.59.49; Fri, 10 Feb 2023 07:00:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WCr19W7W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232543AbjBJO4d (ORCPT + 99 others); Fri, 10 Feb 2023 09:56:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbjBJO4Y (ORCPT ); Fri, 10 Feb 2023 09:56:24 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE0B6C7C1; Fri, 10 Feb 2023 06:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040983; x=1707576983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jUL6wp0NTeLmMM6UL4qWTlmx/HlyA4RONhL6c9GtXJ4=; b=WCr19W7W4Qv/dCaBJj3l11F6MkG9BnzPkTJqMLvv/hrrLMl/f4cQsnFK BsTH74EzcrUkrDNpNM/dgXZPGpJUGraJfnR8yBBp59/+eax+lCy98LrKp MklT3TzhMR7vsdex4fQ3dun+tgipK2H+dFa5fJhSj00GS5LiEqO1CDrKR wX7TsalQLM0s+4NgJUj+OY1Y/Gj9vhCKbtazwED+CiL298FzFTNiodShD LjGzQ+KH4g7epdS7mFRJqq0BUBbgh6oPos7JfH6B7gVEhfJM7nO0iqKff FPiKq+BzFt2PoxDJUJdDwpjkKe5ComNzm8WIVX7nhhVkvpqPn/EbQT1ki A==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836326" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836326" 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 Cc: Ludovic Desroches , Linus Walleij , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Andy Shevchenko 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757456589289078832?= X-GMAIL-MSGID: =?utf-8?q?1757456589289078832?= 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: 55433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1000342wrn; Fri, 10 Feb 2023 07:02:03 -0800 (PST) X-Google-Smtp-Source: AK7set+2vihc09BEgwrfx6UI5/nDiluqKLlbbZIx8Njgli8SCTStIMToC7E6DNi22Bk39ZUu6lDT X-Received: by 2002:a17:906:3857:b0:8aa:a7b6:1c4c with SMTP id w23-20020a170906385700b008aaa7b61c4cmr13206290ejc.21.1676041323185; Fri, 10 Feb 2023 07:02:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676041323; cv=none; d=google.com; s=arc-20160816; b=cSMb9EsbBEg2W5+KMjA1sYuo4LyXn/wB/rGlMPej23lMoMj64PTdXC2Qcw1TQW2tSA 3KVDAg+KJhjfBEy9Pn86x685fSLyYgGrymMDOAmfyP86hoBLN0QRlLTc1t/KO1RnNu08 VWbLd8WCO/0A0aYtfcHBBTZAsFKmQFZj0nNENMIhqiWFnb9zFmnfY0HaIk0Xy95nSiA+ +oqDXGDrB+x0oK+bvblwHMw5HLT4MuJygG3jcM6vHMzJxJjPPaPfOM7URwTZSRVdRt+g MDe5kmWELQsHnDjxfWhZLnbyYvcjK09LAEizkHZJEpt5zwOKNIJQPVpp+wA4kt0+Lurw 3y0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c9Rd0sTUCuUIodbh96lW/HCx3Uc+lZOOEHzmH89j8zU=; b=t+NZNjDR5RtSlnKysz/kxK32+dKZ5+7BQEsIuzRY5T5ljtjHmQ0TYCdr/lfVvkxZ5Z WTR1y+qgDTrCWwU5VKUPzOq4mQ120S8VCJ06NC1QkV6AgKB0h/2FdxB6g9GwhlhsaqwN R292jGRE1upqJ7mjFYV1kA20RvW1tOr4XSppzPOD71LHEvSr11e7RqQBjCo6san4T6bZ fQ+NnKIYV5rbrr9XpioZw2q3ntu8GOPRBLhG+lwHGBsgWXKVx2QTbDNqTL/qBupIqOqR ndgkA+e9aR4VtRoRY16SYYyC868b1sSSLDZ9JwnkgL2xpB5zkTCHzwbE3UZa62trTZo4 al8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZRAVI9lZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om25-20020a170907a19900b00889a972c67esi6391471ejc.225.2023.02.10.07.01.31; Fri, 10 Feb 2023 07:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZRAVI9lZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232238AbjBJO4f (ORCPT + 99 others); Fri, 10 Feb 2023 09:56:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbjBJO4Y (ORCPT ); Fri, 10 Feb 2023 09:56:24 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB7C36C7E0; Fri, 10 Feb 2023 06:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040983; x=1707576983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o+AkmZ/j0Ltm2vhm8z9qz/CNnGgU1gRksq4fGSdRq2A=; b=ZRAVI9lZewkGovCvJFA4ELxbEj7yNcislun+FbR2mWA3NF5s/oyleXo4 PnOsYPkexDk258+v7jjl84c8EwcUP2o9kkk10zKrmLOUKXqSfE6QpU+KD T85pNX3pTBK5DhwAySm4DGc8TD+AY3xOUTvAmirM+x5YzMFTNpmiZ5t9F dZ3pCYtoCZE9DblHapwkrq9GN3QkTMyGa8JyHhrTw9khRVFypTZOY0i6Z iiZIXyqESEgPaaKwjuB+sHSDB4HscaY4BqiHTI548zgqV7adXdd3Y8HDR Avo0Fv3yc1x53lqqvCa0TKWoaYyo5N06DTPrSdT/4x+an3Fz0jLAexbJV w==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="395041588" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="395041588" 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:21 -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 Cc: Ludovic Desroches , Linus Walleij , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Andy Shevchenko 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757456706714936375?= X-GMAIL-MSGID: =?utf-8?q?1757456706714936375?= 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: 55428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp998853wrn; Fri, 10 Feb 2023 07:00:10 -0800 (PST) X-Google-Smtp-Source: AK7set/1kvN3mu+AgIemWBSH7+pkOqdRF7RNcSR55jWY0HvHDszrDDrunz0do3qXZiAwoWFZlqbw X-Received: by 2002:a17:906:e2c1:b0:87f:546d:7cb4 with SMTP id gr1-20020a170906e2c100b0087f546d7cb4mr17007788ejb.64.1676041210458; Fri, 10 Feb 2023 07:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676041210; cv=none; d=google.com; s=arc-20160816; b=tO7EuYWQ4XEyCSuMFAj/62NUGVkpXH3qczoOg3X/mQ6fqBrF9LVJROtcPu8/vP8aPJ MipmYN9otatZQ5Qec9CiYU5EPk9Mdr+UT6+One4uHrUCQraiI5rppJmmR8Yyb/P/ubDu mn/gn8jf9+EeRhKXQFiozHf4V9kg/CpK56m79jWAwa3nNY4eehzdAzZuGNifa14poWjV 4Ibrax3xQuzns+cCqi2kjP4S8i2+V5DcDzyE2V1hOcJF7oHPcl2rk7kl1UZ3zjTE11BZ M2yEmKywZ2h4WJRuCoBF5KNlzrxIhkQf5bpzWo12gCwejPOOEhcxrGp9LpoqElZ6ejXN HHOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oM4WGTdeZ8v4AfGRvIDu9+KXUTI5lTyu3TKlK1Wrgwc=; b=TnsSioDkoYHR6Cn9Br565eMOMwVkUDkV89vvf1yg+n030y4i6Su6NErRTdnS10Qmdh ait8GNFOJHyewvfNwgvMGDjFerZF37DiegMmSpZTPF6lNLxVwjtQkbiyhSPAhYBcpuAO DNl0uAu2e2qkjPDVDOSLWbihNPUkPUeYsYLO015w4e6yw/yMeHNO+SgofGSeRfjNS7qz ai5LqxhVn1pwR5EL24Szhz8FIsy5dMOzXUfVI1yEz49MHKgsv0jNMTVwXf8Bt8VUbYPh x0865pNCf/F2zE2RE6xqI3npO89nUViELNX4JHAZSTdPrsyptiJLOw+PWOJbOo2g79mP 0o7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=grt4cNHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020aa7d3c9000000b0049e078ff8c8si5669983edr.333.2023.02.10.06.59.46; Fri, 10 Feb 2023 07:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=grt4cNHf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232535AbjBJO43 (ORCPT + 99 others); Fri, 10 Feb 2023 09:56:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbjBJO4X (ORCPT ); Fri, 10 Feb 2023 09:56:23 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B0C6C7D2; Fri, 10 Feb 2023 06:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676040982; x=1707576982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S5CRSmT8K9GvBmi5rjBq6cSRiB9PaGnL3gOxhpG0i+4=; b=grt4cNHfaxyJlkx5IBy4lPX1l1V2E1eLxiuNG0iEO0q9p5OyGDJaOKsN j+vbtFJsxBn89v6XBvCduoi969N/xJo4PTb1Q+HCqdBkV/WJrJptoYgAq bTNY19KGrSwc3P38XQeeSJWjCB6mQ8angOWYpes8zzbW5c5GZci4/F20A 5RooiyUy8YeTWd0xC/lgPCUb7bXxFpupmmWwsuZ/FrPCJfixfSoG1CPSP ls7YdiRvrhDFSxL68XPrCKHXeqBYgBmjPIYM8OnNHHaquU4hM+My96O8q fnhWuCOV1nHgB+bPzRz5PoYzMU8ZUgC9nkg5RP5QXyUKTLiTLgbvDSnba g==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="395041591" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="395041591" 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:21 -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 Cc: Ludovic Desroches , Linus Walleij , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Andy Shevchenko 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757456588403643503?= X-GMAIL-MSGID: =?utf-8?q?1757456588403643503?= 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: 55431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp999270wrn; Fri, 10 Feb 2023 07:00:46 -0800 (PST) X-Google-Smtp-Source: AK7set/f3wUvkok9vEesAr9A4jICcWuDRMow+z9EFM5Ss/9W9TfDSUcS/fcrN7uV0AIARmpbYti+ X-Received: by 2002:a17:906:d051:b0:86f:3dfa:4016 with SMTP id bo17-20020a170906d05100b0086f3dfa4016mr14407281ejb.7.1676041246605; Fri, 10 Feb 2023 07:00:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676041246; cv=none; d=google.com; s=arc-20160816; b=N++bzPPyqjc9wiQh0VYwrQnNX11TMSuf0bgB7/eV0n33wsyINwAbJfvZeHak3IWKmA Q45/f2hG/yLAeFoR4pnVq6js9ZcgcyZvpvWVDeOwrF7cv1918GkhGTcvABl7vaEIXnA6 6UZGyV6EMvQqoNhgI40F9oRxth47NcsFL5vbAJ6VysnLyLEtQ+iqhc6G1TsFJdODJdl4 J/j01I7YcdvZY8ENUaGM6wIrZ5Ahb15Vui+MoQm+Zsjz2fst9aK9p9Sf6rXs3Znj/JAy 7TE8aXDDx5TStOu1iTKIPnhsyQCAwN4SXJsFuQx5j14RLEPAFfEwqlxxngfBeXZ6WVxj 6psA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tN3mKFhLolw95s1ReCSpIt42btJCcpMK0OIz4T3BU/k=; b=joPkd2jBTi+nZMlE4Qh1Y+6R6mx+QDCbMWf1GD/4XnWesX+ZA+NrT8uQmLHEJzq9Er rh8/157D9Ucjgi+vZ5lFSA/CfTZdOy4EdU44GLAd0XrvaCCX4bPshKunTrIMr2W5MVOB vgEEilzP9mIQ7PDt5zN/j+Gn3KGKRRSI/c/2r5dvDydLP+vz/F5m+xgKxLy6+jiIo16I nDzzXU0UIk7O1CSQW0anK3H0zZHUHsYOThBVgfxEeAL8XctBt/wpG2oyp65K65lOdEId sW1xkk63eOYhq7v4YLpGmld5fp/c7IACyNkTBfqcGjMigPLBO8zoOGieisqOAkSzmTCK a3Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eaam5r0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 14-20020a170906018e00b0087bd78cd19csi6862531ejb.10.2023.02.10.07.00.21; Fri, 10 Feb 2023 07:00:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eaam5r0d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232537AbjBJO4i (ORCPT + 99 others); Fri, 10 Feb 2023 09:56:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbjBJO40 (ORCPT ); Fri, 10 Feb 2023 09:56:26 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056D971027; Fri, 10 Feb 2023 06:56:24 -0800 (PST) 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=zd5Esd2sOCM8trmFSB0vVSIXyOZ3q8JrPvYqADwoYnE=; b=eaam5r0dr4vmyq285mPD0eLnYvRcL9KKHCgNSvKG8Mv98YyULEVPeGNe EsfBIC8ibzPjhJHjBs5R3cpT3wuMaV5Gen/pxQItRdNxQG0K2bmU9SnbI ej2JCO0zoyhWunPOKMstuabDDWs/CXV6h/WOGGQjl868NZG6XTRm2vxdW X6ttcWKDsHINexrtdtt/xSjAwRT8/Ykh8eCQ4t52JWlkqFvkm7tDr5gAp 9uuX7iKtahZcu8qzZ8qcTNrI/G9l6OCxDddj0wpUD/Gdn+i6OZvO35oQX CZ2ZGarvdF5Wm4iZ1ketWHl1DsSitKhI4xETncEBiQ6Ssu+rVFJUfRE0p Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10617"; a="357836334" X-IronPort-AV: E=Sophos;i="5.97,287,1669104000"; d="scan'208";a="357836334" 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 Cc: Ludovic Desroches , Linus Walleij , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Andy Shevchenko 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757456625890305032?= X-GMAIL-MSGID: =?utf-8?q?1757456625890305032?= 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; }