From patchwork Thu Jun 4 23:25:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 6550531 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A7F9F9F1C1 for ; Thu, 4 Jun 2015 23:25:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC67320702 for ; Thu, 4 Jun 2015 23:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B067206F8 for ; Thu, 4 Jun 2015 23:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932303AbbFDXZG (ORCPT ); Thu, 4 Jun 2015 19:25:06 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:36374 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932284AbbFDXZE (ORCPT ); Thu, 4 Jun 2015 19:25:04 -0400 Received: by lbbqq2 with SMTP id qq2so36161848lbb.3 for ; Thu, 04 Jun 2015 16:25:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=mYEKdRAO/6dVdjRL2Jjd9h6Pb3gD9DabSQyKCtfcIL4=; b=EYWgF4IUkzwByF1LKFhSWOiaHID1/BSc3XgFGUZ8aJjXmW69g/AfYH1YqD4x/n72GT 7G4uNj5RWrybcqlkFCWfScJyY2oR2X1h3dmGIytz79LFrKCdisH9FX1AwJiubXZyiCfl wsh5x6VL5nX6rIp8KAq9flL+zQ9EKdHpn41UbYgDDaY7E4U9ArDLtVMFbKaD5aOAzjSQ HzWRLRzLPWdnE8Rgjm/8UwGARfLUlgs87lhDUeiBh6xuXkzNpnerLidcEI+xrqxAcqtx msVxh7OWyGSq9jSeXMUNT2+q8HKLlkWO7TEOttgRiujbFm0b+176jC6jmlbin9+Y1B7Y 3zWQ== X-Gm-Message-State: ALoCoQmnApKj88NIgBnJyIyezZ3WlD8w7mO/tHwFrcxK1YyL77Oens9JB4aGqt9ndWYAeMMwHJ8k X-Received: by 10.112.53.226 with SMTP id e2mr462078lbp.124.1433460302646; Thu, 04 Jun 2015 16:25:02 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp85-141-196-196.pppoe.mtu-net.ru. [85.141.196.196]) by mx.google.com with ESMTPSA id a7sm1179869lbc.36.2015.06.04.16.25.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 16:25:01 -0700 (PDT) Date: Thu, 04 Jun 2015 16:25:01 -0700 (PDT) X-Google-Original-Date: Fri, 05 Jun 2015 02:25 +0300 From: Sergei Shtylyov To: linus.walleij@linaro.org, linux-sh@vger.kernel.org, laurent.pinchart@ideasonboard.com, linux-gpio@vger.kernel.org Subject: [PATCH v2 1/4] sh-pfc: do not call sh_pfc_get_pin_index() when unnecessary Message-ID: <10321666.EILxzFPKZf@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.7 (Linux/3.19.8-100.fc20.x86_64; KDE/4.14.7; x86_64; ; ) In-Reply-To: <4326653.qPvIJDU6F2@wasted.cogentembedded.com> References: <4326653.qPvIJDU6F2@wasted.cogentembedded.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Calling sh_pfc_get_pin_index() to calculate a pin index based on the collected pin range data is unnecessary when we're dealing with 'pfc->info->pins' and 'chip->pins' arrays as those always reperesent the pins starting from index 0 sequentially. Being a mere optimization at this time, this change will become crucial when we'll allow the "holes" in those arrays... Signed-off-by: Sergei Shtylyov --- Changes in version 2: - new patch. drivers/pinctrl/sh-pfc/gpio.c | 6 ++---- drivers/pinctrl/sh-pfc/pinctrl.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pinctrl/drivers/pinctrl/sh-pfc/gpio.c =================================================================== --- linux-pinctrl.orig/drivers/pinctrl/sh-pfc/gpio.c +++ linux-pinctrl/drivers/pinctrl/sh-pfc/gpio.c @@ -52,8 +52,7 @@ static void gpio_get_data_reg(struct sh_ struct sh_pfc_gpio_data_reg **reg, unsigned int *bit) { - int idx = sh_pfc_get_pin_index(chip->pfc, offset); - struct sh_pfc_gpio_pin *gpio_pin = &chip->pins[idx]; + struct sh_pfc_gpio_pin *gpio_pin = &chip->pins[offset]; *reg = &chip->regs[gpio_pin->dreg]; *bit = gpio_pin->dbit; @@ -138,9 +137,8 @@ static int gpio_setup_data_regs(struct s static int gpio_pin_request(struct gpio_chip *gc, unsigned offset) { struct sh_pfc *pfc = gpio_to_pfc(gc); - int idx = sh_pfc_get_pin_index(pfc, offset); - if (idx < 0 || pfc->info->pins[idx].enum_id == 0) + if (pfc->info->pins[offset].enum_id == 0) return -EINVAL; return pinctrl_request_gpio(offset); Index: linux-pinctrl/drivers/pinctrl/sh-pfc/pinctrl.c =================================================================== --- linux-pinctrl.orig/drivers/pinctrl/sh-pfc/pinctrl.c +++ linux-pinctrl/drivers/pinctrl/sh-pfc/pinctrl.c @@ -370,7 +370,7 @@ static int sh_pfc_gpio_request_enable(st /* If GPIOs are handled externally the pin mux type need to be * set to GPIO here. */ - const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; + const struct sh_pfc_pin *pin = &pfc->info->pins[offset]; ret = sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_GPIO); if (ret < 0) @@ -410,7 +410,7 @@ static int sh_pfc_gpio_set_direction(str struct sh_pfc *pfc = pmx->pfc; int new_type = input ? PINMUX_TYPE_INPUT : PINMUX_TYPE_OUTPUT; int idx = sh_pfc_get_pin_index(pfc, offset); - const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; + const struct sh_pfc_pin *pin = &pfc->info->pins[offset]; struct sh_pfc_pin_config *cfg = &pmx->configs[idx]; unsigned long flags; unsigned int dir; @@ -452,8 +452,7 @@ static const struct pinmux_ops sh_pfc_pi static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin, enum pin_config_param param) { - int idx = sh_pfc_get_pin_index(pfc, _pin); - const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; + const struct sh_pfc_pin *pin = &pfc->info->pins[_pin]; switch (param) { case PIN_CONFIG_BIAS_DISABLE: