From patchwork Wed Jul 11 16:33:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 942597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41Ql4S31Lcz9rxs for ; Thu, 12 Jul 2018 02:33:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387727AbeGKQie (ORCPT ); Wed, 11 Jul 2018 12:38:34 -0400 Received: from sauhun.de ([88.99.104.3]:51778 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387712AbeGKQie (ORCPT ); Wed, 11 Jul 2018 12:38:34 -0400 Received: from localhost (p54B3362F.dip0.t-ipconnect.de [84.179.54.47]) by pokefinder.org (Postfix) with ESMTPSA id 0C6E956A486; Wed, 11 Jul 2018 18:33:24 +0200 (CEST) From: Wolfram Sang To: linux-gpio@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Linus Walleij , Geert Uytterhoeven , Wolfram Sang Subject: [PATCH] gpiolib: use better errno if get_direction is not available Date: Wed, 11 Jul 2018 18:33:19 +0200 Message-Id: <20180711163319.28004-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org EINVAL is very generic, use ENOTSUPP in case the gpiochip does not provide this function. While removing the assignment from the 'status' variable, use better indentation in the declaration block. Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman Reviewed-by: Linus Walleij --- I got puzzled by the EINVAL until I found out that gpio-rcar simply does not implement it. @Geert: any reason gpio-rcar is missing it? I would need it for the i2c-gpio-fault-injector. drivers/gpio/gpiolib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..18719f64e80b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -210,15 +210,15 @@ static int gpiochip_find_base(int ngpio) */ int gpiod_get_direction(struct gpio_desc *desc) { - struct gpio_chip *chip; - unsigned offset; - int status = -EINVAL; + struct gpio_chip *chip; + unsigned offset; + int status; chip = gpiod_to_chip(desc); offset = gpio_chip_hwgpio(desc); if (!chip->get_direction) - return status; + return -ENOTSUPP; status = chip->get_direction(chip, offset); if (status > 0) {