All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] usb: phy: phy-generic: No need to call gpiod_direction_output() twice
       [not found]           ` <CAOMZO5AOevmZLKNSRygeWEGzQp-MLkp8pg8Jr536Y-xXPPTKZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-02-03 20:52             ` Felipe Balbi
       [not found]               ` <20150203205217.GA27736-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Felipe Balbi @ 2015-02-03 20:52 UTC (permalink / raw)
  To: Fabio Estevam, Linus Walleij
  Cc: Felipe Balbi, Robert Jarzmik, USB list, Fabio Estevam,
	Linux OMAP Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: phy: phy-generic: No need to call gpiod_direction_output() twice
       [not found]               ` <20150203205217.GA27736-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
@ 2015-02-03 21:14                 ` Fabio Estevam
  0 siblings, 0 replies; 2+ messages in thread
From: Fabio Estevam @ 2015-02-03 21:14 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Linus Walleij, Robert Jarzmik, USB list, Fabio Estevam,
	Linux OMAP Mailing List

On Tue, Feb 3, 2015 at 6:52 PM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:

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

Yes, I will send a v3 without the NULL check.

gpiod_set_value returns immediately if desc is NULL:

void gpiod_set_value(struct gpio_desc *desc, int value)
{
    if (!desc)
        return;
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-03 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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             ` [PATCH] usb: phy: phy-generic: No need to call gpiod_direction_output() twice Felipe Balbi
     [not found]               ` <20150203205217.GA27736-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-02-03 21:14                 ` Fabio Estevam

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.