Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753603AbcD1J6H (ORCPT ); Thu, 28 Apr 2016 05:58:07 -0400 Received: from mail-oi0-f54.google.com ([209.85.218.54]:34813 "EHLO mail-oi0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbcD1J6F convert rfc822-to-8bit (ORCPT ); Thu, 28 Apr 2016 05:58:05 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 28 Apr 2016 12:58:03 +0300 Message-ID: Subject: Re: [RFC v4 3/8] gpio: generic: add DT support for generic memory-mapped GPIOs From: Andy Shevchenko To: Christian Lamparter Cc: "linux-gpio@vger.kernel.org" , devicetree , "linux-kernel@vger.kernel.org" , linux-arm Mailing List , =?UTF-8?B?w4FsdmFybyBGZXJuw6FuZGV6IFJvamFz?= , Kumar Gala , Alexander Shiyan , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring , Alexandre Courbot , Linus Walleij Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2170 Lines: 80 On Thu, Apr 28, 2016 at 12:05 PM, Christian Lamparter wrote: > From: Álvaro Fernández Rojas > > This patch adds support for defining memory-mapped GPIOs > which provide a compatible interface for the existing > generic-gpio driver. > +static inline void set_resource_address(struct resource *res, > + resource_size_t start, > + resource_size_t len) > +{ > + res->start = start; > + res->end = start + len - 1; > +} It might make sense to put this in the generic (resource related, e.g. ioport.h) header. There are plenty users of such already and who knows how many will come. > #include > #include > #include > +#include > +#include Perhaps + empty line? > +#include "gpio-mmio-compat.h" [] > +#ifdef CONFIG_OF > +static int bgpio_basic_mmio_parse_dt(struct platform_device *pdev, > + struct bgpio_pdata *pdata, > + unsigned long *flags) > +{ > + struct device *dev = &pdev->dev; > + int err; > + > + err = of_property_read_u32(dev->of_node, "ngpio", &pdata->ngpio); > + if (err && err != -EINVAL) > + return err; I think check for -EINVAL needs explanation. > +} [] > + pdata = bgpio_parse_dt(pdev, &flags); > + if (IS_ERR(pdata)) { > + return PTR_ERR(pdata); > + } else if (!pdata) { Redundant else > + pdata = dev_get_platdata(dev); > + flags = pdev->id_entry->driver_data; > + } > > r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); > if (!r) > @@ -646,6 +734,9 @@ MODULE_DEVICE_TABLE(platform, bgpio_id_table); > static struct platform_driver bgpio_driver = { > .driver = { > .name = "basic-mmio-gpio", > +#ifdef CONFIG_OF Doesn't of_match_ptr do this for you? > + .of_match_table = of_match_ptr(bgpio_of_match), > +#endif -- With Best Regards, Andy Shevchenko