lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdaVtkWXmf8ON=3Pa2CYZKWRw2am+ULfzsTBPmXjbP44PA@mail.gmail.com>
Date:	Tue, 2 Dec 2014 15:25:36 +0100
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Benoit Parrot <bparrot@...com>
Cc:	Alexandre Courbot <gnurou@...il.com>,
	Pantelis Antoniou <panto@...oniou-consulting.com>,
	Jiri Prchal <jiri.prchal@...ignal.cz>,
	Maxime Ripard <maxime.ripard@...e-electrons.com>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>
Subject: Re: [Patch v2 1/2] gpio: add GPIO hogging mechanism

On Tue, Dec 2, 2014 at 1:22 AM, Benoit Parrot <bparrot@...com> wrote:
> Alexandre Courbot <gnurou@...il.com> wrote on Fri [2014-Nov-28 16:30:01 +0900]:
>> On Fri, Nov 21, 2014 at 8:54 AM, Benoit Parrot <bparrot@...com> wrote:

>> > +       }
>> > +
>> > +       if (tmp > MAX_PHANDLE_ARGS) {
>> > +               desc = ERR_PTR(-EINVAL);
>> > +               goto out;
>> > +       }
>> > +
>> > +       gg_data.gpiospec.args_count = tmp;
>> > +       gg_data.gpiospec.np = chip_np;
>> > +       for (i = 0; i < tmp; i++) {
>> > +               ret = of_property_read_u32(np, "gpios",
>> > +                                          &gg_data.gpiospec.args[i]);
>> > +               if (ret) {
>> > +                       desc = ERR_PTR(ret);
>> > +                       goto out;
>> > +               }
>> > +       }
>> > +
>> > +       gpiochip_find(&gg_data, of_gpiochip_find_and_xlate);
>>
>> This seems to work but only supports one GPIO per hog node. It would
>> be nice to be able to specify several GPIOs to which the same settings
>> need to be applied.
>
> This is on purpose following Linus Walleij's comment.

Yes, I think either we have separate nodes for each hogged line *OR*
we just put a list of hogs under the gpiochip, no special node at all.

The one-node-per-hog pattern has the upside of being usable
to also name the hogs. (Exporting them is dubious however!
I would add a special type of node for that.)

>> > +       if (err < 0)
>> > +               return err;
>> > +
>> > +       if (lflags & GPIO_ACTIVE_LOW)
>> > +               set_bit(FLAG_ACTIVE_LOW, &desc->flags);
>> > +       if (lflags & GPIO_OPEN_DRAIN)
>> > +               set_bit(FLAG_OPEN_DRAIN, &desc->flags);
>> > +       if (lflags & GPIO_OPEN_SOURCE)
>> > +               set_bit(FLAG_OPEN_SOURCE, &desc->flags);
>> > +
>> > +       /* No particular flag request, not really hogging then... */
>> > +       if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
>> > +               pr_warn("%s: GPIO %s: no hogging direction specified, bailing out\n",
>> > +                        __func__, name);
>> > +               err = -EINVAL;
>> > +               goto free_gpio;
>> > +       }
>> > +
>> > +       /* Process flags */
>> > +       if (dflags & GPIOD_FLAGS_BIT_DIR_OUT)
>> > +               err = gpiod_direction_output(desc,
>> > +                                            dflags & GPIOD_FLAGS_BIT_DIR_VAL);
>> > +       else
>> > +               err = gpiod_direction_input(desc);
>> > +
>> > +       if (err < 0) {
>> > +               pr_warn("%s: GPIO %s setting direction/value failed\n",
>> > +                        __func__, name);
>> > +               goto free_gpio;
>> > +       }
>>
>> I would suggest to factorize this code that is similar to the one
>> found in __gpiod_get_index(). Do all the DT parsing in a function that
>> just returns a descriptor and the
>
> I would tend to agree.
> But as Linus suggested I was trying to contain the changes to gpiolib_of.c only.

Yes I prefer we begin by supporting it in OF and then generalize it later
if more users (board files, ACPI) appear.

Not a big deal but I want to avoid big design up front unless it's
easy and a few alterations.
http://c2.com/cgi/wiki?BigDesignUpFront

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ