Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4645482ybl; Wed, 22 Jan 2020 01:58:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzjC69X7w+jN5enBcwgR3WDUyJSOf97WWWFcUwGtyu2KwKy2bb5S9DW7Y1SwUXB38sOWnzI X-Received: by 2002:aca:530e:: with SMTP id h14mr6070617oib.105.1579687104505; Wed, 22 Jan 2020 01:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579687104; cv=none; d=google.com; s=arc-20160816; b=IzEyxw8zwYdhxhAMGCR1g1DSOWa7cfexYtrliFA3ShXxkTPeMuOYiKaVKfFYmHCFb9 7TXY9XcaGv5NDYThTpmOgw7K721uFldPfOAGroqpMgQ+ijy+0IfUhjblQx6fksdv3a4I Iuqwwup5RRBtxQ43Xkn+VJ8LjBdYxIP8HXrqIfFe6Zs4/f/XzQNjQoTAVyAcW/tK10Qy 4vfa/CIfNuKe6Mog6bE8T4ku0iMVyPde5qIFUkrnYR0D9NTuAaixsSwdbGKUKEODZgJC uy9nt0GrDXKLuGw0IgyJF5D79TrYMdZGyDpcyyxhI3E+YU7u57oN414idnAjeePJ50Jz o98Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wUMWvxsRzLyOpMxh4eu54nF30XUioTAHKUVQdhKWSfU=; b=JEZr8Gj9V42qh4x1Odfqc5s/QPSfMaQS5DOskzgpbWQRjh65jtWMkWy3xwnP09lLHv 7hoeQ7OyyRKMPHhV/8o5P9o1/TxrpFdNr0HsWqyrQr20PQDJyLROZCPUlGx2OHVPTGLp McDG6OqOPrkW8kJ7c5mBtCNCeQfVB12TCKC97JXC6mJf/T4J4ITEAqE0G+l7bkNXL4YG Mtn27/OE4O2sajumLdVq9Uy8/xgahwA7fIbBe/Wb3o4OKqv9g1Ju0idK01qsx2DSAezR +H4G+/agdI8VT3eVMJumSsu9cDT9dG4BWtV76tKEQIs5bDFX6oOEIWu7GhedvOPXVYaF GDFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w2wyqve+; 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 25si20662707oix.178.2020.01.22.01.58.13; Wed, 22 Jan 2020 01:58:24 -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=@kernel.org header.s=default header.b=w2wyqve+; 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 S1729441AbgAVJa5 (ORCPT + 99 others); Wed, 22 Jan 2020 04:30:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:42618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729418AbgAVJay (ORCPT ); Wed, 22 Jan 2020 04:30:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E4A524672; Wed, 22 Jan 2020 09:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685453; bh=53AOoU1G7jey+hqH9owKJVKmsYlL8quByNMFxxxTPxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w2wyqve+EsMHp2+ysisWX4U6LgVCX3I9u7DI3NL8aVMeIk/K2GHOAMGH5mMm3Q9vU irrPLMDvdqetMnbPlgRYeO2sVagkVC3Dh+qOEnK0T7glX10tc/fMdirC0sIBH+Cu/a b6G7s6C7KxfQZBWuIvIhmY8bNLF5K2UFv7YeIxwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Linus Walleij Subject: [PATCH 4.4 20/76] gpio: Fix error message on out-of-range GPIO in lookup table Date: Wed, 22 Jan 2020 10:28:36 +0100 Message-Id: <20200122092753.687226381@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092751.587775548@linuxfoundation.org> References: <20200122092751.587775548@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven commit d935bd50dd14a7714cbdba9a76435dbb56edb1ae upstream. When a GPIO offset in a lookup table is out-of-range, the printed error message (1) does not include the actual out-of-range value, and (2) contains an off-by-one error in the upper bound. Avoid user confusion by also printing the actual GPIO offset, and correcting the upper bound of the range. While at it, use "%u" for unsigned int. Sample impact: -requested GPIO 0 is out of range [0..32] for chip e6052000.gpio +requested GPIO 0 (45) is out of range [0..31] for chip e6052000.gpio Fixes: 2a3cf6a3599e9015 ("gpiolib: return -ENOENT if no GPIO mapping exists") Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20191127095919.4214-1-geert+renesas@glider.be Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1949,8 +1949,9 @@ static struct gpio_desc *gpiod_find(stru if (chip->ngpio <= p->chip_hwnum) { dev_err(dev, - "requested GPIO %d is out of range [0..%d] for chip %s\n", - idx, chip->ngpio, chip->label); + "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n", + idx, p->chip_hwnum, chip->ngpio - 1, + chip->label); return ERR_PTR(-EINVAL); }