From patchwork Sat Nov 14 08:38:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bamvor Zhang Jian X-Patchwork-Id: 56558 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp241939lbb; Sat, 14 Nov 2015 00:39:16 -0800 (PST) X-Received: by 10.68.231.168 with SMTP id th8mr18817136pbc.22.1447490356403; Sat, 14 Nov 2015 00:39:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fi15si22366894pac.191.2015.11.14.00.39.16; Sat, 14 Nov 2015 00:39:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-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-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbbKNIjP (ORCPT + 4 others); Sat, 14 Nov 2015 03:39:15 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:36771 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbbKNIjP (ORCPT ); Sat, 14 Nov 2015 03:39:15 -0500 Received: by pacdm15 with SMTP id dm15so123311273pac.3 for ; Sat, 14 Nov 2015 00:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bXD+2XManNYBkY/aOyqb39hxlGLAQ47WbB/bnBtjD/M=; b=O+2A+r8jAEmf1ycd6oDlyoO3hK6rUlgtgGQoL5hsROZmmlUZbemTT0oKZGfhARc5j+ np0OXzfGpQw0em4XPY2iV/Ww6tUaHw+c/5z8d8UjeZMyMyV+WWy5ByQPJ7n3mAx7VNs9 pmjeYYfFfxbcuz3ZRNoEMzE6S9mehWSgbZA3VOLwEimpCR3cwGhVhIyZdqN879cqzWUx gPf/QH/XKTsNphPcLrSXP172Lu+q34kzK/u5LYUwGypMrx0ZVkQO5PKJuV0EKaMTyVGD YT1MfXCFaiuFe6l2Y17z1GsxtJLejjTTm+ymXDtvq/8Id52D3BLxXRjHyriu3I+EKZ47 8oog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bXD+2XManNYBkY/aOyqb39hxlGLAQ47WbB/bnBtjD/M=; b=D7lsNfePoKQ1zDUDR+NxY2YWEfCHmYkUpC3T4Rzp2kUWlaFtcwW2N+AiFcVYXtdn5r pGuUfhD4+CaPRZ/seGMVSBW6cRXNdo0/BaTsXj0iPmZQ03v+hUEwuwBtk41hr+8d+jRj OitGO4znUVCaZwuvMo9bZ1WwGfclGDRq/XoaKuxMdfQDB4L0MyLMScyIrXCUDwl7mF7Q K6g18oIEtb3JmM8cRWN6jx/5FND6kzdEBwu4eqRQ+7M0NsZd6Vk2y+kA8yMsTurjJJ4C 4mgDzpjMn6r2R2cD3geUdJ1pj5T/6GltHdfn40faDOS6Dci/i33UN40F42fAuPfbJJOh qa8w== X-Gm-Message-State: ALoCoQmrJuUsOdPoYes0Fqa0p6oC1+SognsESxpMNJMgnAE5vbVDiOjD+Jt8r2KWGcG3DLXmFFy0 X-Received: by 10.68.230.170 with SMTP id sz10mr38691238pbc.139.1447490354761; Sat, 14 Nov 2015 00:39:14 -0800 (PST) Received: from linux-j170.site ([116.251.213.227]) by smtp.gmail.com with ESMTPSA id ur1sm8863768pbc.44.2015.11.14.00.39.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Nov 2015 00:39:14 -0800 (PST) From: Bamvor Jian Zhang To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, broonie@kernel.org, Bamvor Jian Zhang Subject: [PATCH 2/2] gpiolib: do not allow to insert an empty gpiochip Date: Sat, 14 Nov 2015 16:38:56 +0800 Message-Id: <1447490336-10209-3-git-send-email-bamvor.zhangjian@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447490336-10209-1-git-send-email-bamvor.zhangjian@linaro.org> References: <1447490336-10209-1-git-send-email-bamvor.zhangjian@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We need to check if number of gpio is positive if there is no such check in devicetree or acpi or whatever called before gpiochip_add. I suppose that devicetree and acpi do not allow insert gpiochip with zero number but I do not know if it is enough to ignore this check in gpiochip_add. Signed-off-by: Bamvor Jian Zhang --- drivers/gpio/gpiolib.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc135d9..868ff15 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -327,6 +327,9 @@ int gpiochip_add(struct gpio_chip *chip) if (!descs) return -ENOMEM; + if (chip->ngpio == 0) + return -EINVAL; + spin_lock_irqsave(&gpio_lock, flags); if (base < 0) {