From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbdI2KPU (ORCPT ); Fri, 29 Sep 2017 06:15:20 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:38164 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbdI2KPO (ORCPT ); Fri, 29 Sep 2017 06:15:14 -0400 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com From: Charles Keepax To: CC: , , Subject: [PATCH RFC 1/4] pinctrl: Factor out individual pin handling from pinmux_pins_show Date: Fri, 29 Sep 2017 11:15:00 +0100 Message-ID: <20170929101503.6769-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170929101503.6769-1-ckeepax@opensource.cirrus.com> References: <20170929101503.6769-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709290149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new helper function to be called for each pin rather than keeping everything in the same function. Primarily this just reduces the code indentation a bit. Signed-off-by: Charles Keepax --- drivers/pinctrl/pinmux.c | 100 +++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 55502fc4479c..e76e6f6a79d6 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -555,12 +555,61 @@ static int pinmux_functions_show(struct seq_file *s, void *what) return 0; } -static int pinmux_pins_show(struct seq_file *s, void *what) +static int pinmux_pin_show(struct seq_file *s, unsigned int pin) { struct pinctrl_dev *pctldev = s->private; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinmux_ops *pmxops = pctldev->desc->pmxops; - unsigned i, pin; + struct pin_desc *desc = pin_desc_get(pctldev, pin); + bool is_hog = false; + + /* Skip if we cannot search the pin */ + if (desc == NULL) + return 0; + + if (desc->mux_owner && + !strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev))) + is_hog = true; + + if (pmxops->strict) { + if (desc->mux_owner) + seq_printf(s, "pin %d (%s): device %s%s", + pin, desc->name, desc->mux_owner, + is_hog ? " (HOG)" : ""); + else if (desc->gpio_owner) + seq_printf(s, "pin %d (%s): GPIO %s", + pin, desc->name, desc->gpio_owner); + else + seq_printf(s, "pin %d (%s): UNCLAIMED", + pin, desc->name); + } else { + /* For non-strict controllers */ + seq_printf(s, "pin %d (%s): %s %s%s", pin, desc->name, + desc->mux_owner ? desc->mux_owner + : "(MUX UNCLAIMED)", + desc->gpio_owner ? desc->gpio_owner + : "(GPIO UNCLAIMED)", + is_hog ? " (HOG)" : ""); + } + + /* If mux: print function+group claiming the pin */ + if (desc->mux_setting) + seq_printf(s, " function %s group %s\n", + pmxops->get_function_name(pctldev, + desc->mux_setting->func), + pctlops->get_group_name(pctldev, + desc->mux_setting->group)); + else + seq_puts(s, "\n"); + + return 0; +} + +static int pinmux_pins_show(struct seq_file *s, void *what) +{ + struct pinctrl_dev *pctldev = s->private; + const struct pinmux_ops *pmxops = pctldev->desc->pmxops; + unsigned int i; if (!pmxops) return 0; @@ -576,51 +625,8 @@ static int pinmux_pins_show(struct seq_file *s, void *what) mutex_lock(&pctldev->mutex); /* The pin number can be retrived from the pin controller descriptor */ - for (i = 0; i < pctldev->desc->npins; i++) { - struct pin_desc *desc; - bool is_hog = false; - - pin = pctldev->desc->pins[i].number; - desc = pin_desc_get(pctldev, pin); - /* Skip if we cannot search the pin */ - if (desc == NULL) - continue; - - if (desc->mux_owner && - !strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev))) - is_hog = true; - - if (pmxops->strict) { - if (desc->mux_owner) - seq_printf(s, "pin %d (%s): device %s%s", - pin, desc->name, desc->mux_owner, - is_hog ? " (HOG)" : ""); - else if (desc->gpio_owner) - seq_printf(s, "pin %d (%s): GPIO %s", - pin, desc->name, desc->gpio_owner); - else - seq_printf(s, "pin %d (%s): UNCLAIMED", - pin, desc->name); - } else { - /* For non-strict controllers */ - seq_printf(s, "pin %d (%s): %s %s%s", pin, desc->name, - desc->mux_owner ? desc->mux_owner - : "(MUX UNCLAIMED)", - desc->gpio_owner ? desc->gpio_owner - : "(GPIO UNCLAIMED)", - is_hog ? " (HOG)" : ""); - } - - /* If mux: print function+group claiming the pin */ - if (desc->mux_setting) - seq_printf(s, " function %s group %s\n", - pmxops->get_function_name(pctldev, - desc->mux_setting->func), - pctlops->get_group_name(pctldev, - desc->mux_setting->group)); - else - seq_printf(s, "\n"); - } + for (i = 0; i < pctldev->desc->npins; i++) + pinmux_pin_show(s, pctldev->desc->pins[i].number); mutex_unlock(&pctldev->mutex); -- 2.11.0