Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1044013ybl; Tue, 3 Dec 2019 00:18:48 -0800 (PST) X-Google-Smtp-Source: APXvYqy0+mATluhSAbR2LBpd9eTnVmpd5s4UUVfA5ARNZP96HcdtdXDpH+5RAqG2zyLXnm5Cyr0l X-Received: by 2002:a05:6830:130d:: with SMTP id p13mr940522otq.161.1575361128905; Tue, 03 Dec 2019 00:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575361128; cv=none; d=google.com; s=arc-20160816; b=bSX7c4hwuLc/2r9dE1fnQIMYFr63300x3NpParJf0fgJ6SxKaIbflgxyEkeIWEzsnI 3eyc4ZaD0udnZeCzApCDFr83qZbCdwKo/0wQT8GPGF2l5MoKS/qu62ABMHgJjazkdLKV vY9j0jc4fuPRm86+n0DCp861hPX4V1z47gN4G60HkwDw8XtIX9XOUUj/VlUN9+7xu13Q KyN3z8ql8LB3lmvgbj1XOuJtG0AolqMYuL9AAuQnm2p7VrB7IFuJRVL/OlqtfftHbV+Q iN61Hgq/B72MPorsm+wlAZQS/7vpgI/NacZCkRhBLHRLbTqYQTPCQHxpvpJzFYvv7DhZ o4Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=gBtOE1GdWf2jzATlRbrF8r8Pac6d5nQ4OzH7cwGAR94=; b=dFKg0Zv1wFsIa/ShJ3rh6eZdrBid9gjwFRiavWA10hslYXVUbYGfnaMgAfB2uEJ+bP x+9Nwpie8Sszxt3CMFFw2c0W5uZmZ+WB9RFG42FzI4DSA1Z1zoeflXf8+4u1OuGul+bH O1C9g8FPTBxw8yhWLGzyrJ9rj2IEo/+Omp7tausqsnuTZFqIt8MtXRP2b9SM7IxWQDFg Zasg4LxwjBM2VZiAx2eHotrhQOnxPTFmBEkGIkQrgrvOKl+m0RkHHK5D103wzEtwYlDL qwWNAVU/mKGkhOtd4qXwz87OecxIE7hUpjJPFmahQZtWG2Tk3HYeeWDPlvjjOzwEGakI iuSA== 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 q8si910711otg.108.2019.12.03.00.18.36; Tue, 03 Dec 2019 00:18:48 -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; 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 S1726469AbfLCISL (ORCPT + 99 others); Tue, 3 Dec 2019 03:18:11 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:39478 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbfLCISK (ORCPT ); Tue, 3 Dec 2019 03:18:10 -0500 Received: by mail-ot1-f67.google.com with SMTP id 77so2148995oty.6; Tue, 03 Dec 2019 00:18:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gBtOE1GdWf2jzATlRbrF8r8Pac6d5nQ4OzH7cwGAR94=; b=b+m13b3CkvQfHjFMmIRLCWHuM3weg+qEBDCakTYL5msGW+URm18UNn563N0Kqw0ut0 xP+lH3/HGq2BMU+spjBBYcC9Cb+78tpW7yy3ySLggmRmVByCMwTFY/4Ucgo7Akiw1A75 mKq37EDgN3klAjpfcS9hSaEsn9XhutvYasivZbdaNzFibSZb9eIiq/vjmdYT4bGqye72 69xqvTZx6uZbXcVaAdCu+pl7J5bICfLM9oM9eT7tn7grjfm7cRGDm/txW5VVZiZgdymC 7cmXLlpLlGXahovpcl0/xVYTkBbjErfggae43lJxfDghOHpRjJJGJmo0ixWOGHuKJ+vc ZRPQ== X-Gm-Message-State: APjAAAVRpMyApozG4Ibe0l5j8+hA7Rzmk6Tvm+WtGxmLkU6Kbl8uBdd3 jMSNYPA4mZ0hGvW5CIcvZwYnulIG/ppA1P/HhL8= X-Received: by 2002:a9d:3a37:: with SMTP id j52mr2353717otc.39.1575361089532; Tue, 03 Dec 2019 00:18:09 -0800 (PST) MIME-Version: 1.0 References: <20191127084253.16356-1-geert+renesas@glider.be> <20191127084253.16356-6-geert+renesas@glider.be> <585c4ad9-31fc-e87e-07c4-b8d6aa09c7e4@mentor.com> In-Reply-To: <585c4ad9-31fc-e87e-07c4-b8d6aa09c7e4@mentor.com> From: Geert Uytterhoeven Date: Tue, 3 Dec 2019 09:17:58 +0100 Message-ID: Subject: Re: [PATCH v3 5/7] gpio: Add GPIO Aggregator/Repeater driver To: Harish Jenny K N Cc: Geert Uytterhoeven , Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Rob Herring , Mark Rutland , Eugeniu Rosca , Alexander Graf , Peter Maydell , Paolo Bonzini , Phil Reid , Marc Zyngier , Christoffer Dall , Magnus Damm , "open list:GPIO SUBSYSTEM" , "open list:DOCUMENTATION" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-Renesas , Linux Kernel Mailing List , QEMU Developers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Harish, On Tue, Dec 3, 2019 at 6:42 AM Harish Jenny K N wrote: > > +static int gpio_aggregator_probe(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + struct gpio_desc **descs; > > + struct gpiochip_fwd *fwd; > > + int i, n; > > + > > + n = gpiod_count(dev, NULL); > > + if (n < 0) > > + return n; > > + > > + descs = devm_kmalloc_array(dev, n, sizeof(*descs), GFP_KERNEL); > > + if (!descs) > > + return -ENOMEM; > > + > > + for (i = 0; i < n; i++) { > > + descs[i] = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS); > > can you please add this check as well as we need to return EPROBE_DEFER. > > if (desc[i] == ERR_PTR(-ENOENT)) > < return -EPROBE_DEFER; So gpiod_get_index() nevers return -EPROBE_DEFER, but returns -ENOENT instead? How can a driver distinguish between "GPIO not found" and "gpiochip driver not yet initialized"? Worse, so the *_optional() variants will return NULL in both cases, too, so the caller will always fall back to optional GPIO not present? Or am I missing something? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds