Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp289934pxx; Thu, 29 Oct 2020 02:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznkNN9qPsb1WRudjvV7yKHbnnSNACyjYYw8uJSK5ECobA7+AA3AJ9NA//n4dmcuN+1I/7V X-Received: by 2002:a17:906:329b:: with SMTP id 27mr3010233ejw.329.1603964541978; Thu, 29 Oct 2020 02:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603964541; cv=none; d=google.com; s=arc-20160816; b=SaWdOjaclfqsxuiGuZPGzVrnRzfzAP26cBTr8cR9tCvjKBsF2YdkRoyxS3Nz9D6qAC UOzqp/anJ1M9ucI6YJQPx4M13acrySA8pJ+fjhwpVDE3fEHDxJYefImBUwLDQfKF7tdb jeBZSONJSBXyzTtzSBZgn4xy+/5/NEeaUKIE9dSeofTQiM8KrwGUok8CAGmFjCQaDi0f ZKsKJ1hWiPzgL0A1e2FAl77BWIWO32TN6RnDFXabvKdmgmnjgKvxNcNU4IMrfpdC6x0n M+pVKT93cWAvofN/Jn0pCP99TKqekCqqRzE13JvyaDaNOARFBnITkOIwTOnZNOxgv458 A2RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Yq/HD2p2UXGt7TQ9bcMnJo/aX/+JkANs44100D8poYQ=; b=gmO9OhUw61w/7b8FATyEVflXAyiWhQnDrKTx/N0vD6L55dkwiiGMWLroFEvlDo8aKW kUgqvROzeV5reHtmR/zzBdfIQCNfX3Bcr8Cs54guT2antDCOExERf3XndMe/cZhCMDnb nRbuZfU0B7m5Dpl8+cKqI2fTVvWsT/Mz+LKbqsqflbeDS3cm2mTAW6IYtBoxfTx2o+vN i4nVywdzA1ezwowW85lI5FEOoUDVm07lKARLw5iuo6OOUUnKH+8Zmyz55n71s0fUL3Be vtW3vxbzf0/IzP26SphdOSVVz3lRA6ysUI8yqF/dFeL/IVCjIwGZEK94exI9YwqkDLiN aT0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=A+JUmcBH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si1665032ejc.745.2020.10.29.02.41.59; Thu, 29 Oct 2020 02:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=A+JUmcBH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgJ2JjU (ORCPT + 99 others); Thu, 29 Oct 2020 05:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbgJ2JjU (ORCPT ); Thu, 29 Oct 2020 05:39:20 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D73DC0613D3 for ; Thu, 29 Oct 2020 02:39:18 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id j24so2849237ejc.11 for ; Thu, 29 Oct 2020 02:39:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Yq/HD2p2UXGt7TQ9bcMnJo/aX/+JkANs44100D8poYQ=; b=A+JUmcBH2PhQSHni38Yxh3pG6TqbFemyrIAYCY1MG5RLVEr+yA0yzKBmUu8qhq1TFy cS7CZR95snp+Ha7KBoP0aBh7jgLpf0WjJHX/nUvAntNcKoV09MLSVF5DDqzVM4OeCP1y LTlOMAnrGkv7y2R6lCVPu/cKvvi9Gjn/55l+SRAvFrg3BuHClNQ19vEnskRJ1VThh91f MQM82F6GxMsBPOvv7Lk/IKl4mJ6CB9MvbK80jq1cOyPBfVleVqjIu9ZZvTmzwqFP/N11 j1Qsp37eK0fQcJ9sNN2khgzxkBA5D2CchIJFJj2BCECDKNuNoGdeV93Uc5SxEhEsxlKa kszg== 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=Yq/HD2p2UXGt7TQ9bcMnJo/aX/+JkANs44100D8poYQ=; b=n5JZ6Sg8xbGIcCV7x7o+giOvUtOczBQFc3jLPOFJson6waJvX5izWk7w26u1T5gYJW FlORWgurW0eVinn3U3ZgVkpK/+/nujYpc9m6HLnQ8oo23//0IlJIJ+ovYAygJVNzb/1d fGNnTjUSVAYLFFcZ+UMFaKeDFFaXBmrCHTYJcjGxNASJQRVD5t1PszmXNpzMeoVDbDnW 0QcITLsWzbTj34q4krpFjN43Yj+gISGnGHpyWn5vNdzkNFriNEvpmdPvXMfxgjelCBt5 EEOzrdR7qdf6QQglb3p7rz1NYoOztxS72RbpXXTTyiQX1Wte3tPUXTs/dhwIIzscs5Y2 8Yeg== X-Gm-Message-State: AOAM530eyDS4qLKGvQ6f6HZ2GqTAKm//fp6YGhWsHX8iaf6CPub9JEHy kZLwxqfEGRRfXpzJHRjZ7g6TEgXrVgvhvEtptso1mA== X-Received: by 2002:a17:906:14d:: with SMTP id 13mr3119677ejh.516.1603964356832; Thu, 29 Oct 2020 02:39:16 -0700 (PDT) MIME-Version: 1.0 References: <20201029081721.9593-1-vincent.whitchurch@axis.com> In-Reply-To: <20201029081721.9593-1-vincent.whitchurch@axis.com> From: Bartosz Golaszewski Date: Thu, 29 Oct 2020 10:39:06 +0100 Message-ID: Subject: Re: [PATCH v4] gpio: mockup: Allow probing from device tree To: Vincent Whitchurch Cc: Bamvor Jian Zhang , Linus Walleij , kernel@axis.com, linux-devicetree , Andy Shevchenko , linux-gpio , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2020 at 9:17 AM Vincent Whitchurch wrote: > > Allow the mockup driver to be probed via the device tree without any > module parameters, allowing it to be used to configure and test higher > level drivers like the leds-gpio driver and corresponding userspace > before actual hardware is available. > > Signed-off-by: Vincent Whitchurch > --- > > Notes: > v4: > - Remove of_match_ptr() to fix unused variable warning with W=1 > - Include linux/mod_devicetable.h instead of linux/of.h > > v3: > - Keep includes sorted alphabetically > - Drop CONFIG_OF ifdefs > > v2: > - Remove most of the added code, since the latest driver doesn't need it. > - Drop DT binding document, since Rob Herring was OK with not documenting this: > https://lore.kernel.org/linux-devicetree/5baa1ae6.1c69fb81.847f2.3ab1@mx.google.com/ > > Range-diff against v3: > 1: 1e9b8f36676d ! 1: 4e8fdcfe1a47 gpio: mockup: Allow probing from device tree > @@ Commit message > > > ## Notes ## > + v4: > + - Remove of_match_ptr() to fix unused variable warning with W=1 > + - Include linux/mod_devicetable.h instead of linux/of.h > + > v3: > - Keep includes sorted alphabetically > - Drop CONFIG_OF ifdefs > @@ Notes > > ## drivers/gpio/gpio-mockup.c ## > @@ > + #include > #include > #include > ++#include > #include > -+#include > #include > #include > - #include > @@ drivers/gpio/gpio-mockup.c: static int gpio_mockup_probe(struct platform_device *pdev) > return 0; > } > @@ drivers/gpio/gpio-mockup.c: static int gpio_mockup_probe(struct platform_device > static struct platform_driver gpio_mockup_driver = { > .driver = { > .name = "gpio-mockup", > -+ .of_match_table = of_match_ptr(gpio_mockup_of_match), > ++ .of_match_table = gpio_mockup_of_match, > }, > .probe = gpio_mockup_probe, > }; > Please don't do the above. > drivers/gpio/gpio-mockup.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c > index 67ed4f238d43..28b757d34046 100644 > --- a/drivers/gpio/gpio-mockup.c > +++ b/drivers/gpio/gpio-mockup.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -460,9 +461,16 @@ static int gpio_mockup_probe(struct platform_device *pdev) > return 0; > } > > +static const struct of_device_id gpio_mockup_of_match[] = { > + { .compatible = "gpio-mockup", }, > + {}, > +}; > +MODULE_DEVICE_TABLE(of, gpio_mockup_of_match); > + > static struct platform_driver gpio_mockup_driver = { > .driver = { > .name = "gpio-mockup", > + .of_match_table = gpio_mockup_of_match, > }, > .probe = gpio_mockup_probe, > }; > @@ -556,8 +564,7 @@ static int __init gpio_mockup_init(void) > { > int i, num_chips, err; > > - if ((gpio_mockup_num_ranges < 2) || > - (gpio_mockup_num_ranges % 2) || > + if ((gpio_mockup_num_ranges % 2) || > (gpio_mockup_num_ranges > GPIO_MOCKUP_MAX_RANGES)) > return -EINVAL; > > -- > 2.28.0 > Applied now, thanks! Bartosz