Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp448807ybb; Wed, 25 Mar 2020 03:05:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsjSdU1k6VY6eTAb/w0h20imkY1VjbyrpYyKA9wDfXYWeyAJEDc5jIXshjIWSg+DbaHRTmF X-Received: by 2002:a4a:250b:: with SMTP id g11mr804803ooa.27.1585130739056; Wed, 25 Mar 2020 03:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585130739; cv=none; d=google.com; s=arc-20160816; b=ZJaz9h6gS45Innl6BMWLTjOa9tXkP07EDBv9kSu/EfUJLM5MOAuGblVoENZrj6zoHJ BfjX2F8DL/JlJvgPYiqkZE3sCIwTvKyxpUxqewcGRB3Y06q0sOqUKxl15KtXL74CIX0F /xRyyShf3w4hXzH/8Ohs6FlKxxdgh6uyBgSRg3OPR5TXpNsGKOX7fwXWZpvtDZJrEkjV VRJa7Qiy9Hgp+guDzjEU3ftKGqVf95Ex12EQxwuuix2b7wG0hS+F/1swy7i6madcqqdh woRTxVbYbsVmB2ZeeSJfrqsziWOGycOssxmZzvnTrOJ3w8SUyY4PxIG75L7gtS6t2JsQ j32A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PQKwMcv25T0AkIZh3fwXDfLSZun58F63ziNfjMlnTv4=; b=rrWl2WPLbJbaXNOHhe9OYitcvwr/OI4tGSLxHKcJ5PBO3+1+b+YdqaFgwXgLnVhll9 N14ixG9St8TgefqnlVHhrGLsYWT1j6M6Fkgf8XULzg+riLOGecN7YDsVaKnr4ab1BQdd /gqUH1W0EWYiVg1xBUkmWIOg7P8kJydZzD519JQzcO8ewecCEBzjfA0U6ImmanioNc0G BgZxMCwhcUpPrzHYS/Lr/ZFr6lOLVcry3KkjfXBzUFH+0mOAADUB51374lP4RlqiIdqM tMA/Iho/T4nUafZT1kgUB9JXI6FrTEG3eX2f9h+uK+mgYO+3Fz8q41OynD+N0HmBLbOv 0qFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si1315384oov.25.2020.03.25.03.05.27; Wed, 25 Mar 2020 03:05:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727400AbgCYKEq (ORCPT + 99 others); Wed, 25 Mar 2020 06:04:46 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:45048 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbgCYKEp (ORCPT ); Wed, 25 Mar 2020 06:04:45 -0400 Received: from ramsan ([84.195.182.253]) by andre.telenet-ops.be with bizsmtp id Ja4k220075USYZQ01a4kSx; Wed, 25 Mar 2020 11:04:44 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1jH2tw-00033v-1k; Wed, 25 Mar 2020 11:04:44 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1jH2tw-0003ef-0v; Wed, 25 Mar 2020 11:04:44 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/2] gpiolib: Pass gpio_desc to gpio_set_config() Date: Wed, 25 Mar 2020 11:04:38 +0100 Message-Id: <20200325100439.14000-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200325100439.14000-1-geert+renesas@glider.be> References: <20200325100439.14000-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All callers of gpio_set_config() have to convert a gpio_desc to a gpio_chip and offset. Avoid these duplicated conversion steps by letting gpio_set_config() take a gpio_desc pointer directly. Signed-off-by: Geert Uytterhoeven --- drivers/gpio/gpiolib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cf7ee9a0ddde6b45..8eeb29de12cb5811 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3244,9 +3244,9 @@ static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, return gc->set_config(gc, offset, config); } -static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, - enum pin_config_param mode) +static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) { + struct gpio_chip *chip = desc->gdev->chip; unsigned long config; unsigned arg; @@ -3261,7 +3261,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, } config = PIN_CONF_PACKED(mode, arg); - return gpio_do_set_config(gc, offset, config); + return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config); } static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) @@ -3277,7 +3277,7 @@ static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) bias = PIN_CONFIG_BIAS_PULL_DOWN; if (bias) { - ret = gpio_set_config(chip, gpio_chip_hwgpio(desc), bias); + ret = gpio_set_config(desc, bias); if (ret != -ENOTSUPP) return ret; } @@ -3435,8 +3435,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) gc = desc->gdev->chip; if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { /* First see if we can enable open drain in hardware */ - ret = gpio_set_config(gc, gpio_chip_hwgpio(desc), - PIN_CONFIG_DRIVE_OPEN_DRAIN); + ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_DRAIN); if (!ret) goto set_output_value; /* Emulate open drain by not actively driving the line high */ @@ -3446,8 +3445,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) } } else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { - ret = gpio_set_config(gc, gpio_chip_hwgpio(desc), - PIN_CONFIG_DRIVE_OPEN_SOURCE); + ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_SOURCE); if (!ret) goto set_output_value; /* Emulate open source by not actively driving the line low */ @@ -3456,8 +3454,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) goto set_output_flag; } } else { - gpio_set_config(gc, gpio_chip_hwgpio(desc), - PIN_CONFIG_DRIVE_PUSH_PULL); + gpio_set_config(desc, PIN_CONFIG_DRIVE_PUSH_PULL); } set_output_value: -- 2.17.1