From patchwork Fri Nov 5 12:42:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11B0FC433EF for ; Fri, 5 Nov 2021 12:43:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBFA1611EF for ; Fri, 5 Nov 2021 12:43:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DBFA1611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wkyxhUGtZHE8izEF1TWm1Uome3XAmj6jxK5p3cyKgQo=; b=EnERmcctTJyMHQ uaL5ggLZJfXy2GVxkm4UiTJY4lW3w987vF+gn5C2ij958qlujdZizeldkJ53+JOdojW1n++wEBM9P zorYNQeza1HLw32Qeu99HA/E/UDlhUcujATrSegynMTx0oKa4tyrWG4f73YwofJIUa0acQ9CypuOo qJRw6wOrzf3DVLusoVO0rP9loW+FHWeBFt69GSmmHPydU/Il8q8LpBDM+mOQTJfcCKOJV3B5YPDUa PiPU4V8Xoqa0FGyXcupFU1IPsKTPM5cXdc0rkCPJ4J//XK6hWfscWb56t79IzjJTbv5T3aq6rVZ0/ 5MpCh5Zf+ErGg8mykZtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyZA-00BGfm-Ms; Fri, 05 Nov 2021 12:43:32 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYk-00BGUF-Hl; Fri, 05 Nov 2021 12:43:07 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="218789400" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="218789400" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="532577175" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 05 Nov 2021 05:42:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0C9D312B; Fri, 5 Nov 2021 14:43:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 01/19] lib/string_helpers: Introduce kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:24 +0200 Message-Id: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054306_673047_C12E1444 X-CRM114-Status: GOOD ( 14.34 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org We have a few users already that basically want to have array of sequential strings to be allocated and filled. Provide a helper for them (basically adjusted version from gpio-mockup.c). Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- include/linux/string_helpers.h | 1 + lib/string_helpers.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index 4ba39e1403b2..f67a94013c87 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -100,6 +100,7 @@ char *kstrdup_quotable(const char *src, gfp_t gfp); char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp); char *kstrdup_quotable_file(struct file *file, gfp_t gfp); +char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n); void kfree_strarray(char **array, size_t n); #endif diff --git a/lib/string_helpers.c b/lib/string_helpers.c index d5d008f5b1d9..9758997c465e 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -674,6 +674,39 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp) } EXPORT_SYMBOL_GPL(kstrdup_quotable_file); +/** + * kasprintf_strarray - allocate and fill array of sequential strings + * @gfp: flags for the slab allocator + * @prefix: prefix to be used + * @n: amount of lines to be allocated and filled + * + * Allocates and fills @n strings using pattern "%s-%zu", where prefix + * is provided by caller. The caller is responsible to free them with + * kfree_strarray() after use. + * + * Returns array of strings or NULL when memory can't be allocated. + */ +char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n) +{ + char **names; + size_t i; + + names = kcalloc(n + 1, sizeof(char *), gfp); + if (!names) + return NULL; + + for (i = 0; i < n; i++) { + names[i] = kasprintf(gfp, "%s-%zu", prefix, i); + if (!names[i]) { + kfree_strarray(names, i); + return NULL; + } + } + + return names; +} +EXPORT_SYMBOL_GPL(kasprintf_strarray); + /** * kfree_strarray - free a number of dynamically allocated strings contained * in an array and the array itself From patchwork Fri Nov 5 12:42:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97090C433EF for ; Fri, 5 Nov 2021 12:43:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6007761212 for ; Fri, 5 Nov 2021 12:43:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6007761212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/GS4eLHzCdUolPi8hAw6EBtLGmSGc+GkxbtcJ4IqFf0=; b=OBjG/WOBjR35OD rcRpqSPkaCD869r9Kywl+SrSThmkaREaVR/bQc6R6PNahWq50wIOEuYHVEPvByipAhkmwtdOrnYCz Wnp8PtUvHMjnmH6PhKCEapZcSaV2wfl2S2soz0NI2N53q6+wkhpJIMEQ+XPJuu52z46+fCUVpdec+ PW4oDkYoBUfdlwB/8vxXQzYn1gBh3glMVJhDwuSqL0E+F+QO66QsGazRPHKvKbsE0k52wCgwFTkEG TGKbFbTbkbwHnOyg2QSMo0x4Abo8gscOZ9yFnIqDar4YrnRaTHF/CFmV3QwLFz/suRMbtkMmNjVkC seum+T+j0x290vqt8DDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyZM-00BGkr-KT; Fri, 05 Nov 2021 12:43:44 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYl-00BGUF-W1; Fri, 05 Nov 2021 12:43:09 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="218789408" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="218789408" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="579644106" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Nov 2021 05:42:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1BE5C11E; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 02/19] lib/string_helpers: Introduce managed variant of kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:25 +0200 Message-Id: <20211105124242.27288-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054308_115425_D4D26880 X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Some of the users want to have easy way to allocate array of strings that will be automatically cleaned when associated device is gone. Introduce managed variant of kasprintf_strarray() for such use cases. Signed-off-by: Andy Shevchenko --- include/linux/string_helpers.h | 3 +++ lib/string_helpers.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index f67a94013c87..7a22921c9db7 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -7,6 +7,7 @@ #include #include +struct device; struct file; struct task_struct; @@ -103,4 +104,6 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp); char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n); void kfree_strarray(char **array, size_t n); +char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n); + #endif diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 9758997c465e..90f9f1b7afec 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -730,6 +731,36 @@ void kfree_strarray(char **array, size_t n) } EXPORT_SYMBOL_GPL(kfree_strarray); +struct strarray { + char **array; + size_t n; +}; + +static void devm_kfree_strarray(struct device *dev, void *res) +{ + struct strarray *array = res; + + kfree_strarray(array->array, array->n); +} + +char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n) +{ + struct strarray *ptr; + + ptr = devres_alloc(devm_kfree_strarray, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n); + if (!ptr->array) { + devres_free(ptr); + return ERR_PTR(-ENOMEM); + } + + return ptr->array; +} +EXPORT_SYMBOL_GPL(devm_kasprintf_strarray); + /** * strscpy_pad() - Copy a C-string into a sized buffer * @dest: Where to copy the string to From patchwork Fri Nov 5 12:42:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D2E8C433EF for ; Fri, 5 Nov 2021 12:54:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E878560EE9 for ; Fri, 5 Nov 2021 12:54:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E878560EE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mbq+q1AHFdJjk7shscXpC4k8aJPi5fT9UQYipWAIScQ=; b=HY4zvsfWdKUVWq aIhigt94PVLSsCCTH67r84VN1HsVaH3hSGwAG08wDTcx/REdVW/V011jsiN02u9YZfZBzodVdJNBZ EazK0ZonpfhzyEURidyhZpVjQDS0m7ab86B2L0nU2DbQsF6Bo8gPLUUKZZ3a0nazeSPqEZ6gvA6FC HCdN8AvI73XHkFgpvaC5HfWYA9EwnBkhYZkK8Q1QZ5SVbkYnhyJP3pN2wC2hB69QCGX6NAqLMvvfY zuG0k3+Z3JejwuNXMTFp/0/taHS+1WbzWb59frRP20P/CkBRkUWYi8e15GXo1VxXbb44V7oArdvQ4 t2d16wQrKkBNtUvaLH8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyjc-00BMLG-CY; Fri, 05 Nov 2021 12:54:20 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyag-00BGUE-E3; Fri, 05 Nov 2021 12:45:07 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="318091777" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="318091777" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="490310777" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 05 Nov 2021 05:42:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 315D6436; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 03/19] pinctrl/rockchip: Drop wrong kernel doc annotation Date: Fri, 5 Nov 2021 14:42:26 +0200 Message-Id: <20211105124242.27288-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054506_530320_2BB59A5F X-CRM114-Status: GOOD ( 11.62 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Kernel doc validator is not happy: .../pinctrl-rockchip.c:45: warning: This comment starts with '/**', but isn't a kernel-doc comment. Drop it as it's indeed not a kernel doc comment. Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 5ce260f152ce..6031d98d9849 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -39,7 +39,7 @@ #include "pinconf.h" #include "pinctrl-rockchip.h" -/** +/* * Generate a bitmask for setting a value (v) with a write mask bit in hiword * register 31:16 area. */ From patchwork Fri Nov 5 12:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCEF4C433F5 for ; Fri, 5 Nov 2021 12:44:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E668611EF for ; Fri, 5 Nov 2021 12:44:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8E668611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ja0BVLIQuBfw0YVnkFOa5cWgB5DT0MnlSCzo81JuVHk=; b=cio+DwJwJSHJJN pr1jYROLUiZSCrwAs4YKlSPnfbt9wiNyk8w2uvKkvZrxpOpTZleOZivGh5D4qHG/6PWlNUcoImXyv xqZZG5MFCbahlK+9w07ynnQgYAXnf9BREobU4i9Dn4bv6DwQlwLwzebccOt2ytebOOOzw0wruUJgL 4f+tHJZC8cPkC8qZgXzvUK7mbVFjpoZR3oS/1OouOZqU4MS/diKrc3tT+HkmTQxUm3+1k51ApaVej YU3QxbaZGg2thMkPEHrZdMW923qBPmNbGejx4PyGXVt7KM5/OhxG86b0so6kzPyVQuUuKfB2tfoNh /44xEu31cBU4JVlI09rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyZZ-00BGsF-BY; Fri, 05 Nov 2021 12:43:57 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYk-00BGUD-Nn; Fri, 05 Nov 2021 12:43:10 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539401" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539401" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="450560674" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 05 Nov 2021 05:43:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3EA0843A; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 04/19] pinctrl/rockchip: Use temporary variable for struct device Date: Fri, 5 Nov 2021 14:42:27 +0200 Message-Id: <20211105124242.27288-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054306_825082_B3F517E7 X-CRM114-Status: GOOD ( 17.97 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 116 +++++++++++++---------------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 6031d98d9849..ae80c95bae87 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -285,6 +285,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, { struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); const struct rockchip_pin_group *grp; + struct device *dev = info->dev; struct pinctrl_map *new_map; struct device_node *parent; int map_num = 1; @@ -296,8 +297,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, */ grp = pinctrl_name_to_group(info, np->name); if (!grp) { - dev_err(info->dev, "unable to find group for node %pOFn\n", - np); + dev_err(dev, "unable to find group for node %pOFn\n", np); return -EINVAL; } @@ -331,7 +331,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, new_map[i].data.configs.num_configs = grp->data[i].nconfigs; } - dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n", + dev_dbg(dev, "maps: function %s group %s num %d\n", (*map)->data.mux.function, (*map)->data.mux.group, map_num); return 0; @@ -872,20 +872,20 @@ static int rockchip_verify_mux(struct rockchip_pin_bank *bank, int pin, int mux) { struct rockchip_pinctrl *info = bank->drvdata; + struct device *dev = info->dev; int iomux_num = (pin / 8); if (iomux_num > 3) return -EINVAL; if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) { - dev_err(info->dev, "pin %d is unrouted\n", pin); + dev_err(dev, "pin %d is unrouted\n", pin); return -EINVAL; } if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) { if (mux != RK_FUNC_GPIO) { - dev_err(info->dev, - "pin %d only supports a gpio mux\n", pin); + dev_err(dev, "pin %d only supports a gpio mux\n", pin); return -ENOTSUPP; } } @@ -909,6 +909,7 @@ static int rockchip_verify_mux(struct rockchip_pin_bank *bank, static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) { struct rockchip_pinctrl *info = bank->drvdata; + struct device *dev = info->dev; int iomux_num = (pin / 8); struct regmap *regmap; int reg, ret, mask, mux_type; @@ -922,8 +923,7 @@ static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux) if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) return 0; - dev_dbg(info->dev, "setting mux of GPIO%d-%d to %d\n", - bank->bank_num, pin, mux); + dev_dbg(dev, "setting mux of GPIO%d-%d to %d\n", bank->bank_num, pin, mux); regmap = (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU) ? info->regmap_pmu : info->regmap_base; @@ -1575,6 +1575,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank, { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; + struct device *dev = info->dev; struct regmap *regmap; int reg, ret; u32 data, temp, rmask_bits; @@ -1620,7 +1621,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank, bit -= 16; break; default: - dev_err(info->dev, "unsupported bit: %d for pinctrl drive type: %d\n", + dev_err(dev, "unsupported bit: %d for pinctrl drive type: %d\n", bit, drv_type); return -EINVAL; } @@ -1632,8 +1633,7 @@ static int rockchip_get_drive_perpin(struct rockchip_pin_bank *bank, rmask_bits = RK3288_DRV_BITS_PER_PIN; break; default: - dev_err(info->dev, "unsupported pinctrl drive type: %d\n", - drv_type); + dev_err(dev, "unsupported pinctrl drive type: %d\n", drv_type); return -EINVAL; } @@ -1652,13 +1652,14 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank, { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; + struct device *dev = info->dev; struct regmap *regmap; int reg, ret, i; u32 data, rmask, rmask_bits, temp; u8 bit; int drv_type = bank->drv[pin_num / 8].drv_type; - dev_dbg(info->dev, "setting drive of GPIO%d-%d to %d\n", + dev_dbg(dev, "setting drive of GPIO%d-%d to %d\n", bank->bank_num, pin_num, strength); ctrl->drv_calc_reg(bank, pin_num, ®map, ®, &bit); @@ -1680,8 +1681,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank, } if (ret < 0) { - dev_err(info->dev, "unsupported driver strength %d\n", - strength); + dev_err(dev, "unsupported driver strength %d\n", strength); return ret; } @@ -1720,7 +1720,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank, bit -= 16; break; default: - dev_err(info->dev, "unsupported bit: %d for pinctrl drive type: %d\n", + dev_err(dev, "unsupported bit: %d for pinctrl drive type: %d\n", bit, drv_type); return -EINVAL; } @@ -1731,8 +1731,7 @@ static int rockchip_set_drive_perpin(struct rockchip_pin_bank *bank, rmask_bits = RK3288_DRV_BITS_PER_PIN; break; default: - dev_err(info->dev, "unsupported pinctrl drive type: %d\n", - drv_type); + dev_err(dev, "unsupported pinctrl drive type: %d\n", drv_type); return -EINVAL; } @@ -1766,6 +1765,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; + struct device *dev = info->dev; struct regmap *regmap; int reg, ret, pull_type; u8 bit; @@ -1800,7 +1800,7 @@ static int rockchip_get_pull(struct rockchip_pin_bank *bank, int pin_num) return rockchip_pull_list[pull_type][data]; default: - dev_err(info->dev, "unsupported pinctrl type\n"); + dev_err(dev, "unsupported pinctrl type\n"); return -EINVAL; }; } @@ -1810,13 +1810,13 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; + struct device *dev = info->dev; struct regmap *regmap; int reg, ret, i, pull_type; u8 bit; u32 data, rmask; - dev_dbg(info->dev, "setting pull of GPIO%d-%d to %d\n", - bank->bank_num, pin_num, pull); + dev_dbg(dev, "setting pull of GPIO%d-%d to %d\n", bank->bank_num, pin_num, pull); /* rk3066b does support any pulls */ if (ctrl->type == RK3066B) @@ -1859,8 +1859,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, } if (ret < 0) { - dev_err(info->dev, "unsupported pull setting %d\n", - pull); + dev_err(dev, "unsupported pull setting %d\n", pull); return ret; } @@ -1872,7 +1871,7 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, ret = regmap_update_bits(regmap, reg, rmask, data); break; default: - dev_err(info->dev, "unsupported pinctrl type\n"); + dev_err(dev, "unsupported pinctrl type\n"); return -EINVAL; } @@ -1963,12 +1962,13 @@ static int rockchip_set_schmitt(struct rockchip_pin_bank *bank, { struct rockchip_pinctrl *info = bank->drvdata; struct rockchip_pin_ctrl *ctrl = info->ctrl; + struct device *dev = info->dev; struct regmap *regmap; int reg, ret; u8 bit; u32 data, rmask; - dev_dbg(info->dev, "setting input schmitt of GPIO%d-%d to %d\n", + dev_dbg(dev, "setting input schmitt of GPIO%d-%d to %d\n", bank->bank_num, pin_num, enable); ret = ctrl->schmitt_calc_reg(bank, pin_num, ®map, ®, &bit); @@ -2028,10 +2028,11 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); const unsigned int *pins = info->groups[group].pins; const struct rockchip_pin_config *data = info->groups[group].data; + struct device *dev = info->dev; struct rockchip_pin_bank *bank; int cnt, ret = 0; - dev_dbg(info->dev, "enable function %s group %s\n", + dev_dbg(dev, "enable function %s group %s\n", info->functions[selector].name, info->groups[group].name); /* @@ -2310,6 +2311,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, struct rockchip_pinctrl *info, u32 index) { + struct device *dev = info->dev; struct rockchip_pin_bank *bank; int size; const __be32 *list; @@ -2317,7 +2319,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, int i, j; int ret; - dev_dbg(info->dev, "group(%d): %pOFn\n", index, np); + dev_dbg(dev, "group(%d): %pOFn\n", index, np); /* Initialise group */ grp->name = np->name; @@ -2330,18 +2332,14 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, /* we do not check return since it's safe node passed down */ size /= sizeof(*list); if (!size || size % 4) { - dev_err(info->dev, "wrong pins number or pins and configs should be by 4\n"); + dev_err(dev, "wrong pins number or pins and configs should be by 4\n"); return -EINVAL; } grp->npins = size / 4; - grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), - GFP_KERNEL); - grp->data = devm_kcalloc(info->dev, - grp->npins, - sizeof(struct rockchip_pin_config), - GFP_KERNEL); + grp->pins = devm_kcalloc(dev, grp->npins, sizeof(*grp->pins), GFP_KERNEL); + grp->data = devm_kcalloc(dev, grp->npins, sizeof(*grp->data), GFP_KERNEL); if (!grp->pins || !grp->data) return -ENOMEM; @@ -2375,6 +2373,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, struct rockchip_pinctrl *info, u32 index) { + struct device *dev = info->dev; struct device_node *child; struct rockchip_pmx_func *func; struct rockchip_pin_group *grp; @@ -2382,7 +2381,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, static u32 grp_index; u32 i = 0; - dev_dbg(info->dev, "parse function(%d): %pOFn\n", index, np); + dev_dbg(dev, "parse function(%d): %pOFn\n", index, np); func = &info->functions[index]; @@ -2392,8 +2391,7 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, if (func->ngroups <= 0) return 0; - func->groups = devm_kcalloc(info->dev, - func->ngroups, sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -2421,20 +2419,14 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, rockchip_pinctrl_child_count(info, np); - dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); - dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); + dev_dbg(dev, "nfunctions = %d\n", info->nfunctions); + dev_dbg(dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kcalloc(dev, - info->nfunctions, - sizeof(struct rockchip_pmx_func), - GFP_KERNEL); + info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), GFP_KERNEL); if (!info->functions) return -ENOMEM; - info->groups = devm_kcalloc(dev, - info->ngroups, - sizeof(struct rockchip_pin_group), - GFP_KERNEL); + info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), GFP_KERNEL); if (!info->groups) return -ENOMEM; @@ -2446,7 +2438,7 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, ret = rockchip_pinctrl_parse_functions(child, info, i++); if (ret) { - dev_err(&pdev->dev, "failed to parse function\n"); + dev_err(dev, "failed to parse function\n"); of_node_put(child); return ret; } @@ -2461,6 +2453,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, struct pinctrl_desc *ctrldesc = &info->pctl; struct pinctrl_pin_desc *pindesc, *pdesc; struct rockchip_pin_bank *pin_bank; + struct device *dev = &pdev->dev; int pin, bank, ret; int k; @@ -2470,9 +2463,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &rockchip_pmx_ops; ctrldesc->confops = &rockchip_pinconf_ops; - pindesc = devm_kcalloc(&pdev->dev, - info->ctrl->nr_pins, sizeof(*pindesc), - GFP_KERNEL); + pindesc = devm_kcalloc(dev, info->ctrl->nr_pins, sizeof(*pindesc), GFP_KERNEL); if (!pindesc) return -ENOMEM; @@ -2497,9 +2488,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, if (ret) return ret; - info->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, info); + info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info); if (IS_ERR(info->pctl_dev)) { - dev_err(&pdev->dev, "could not register pinctrl driver\n"); + dev_err(dev, "could not register pinctrl driver\n"); return PTR_ERR(info->pctl_dev); } @@ -2513,8 +2504,9 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( struct rockchip_pinctrl *d, struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct device_node *node = dev->of_node; const struct of_device_id *match; - struct device_node *node = pdev->dev.of_node; struct rockchip_pin_ctrl *ctrl; struct rockchip_pin_bank *bank; int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j; @@ -2566,7 +2558,7 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( drv_pmu_offs : drv_grf_offs; } - dev_dbg(d->dev, "bank %d, iomux %d has iom_offset 0x%x drv_offset 0x%x\n", + dev_dbg(dev, "bank %d, iomux %d has iom_offset 0x%x drv_offset 0x%x\n", i, j, iom->offset, drv->offset); /* @@ -2675,8 +2667,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) { struct rockchip_pinctrl *info; struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node, *node; struct rockchip_pin_ctrl *ctrl; - struct device_node *np = pdev->dev.of_node, *node; struct resource *res; void __iomem *base; int ret; @@ -2712,8 +2704,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) rockchip_regmap_config.max_register = resource_size(res) - 4; rockchip_regmap_config.name = "rockchip,pinctrl"; - info->regmap_base = devm_regmap_init_mmio(&pdev->dev, base, - &rockchip_regmap_config); + info->regmap_base = + devm_regmap_init_mmio(dev, base, &rockchip_regmap_config); /* to check for the old dt-bindings */ info->reg_size = resource_size(res); @@ -2725,12 +2717,10 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - rockchip_regmap_config.max_register = - resource_size(res) - 4; + rockchip_regmap_config.max_register = resource_size(res) - 4; rockchip_regmap_config.name = "rockchip,pinctrl-pull"; - info->regmap_pull = devm_regmap_init_mmio(&pdev->dev, - base, - &rockchip_regmap_config); + info->regmap_pull = + devm_regmap_init_mmio(dev, base, &rockchip_regmap_config); } } @@ -2750,7 +2740,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) ret = of_platform_populate(np, rockchip_bank_match, NULL, NULL); if (ret) { - dev_err(&pdev->dev, "failed to register gpio device\n"); + dev_err(dev, "failed to register gpio device\n"); return ret; } From patchwork Fri Nov 5 12:42:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80D5AC433F5 for ; Fri, 5 Nov 2021 12:43:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F04861212 for ; Fri, 5 Nov 2021 12:43:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4F04861212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=u2jjkSR4o2tsZS37QGP+uUbUmWTDacv5299zCSZbtCI=; b=TMEjbvyBYWzw8e 30GS5rnZg2UYkc9+TZWCs5JXm4lrbgb3TcPABaBjjP1IhFlgThwKhEOQrl0+kXEU2uvjjWQ8FFRA7 XO6lLwi1CSbnutGhgThOGdNFx/DlO7MbqJeFljjsaMPCIUNTqsqdB2tB8WdIlvAWrv1/uJhFRWZTu XI0Mh7h7YIBE40tVWhcR7TQn4DZ/SC7BMwlzA40zBhj9/eHYk+UBRTCClkBJggDFuMN1J6cJsAoaG A1YKaxtsPJUeSnGuG3zaYiyc6MHmGBMKToPWvD7vWv0h0EG+FhfQpl6Hj3XHqHoJZvfFXgsZO5w4Z d+W3NKRLhda901VMAOfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyZB-00BGfq-9N; Fri, 05 Nov 2021 12:43:33 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYk-00BGUK-Nn; Fri, 05 Nov 2021 12:43:08 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="218789401" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="218789401" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="600603504" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 05 Nov 2021 05:43:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4B82849B; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 05/19] pinctrl/rockchip: Make use of the devm_platform_get_and_ioremap_resource() Date: Fri, 5 Nov 2021 14:42:28 +0200 Message-Id: <20211105124242.27288-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054306_835039_83EBA0BE X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use the devm_platform_get_and_ioremap_resource() helper instead of calling platform_get_resource() and devm_ioremap_resource() separately. Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index ae80c95bae87..7206ee30a6b2 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2697,8 +2697,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (IS_ERR(info->regmap_base)) return PTR_ERR(info->regmap_base); } else { - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(base)) return PTR_ERR(base); @@ -2712,8 +2711,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) /* Honor the old binding, with pull registers as 2nd resource */ if (ctrl->type == RK3188 && info->reg_size < 0x200) { - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - base = devm_ioremap_resource(&pdev->dev, res); + base = devm_platform_get_and_ioremap_resource(pdev, 1, &res); if (IS_ERR(base)) return PTR_ERR(base); From patchwork Fri Nov 5 12:42:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7DC8C433EF for ; Fri, 5 Nov 2021 12:44:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 934C7611EF for ; Fri, 5 Nov 2021 12:44:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 934C7611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=k4K6DpJqDqPa1cUK0Dt++yVqbHg9g+5bix9XtiF+cLc=; b=2nPhgHBbYQOnOd nvawGtg7+KGbNmDcfQhtvYI7+IDEcp+wmitbqKoe1UO2J9xMhzIFbcmQW7Lj3pXmugbC3Od1GNxxe u9PSyn5+JsJ5WigkkXST8n0WTimZRVwmpKkQDI3IGgkV+HXQpMpmQc9QCFBIO94LqCMdiy4/FloeH +Qsy2lNWU2BKJ6gmtTwtQUw+wqs5kaYZWTJeMo8uTaZmKpew/UuETVmjGOvznRyk0dXf7QIEyUkac zWcGXFArhPsfcJFZJtTysrxt1T79i2D7xAYIsqh3EUbOinLR9sEgm8l54/H+TJs2m4zkcmGee5zf8 FAxo32S4NqqbniTX+7Ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyZp-00BH2B-D2; Fri, 05 Nov 2021 12:44:13 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYn-00BGVm-G2; Fri, 05 Nov 2021 12:43:10 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="232139835" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="232139835" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="498356083" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 05 Nov 2021 05:43:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5863A4B4; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 06/19] pinctrl/rockchip: Convert to use dev_err_probe() Date: Fri, 5 Nov 2021 14:42:29 +0200 Message-Id: <20211105124242.27288-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054309_568419_6D5C4D63 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org It's fine to call dev_err_probe() in ->probe() when error code is known. Convert the driver to use dev_err_probe(). Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 7206ee30a6b2..929c96ea621a 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2331,10 +2331,8 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, list = of_get_property(np, "rockchip,pins", &size); /* we do not check return since it's safe node passed down */ size /= sizeof(*list); - if (!size || size % 4) { - dev_err(dev, "wrong pins number or pins and configs should be by 4\n"); - return -EINVAL; - } + if (!size || size % 4) + return dev_err_probe(dev, -EINVAL, "wrong pins number or pins and configs should be by 4\n"); grp->npins = size / 4; @@ -2489,10 +2487,8 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, return ret; info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info); - if (IS_ERR(info->pctl_dev)) { - dev_err(dev, "could not register pinctrl driver\n"); - return PTR_ERR(info->pctl_dev); - } + if (IS_ERR(info->pctl_dev)) + return dev_err_probe(dev, PTR_ERR(info->pctl_dev), "could not register pinctrl driver\n"); return 0; } @@ -2673,10 +2669,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) void __iomem *base; int ret; - if (!dev->of_node) { - dev_err(dev, "device tree node not found\n"); - return -ENODEV; - } + if (!dev->of_node) + return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) @@ -2685,10 +2679,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) info->dev = dev; ctrl = rockchip_pinctrl_get_soc_data(info, pdev); - if (!ctrl) { - dev_err(dev, "driver data not available\n"); - return -EINVAL; - } + if (!ctrl) + return dev_err_probe(dev, -EINVAL, "driver data not available\n"); info->ctrl = ctrl; node = of_parse_phandle(np, "rockchip,grf", 0); @@ -2737,10 +2729,8 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); ret = of_platform_populate(np, rockchip_bank_match, NULL, NULL); - if (ret) { - dev_err(dev, "failed to register gpio device\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); return 0; } From patchwork Fri Nov 5 12:42:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32AB4C433EF for ; Fri, 5 Nov 2021 12:44:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E788D61212 for ; Fri, 5 Nov 2021 12:44:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E788D61212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wx3Sc9me2HyJM90KqXesQHfzFVLloAck0rM4RlQAmPE=; b=qllEbMcX1rrJYG XtVBmALwLJjqP50zleA48sebH7q9E4UHOVHRkMQEOtXzLhO7P7cnLSwjYbwLeyojbBwzuEi4Ts8+z ZlP3+B9Muuyi4p0ZIo/YRSJa0zTjJVBrhdAsPZenA/af/VIcCdYecwiKOLAC2P7vLWFWovrQ84PGS SzOUtJBP6c8nzq9JkvRYFMv3sCIVaYpqxKwP4ll0E8EblDURSmIyrIR6m14Kt/IZTYhph/QEBNRjo Dg+enTmEk/RmafpBNrkl920rYQH8Li8+xX9akS0WrG3QLZaTtECaoND0Z+QTk4rc47Kg6dBGjqtVI f08BqunWdy48mqSoUBKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miya9-00BHFg-QY; Fri, 05 Nov 2021 12:44:33 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYn-00BGW6-Vw; Fri, 05 Nov 2021 12:43:11 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941076" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941076" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="730520446" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 05 Nov 2021 05:43:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 64BAB512; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 07/19] pinctrl/rockchip: Switch to use devm_kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:30 +0200 Message-Id: <20211105124242.27288-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054310_055280_7AA9D81C X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have a generic helper, switch the module to use it. As a side effect, add check for the memory allocation failures and cleanup it either in error case or when driver is unloading. Signed-off-by: Andy Shevchenko Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 929c96ea621a..438808a867cf 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -33,6 +33,8 @@ #include #include #include +#include + #include #include "core.h" @@ -2452,6 +2454,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, struct pinctrl_pin_desc *pindesc, *pdesc; struct rockchip_pin_bank *pin_bank; struct device *dev = &pdev->dev; + char **pin_names; int pin, bank, ret; int k; @@ -2471,10 +2474,14 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, pdesc = pindesc; for (bank = 0, k = 0; bank < info->ctrl->nr_banks; bank++) { pin_bank = &info->ctrl->pin_banks[bank]; + + pin_names = devm_kasprintf_strarray(dev, pin_bank->name, pin_bank->nr_pins); + if (IS_ERR(pin_names)) + return PTR_ERR(pin_names); + for (pin = 0; pin < pin_bank->nr_pins; pin++, k++) { pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "%s-%d", - pin_bank->name, pin); + pdesc->name = pin_names[pin]; pdesc++; } From patchwork Fri Nov 5 12:42:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C620C433F5 for ; Fri, 5 Nov 2021 12:50:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3B1060C51 for ; Fri, 5 Nov 2021 12:50:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F3B1060C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9vzZoIoUZL/a1ZuhUeF3ZZg/uQooiD5EUMOY0v72cqE=; b=F7PiFbLaZKcqKj NvUKpWvp0yQKH5i6tNSCvZ/xMj4A09XcIHmvg6L+xztXATcxNppcK8dbZJHfWjFKZYYEV2sXL3kOj ILm28ciZJMdi0cEi8Jzbn0J2060ZCGCQx+Ha9oSuMfDZ7blNfkjoY3DtR3D6lpBusANa3XlQN38sO I7GMb+lRjTtvqbd17kiU2eIwfl3F2CXW9vGyI0xM1ORCZgE9hbbvnth/+IWCAgCurLr5aGl8HwOSi i+cp9flx5ORShe28wqY9JCpHQiGba8JvdvemxYdrf18eJo5X4IbN9MzQ4yFpD7ONFwRyXGQiMdEWT oT+gD0/4SFa5+2kxmIXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyfo-00BKX9-IL; Fri, 05 Nov 2021 12:50:24 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYr-00BGZA-Np; Fri, 05 Nov 2021 12:43:15 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941092" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941092" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="542718189" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 05 Nov 2021 05:43:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 714BB616; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 08/19] pinctrl: armada-37xx: Fix function name in the kernel doc Date: Fri, 5 Nov 2021 14:42:31 +0200 Message-Id: <20211105124242.27288-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054313_813420_4B31ADBC X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Kernel doc validator is not happy: .../pinctrl-armada-37xx.c:926: warning: expecting prototype for armada_37xx_fill_funcs(). Prototype was for armada_37xx_fill_func() instead Fix this by updating function name in the kernel doc. Signed-off-by: Andy Shevchenko Reviewed-by: Gregory CLEMENT --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 5cb018f98800..5615cb7a1209 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -913,7 +913,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) } /** - * armada_37xx_fill_funcs() - complete the funcs array + * armada_37xx_fill_func() - complete the funcs array * @info: info driver instance * * Based on the data available from the armada_37xx_pin_group array From patchwork Fri Nov 5 12:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C4B5C433EF for ; Fri, 5 Nov 2021 12:48:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9EE7603E9 for ; Fri, 5 Nov 2021 12:48:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E9EE7603E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eHf1YT9SzIgD55uz7crxFcN02+WGnLvayjHCp5zRrVQ=; b=WTMsG+To8d06h+ C5+neRLASWWgi5vT3k/JSgT756wLcx7P4C1qlTXDjPRjvHT6OdZ2DxKe5mmUL2BQkLwPwKXsxsDb8 7Wa6HLde2neniEZQ0HD11qcjWkTYHyiHpTEHjYN1FkI6PMMoDA10GGumEzdZ6CtEFAIojrd7V0f5x G/+v6bUFl3/xz6//iS4bXkUOijkkL/fKcNzYyTtZYZZ2KsT7H7BK8Okqev3KsTldAEfUGXtBw2Xwv YEdd0wXg56NcxhRapo9Z/AcKSAkiafnwC0SzEmbvHztIbw25butrew/ZjqMe1FScar0acvHyxNcvR G4bA3xlvPSlbYsEFaulw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miye8-00BJhl-CJ; Fri, 05 Nov 2021 12:48:40 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYq-00BGXk-2j; Fri, 05 Nov 2021 12:43:14 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941090" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941090" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="542718188" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 05 Nov 2021 05:43:04 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7D7D262B; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 09/19] pinctrl: armada-37xx: Use temporary variable for struct device Date: Fri, 5 Nov 2021 14:42:32 +0200 Message-Id: <20211105124242.27288-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054312_286163_06BCFA7A X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko Reviewed-by: Gregory CLEMENT --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 56 +++++++++------------ 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 5615cb7a1209..37f92dc54d7a 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -341,12 +341,12 @@ static int armada_37xx_pmx_set_by_name(struct pinctrl_dev *pctldev, struct armada_37xx_pin_group *grp) { struct armada_37xx_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); + struct device *dev = info->dev; unsigned int reg = SELECTION; unsigned int mask = grp->reg_mask; int func, val; - dev_dbg(info->dev, "enable function %s group %s\n", - name, grp->name); + dev_dbg(dev, "enable function %s group %s\n", name, grp->name); func = match_string(grp->funcs, NB_FUNCS, name); if (func < 0) @@ -722,16 +722,16 @@ static unsigned int armada_37xx_irq_startup(struct irq_data *d) static int armada_37xx_irqchip_register(struct platform_device *pdev, struct armada_37xx_pinctrl *info) { - struct device_node *np = info->dev->of_node; struct gpio_chip *gc = &info->gpio_chip; struct irq_chip *irqchip = &info->irq_chip; struct gpio_irq_chip *girq = &gc->irq; struct device *dev = &pdev->dev; + struct device_node *np; struct resource res; int ret = -ENODEV, i, nr_irq_parent; /* Check if we have at least one gpio-controller child node */ - for_each_child_of_node(info->dev->of_node, np) { + for_each_child_of_node(dev->of_node, np) { if (of_property_read_bool(np, "gpio-controller")) { ret = 0; break; @@ -750,12 +750,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, return 0; } - if (of_address_to_resource(info->dev->of_node, 1, &res)) { + if (of_address_to_resource(dev->of_node, 1, &res)) { dev_err(dev, "cannot find IO resource\n"); return -ENOENT; } - info->base = devm_ioremap_resource(info->dev, &res); + info->base = devm_ioremap_resource(dev, &res); if (IS_ERR(info->base)) return PTR_ERR(info->base); @@ -774,8 +774,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, * the chained irq with all of them. */ girq->num_parents = nr_irq_parent; - girq->parents = devm_kcalloc(&pdev->dev, nr_irq_parent, - sizeof(*girq->parents), GFP_KERNEL); + girq->parents = devm_kcalloc(dev, nr_irq_parent, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) return -ENOMEM; for (i = 0; i < nr_irq_parent; i++) { @@ -794,11 +793,12 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, static int armada_37xx_gpiochip_register(struct platform_device *pdev, struct armada_37xx_pinctrl *info) { + struct device *dev = &pdev->dev; struct device_node *np; struct gpio_chip *gc; int ret = -ENODEV; - for_each_child_of_node(info->dev->of_node, np) { + for_each_child_of_node(dev->of_node, np) { if (of_find_property(np, "gpio-controller", NULL)) { ret = 0; break; @@ -811,19 +811,16 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev, gc = &info->gpio_chip; gc->ngpio = info->data->nr_pins; - gc->parent = &pdev->dev; + gc->parent = dev; gc->base = -1; gc->of_node = np; gc->label = info->data->name; ret = armada_37xx_irqchip_register(pdev, info); - if (ret) - return ret; - ret = devm_gpiochip_add_data(&pdev->dev, gc, info); if (ret) return ret; - return 0; + return devm_gpiochip_add_data(dev, gc, info); } /** @@ -874,13 +871,13 @@ static int armada_37xx_add_function(struct armada_37xx_pmx_func *funcs, static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) { int n, num = 0, funcsize = info->data->nr_pins; + struct device *dev = info->dev; for (n = 0; n < info->ngroups; n++) { struct armada_37xx_pin_group *grp = &info->groups[n]; int i, j, f; - grp->pins = devm_kcalloc(info->dev, - grp->npins + grp->extra_npins, + grp->pins = devm_kcalloc(dev, grp->npins + grp->extra_npins, sizeof(*grp->pins), GFP_KERNEL); if (!grp->pins) @@ -898,8 +895,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) ret = armada_37xx_add_function(info->funcs, &funcsize, grp->funcs[f]); if (ret == -EOVERFLOW) - dev_err(info->dev, - "More functions than pins(%d)\n", + dev_err(dev, "More functions than pins(%d)\n", info->data->nr_pins); if (ret < 0) continue; @@ -925,6 +921,7 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) { struct armada_37xx_pmx_func *funcs = info->funcs; + struct device *dev = info->dev; int n; for (n = 0; n < info->nfuncs; n++) { @@ -932,8 +929,7 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) const char **groups; int g; - funcs[n].groups = devm_kcalloc(info->dev, - funcs[n].ngroups, + funcs[n].groups = devm_kcalloc(dev, funcs[n].ngroups, sizeof(*(funcs[n].groups)), GFP_KERNEL); if (!funcs[n].groups) @@ -962,6 +958,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, const struct armada_37xx_pin_data *pin_data = info->data; struct pinctrl_desc *ctrldesc = &info->pctl; struct pinctrl_pin_desc *pindesc, *pdesc; + struct device *dev = &pdev->dev; int pin, ret; info->groups = pin_data->groups; @@ -973,9 +970,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &armada_37xx_pmx_ops; ctrldesc->confops = &armada_37xx_pinconf_ops; - pindesc = devm_kcalloc(&pdev->dev, - pin_data->nr_pins, sizeof(*pindesc), - GFP_KERNEL); + pindesc = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*pindesc), GFP_KERNEL); if (!pindesc) return -ENOMEM; @@ -994,14 +989,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, * we allocate functions for number of pins and hope there are * fewer unique functions than pins available */ - info->funcs = devm_kcalloc(&pdev->dev, - pin_data->nr_pins, - sizeof(struct armada_37xx_pmx_func), - GFP_KERNEL); + info->funcs = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*info->funcs), GFP_KERNEL); if (!info->funcs) return -ENOMEM; - ret = armada_37xx_fill_group(info); if (ret) return ret; @@ -1010,9 +1001,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, if (ret) return ret; - info->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, info); + info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info); if (IS_ERR(info->pctl_dev)) { - dev_err(&pdev->dev, "could not register pinctrl driver\n"); + dev_err(dev, "could not register pinctrl driver\n"); return PTR_ERR(info->pctl_dev); } @@ -1143,8 +1134,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) struct regmap *regmap; int ret; - info = devm_kzalloc(dev, sizeof(struct armada_37xx_pinctrl), - GFP_KERNEL); + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -1152,7 +1142,7 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) regmap = syscon_node_to_regmap(np); if (IS_ERR(regmap)) { - dev_err(&pdev->dev, "cannot get regmap\n"); + dev_err(dev, "cannot get regmap\n"); return PTR_ERR(regmap); } info->regmap = regmap; From patchwork Fri Nov 5 12:42:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93873C433EF for ; Fri, 5 Nov 2021 12:47:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55E0C603E9 for ; Fri, 5 Nov 2021 12:47:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55E0C603E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZQyClWoW1gYC2v7BDa1Fo1aSTRR2arSQl/jY721UZrA=; b=mCCK8Qlactzfec +I+fSKTkyoi55yukakedc0obtOlOE5gpVA3TcaNQInxUy9D8UiyxWcd0oXNS2lzVdT0zKykcM9ljN rhb8sVnCgIn8mKJ7kHoNXYsekXvGera19UUCL+Zdi84aAyXVGdkQTfV9bHhg1/e+O/0NmsTP9hMo3 eQexlQWdMg1vAUmOXjgdfL4phZNIU5LJa6UuR1PZcLsVeDtkUhZy1kYF4UxtGfTuiIQ7pgK0DX7Ue PKijjicdvpeHESsOY4peXLlmy1kafDApEYY5PIZPBE54NQhXFh2F9pmmCkX7bBZMoOzp7sh+zg6xz /YPr+SoNzRmsGAbGr0VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miycr-00BIyz-CW; Fri, 05 Nov 2021 12:47:21 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYp-00BGW6-R9; Fri, 05 Nov 2021 12:43:13 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941088" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941088" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="542718192" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 89BCA69F; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 10/19] pinctrl: armada-37xx: Make use of the devm_platform_ioremap_resource() Date: Fri, 5 Nov 2021 14:42:33 +0200 Message-Id: <20211105124242.27288-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054311_966510_023670B6 X-CRM114-Status: GOOD ( 11.20 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use the devm_platform_ioremap_resource() helper instead of calling of_address_to_resource() and devm_ioremap_resource() separately. Signed-off-by: Andy Shevchenko Reviewed-by: Gregory CLEMENT --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 37f92dc54d7a..282b3fac3bec 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -727,7 +727,6 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, struct gpio_irq_chip *girq = &gc->irq; struct device *dev = &pdev->dev; struct device_node *np; - struct resource res; int ret = -ENODEV, i, nr_irq_parent; /* Check if we have at least one gpio-controller child node */ @@ -750,12 +749,7 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, return 0; } - if (of_address_to_resource(dev->of_node, 1, &res)) { - dev_err(dev, "cannot find IO resource\n"); - return -ENOENT; - } - - info->base = devm_ioremap_resource(dev, &res); + info->base = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(info->base)) return PTR_ERR(info->base); From patchwork Fri Nov 5 12:42:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4298DC433F5 for ; Fri, 5 Nov 2021 12:45:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1308B60F21 for ; Fri, 5 Nov 2021 12:45:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1308B60F21 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o81ta9oVaF2cSKKVRsY2AmVa0hYxAtoCxH+i7dmZ9vI=; b=KZ0FD5QmLRlgnx AryjWBmAP09yQwuaap7edWXd2nVSEnGGqhNMUqKhChUDYOAILp7XNiVnRnFGv5zuomxQNJOieeX/D 53stzfyPpgCuyuH3qthRLpksJJ0hGl3sn6iCrMJbWCG1FB2ZvhvkUbrX41Gity/TVVLoofy/Y5rcJ 3ASO9nScHvXsEqTmmlFbYJH+hgBgetVzohX7TlPdCsqlZKq/gJAm6yOLvFhlNmndV9m8nfkc00y0n OuKQz3Xoyueanc7yJl4wx0zAFeNlJhYVk9tYfGi5ase9+XHDdHMmPYRH0ZMpGZAnCiKMPKNQAkYc+ HZAzV3yLS89LZvbBMZdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miybJ-00BI2p-TG; Fri, 05 Nov 2021 12:45:45 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYo-00BGWo-Rj; Fri, 05 Nov 2021 12:43:12 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539419" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539419" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="501921083" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 970FE74D; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 11/19] pinctrl: armada-37xx: Convert to use dev_err_probe() Date: Fri, 5 Nov 2021 14:42:34 +0200 Message-Id: <20211105124242.27288-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054310_945159_0B2C3E47 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org It's fine to call dev_err_probe() in ->probe() when error code is known. Convert the driver to use dev_err_probe(). Signed-off-by: Andy Shevchenko Reviewed-by: Gregory CLEMENT --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 282b3fac3bec..f48745c43419 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -736,10 +736,8 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, break; } } - if (ret) { - dev_err(dev, "no gpio-controller child node\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "no gpio-controller child node\n"); nr_irq_parent = of_irq_count(np); spin_lock_init(&info->irq_lock); @@ -996,10 +994,8 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, return ret; info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info); - if (IS_ERR(info->pctl_dev)) { - dev_err(dev, "could not register pinctrl driver\n"); - return PTR_ERR(info->pctl_dev); - } + if (IS_ERR(info->pctl_dev)) + return dev_err_probe(dev, PTR_ERR(info->pctl_dev), "could not register pinctrl driver\n"); return 0; } @@ -1135,10 +1131,8 @@ static int __init armada_37xx_pinctrl_probe(struct platform_device *pdev) info->dev = dev; regmap = syscon_node_to_regmap(np); - if (IS_ERR(regmap)) { - dev_err(dev, "cannot get regmap\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), "cannot get regmap\n"); info->regmap = regmap; info->data = of_device_get_match_data(dev); From patchwork Fri Nov 5 12:42:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6F31C433F5 for ; Fri, 5 Nov 2021 12:46:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85E9560F21 for ; Fri, 5 Nov 2021 12:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85E9560F21 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fYFZ3Y3pecUMq3LOHTxxq2OFhygRqGUcLYGb0wtMzOE=; b=D4uPtVzhw9Lrgv B0AHNt46JQOeHuVTxtLc0/tkcjhd3jbkTLO75pc3R3ms10ZtYpbwtO333ax0uYNxwGkDqb+Ecq2jW Cws4K44G13MnHZl0tAExPKnGuDI0NCZ1hwvCUS+Iy+raemcHIvBYp0odON7YsGZ5+8QVi5B8gGlHI eHioZH2HZjWfPfM/wpRKkuysrfqCGa8f3waQvwH8kJAguD2j9Wog1b5Mc+AjJTkFjTLe+BJ6n5pXf QH8zjcu2HP04tXvtYF0+6DIi1Ry6v9OjVWSWAQyvh0MOmGe0lAf8bnCd3H1/bygwLXu9fiHlxIYr+ CJIebrm1lBm7+W7ma6bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miycQ-00BIix-7E; Fri, 05 Nov 2021 12:46:54 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYp-00BGUD-Pg; Fri, 05 Nov 2021 12:43:13 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539420" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539420" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="490310817" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A3A167AF; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 12/19] pinctrl: armada-37xx: Switch to use devm_kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:35 +0200 Message-Id: <20211105124242.27288-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054311_897785_C834804B X-CRM114-Status: GOOD ( 15.77 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have a generic helper, switch the module to use it. As a side effect, add check for the memory allocation failures and cleanup it either in error case or when driver is unloading. Signed-off-by: Andy Shevchenko Reviewed-by: Gregory CLEMENT --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index f48745c43419..08cad14042e2 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "../pinctrl-utils.h" @@ -951,6 +952,7 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, struct pinctrl_desc *ctrldesc = &info->pctl; struct pinctrl_pin_desc *pindesc, *pdesc; struct device *dev = &pdev->dev; + char **pin_names; int pin, ret; info->groups = pin_data->groups; @@ -969,11 +971,14 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ctrldesc->pins = pindesc; ctrldesc->npins = pin_data->nr_pins; + pin_names = devm_kasprintf_strarray(dev, pin_data->name, pin_data->nr_pins); + if (IS_ERR(pin_names)) + return PTR_ERR(pin_names); + pdesc = pindesc; for (pin = 0; pin < pin_data->nr_pins; pin++) { pdesc->number = pin; - pdesc->name = kasprintf(GFP_KERNEL, "%s-%d", - pin_data->name, pin); + pdesc->name = pin_names[pin]; pdesc++; } From patchwork Fri Nov 5 12:42:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41F12C433F5 for ; Fri, 5 Nov 2021 12:46:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02F9A61212 for ; Fri, 5 Nov 2021 12:46:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 02F9A61212 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uxrN47zLLNxReuuzLIfYztz91bkoNc0DR1pu2fG6R9c=; b=NL7CsPkwZOLbH5 GS+DmY2h2E2P+x9Wcg9u5nzf7v9YT4ANpB3I/VpxLnQ7X02GLNsNTvQAcq7TmmHZ8+QXcQizyss9q d31OZ4xfD5y3r1EFy6u+HDmPYErI+19JtCOertT28FWE9sY3RqsEZJ08srE56qWxQ0FWaUsmRqakT cCo+UemNobiLDsSE73IE2JeWexTUsbU0xBpHq+TwMXpUEgDdKK9sgyljiBditWfwuknt7LC0qtWMN RhL6raHKpkNNDmyldHxER2l8tCCO8g0BN3sW78j012D1QbRm1QKd3ceMz2sFgNkUDUZ0gl9QhocZn jzqaj+91KgjnED8HZo0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miybu-00BIPr-Gc; Fri, 05 Nov 2021 12:46:22 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYp-00BGX6-AQ; Fri, 05 Nov 2021 12:43:12 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="218789428" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="218789428" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="579644682" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B012C825; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 13/19] pinctrl: st: Drop wrong kernel doc annotations Date: Fri, 5 Nov 2021 14:42:36 +0200 Message-Id: <20211105124242.27288-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054311_444077_753B94A2 X-CRM114-Status: GOOD ( 13.76 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Kernel doc validator is not happy: .../pinctrl-st.c:59: warning: This comment starts with '/**', but isn't a kernel-doc comment. .../pinctrl-st.c:73: warning: This comment starts with '/**', but isn't a kernel-doc comment. Drop them as they are indeed not a kernel doc comments. Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 1482a01dfec7..ae8783b34ed2 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -55,7 +55,7 @@ #define ST_GPIO_DIRECTION_OUT 0x2 #define ST_GPIO_DIRECTION_IN 0x4 -/** +/* * Packed style retime configuration. * There are two registers cfg0 and cfg1 in this style for each bank. * Each field in this register is 8 bit corresponding to 8 pins in the bank. @@ -69,7 +69,7 @@ #define RT_P_CFG1_CLKNOTDATA_FIELD(reg) REG_FIELD(reg, 16, 23) #define RT_P_CFG1_DOUBLE_EDGE_FIELD(reg) REG_FIELD(reg, 24, 31) -/** +/* * Dedicated style retime Configuration register * each register is dedicated per pin. */ From patchwork Fri Nov 5 12:42:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3070FC433F5 for ; Fri, 5 Nov 2021 12:48:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00BE560C51 for ; Fri, 5 Nov 2021 12:48:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 00BE560C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7Ti4vazDubNVD/Qp4YUcXvUeEjlP/FTjcnikedCAFjU=; b=X3ry9R29BM1gw5 IoX+Px55rPmJkyvM77drl7mICEdH2vesQNvbWLvIvA7Dwk5K4QHuAhynohH4Qdxc6IpUb9sjRN2Bu 8EZkD3tHI07OR4hCyAvvZcM/DF7zPzDGOx79DtChHQIWrT6LIT10w7XLgn+3G6A4Wcn0n8u/NLfgk gyhZVPiMQzpd1wUvvpOEukfAet7wucyp9WU8EH85I9IR+fw4kzINWQWqZrw1Ci5KHs0G4ycgSv9tM dfw1jaOktQE2VoLG9RbRtAdtTrg3mevg3eShNu3iR6tcwnsfxh0OXhIxA8713W+8jgb6rzcy1Ns8j te3M1zm01BHXm7e16XnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miydX-00BJN0-1C; Fri, 05 Nov 2021 12:48:03 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYp-00BGXH-Qy; Fri, 05 Nov 2021 12:43:14 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="229354648" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="229354648" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="579644683" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD5078A2; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 14/19] pinctrl: st: Use temporary variable for struct device Date: Fri, 5 Nov 2021 14:42:37 +0200 Message-Id: <20211105124242.27288-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054311_956396_244513FA X-CRM114-Status: GOOD ( 18.75 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use temporary variable for struct device to make code neater. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-st.c | 73 +++++++++++++++++------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index ae8783b34ed2..f592e9ad93fc 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -814,26 +814,25 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, { struct st_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); const struct st_pctl_group *grp; + struct device *dev = info->dev; struct pinctrl_map *new_map; struct device_node *parent; int map_num, i; grp = st_pctl_find_group_by_name(info, np->name); if (!grp) { - dev_err(info->dev, "unable to find group for node %pOFn\n", - np); + dev_err(dev, "unable to find group for node %pOFn\n", np); return -EINVAL; } map_num = grp->npins + 1; - new_map = devm_kcalloc(pctldev->dev, - map_num, sizeof(*new_map), GFP_KERNEL); + new_map = devm_kcalloc(dev, map_num, sizeof(*new_map), GFP_KERNEL); if (!new_map) return -ENOMEM; parent = of_get_parent(np); if (!parent) { - devm_kfree(pctldev->dev, new_map); + devm_kfree(dev, new_map); return -EINVAL; } @@ -853,7 +852,7 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, new_map[i].data.configs.configs = &grp->pin_conf[i].config; new_map[i].data.configs.num_configs = 1; } - dev_info(pctldev->dev, "maps: function %s group %s num %d\n", + dev_info(dev, "maps: function %s group %s num %d\n", (*map)->data.mux.function, grp->name, map_num); return 0; @@ -1173,6 +1172,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, /* bank pad direction val altfunction */ const __be32 *list; struct property *pp; + struct device *dev = info->dev; struct st_pinconf *conf; struct device_node *pins; int i = 0, npins = 0, nr_props, ret = 0; @@ -1197,9 +1197,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np, grp->npins = npins; grp->name = np->name; - grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL); - grp->pin_conf = devm_kcalloc(info->dev, - npins, sizeof(*conf), GFP_KERNEL); + grp->pins = devm_kcalloc(dev, npins, sizeof(*grp->pins), GFP_KERNEL); + grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL); if (!grp->pins || !grp->pin_conf) { ret = -ENOMEM; @@ -1247,6 +1246,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, static int st_pctl_parse_functions(struct device_node *np, struct st_pinctrl *info, u32 index, int *grp_index) { + struct device *dev = info->dev; struct device_node *child; struct st_pmx_func *func; struct st_pctl_group *grp; @@ -1256,11 +1256,10 @@ static int st_pctl_parse_functions(struct device_node *np, func->name = np->name; func->ngroups = of_get_child_count(np); if (func->ngroups == 0) { - dev_err(info->dev, "No groups defined\n"); + dev_err(dev, "No groups defined\n"); return -EINVAL; } - func->groups = devm_kcalloc(info->dev, - func->ngroups, sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -1275,8 +1274,7 @@ static int st_pctl_parse_functions(struct device_node *np, return ret; } } - dev_info(info->dev, "Function[%d\t name:%s,\tgroups:%d]\n", - index, func->name, func->ngroups); + dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups); return 0; } @@ -1577,10 +1575,11 @@ static const struct of_device_id st_pctl_of_match[] = { static int st_pctl_probe_dt(struct platform_device *pdev, struct pinctrl_desc *pctl_desc, struct st_pinctrl *info) { + struct device *dev = &pdev->dev; int ret = 0; int i = 0, j = 0, k = 0, bank; struct pinctrl_pin_desc *pdesc; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; struct device_node *child; int grp_index = 0; int irq = 0; @@ -1588,30 +1587,26 @@ static int st_pctl_probe_dt(struct platform_device *pdev, st_pctl_dt_child_count(info, np); if (!info->nbanks) { - dev_err(&pdev->dev, "you need at least one gpio bank\n"); + dev_err(dev, "you need at least one gpio bank\n"); return -EINVAL; } - dev_info(&pdev->dev, "nbanks = %d\n", info->nbanks); - dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions); - dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups); + dev_info(dev, "nbanks = %d\n", info->nbanks); + dev_info(dev, "nfunctions = %d\n", info->nfunctions); + dev_info(dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kcalloc(&pdev->dev, - info->nfunctions, sizeof(*info->functions), GFP_KERNEL); + info->functions = devm_kcalloc(dev, info->nfunctions, sizeof(*info->functions), GFP_KERNEL); - info->groups = devm_kcalloc(&pdev->dev, - info->ngroups, sizeof(*info->groups), - GFP_KERNEL); + info->groups = devm_kcalloc(dev, info->ngroups, sizeof(*info->groups), GFP_KERNEL); - info->banks = devm_kcalloc(&pdev->dev, - info->nbanks, sizeof(*info->banks), GFP_KERNEL); + info->banks = devm_kcalloc(dev, info->nbanks, sizeof(*info->banks), GFP_KERNEL); if (!info->functions || !info->groups || !info->banks) return -ENOMEM; info->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); if (IS_ERR(info->regmap)) { - dev_err(info->dev, "No syscfg phandle specified\n"); + dev_err(dev, "No syscfg phandle specified\n"); return PTR_ERR(info->regmap); } info->data = of_match_node(st_pctl_of_match, np)->data; @@ -1621,7 +1616,7 @@ static int st_pctl_probe_dt(struct platform_device *pdev, if (irq > 0) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "irqmux"); - info->irqmux_base = devm_ioremap_resource(&pdev->dev, res); + info->irqmux_base = devm_ioremap_resource(dev, res); if (IS_ERR(info->irqmux_base)) return PTR_ERR(info->irqmux_base); @@ -1632,8 +1627,7 @@ static int st_pctl_probe_dt(struct platform_device *pdev, } pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK; - pdesc = devm_kcalloc(&pdev->dev, - pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL); + pdesc = devm_kcalloc(dev, pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL); if (!pdesc) return -ENOMEM; @@ -1663,7 +1657,7 @@ static int st_pctl_probe_dt(struct platform_device *pdev, ret = st_pctl_parse_functions(child, info, i++, &grp_index); if (ret) { - dev_err(&pdev->dev, "No functions found.\n"); + dev_err(dev, "No functions found.\n"); of_node_put(child); return ret; } @@ -1675,24 +1669,25 @@ static int st_pctl_probe_dt(struct platform_device *pdev, static int st_pctl_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct st_pinctrl *info; struct pinctrl_desc *pctl_desc; int ret, i; - if (!pdev->dev.of_node) { - dev_err(&pdev->dev, "device node not found.\n"); + if (!dev->of_node) { + dev_err(dev, "device node not found.\n"); return -EINVAL; } - pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL); + pctl_desc = devm_kzalloc(dev, sizeof(*pctl_desc), GFP_KERNEL); if (!pctl_desc) return -ENOMEM; - info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; - info->dev = &pdev->dev; + info->dev = dev; platform_set_drvdata(pdev, info); ret = st_pctl_probe_dt(pdev, pctl_desc, info); if (ret) @@ -1702,11 +1697,11 @@ static int st_pctl_probe(struct platform_device *pdev) pctl_desc->pctlops = &st_pctlops; pctl_desc->pmxops = &st_pmxops; pctl_desc->confops = &st_confops; - pctl_desc->name = dev_name(&pdev->dev); + pctl_desc->name = dev_name(dev); - info->pctl = devm_pinctrl_register(&pdev->dev, pctl_desc, info); + info->pctl = devm_pinctrl_register(dev, pctl_desc, info); if (IS_ERR(info->pctl)) { - dev_err(&pdev->dev, "Failed pinctrl registration\n"); + dev_err(dev, "Failed pinctrl registration\n"); return PTR_ERR(info->pctl); } From patchwork Fri Nov 5 12:42:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3046C433F5 for ; Fri, 5 Nov 2021 12:45:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DF8C611EF for ; Fri, 5 Nov 2021 12:45:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DF8C611EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lni9IM/Bn3qA10qrc7JlQWnYxNjAJ0K1N9FpUtfYHEQ=; b=Dq7ANMKS/8mimC 0C9Tg/9TPeSML6Z8rx5yaLBJbNEDAYzls3/JzOB5qTEOqV23hVwI0PGwUo2OoWUBFQu7mOYrJxjtK k2mUi03Ys/XIS0+9eJmtDeoI+yJ5d3HE6LAfL8MUKWAx6Oblx80sm6KguoaYgzgHMUvwH4mdObSNI tIOOAMFjL0R7yNUQPOVqIZq9rcB+UggTdErSlfsII3Wd5vV+En+hP1ZIQrzsdM9Nz1wJF7NeCKqbv gS9l6MSBQ4VHiTeXu83DQZJuuMQIiCDE2onjUGo/aIgQ4Zq21oCwe8kAiLU8YsZeIAxi6thqhFCsw VjHC2BkAsPTa89wMF99g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyaZ-00BHVw-Rt; Fri, 05 Nov 2021 12:44:59 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYo-00BGUD-Es; Fri, 05 Nov 2021 12:43:11 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539415" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539415" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="501921085" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 05 Nov 2021 05:43:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C9C8D904; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 15/19] pinctrl: st: Make use of the devm_platform_ioremap_resource_byname() Date: Fri, 5 Nov 2021 14:42:38 +0200 Message-Id: <20211105124242.27288-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054310_547555_CEDC61B9 X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use the devm_platform_ioremap_resource_byname() helper instead of calling platform_get_resource_byname() and devm_ioremap_resource() separately. Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index f592e9ad93fc..bccde0b8f012 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1583,7 +1583,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev, struct device_node *child; int grp_index = 0; int irq = 0; - struct resource *res; st_pctl_dt_child_count(info, np); if (!info->nbanks) { @@ -1614,16 +1613,12 @@ static int st_pctl_probe_dt(struct platform_device *pdev, irq = platform_get_irq(pdev, 0); if (irq > 0) { - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "irqmux"); - info->irqmux_base = devm_ioremap_resource(dev, res); - + info->irqmux_base = devm_platform_ioremap_resource_byname(pdev, "irqmux"); if (IS_ERR(info->irqmux_base)) return PTR_ERR(info->irqmux_base); irq_set_chained_handler_and_data(irq, st_gpio_irqmux_handler, info); - } pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK; From patchwork Fri Nov 5 12:42:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FF2CC433EF for ; Fri, 5 Nov 2021 12:50:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0E0560C51 for ; Fri, 5 Nov 2021 12:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D0E0560C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UuaEYsfQOqGvjADz7N9euRWNQsxZa5JXlNaAVBhNgsc=; b=vTEKeLstHT9rRK B7s+2rPEuFlHl0tubyrqbPQTHqW/j6qY2G2J2Y+CaeqODsKcbaOPt+rWgrWgH1oL6hnoy6LVW8HLw ZkXmGe9Ovxh8Q77l8lT/u5l38yZ0rcuxXtkRAU1SVydaW++F0VVJ/jKgbeRrU/Vyzsof6JjyqaFfl y8MjjU3SkiX56iADm5MESdjNaf1N5q7MhNQBdvjHHd+gwuOHTarf8aw/kahv8u0ye8gnvX/os6y/C WFrTH/1IP3BZwuWHt1cSv1QXbzy6xAbOdJkVndaiLGRHax8Eo1EzZ5JPF2bJpHN3s5yKQYwPpdgoe MUE/CPtSD9nZlhq2sUWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyfm-00BKWI-Lv; Fri, 05 Nov 2021 12:50:22 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYr-00BGVm-L1; Fri, 05 Nov 2021 12:43:15 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="232139848" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="232139848" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="498356092" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 05 Nov 2021 05:43:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D409E931; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 16/19] pinctrl: st: Convert to use dev_err_probe() Date: Fri, 5 Nov 2021 14:42:39 +0200 Message-Id: <20211105124242.27288-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054313_721563_E503C327 X-CRM114-Status: GOOD ( 13.45 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org It's fine to call dev_err_probe() in ->probe() when error code is known. Convert the driver to use dev_err_probe(). Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index bccde0b8f012..9cb0da88b098 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1255,10 +1255,8 @@ static int st_pctl_parse_functions(struct device_node *np, func = &info->functions[index]; func->name = np->name; func->ngroups = of_get_child_count(np); - if (func->ngroups == 0) { - dev_err(dev, "No groups defined\n"); - return -EINVAL; - } + if (func->ngroups == 0) + return dev_err_probe(dev, -EINVAL, "No groups defined\n"); func->groups = devm_kcalloc(dev, func->ngroups, sizeof(*func->groups), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -1555,10 +1553,8 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, skip_irq: err = gpiochip_add_data(&bank->gpio_chip, bank); - if (err) { - dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); - return err; - } + if (err) + return dev_err_probe(dev, err, "Failed to add gpiochip(%d)!\n", bank_num); dev_info(dev, "%s bank added.\n", range->name); return 0; @@ -1585,10 +1581,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, int irq = 0; st_pctl_dt_child_count(info, np); - if (!info->nbanks) { - dev_err(dev, "you need at least one gpio bank\n"); - return -EINVAL; - } + if (!info->nbanks) + return dev_err_probe(dev, -EINVAL, "you need at least one gpio bank\n"); dev_info(dev, "nbanks = %d\n", info->nbanks); dev_info(dev, "nfunctions = %d\n", info->nfunctions); @@ -1604,10 +1598,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, return -ENOMEM; info->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); - if (IS_ERR(info->regmap)) { - dev_err(dev, "No syscfg phandle specified\n"); - return PTR_ERR(info->regmap); - } + if (IS_ERR(info->regmap)) + return dev_err_probe(dev, PTR_ERR(info->regmap), "No syscfg phandle specified\n"); info->data = of_match_node(st_pctl_of_match, np)->data; irq = platform_get_irq(pdev, 0); @@ -1695,10 +1687,8 @@ static int st_pctl_probe(struct platform_device *pdev) pctl_desc->name = dev_name(dev); info->pctl = devm_pinctrl_register(dev, pctl_desc, info); - if (IS_ERR(info->pctl)) { - dev_err(dev, "Failed pinctrl registration\n"); - return PTR_ERR(info->pctl); - } + if (IS_ERR(info->pctl)) + return dev_err_probe(dev, PTR_ERR(info->pctl), "Failed pinctrl registration\n"); for (i = 0; i < info->nbanks; i++) pinctrl_add_gpio_range(info->pctl, &info->banks[i].range); From patchwork Fri Nov 5 12:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0D5DC433F5 for ; Fri, 5 Nov 2021 12:50:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E6DF60C51 for ; Fri, 5 Nov 2021 12:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6E6DF60C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A/E8QmDUUbhFdr/B2rLN/K2aT0612qPB57++rjysKqk=; b=I5VcMGOFlbbgVA MIICRn9oReTyxsRWh80XMCOpO7lkHqThZxiLSfdjYtsFoGC21TeLkIdHh2wzucvFLaPPOHfLZtT0A +miWqQLzDVy26tQ7gW/BUgRC4wecNKDne9eceAGHXX9B2bdp1AsSteJlbye7NpTt4Rb6Kn8CyIXLs Dpt2OgpgnO5KpQYQeeuZKDNsXeYJ9EazKvsjkbuJ9PlmyMh+epDiOdlawxjM+lz//3M1KR67YfOdi hNXg5xDAMnDGd5NbTTD5cXWQJQW2pitTLZH7BXqw+8f+t4DR/ObmbAR1rqExJOmPgb7mcTGH1wSd9 mSSEKFB+7l7mH9fdXopQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyfl-00BKVi-Jl; Fri, 05 Nov 2021 12:50:21 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYr-00BGW6-S0; Fri, 05 Nov 2021 12:43:15 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="211941098" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="211941098" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="730520456" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 05 Nov 2021 05:43:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DDDE5ABE; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 17/19] pinctrl: st: Switch to use devm_kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:40 +0200 Message-Id: <20211105124242.27288-17-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054313_941736_75E3370B X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have a generic helper, switch the module to use it. As a side effect, add check for the memory allocation failures and cleanup it either in error case or when driver is unloading. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/pinctrl/pinctrl-st.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 9cb0da88b098..0fea71fd9a00 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1624,6 +1624,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, for_each_child_of_node(np, child) { if (of_property_read_bool(child, "gpio-controller")) { const char *bank_name = NULL; + char **pin_names; + ret = st_gpiolib_register_bank(info, bank, child); if (ret) { of_node_put(child); @@ -1632,10 +1634,16 @@ static int st_pctl_probe_dt(struct platform_device *pdev, k = info->banks[bank].range.pin_base; bank_name = info->banks[bank].range.name; + + pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK); + if (IS_ERR(pin_names)) { + of_node_put(child); + return PTR_ERR(pin_names); + } + for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) { pdesc->number = k; - pdesc->name = kasprintf(GFP_KERNEL, "%s[%d]", - bank_name, j); + pdesc->name = pin_names[j]; pdesc++; } st_parse_syscfgs(info, bank, child); From patchwork Fri Nov 5 12:42:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2841FC433EF for ; Fri, 5 Nov 2021 12:51:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC75D611EE for ; Fri, 5 Nov 2021 12:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DC75D611EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gnEM6ieOrCWojeZcAWWsN750PV1dTaMR8csP4lHZeC0=; b=1jVvEIIq+86Asj qRdX6EfsUjSUei7K5tU7ZgwMkL0VfCv6A8ilKGlba9khjpx9BGxI7rGdaXYirw2t2i5mcq+OTgaYk ohm7j/obMCCwWx39T7wo8sqpVcb8/e+Hd4J3jd3LkJGrxcMnkJEun6xrmBkXgH0vL8LWi570KbMmY UcWy7BtuH9/oGww0MROX2UnZSrIm4ZWPn804GjmXVuRIbEj27oAXo63YrdYhcF2xcqgME9V9hryrS 6ptnHC4cBMLnwA5Lla8Ih1AceLzi+ZJW9+t5vSuqt25oLy2uSAGfdKxawceU4isiqPL7nilRmLASf kaD9oDwE8cmsE09IGuxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miygx-00BL7z-MW; Fri, 05 Nov 2021 12:51:35 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYt-00BGak-V5; Fri, 05 Nov 2021 12:43:17 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539437" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539437" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="490310853" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 05 Nov 2021 05:43:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E7B6EB02; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 18/19] pinctrl: zynqmp: Unify pin naming Date: Fri, 5 Nov 2021 14:42:41 +0200 Message-Id: <20211105124242.27288-18-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054316_037757_1BF6AC18 X-CRM114-Status: GOOD ( 14.79 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have devm_kasprintf_strarray() helper, which is used in the rest of pin control drivers, it makes sense to switch this driver to it. The pin names are not part of any ABI and hence there will be no regression based on that. Otherwise all generated pin names will follow the same schema in the pin control subsystem. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/pinctrl/pinctrl-zynqmp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-zynqmp.c b/drivers/pinctrl/pinctrl-zynqmp.c index e14012209992..6cc307595783 100644 --- a/drivers/pinctrl/pinctrl-zynqmp.c +++ b/drivers/pinctrl/pinctrl-zynqmp.c @@ -809,6 +809,7 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev, unsigned int *npins) { struct pinctrl_pin_desc *pins, *pin; + char **pin_names; int ret; int i; @@ -820,13 +821,14 @@ static int zynqmp_pinctrl_prepare_pin_desc(struct device *dev, if (!pins) return -ENOMEM; + pin_names = devm_kasprintf_strarray(dev, ZYNQMP_PIN_PREFIX, *npins); + if (IS_ERR(pin->name)) + return PTR_ERR(pin_names); + for (i = 0; i < *npins; i++) { pin = &pins[i]; pin->number = i; - pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", - ZYNQMP_PIN_PREFIX, i); - if (!pin->name) - return -ENOMEM; + pin->name = pin_names[i]; } *zynqmp_pins = pins; From patchwork Fri Nov 5 12:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12604665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72479C433EF for ; Fri, 5 Nov 2021 12:52:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EA1060EE9 for ; Fri, 5 Nov 2021 12:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2EA1060EE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ldaMgQt4DzhiLjynWSbLm145RbcZizGQ3PWESpbFpn8=; b=oXNhZPXVEC/ic4 fmfwlLwgjKV7r3u6n3vkYA/mlRc9+u275TqqwoWJpEX0/d17KSZUhKWwbe76mYmcpdRm5Xw9ZTmW0 hZung1fpgjDei/Bvmd/qA6m0ilYegOxlsGpyWFJVPHdquxRtkFQDai+OmW/vUy3wpxphkqnXj2NWG 8fWWz8oFgjOaSYz0/vnlA5hpMMQay0PEpcke4WCUQXEdHA7xbDOaJCjxccXhoVpOt57HAVTgqgiZf /LG5rPich+fLDGFrj29JmcwFDdWH93WX16Dq8F6gJzNuSav5JbKlG9uQ59hNKkbtbbnd8KPwphjoA O1j0xlO6g19yW+zXzDhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyi7-00BLeh-NY; Fri, 05 Nov 2021 12:52:47 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1miyYv-00BGak-74; Fri, 05 Nov 2021 12:43:18 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10158"; a="255539442" X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="255539442" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2021 05:43:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,211,1631602800"; d="scan'208";a="490310854" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 05 Nov 2021 05:43:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F15A8B0F; Fri, 5 Nov 2021 14:43:01 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , Jianqun Xu , Linus Walleij , Sai Krishna Potthuri , Andrew Morton , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Bamvor Jian Zhang , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Heiko Stuebner , Patrice Chotard , Michal Simek , Andy Shevchenko Subject: [PATCH v1 19/19] gpio: mockup: Switch to use kasprintf_strarray() Date: Fri, 5 Nov 2021 14:42:42 +0200 Message-Id: <20211105124242.27288-19-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> References: <20211105124242.27288-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211105_054317_306756_5777609E X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Since we have a generic helper, switch the module to use it. No functional change intended. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Acked-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index d26bff29157b..8943cea92764 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -491,27 +491,6 @@ static void gpio_mockup_unregister_pdevs(void) } } -static __init char **gpio_mockup_make_line_names(const char *label, - unsigned int num_lines) -{ - unsigned int i; - char **names; - - names = kcalloc(num_lines + 1, sizeof(char *), GFP_KERNEL); - if (!names) - return NULL; - - for (i = 0; i < num_lines; i++) { - names[i] = kasprintf(GFP_KERNEL, "%s-%u", label, i); - if (!names[i]) { - kfree_strarray(names, i); - return NULL; - } - } - - return names; -} - static int __init gpio_mockup_register_chip(int idx) { struct property_entry properties[GPIO_MOCKUP_MAX_PROP]; @@ -538,7 +517,7 @@ static int __init gpio_mockup_register_chip(int idx) properties[prop++] = PROPERTY_ENTRY_U16("nr-gpios", ngpio); if (gpio_mockup_named_lines) { - line_names = gpio_mockup_make_line_names(chip_label, ngpio); + line_names = kasprintf_strarray(GFP_KERNEL, chip_label, ngpio); if (!line_names) return -ENOMEM;