From patchwork Mon Feb 13 15:45:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 56347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2420048wrn; Mon, 13 Feb 2023 07:54:00 -0800 (PST) X-Google-Smtp-Source: AK7set9XBpE2FjXmmispK7ymr+8Su3BaqtENn4DeVocPHAWKQ11c0LqzEfrWPvgWwT/qqPyYJ+fT X-Received: by 2002:a17:906:700a:b0:88d:ba89:1831 with SMTP id n10-20020a170906700a00b0088dba891831mr20047007ejj.2.1676303640611; Mon, 13 Feb 2023 07:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676303640; cv=none; d=google.com; s=arc-20160816; b=f4q9Y7GhQKif3YpykvedrtS/NweYP1PTjsxdABfB3A4aXHHsZxGPnljEK/BoL9tb6E YO64WZIVS+iqsN2WusFKBPc3sNJtFV3ZZtisBgJqatQ2UVM0pciO7Evx6eGeBu69cV6w 8vKxPdS/NWqt4fYZ1yuYybqfhxzlxdcg5p75aqjT3dAko48MNXcl+HDKbYMUScNpQhVp NipTzOI+gFuURRic10mtnVVfLu6+ADt3BLtV6T3flis+dZ0UXlySfTGEaxncOYbrqCUK zed6VBC3/M+i+Ozur7eRYzvxW5pEZWUawtmO6SFsLZWlvZ+A9DZuKQgdNxMxKUN0RTVZ mlCA== 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=dFgg2yj0R7JoUxwnIzZR5TF02e6qsxN1vXLD19lqHHI=; b=B92HePzmolKE8kwQ8COZ65MTROkKDDOig+KdsZuMqfGF/HY1ceRGTm5AopV2hUkRPn sQVju1ABlAxQZj26131dTTqF+2nr7sdKrrLsicNgQHkTYksQNYx6gOKksHguNCbJ2Np6 mbuGLtgZlw33NNWO2PzToEikwMpCTMBPJVjsIa74+24ykmGpVB7JOaZruyFxYS1yibdZ 8M0G+xey9HyY0bMcZ5VbdwH+GNhO1E8suBcW2BECSx8RFhKJe6NZJNlPEVfcP9If4CXF gKo3mJiaFuwccgXEoD2pQu+CK7LNJQPZBqpUE6arRF3D63iLSjB/OmMI0YFeDCRXS4ZB FQgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TXAwbsKI; 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 zy22-20020a17090734d600b00887cdc2699fsi13594987ejb.544.2023.02.13.07.53.37; Mon, 13 Feb 2023 07:54:00 -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=TXAwbsKI; 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 S230396AbjBMPpO (ORCPT + 99 others); Mon, 13 Feb 2023 10:45:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjBMPo7 (ORCPT ); Mon, 13 Feb 2023 10:44:59 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7C6193E9; Mon, 13 Feb 2023 07:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676303098; x=1707839098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RxT731gyTPHtkinLs+KBJv0pPNDJEuCGaqZA4MmUQ3E=; b=TXAwbsKIaac37qfOGL5OqszYBN/2P00nlNCn7WEWVvUvoNZwZ/E+15+C QNkgHhFmLqNwa6PrmodJPyM/an07JubKAVyuQ01UtLVr9I1GN1ab7xHjh LBWUF9MGozbcimy7d44JIy9+RVpApGZQiHC2dJLlOrnfzynf2jyq6ELcC qFORj3G47MI7KIZlUgGBH10e28Xnq9x5WAQKlT97cwMFQ+xUkoORStmS+ +5o4HPmIf5KSNpQ3k1pzmIuAy7di1AeL1lI3bveLM3Bp9IhwPMnM7mgAp B79IkqSOQzH7+xGMqScjlc1UZUtK106k8Qs6yXBSE6CqLDUqpxVKHN20M A==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="310549204" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="310549204" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 07:44:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="701301717" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="701301717" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 13 Feb 2023 07:44:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1C8CAD0; Mon, 13 Feb 2023 17:45:35 +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 v2 1/5] pinctrl: at91: use devm_kasprintf() to avoid potential leaks (part 2) Date: Mon, 13 Feb 2023 17:45:28 +0200 Message-Id: <20230213154532.32992-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213154532.32992-1-andriy.shevchenko@linux.intel.com> References: <20230213154532.32992-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_PASS, 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?1757731766595073553?= X-GMAIL-MSGID: =?utf-8?q?1757731766595073553?= 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 Reviewed-by: Claudiu Beznea Tested-by: Claudiu Beznea --- 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 2e7debb905d5..5c01765c7a2a 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 **names; + + 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 *name = names[j]; + + strreplace(name, '-', i + 'A'); + pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "pio%c%d", i + 'A', j); + pdesc->name = 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(names[i], '-', alias_idx + 'A'); chip->names = (const char *const *)names; From patchwork Mon Feb 13 15:45:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 56345 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2419958wrn; Mon, 13 Feb 2023 07:53:51 -0800 (PST) X-Google-Smtp-Source: AK7set/qUQFcmTdBzzvlBBAao9iIFkZJbisk6166Wc+gWFJTcjsB46GiXIB5NhoFdenL7Qwo07da X-Received: by 2002:a50:d69b:0:b0:4ac:b866:7ebb with SMTP id r27-20020a50d69b000000b004acb8667ebbmr8171685edi.9.1676303630888; Mon, 13 Feb 2023 07:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676303630; cv=none; d=google.com; s=arc-20160816; b=QDznKJtVt3ROceHS8PpbfsDxju900H+GibmnGe4monxJEiL7WklIwqafR3I/X5LRRe +nGOHBjXzK0EBfPG1mYHrXU8kLVwrFsUckCBaH/BeMklJl2hSJZ34xQyBncIidQvHehU /fd3/5zms7tGXZoXJ1Ie12r5X8oZd1S4AqZIKgmy9Rv7ju0hWHd1U1h9AbiLBfuLdLY2 91uFmAVurcPrPxdmeZ0mqMsq0K5e385vGL4M0MDOFyql8nQMdUIpZwU6FWO3VTzQV3Ej Q6wCs1pZZb1gOAXGu2ylbwiscEfvIXD0XDS1UgubBYRa2+8M4gwyiGKPWrl/dC7fdvXD wbKg== 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=UD5JD8FOKCaphV/AgDpD79DUz09XDK0GsrflfghtnPs=; b=IaruIR9i3jKfsKjOP3KLtaCPBgSrxWf+cgT2Sco0d/5G4WgMrSnPQJAKBzYg3aheHS brt/Y/jrzTIPvkke1kY+qfJGhVZfxhVA62zmWKeSWJ1IAZWWSv8D2jufNSP+R1sNY9c4 12uKvu3118lfcIliejYm6wcmbsi+exKSUd5KTJ1F6LWQjdpA28tj34Tn+8guRmOOGOxL spDlsbAyV2yeDiSTY9BnK0A6j201AiXqfFnXfsC0ZTpJvTjK9fuGC6JMPV5rLKYA2SPh IUHIM5rMI0VBjsa8pbxGtfDQafA1pHVwCEd8UTo8qy85ECoDGaX7BOS8Kea3SqVR03uj 8DnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y9tMvkc3; 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 c12-20020aa7d60c000000b004acc585f25dsi4476519edr.388.2023.02.13.07.53.27; Mon, 13 Feb 2023 07:53:50 -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=Y9tMvkc3; 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 S230334AbjBMPpH (ORCPT + 99 others); Mon, 13 Feb 2023 10:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbjBMPpA (ORCPT ); Mon, 13 Feb 2023 10:45:00 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23332193E5; Mon, 13 Feb 2023 07:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676303100; x=1707839100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ll159MuJ96PpKE3mCeyHLSWBuVer23prtFbhwbeYB74=; b=Y9tMvkc3pXsONTpcyl6yEE/DM0tzD1dwOU+CtILPKQ0v8fNr5nECiViK MT662o7/oShMuOsiQvGI0TkfjOqNd/ch/zb06OeBkk8Yp4CRlbf5gxMrY /1sL8rUcRz/dSFhwTuOqrX1UnVukpjtqoouuPMfQDip5XCgrlXB05mZId TgS1cAD8s6wFSvmjYCQwdHhAE2pr/iyLKALGHHC0UPXuTLHSzb/2soMw/ SXk4pWnhJHaC5iNuo5D2+iDdmIThklYRAF6NJ/8y4r/eG6LIUqW7B0yGw 7Xxd/Kb5W3/4PRPhNnodnPL0+dXfBPxMa99w25gYZrRGPFVcHVJV2tUr9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="318938342" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="318938342" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 07:44:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="618682263" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="618682263" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 13 Feb 2023 07:44:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 21B551F8; Mon, 13 Feb 2023 17:45:35 +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 v2 2/5] pinctrl: at91: Don't mix non-devm calls with devm ones Date: Mon, 13 Feb 2023 17:45:29 +0200 Message-Id: <20230213154532.32992-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213154532.32992-1-andriy.shevchenko@linux.intel.com> References: <20230213154532.32992-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?1757731756030909390?= X-GMAIL-MSGID: =?utf-8?q?1757731756030909390?= 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 Reviewed-by: Claudiu Beznea Tested-by: Claudiu Beznea --- 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 5c01765c7a2a..6d9015ed8a3b 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 Mon Feb 13 15:45:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 56351 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2420686wrn; Mon, 13 Feb 2023 07:55:25 -0800 (PST) X-Google-Smtp-Source: AK7set8Qmygi/2T1IivjU6ZtwJLOpj70nS8ldAIy52bTO2KnVGIN3NbaSU3oKpptVBDKdWRshVXf X-Received: by 2002:a62:1c58:0:b0:5a8:5101:d667 with SMTP id c85-20020a621c58000000b005a85101d667mr14254543pfc.22.1676303725463; Mon, 13 Feb 2023 07:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676303725; cv=none; d=google.com; s=arc-20160816; b=qb6LYn3oAcJuwYdaM5/Unf8QyRj8mC4QLMA+h/qv22oZijioAoSkOhOvWFVyF6oGYu 1AGZnRtkO6prwoYD/l7IOCIcv6s0N2XXflNNhV9Wwy3DQxYf8xvMd3bu5M0V91qrHwJF 0XXqIk48G2JCqZz47hBKD2ASEU2wq7GUMOpCAFuhHwffka1QJgewb7KvKbGfWaaZSFIf jY5bpw5FFizbk40Sz3baOtuwPibFw+xlhx7Rm1Q8iyFTefd4Aj5Kf5I864VzRawT3mCr u1pxa2Mm8oXdvSIii9GN3LlxEm+NyMXKKq7aeItPsyU42O1I4HCnSxO6JOOQfCyy02vJ eb4g== 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=gqfll6WyEFoozZWN7bWc+Tt8WhPW6Hy6N/uvh/bV5Ig=; b=jcQt4IEoJF7H3cuqBs63KY8AU49K2GFucfJEfzsBiYD9TGGLOeT8CA69yACFCB+e2+ 4T1FP7EYWqiea+s0CV9oOxMXYa/vsuXB+ARj3xvhIHKdgWovwL0VRkCVOGnv8b+8v6zX JKzXG9lu0bRoCQenP3OQ86Jcgjj+KHX8gyRTCQSKYpGLAA33SOPtv0WiYs4ZWfVKu0pS Nmmuu01NYix7LI4EiaompYx3ZyQvW0ql/MA2FzD0zEQLcV+HGnFOCGwhYI8PdzZHijub aJlAw99QPbeEB70c/RlZ7xh5lkUHw2UuYmnOEN9xaRDntD6l0AjeLQ4myXqWMYXmZ/Uk t1gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KL7kCTd0; 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 p129-20020a622987000000b00593aa521c50si11871753pfp.355.2023.02.13.07.55.13; Mon, 13 Feb 2023 07:55:25 -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=KL7kCTd0; 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 S229647AbjBMPpE (ORCPT + 99 others); Mon, 13 Feb 2023 10:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbjBMPpB (ORCPT ); Mon, 13 Feb 2023 10:45:01 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B6E8193EC; Mon, 13 Feb 2023 07:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676303100; x=1707839100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCTJpmH0g4s615gzulXEqG52DaZfgj/STvSUqeWLqJI=; b=KL7kCTd0z6e2vpfL9YlSg3ke+sGAG0awaORtOL5Bb39mHRAsV1CYXeWU Sx/MjIme8N/BzugoRVWI+pfr5Qt4byAYjwMmczhQYZYvo77HDtJgo3OH5 8U5dmL3DLINZEEK7enPAAWeBI+D1xe2AGZKaf2FDNmZztbL1a3k2iTfsp 7ohmerCOlPD37zdY0i8Zzoh8lJHDNqgJAEfmjNb8doLm0FhC4NBsxQMdE Q4lgx+GTzY0hcVpCr+aWTizUEc+uFUlLk4OWML+M5rESVl44G3M69KoMb uDY9qa6yTFYovnUFVJl/xFA55L5MkefQFV2zXrrN2G3h1Dgk34NOlcklp Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="318938347" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="318938347" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 07:44:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="618682265" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="618682265" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 13 Feb 2023 07:44:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 26C61210; Mon, 13 Feb 2023 17:45:35 +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 v2 3/5] pinctrl: at91: Use of_device_get_match_data() Date: Mon, 13 Feb 2023 17:45:30 +0200 Message-Id: <20230213154532.32992-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213154532.32992-1-andriy.shevchenko@linux.intel.com> References: <20230213154532.32992-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?1757731855084548982?= X-GMAIL-MSGID: =?utf-8?q?1757731855084548982?= Use of_device_get_match_data() to simplify the code. Signed-off-by: Andy Shevchenko Reviewed-by: Claudiu Beznea Tested-by: Claudiu Beznea --- 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 6d9015ed8a3b..055a88b2dacc 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 Mon Feb 13 15:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 56348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2420053wrn; Mon, 13 Feb 2023 07:54:01 -0800 (PST) X-Google-Smtp-Source: AK7set+arXhneXfahalSDmL90ksLtvMZV0xLh7Tftkf6R991EeH4TnIAPNfbmLXrkHdqbdFRVRNC X-Received: by 2002:a17:906:6a1b:b0:8af:b63:b4bf with SMTP id qw27-20020a1709066a1b00b008af0b63b4bfmr23323422ejc.27.1676303641510; Mon, 13 Feb 2023 07:54:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676303641; cv=none; d=google.com; s=arc-20160816; b=sMw3Eym5YBcHxnZj8XknxD91Lz05jR47rz5X1q7Toi8hi0S78SorRf37ef5TOWjYkB IUcFs3/bo81JTqamw12vqFct//L+2UlfnmLsy8OfibfUm10B2q03GJm9lcLoPtrVo6wk yXhOW7bCQS0AuucF8Dw1nOmkrfKH23CvJjXykiNQjSAWgCfq17NslU0alxfMDlWMzHIm uRWwSSxnhNU1n03SnF+67iJH6V/lwck82L3UqXJiy/I+q1GcdwSXzklmaSaow9rM/r7Y 7/cZGx2q49ESik1DHL1aqTeHn9D23+69DLm/wixDxOlBVDaOca58ZleKUWosEBMgM2Nk kCeA== 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=rdMiWKQC1hlPpa2SdxpvHzTO/KSsblx/A6vXD6VgrsA=; b=HTgGamOwrspUfMD8QXlkW3IWDRkxR+UFQd73RzI9E91hTkid1jPzkaH976wsdXq+t3 nZp2uhfK41/vBSfM7hHmD9VpQ+NBdbXeCk+qAkW0cBPBLtniggpNHiWI8bu99/pS66EN 4yUiKVFWKj+mMvHYp7qKaG9F6pwUntU+9Six5UECeCVHLJOBEnNSKQ/PSa0QP5Uo88VO OSPJrpTnJGFR9Cgfrv24K/UaKgb//j4XNjhSWv8ExB6tho2SGlyAblmEM1LRWLN/6c3S 4YzojQz7T+I1r29N6Ls7TiDptEnqgWWo6+7e2+5bvx0PQ6+BIxK1ysU7r3E7+QuzxpcM 2lLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nubYMMJd; 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 fv21-20020a170907509500b008889c61b774si12354940ejc.553.2023.02.13.07.53.38; Mon, 13 Feb 2023 07:54:01 -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=nubYMMJd; 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 S230308AbjBMPpQ (ORCPT + 99 others); Mon, 13 Feb 2023 10:45:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjBMPpA (ORCPT ); Mon, 13 Feb 2023 10:45:00 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D864918AA6; Mon, 13 Feb 2023 07:44:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676303099; x=1707839099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zzxIlYVnR6VJLt47TJ3ykVLlCuoXt8jJ7FTfl30GJ0g=; b=nubYMMJdJSxhdlrhmh4S5NlYX8twijjwtbFCFv3HUM1gPkUqq6fGoc/S WnD6lb/HLGBHVkPb12J5WQrrMYzpxu0dBd4Z218KEwA/BnwqceFaBE8yg FvcyARaKqEKWtepInH0qMAOO2aeQ2Kev7H5ENeQ2FiFtNizLwAPK5QvO/ kkNMvc7M+fVmbMVAiC+iO95WlVzGEtNGP0iAciuiSgoOdKKD7rO8lXNv6 l277T6226iB5FAKbmcGmMY6mjRWAFsCZ8f6sWmEcXdBr5hWYGM1sZzsa1 kb/1fmmLCWwXtcWfM5NrRvSQjL8C1hhT9tC5QfNyKyUv7XySV0Sr4G1kJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="310549207" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="310549207" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 07:44:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="701301720" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="701301720" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 13 Feb 2023 07:44:55 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3A765252; Mon, 13 Feb 2023 17:45:35 +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 v2 4/5] pinctrl: at91: Use dev_err_probe() instead of custom messaging Date: Mon, 13 Feb 2023 17:45:31 +0200 Message-Id: <20230213154532.32992-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213154532.32992-1-andriy.shevchenko@linux.intel.com> References: <20230213154532.32992-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_PASS, 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?1757731766809568207?= X-GMAIL-MSGID: =?utf-8?q?1757731766809568207?= 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 Reviewed-by: Claudiu Beznea Tested-by: Claudiu Beznea --- 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 055a88b2dacc..08f88403affb 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(names[i], '-', 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 Mon Feb 13 15:45:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 56346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2419998wrn; Mon, 13 Feb 2023 07:53:54 -0800 (PST) X-Google-Smtp-Source: AK7set9uLG/8CcmL3wCM28xttKeDSKs8tgLmWtVgzLwhFRw2pFk2Z5nkphjvStFyFriFuvdVSfpE X-Received: by 2002:a17:902:e193:b0:19a:9dab:3438 with SMTP id y19-20020a170902e19300b0019a9dab3438mr3393285pla.2.1676303634651; Mon, 13 Feb 2023 07:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676303634; cv=none; d=google.com; s=arc-20160816; b=KKnZsCOEyZ6QYuuMJxBkPK7e18r0Km37eryRq2XscatJWVv8s4AREdvLfR0HeuB2q6 8OLMRzs86OiQucnrRUfvCn9ZWlhnPoHy6cY50oobZ/vs4OhSVyJvJhsmHmvGTh2nVSyE ugSAtZDudQwzBGqP3wANYrBoBPeamIl2Jt24eUxJI92i1tljh5l4XqZ2jK6FvXIdhBuV Yt2Tx/FP504aFWa9/c/MRbBcf2W8jDJlqjYOcbJwbPCcOGX5V1/IXVBv2QJANkSyfwRI V+M2quco4cyRn5jMLgCdEHCNup+Wrm/lX3xP/P6aRa2hpgbUDsTWAyLaMC8QjKeeXlYV +RLQ== 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=dkq8Nvol0hOdtsGY6M6D3gt9c1AJW9ZN6usT54rz924=; b=gv0TWsR6hm7xWyI67FB7jBSI2D1hkHTzDpBo4WPc3qizx/3IZhA7sd6ErvTZytHCeI fZq8xrG7dVMIVwq0+cWiKUz96lGeNifFYbDpB+RYEkMcpZ2D9qldvpJejFlgrgU5YlZv r4BXbN5KLsrU33qabTMUZ9jHY7hsEb10OwCOSHJp7F2wVDOkMSSHg5EFOL071QlyPItb mSaadC3PP1fBngHkqD3XreZwFMdws/AtbuXQ/1VvL5He/RjGWmI0oiUr7lpOMK7Kx6Ys r/D9jepjQ7xBE5GY60f3PrHdAa2D74CgpwNHsu3vDUppyMDV2HrDj8iGzidxNbAeeC5I iUEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nB6osN9p; 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 ik6-20020a170902ab0600b0019a826d3051si6813425plb.637.2023.02.13.07.53.42; Mon, 13 Feb 2023 07:53:54 -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=nB6osN9p; 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 S229854AbjBMPpS (ORCPT + 99 others); Mon, 13 Feb 2023 10:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbjBMPpD (ORCPT ); Mon, 13 Feb 2023 10:45:03 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE9918AA6; Mon, 13 Feb 2023 07:45:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676303102; x=1707839102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hDHWza/hTNXaQ+1x9vJMEvDHotzqCdmFV+4VMwkFn1g=; b=nB6osN9pw4CuBpjbm9WC4Kl0DASFmIzacOpRLZ+0GWj5d9p24559twxg qKbEdNttxViXZNmMk3jxQNhtapGd64oNiPQ+VTNCICADztJdZRNgniNB+ 0pFGtkmUWSy5V1WmEIAFi56yKBN+utMQhLWylQgUT1yXOC3siS68UcGUn 7P39gjj8mzxWEQSUcwhQ5SjQjsFfZZotSKUDvFpKHUwWSLXLfUcXpE5Lq RQX9IHpHpypV7Pg3BC12yyzYnidEvRqkhGzT7oTImIwMDYMY4EH+pVXf+ 1VM0UDcipGqyHZ4qmTiqSNJkmOxcBpu69VI6Mit4/iSwZSK50E70G6hvF g==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="318938358" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="318938358" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 07:45:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="618682273" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="618682273" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 13 Feb 2023 07:44:59 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4056E269; Mon, 13 Feb 2023 17:45:35 +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 v2 5/5] pinctrl: at91: Utilise temporary variable for struct device Date: Mon, 13 Feb 2023 17:45:32 +0200 Message-Id: <20230213154532.32992-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213154532.32992-1-andriy.shevchenko@linux.intel.com> References: <20230213154532.32992-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?1757731759874805428?= X-GMAIL-MSGID: =?utf-8?q?1757731759874805428?= 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 08f88403affb..7ada36ca64eb 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; }