All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"open list:LINUX FOR POWERPC PA SEMI PWRFICIENT"
	<linuxppc-dev@lists.ozlabs.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	"Albert Herranz" <albert_herranz@yahoo.es>,
	"Segher Boessenkool" <segher@kernel.crashing.org>,
	"Linus Walleij" <linus.walleij@linaro.org>
Subject: Re: [PATCH v2 3/6] gpio: Add GPIO driver for Nintendo Wii
Date: Wed, 31 Jan 2018 09:37:17 +0100	[thread overview]
Message-ID: <20180131083717.xhwaepwd6qxeqncv@latitude> (raw)
In-Reply-To: <CAHp75VcWshngZFuUp4hzYdD43HF7TZ1sRE3Dh+HckB5do1=gGw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]

Hi,

On Sun, Jan 28, 2018 at 07:31:58PM +0200, Andy Shevchenko wrote:
> On Mon, Jan 22, 2018 at 7:04 AM, Jonathan Neuschäfer
> <j.neuschaefer@gmx.net> wrote:
> 
> Style issues below.
> 
> > +#define HW_GPIO_OWNER          0x3c
> > +
> > +
> > +struct hlwd_gpio {
> 
> No need extra empty line in between.

Ok.

> > +       struct gpio_chip gpioc;
> > +       void __iomem *regs;
> > +       struct device *dev;
> > +};
> > +
> > +static int hlwd_gpio_probe(struct platform_device *pdev)
> > +{
> > +       struct hlwd_gpio *hlwd;
> > +       struct resource *regs_resource;
> > +       u32 ngpios;
> > +       int res;
> > +
> > +       hlwd = devm_kzalloc(&pdev->dev, sizeof(*hlwd), GFP_KERNEL);
> > +       if (!hlwd)
> > +               return -ENOMEM;
> > +
> 
> > +       /* Save the struct device pointer so dev_info, etc. can be used. */
> 
> Useless.

Ok

> > +       hlwd->dev = &pdev->dev;
> > +
> 
> > +       regs_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> 
> > +       if (IS_ERR(regs_resource))
> > +               return PTR_ERR(regs_resource);
> > +
> 
> This is redundant. Below does it for ya.

devm_ioremap_resource does not check if the resource argument is a
negative error (which is what I'm trying to catch in the above code).
But it seems that platform_get_resource can't return a negative error,
so you're right. Thanks.

> 
> > +       hlwd->regs = devm_ioremap_resource(&pdev->dev, regs_resource);
> > +       if (IS_ERR(hlwd->regs))
> > +               return PTR_ERR(hlwd->regs);
> 
> 
> > +       res = bgpio_init(&hlwd->gpioc, &pdev->dev, 4,
> > +                       hlwd->regs + HW_GPIOB_IN, hlwd->regs + HW_GPIOB_OUT,
> > +                       NULL, hlwd->regs + HW_GPIOB_DIR, NULL,
> > +                       BGPIOF_BIG_ENDIAN_BYTE_ORDER);
> 
> > +
> 
> Remove this extra line.

Ok.

> 
> > +       if (res < 0) {
> > +               dev_warn(hlwd->dev, "bgpio_init failed: %d\n", res);
> > +               return res;
> > +       }
> 
> > +       if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios))
> > +               ngpios = 32;
> 
> A nit: I would rather go with
> res = of_property_read(...);
> if (res)
>   ngpios = 32;

Ok, I have no strong opinion on this, so I'll do what you suggest.


Thanks,
Jonathan Neuschäfer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2018-01-31  8:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  5:04 [PATCH v2 0/6] Nintendo Wii GPIO driver Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 1/6] resource: Extend the PPC32 reserved memory hack Jonathan Neuschäfer
     [not found]   ` <20180122050411.32460-2-j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
2018-01-23 12:58     ` Michael Ellerman
2018-01-23 12:58       ` Michael Ellerman
2018-01-23 12:58       ` Michael Ellerman
2018-01-23 16:37       ` Jonathan Neuschäfer
2018-01-24  1:23         ` Michael Ellerman
2018-01-24  1:23           ` Michael Ellerman
2018-01-24  1:23           ` Michael Ellerman
2018-01-27  8:00           ` Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 2/6] powerpc: wii: Explicitly configure GPIO owner for poweroff pin Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 3/6] gpio: Add GPIO driver for Nintendo Wii Jonathan Neuschäfer
2018-01-28 17:31   ` Andy Shevchenko
2018-01-28 17:31     ` Andy Shevchenko
2018-01-31  8:37     ` Jonathan Neuschäfer [this message]
2018-02-07 12:29   ` Linus Walleij
2018-02-07 12:29     ` Linus Walleij
2018-02-07 12:54     ` Jonathan Neuschäfer
2018-01-22  5:04 ` [PATCH v2 4/6] dt-bindings: gpio: Add binding for Wii GPIO controller Jonathan Neuschäfer
2018-02-07 12:26   ` Linus Walleij
2018-02-07 12:26     ` Linus Walleij
2018-01-22  5:04 ` [PATCH v2 5/6] powerpc: wii.dts: Add ngpios property Jonathan Neuschäfer
     [not found] ` <20180122050411.32460-1-j.neuschaefer-hi6Y0CQ0nG0@public.gmane.org>
2018-01-22  5:04   ` [PATCH v2 6/6] powerpc: wii.dts: Add GPIO line names Jonathan Neuschäfer
2018-01-22  5:04     ` Jonathan Neuschäfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180131083717.xhwaepwd6qxeqncv@latitude \
    --to=j.neuschaefer@gmx.net \
    --cc=albert_herranz@yahoo.es \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.