From patchwork Mon Mar 11 14:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13588793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75A71C5475B for ; Mon, 11 Mar 2024 14:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type: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=OcAFZESsRK35G2hLr0owmYqAlMunx9T5ZwMAKDF5vm4=; b=tRLz2nyNViR4A/ vOpUOhScGN7HllcHK+s87uabBAAThj4LfB3BpeNCXkgYUR2zxpKRWtmCU4eY4qRChh2/OSH+IHyTh U9kLSLB8ckuQep5Z37emfE4jCz+3KMD1MEntobfoNRJFACDmTYuNbgH+33M2NE5QTcxp8ZEMGSajg KytEfkR84I84BybxnqJoMf5M0RwSXPo2CC0EP3EmzpaomF2RjaSIifzHijz9x2Kv/BN07CNq1XCc1 US3Spn4DOvBFL3gf3jZ36IbDRmuzUfhqe8raNI6HtOZBdjtGSfhvSIHzxOeXRPgWso61wKXHRWIH+ IxagOu5n1e/UKCm88r7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjgKX-00000001k7B-3VLc; Mon, 11 Mar 2024 14:08:41 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjgKV-00000001k6R-0ApT for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 14:08:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710166119; x=1741702119; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4opJTjHk6eRIzxcJR3OPwb0vcJcIOIZAXBxw8+TIagA=; b=bd5kjuqknv7jNcVOdKnAxMXk4OThBZ99rfbRUPTZkCDs8ygqFpy/1gp3 EU1ZajYHJ4lJLbyIaRfgf2gkuYEEkbcEfpWcUtQCs+qTquCLlN9WgWuOR QfNT+qMJX1JrcaOV4R+TnvJTGLVA65ijyR0FTqXszQKTH/4ft0KWL3C8C 9O+FG7TaNPCf7wBn/Z9GLRjMDGNvfSKdLflDo/7E6SFumHZFZioRmSpo3 XO7s1BZMJTqGt4RBNZXzrPPddwo5Cbtkw/Gcd4KBNqvQNSGWELBXSX8ao W+6DmlYtON55SJ+1TK0jx5wv51wFfIJ0/Pe9DFLpMtDymYEAfB/5TQSVG g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="22351043" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="22351043" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 07:08:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="937049955" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="937049955" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Mar 2024 07:08:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 393A1177; Mon, 11 Mar 2024 16:08:34 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Linus Walleij Subject: [PATCH v1 1/1] pinctrl: pxa2xx: Make use of struct pinfunction Date: Mon, 11 Mar 2024 16:08:33 +0200 Message-ID: <20240311140833.1168742-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_070839_192943_A19335E2 X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since pin control provides a generic data type for the pin function, use it in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 24 ++++++++++-------------- drivers/pinctrl/pxa/pinctrl-pxa2xx.h | 8 +------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c index d2568dab8c78..f24bf49fa82b 100644 --- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c +++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c @@ -109,7 +109,7 @@ static const char *pxa2xx_pmx_get_func_name(struct pinctrl_dev *pctldev, unsigned function) { struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); - struct pxa_pinctrl_function *pf = pctl->functions + function; + struct pinfunction *pf = pctl->functions + function; return pf->name; } @@ -127,7 +127,7 @@ static int pxa2xx_pmx_get_func_groups(struct pinctrl_dev *pctldev, unsigned * const num_groups) { struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); - struct pxa_pinctrl_function *pf = pctl->functions + function; + struct pinfunction *pf = pctl->functions + function; *groups = pf->groups; *num_groups = pf->ngroups; @@ -249,11 +249,11 @@ static struct pinctrl_desc pxa2xx_pinctrl_desc = { .pmxops = &pxa2xx_pinmux_ops, }; -static const struct pxa_pinctrl_function * -pxa2xx_find_function(struct pxa_pinctrl *pctl, const char *fname, - const struct pxa_pinctrl_function *functions) +static const struct pinfunction *pxa2xx_find_function(struct pxa_pinctrl *pctl, + const char *fname, + const struct pinfunction *functions) { - const struct pxa_pinctrl_function *func; + const struct pinfunction *func; for (func = functions; func->name; func++) if (!strcmp(fname, func->name)) @@ -264,8 +264,8 @@ pxa2xx_find_function(struct pxa_pinctrl *pctl, const char *fname, static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) { + struct pinfunction *functions; int i; - struct pxa_pinctrl_function *functions; struct pxa_desc_function *df; /* @@ -296,9 +296,9 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) static int pxa2xx_build_groups(struct pxa_pinctrl *pctl) { int i, j, ngroups; - struct pxa_pinctrl_function *func; struct pxa_desc_function *df; - char **gtmp; + struct pinfunction *func; + const char **gtmp; gtmp = devm_kmalloc_array(pctl->dev, pctl->npins, sizeof(*gtmp), GFP_KERNEL); @@ -316,13 +316,9 @@ static int pxa2xx_build_groups(struct pxa_pinctrl *pctl) pctl->ppins[j].pin.name; func = pctl->functions + i; func->ngroups = ngroups; - func->groups = - devm_kmalloc_array(pctl->dev, ngroups, - sizeof(char *), GFP_KERNEL); + func->groups = devm_kmemdup(pctl->dev, gtmp, ngroups * sizeof(*gtmp), GFP_KERNEL); if (!func->groups) return -ENOMEM; - - memcpy(func->groups, gtmp, ngroups * sizeof(*gtmp)); } devm_kfree(pctl->dev, gtmp); diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.h b/drivers/pinctrl/pxa/pinctrl-pxa2xx.h index d86d47dbbc94..a0bdcec55158 100644 --- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.h +++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.h @@ -57,12 +57,6 @@ struct pxa_pinctrl_group { unsigned pin; }; -struct pxa_pinctrl_function { - const char *name; - const char **groups; - unsigned ngroups; -}; - struct pxa_pinctrl { spinlock_t lock; void __iomem **base_gafr; @@ -76,7 +70,7 @@ struct pxa_pinctrl { unsigned ngroups; struct pxa_pinctrl_group *groups; unsigned nfuncs; - struct pxa_pinctrl_function *functions; + struct pinfunction *functions; char *name; };