Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>,
	Robert Jarzmik <robert.jarzmik-GANU6spQydw@public.gmane.org>,
	USB list <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Fabio Estevam
	<fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Linux OMAP Mailing List
	<linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] usb: phy: phy-generic: No need to call gpiod_direction_output() twice
Date: Tue, 3 Feb 2015 14:52:17 -0600	[thread overview]
Message-ID: <20150203205217.GA27736@saruman.tx.rr.com> (raw)
In-Reply-To: <CAOMZO5AOevmZLKNSRygeWEGzQp-MLkp8pg8Jr536Y-xXPPTKZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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

On Tue, Feb 03, 2015 at 06:21:24PM -0200, Fabio Estevam wrote:
> Hi Felipe,
> 
> On Sun, Feb 1, 2015 at 3:37 PM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:
> 
> > I like this, very much. Two comments though. We requested the gpio with
> > _optional(), and NULL is a valid gpio_desc, this if (nop->gpiod_reset)
> > is unnecessary. And also, since we don't have anymore the assert
> 
> But if the reset-gpios property is not present in the dts, then
> nop->gpiod_reset is NULL, and it is better not to call
> 'gpiod_direction_output(nop->gpiod_reset, 1)'  in this case, right?

it doesn't make a difference though, right ?
gpiod_direction_output(NULL, 1) won't do anything.

/me goes look at code

Man this is messed up. If you follow gpiod_get_optional, you'll end up
at gpiod_get_index_optional() which I quote below:

1989 struct gpio_desc *__must_check __gpiod_get_index_optional(struct device *dev,
1990                                                         const char *con_id,
1991                                                         unsigned int index,
1992                                                         enum gpiod_flags flags)
1993 {
1994         struct gpio_desc *desc;
1995 
1996         desc = gpiod_get_index(dev, con_id, index, flags);
1997         if (IS_ERR(desc)) {
1998                 if (PTR_ERR(desc) == -ENOENT)
1999                         return NULL;
2000         }
2001 
2002         return desc;
2003 }
2004 EXPORT_SYMBOL_GPL(__gpiod_get_index_optional);

So, if the error code is -ENOENT it returns NULL, that tells me NULL is
a valid gpio descriptor. If you follow gpiod_direction_output() however,
what you get is:

1072 int gpiod_direction_output(struct gpio_desc *desc, int value)
1073 {
1074         if (!desc || !desc->chip) {
1075                 pr_warn("%s: invalid GPIO\n", __func__);
1076                 return -EINVAL;
1077         }
1078         if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
1079                 value = !value;
1080         return _gpiod_direction_output_raw(desc, value);
1081 }
1082 EXPORT_SYMBOL_GPL(gpiod_direction_output);

That pr_warn() tells me NULL is *not* a valid gpio descriptor. Linus, is
that just something that was missed until now ?

> > argument, we should rename nop_reset_set() to nop_reset.
> 
> Agreed, will change it in v2.

Thanks

-- 
balbi

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

       reply	other threads:[~2015-02-03 20:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1422653236-7142-1-git-send-email-festevam@gmail.com>
     [not found] ` <20150130215939.GC30049@saruman.tx.rr.com>
     [not found]   ` <CAOMZO5A=J7HF+AR8aB2CA+we7knoas-vDtLMbh3gVNvgb1aEAg@mail.gmail.com>
     [not found]     ` <CAOMZO5DeyqtjDq0a4_qX2SPbaDZunQbSJimrH23gju1mmdA7vQ@mail.gmail.com>
     [not found]       ` <20150201173750.GA16306@saruman.tx.rr.com>
     [not found]         ` <CAOMZO5AOevmZLKNSRygeWEGzQp-MLkp8pg8Jr536Y-xXPPTKZw@mail.gmail.com>
     [not found]           ` <CAOMZO5AOevmZLKNSRygeWEGzQp-MLkp8pg8Jr536Y-xXPPTKZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-03 20:52             ` Felipe Balbi [this message]
     [not found]               ` <20150203205217.GA27736-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-02-03 21:14                 ` [PATCH] usb: phy: phy-generic: No need to call gpiod_direction_output() twice Fabio Estevam

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=20150203205217.GA27736@saruman.tx.rr.com \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robert.jarzmik-GANU6spQydw@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox