Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7518810ybl; Tue, 24 Dec 2019 04:08:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzNMizBVp+/5js5fvEHD1NSoteb0qSByvpmnBWSz8rvBVyLn5rdmwWLB7ljQaRYtjcYxhXA X-Received: by 2002:a05:6830:1188:: with SMTP id u8mr38542894otq.274.1577189312687; Tue, 24 Dec 2019 04:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577189312; cv=none; d=google.com; s=arc-20160816; b=AvC/KV7x+fgoBa1CdnjGA86tYvAd8h265ygpI3y9jlt+pKkpxQmqv0OV6XQGtH7A+C g0cOQKylQKgreiwUS1n2fAHj0CAxm38P3WdYA0HzeZVrVBhOwFa7r1e6aV8jFwWvczNH O1R2+tB1MFgKBSXHDuVk2alvE0MmfYwvySyw6h/pTOzTmFdWEtXVVD1QIsRewwKc997c MlNKZJZMVHT2nm3QgPULDWk8gqReSUnBiGCvaHgdGw8pwtyecjzTBSa6IKn60FWquV30 Q2zH1NYefI4/igsFhT8haQW+dVvaTNpqSsEcM/u6M/WcTcZcjs8r6n0dgoi7juxTyOjV nM3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b9TsUyN+oyyXjUb/qESjsq0NNsFP2a1lN8TwiMljoxE=; b=toYZI7s4XURMMUHcoeJzAErKLPnTnx0he7QGwPuEXgHebBx1jOw6v0lJeqm9f7b7k2 3pAKwcvblW1T9O+gi4KVE4sqsOuzAhvDI6RQHrb5C9K8sLTrnBZXRu3+nJTRkxpU7JbK hz6AvYUAIzVzD8yp9aazTt43zj3p3L3OjdICUVeVHclRvd9uHQuWZN3PV+PIleGA31UT sYBQIot0MHwvKggWcQJSyH/hur2C56JguXtbNwPZh8HBz6X4fP1yFBzpeF1l4NsWs3IL aNfbOrvmhPI7+gGvTW2f/690fhCMDx3enRRzvhRh4Tl3L0BeD2GSnVbMx42jUMdP4pQS Cb/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=CNgMgsKN; 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 q16si11569887otk.226.2019.12.24.04.08.21; Tue, 24 Dec 2019 04:08:32 -0800 (PST) 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; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=CNgMgsKN; 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 S1726890AbfLXMH0 (ORCPT + 99 others); Tue, 24 Dec 2019 07:07:26 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53902 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbfLXMHV (ORCPT ); Tue, 24 Dec 2019 07:07:21 -0500 Received: by mail-wm1-f66.google.com with SMTP id m24so2258014wmc.3 for ; Tue, 24 Dec 2019 04:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b9TsUyN+oyyXjUb/qESjsq0NNsFP2a1lN8TwiMljoxE=; b=CNgMgsKNVBvdwio7z9GBftsi4FUdPBTsQmUtyMMh2unY2Wrze+jvvC12BLSoV2y71p 4U5iQegTgYvrlIBdk+vs2cy3Ub9kp8Kbzlx32AvzK9mDtDk2+YtjcdkVFBo/x22I4ueC KF3p1HK6wwk842g7keyhHp5oG8lpOEc2tEtY5TRUbd01xSVwBw30vdTKfaLBsmQ2AY2B Pe8Qfuc3ei3zHD4NaegaUY/rBTuW65HrXxBP0C3VR8WbdsZgqOLj5Zsz/1HQ2OauaDj3 u6CH/0TNiwH+pLVRhRnfeUvtqIYkAW3+lgbcBfhr6jMKdzJgCMxuxX3v/CD4XdAGzbgs Eitw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b9TsUyN+oyyXjUb/qESjsq0NNsFP2a1lN8TwiMljoxE=; b=GvrWPMGRX/VoR+peACv9MEo9jTi+coI5xtp/j4RY5UQJTU1mAtnRkxLEp4SSV2IsCR zaft7Ujq7wNrMCG9tVScKmn1HhF6xLrI7MoA6TawKf8yy8z0Tu1KueUxlMQgctoeXy6l AxBlCp42+D5ImwiFeVux2W84+R6FcNPkVC0+t24vS+5223bsJV8y3FZpsAhkagQu1744 QxCdBiUV3VwRyrlvZleYoHcQc7JYUF3G3Dh/YutkitY3/Xi3ijyd/Q2t1LnXKX8NWP4v VP0UvMEtQ1wW/8fn6GjERbEiPbVkh0NPj7O6cgF7qAp5QX4rEzPbM7HmX0jh6aUXJUDD w3vw== X-Gm-Message-State: APjAAAXfJbN15Wc9Mf0wEraixjNDnFVk7nAMHKh/p8pKyFBGToKoo6c+ a8msFKpYWZM2LUdwSAssBUVJ3g== X-Received: by 2002:a7b:c5d8:: with SMTP id n24mr4075908wmk.50.1577189239313; Tue, 24 Dec 2019 04:07:19 -0800 (PST) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id s10sm23829210wrw.12.2019.12.24.04.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 04:07:18 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v4 02/13] gpiolib: have a single place of calling set_config() Date: Tue, 24 Dec 2019 13:06:58 +0100 Message-Id: <20191224120709.18247-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191224120709.18247-1-brgl@bgdev.pl> References: <20191224120709.18247-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Instead of calling the gpiochip's set_config() callback directly and checking its existence every time - just add a new routine that performs this check internally. Call it in gpio_set_config() and gpiod_set_transitory(). Also call it in gpiod_set_debounce() and drop the check for chip->set() as it's irrelevant to this config option. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e5d101ee9ada..616e431039fc 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3042,6 +3042,15 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc); * rely on gpio_request() having been called beforehand. */ +static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, + enum pin_config_param mode) +{ + if (!gc->set_config) + return -ENOTSUPP; + + return gc->set_config(gc, offset, mode); +} + static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, enum pin_config_param mode) { @@ -3060,7 +3069,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, } config = PIN_CONF_PACKED(mode, arg); - return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP; + return gpio_do_set_config(gc, offset, mode); } static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) @@ -3294,15 +3303,9 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) VALIDATE_DESC(desc); chip = desc->gdev->chip; - if (!chip->set || !chip->set_config) { - gpiod_dbg(desc, - "%s: missing set() or set_config() operations\n", - __func__); - return -ENOTSUPP; - } config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); - return chip->set_config(chip, gpio_chip_hwgpio(desc), config); + return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config); } EXPORT_SYMBOL_GPL(gpiod_set_debounce); @@ -3339,7 +3342,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, !transitory); gpio = gpio_chip_hwgpio(desc); - rc = chip->set_config(chip, gpio, packed); + rc = gpio_do_set_config(chip, gpio, packed); if (rc == -ENOTSUPP) { dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", gpio); -- 2.23.0