From patchwork Thu Mar 2 11:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 658283 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B098C6FA8E for ; Thu, 2 Mar 2023 11:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbjCBLBy (ORCPT ); Thu, 2 Mar 2023 06:01:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbjCBLBt (ORCPT ); Thu, 2 Mar 2023 06:01:49 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29197457DB; Thu, 2 Mar 2023 03:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1677754895; x=1709290895; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hyWxrfmSizpBS+n92kWqaBMSXOT85gSrHaQamS5MXSQ=; b=ryLkpByoZuydQnf0QOQtP53i2Cf2DFYDICH+2sH6oTN8i82XmCmJxFdw Uu6okBb6qeLWEqYNZyjAmfef3PfGtWougzkyNOrjqPsg3UhZ3VZDREyyG og3IIcdfVai/lQYBvUXOO83TSojkWFuo8rnKPpno19hkhjK2xtT/Y88ql +ZTNHMYeygfN6rDJEoc+lJ+5DJmv6jHwGOaOV4u3i2NJNpBLVMiSFsDJn /rN3E0VUyHOiv3B1tDUXRkou5uFSgy+dwbNwXjcx5vxoq1BIZJHS7hFrU pr4cmqy20p7UgxyM4OMte2TNL8HpCHgHnD1FUBrpDSmvlQq4cap79uBeF w==; X-IronPort-AV: E=Sophos;i="5.98,227,1673938800"; d="scan'208";a="199564352" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Mar 2023 04:01:34 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Mar 2023 04:01:33 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Mar 2023 04:01:30 -0700 From: Claudiu Beznea To: , , , CC: , , , Claudiu Beznea Subject: [PATCH 1/4] pinctrl: at91-pio4: use devm_clk_get_enabled() Date: Thu, 2 Mar 2023 13:01:13 +0200 Message-ID: <20230302110116.342486-2-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302110116.342486-1-claudiu.beznea@microchip.com> References: <20230302110116.342486-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use devm_clk_get_enabled() to simplify the code. Signed-off-by: Claudiu Beznea --- drivers/pinctrl/pinctrl-at91-pio4.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 39b233f73e13..0aceb723f94c 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -1098,7 +1098,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) if (IS_ERR(atmel_pioctrl->reg_base)) return PTR_ERR(atmel_pioctrl->reg_base); - atmel_pioctrl->clk = devm_clk_get(dev, NULL); + atmel_pioctrl->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(atmel_pioctrl->clk)) { dev_err(dev, "failed to get clock\n"); return PTR_ERR(atmel_pioctrl->clk); @@ -1219,25 +1219,19 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) i, irq); } - ret = clk_prepare_enable(atmel_pioctrl->clk); - if (ret) { - dev_err(dev, "failed to prepare and enable clock\n"); - goto clk_prepare_enable_error; - } - atmel_pioctrl->pinctrl_dev = devm_pinctrl_register(&pdev->dev, &atmel_pinctrl_desc, atmel_pioctrl); if (IS_ERR(atmel_pioctrl->pinctrl_dev)) { ret = PTR_ERR(atmel_pioctrl->pinctrl_dev); dev_err(dev, "pinctrl registration failed\n"); - goto clk_unprep; + goto irq_domain_remove_error; } ret = gpiochip_add_data(atmel_pioctrl->gpio_chip, atmel_pioctrl); if (ret) { dev_err(dev, "failed to add gpiochip\n"); - goto clk_unprep; + goto irq_domain_remove_error; } ret = gpiochip_add_pin_range(atmel_pioctrl->gpio_chip, dev_name(dev), @@ -1254,10 +1248,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) gpiochip_add_pin_range_error: gpiochip_remove(atmel_pioctrl->gpio_chip); -clk_unprep: - clk_disable_unprepare(atmel_pioctrl->clk); - -clk_prepare_enable_error: +irq_domain_remove_error: irq_domain_remove(atmel_pioctrl->irq_domain); return ret; From patchwork Thu Mar 2 11:01:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 658282 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4832EC7EE33 for ; Thu, 2 Mar 2023 11:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjCBLBz (ORCPT ); Thu, 2 Mar 2023 06:01:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjCBLBv (ORCPT ); Thu, 2 Mar 2023 06:01:51 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42BA9460AF; Thu, 2 Mar 2023 03:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1677754899; x=1709290899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bf1Z7/sfzlJmrMOEOjhTIy25zAMrI0ji7izXGtHopIU=; b=dYO4Di4CJyy1Aaqk+akeLRkiMp+nyps3JxGJRHa9nF5ncv8oQ/3O+bP5 hN3EuQS5f/kktg4A3OWE380E8dR33b8w6pBEhk/pjNBYSAdNpknTzB4gj CgTMUZE2qMcX3j/BOS05Lw+PP+WrDW7wLUokSNhkDRtN8U1oxRjmR8e9e Kh8lZbNKYBA2G1YMalGIcQeS1A/BUPieFSVP8r2DdvgrXL88G2wZAgFrq xTSQ8IBclg1zDGJu+bgUwfg048ig+QiMSaXYlskmZIwtqECjJ1f6s1QVC uyJ4ILPQgmyMM9Y8WOWsH/dhfrZl3cjjgANzvISV7u+ayxLql7gOijMUC A==; X-IronPort-AV: E=Sophos;i="5.98,227,1673938800"; d="scan'208";a="203271644" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Mar 2023 04:01:37 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Mar 2023 04:01:35 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Mar 2023 04:01:33 -0700 From: Claudiu Beznea To: , , , CC: , , , Claudiu Beznea Subject: [PATCH 2/4] pinctrl: at91-pio4: use device_get_match_data() Date: Thu, 2 Mar 2023 13:01:14 +0200 Message-ID: <20230302110116.342486-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302110116.342486-1-claudiu.beznea@microchip.com> References: <20230302110116.342486-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use device_get_match_data() to simplify the code. Signed-off-by: Claudiu Beznea --- drivers/pinctrl/pinctrl-at91-pio4.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 0aceb723f94c..93023d0fd75b 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -1067,7 +1067,6 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct pinctrl_pin_desc *pin_desc; const char **group_names; - const struct of_device_id *match; int i, ret; struct atmel_pioctrl *atmel_pioctrl; const struct atmel_pioctrl_data *atmel_pioctrl_data; @@ -1079,12 +1078,11 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) atmel_pioctrl->node = dev->of_node; platform_set_drvdata(pdev, atmel_pioctrl); - match = of_match_node(atmel_pctrl_of_match, dev->of_node); - if (!match) { - dev_err(dev, "unknown compatible string\n"); + atmel_pioctrl_data = device_get_match_data(dev); + if (!atmel_pioctrl_data) { + dev_err(dev, "Invalid device data\n"); return -ENODEV; } - atmel_pioctrl_data = match->data; atmel_pioctrl->nbanks = atmel_pioctrl_data->nbanks; atmel_pioctrl->npins = atmel_pioctrl->nbanks * ATMEL_PIO_NPINS_PER_BANK; /* if last bank has limited number of pins, adjust accordingly */ From patchwork Thu Mar 2 11:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 658881 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C56A4C7EE36 for ; Thu, 2 Mar 2023 11:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbjCBLBz (ORCPT ); Thu, 2 Mar 2023 06:01:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbjCBLBw (ORCPT ); Thu, 2 Mar 2023 06:01:52 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DC448E1B; Thu, 2 Mar 2023 03:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1677754900; x=1709290900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gX9P046dW17ln8lj8QobxPkcMbEPnX2RXibkQe5EQhM=; b=T1xvdqkYKaBAI5U8Hkx0x/VUgRKCQVSHKRzIMTZIwxZwGgS2m/gupWMe 0sVRC4uElOfp6a3CxgXoOiy52gbil+jHpfiLvWoewIqF5LqoSH1Ba+H/4 TOoq9IsjBoz+h3lam//H8Uz1fOe4xTBUKUDlb5gK5Rz1C/DuyksSeT+sA 7SLEyi4+yEenbpPUoYC18wdeT8dARazmsv6QHGNAbTSxkSahTcZxkAoth mynpNvhykr4Pp4eJe16UnOCzvgRt5XY/l2ZhrVEfx+PRYjunCz6DvI84l RXv3y/gFbJYeS/jYQCW+AFZaPRJ46JU2uqhmbQH/y8lXuhQDpDCOYjaFH Q==; X-IronPort-AV: E=Sophos;i="5.98,227,1673938800"; d="scan'208";a="199564392" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Mar 2023 04:01:39 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Mar 2023 04:01:38 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Mar 2023 04:01:36 -0700 From: Claudiu Beznea To: , , , CC: , , , Claudiu Beznea Subject: [PATCH 3/4] pinctrl: at91-pio4: use dev_err_probe() Date: Thu, 2 Mar 2023 13:01:15 +0200 Message-ID: <20230302110116.342486-4-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302110116.342486-1-claudiu.beznea@microchip.com> References: <20230302110116.342486-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use dev_err_probe() to simplify the code. Signed-off-by: Claudiu Beznea --- drivers/pinctrl/pinctrl-at91-pio4.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 93023d0fd75b..783968182bc7 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -1079,10 +1079,9 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, atmel_pioctrl); atmel_pioctrl_data = device_get_match_data(dev); - if (!atmel_pioctrl_data) { - dev_err(dev, "Invalid device data\n"); - return -ENODEV; - } + if (!atmel_pioctrl_data) + return dev_err_probe(dev, -ENODEV, "Invalid device data\n"); + atmel_pioctrl->nbanks = atmel_pioctrl_data->nbanks; atmel_pioctrl->npins = atmel_pioctrl->nbanks * ATMEL_PIO_NPINS_PER_BANK; /* if last bank has limited number of pins, adjust accordingly */ @@ -1097,10 +1096,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) return PTR_ERR(atmel_pioctrl->reg_base); atmel_pioctrl->clk = devm_clk_get_enabled(dev, NULL); - if (IS_ERR(atmel_pioctrl->clk)) { - dev_err(dev, "failed to get clock\n"); - return PTR_ERR(atmel_pioctrl->clk); - } + if (IS_ERR(atmel_pioctrl->clk)) + return dev_err_probe(dev, PTR_ERR(atmel_pioctrl->clk), "failed to get clock\n"); atmel_pioctrl->pins = devm_kcalloc(dev, atmel_pioctrl->npins, @@ -1200,10 +1197,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) atmel_pioctrl->irq_domain = irq_domain_add_linear(dev->of_node, atmel_pioctrl->gpio_chip->ngpio, &irq_domain_simple_ops, NULL); - if (!atmel_pioctrl->irq_domain) { - dev_err(dev, "can't add the irq domain\n"); - return -ENODEV; - } + if (!atmel_pioctrl->irq_domain) + return dev_err_probe(dev, -ENODEV, "can't add the irq domain\n"); atmel_pioctrl->irq_domain->name = "atmel gpio"; for (i = 0; i < atmel_pioctrl->npins; i++) { From patchwork Thu Mar 2 11:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 658880 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E08CC678D4 for ; Thu, 2 Mar 2023 11:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbjCBLB5 (ORCPT ); Thu, 2 Mar 2023 06:01:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjCBLBx (ORCPT ); Thu, 2 Mar 2023 06:01:53 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C560E4743C; Thu, 2 Mar 2023 03:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1677754901; x=1709290901; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mY3cAYnyOKmX1eK5KErN3GRqlF6KJtvyLr/5G2kFtdA=; b=YM0jVCj/lx1/MU0uhBunApAJLzP//SxcCkp7yrmAZIKyk9Z3MJdemmcn QtGDaFeGzrhPMzAbRrTY72hXgo+AmmvhDoBz91AH6iH4CSvajQDHY0C1C udJtTbnzuvbjnwRLSrfU072jhd/G5DmqSy/F+SPOLBclZaGu/ksjx1V5M EcD7UiYUi7KXPUXXvI3KnfHyv15G8JUtHtAREmLdULsWodMT/svhebzTz 1Z1cGnzEXu1cmqe25eMoVJHdiMSV7pyI5ZCa+CGW4cEA9IRnvERRXaqnB SHl/FV4/eStvXNrZIeqJgkh01QUlihX3Bu16Ou7auHruw7Q3xPgd0mrSO A==; X-IronPort-AV: E=Sophos;i="5.98,227,1673938800"; d="scan'208";a="202949584" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Mar 2023 04:01:41 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 2 Mar 2023 04:01:40 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Thu, 2 Mar 2023 04:01:38 -0700 From: Claudiu Beznea To: , , , CC: , , , Claudiu Beznea Subject: [PATCH 4/4] pinctrl: at91-pio4: use proper format specifier for unsigned int Date: Thu, 2 Mar 2023 13:01:16 +0200 Message-ID: <20230302110116.342486-5-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230302110116.342486-1-claudiu.beznea@microchip.com> References: <20230302110116.342486-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use %u instead of %d as line is unsigned int. Signed-off-by: Claudiu Beznea --- drivers/pinctrl/pinctrl-at91-pio4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 783968182bc7..d6426367594e 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -1144,7 +1144,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) pin_desc[i].number = i; /* Pin naming convention: P(bank_name)(bank_pin_number). */ - pin_desc[i].name = kasprintf(GFP_KERNEL, "P%c%d", + pin_desc[i].name = kasprintf(GFP_KERNEL, "P%c%u", bank + 'A', line); group->name = group_names[i] = pin_desc[i].name;