[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcsYjj0_QKSeHFiFjrA92uZWdJPs5pLrzFK_HGM1ehUDw@mail.gmail.com>
Date: Fri, 29 Nov 2013 08:17:15 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Rhyland Klein <rklein@...dia.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: better lookup method for platform GPIOs
> On Thu, Nov 28, 2013 at 10:46 AM, Alexandre Courbot <acourbot@...dia.com> wrote:
One missed, but not least, thing.
>> +static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
>> {
>> const char *dev_id = dev ? dev_name(dev) : NULL;
>> - struct gpio_desc *desc = ERR_PTR(-ENODEV);
>> - unsigned int match, best = 0;
>> - struct gpiod_lookup *p;
>> + struct gpiod_lookup_table *table;
>>
>> mutex_lock(&gpio_lookup_lock);
>>
>> - list_for_each_entry(p, &gpio_lookup_list, list) {
>> - match = 0;
>> + list_for_each_entry(table, &gpio_lookup_list, list) {
[]
>> + if (dev_id != table->dev_id)
>> + continue;
>>
>> - match += 2;
>> - }
>> + return table;
>
> What about
>
> if (dev_id == table->dev_id)
> return table;
>
> ?
And unlock mutex, of course! It seems you missed this in the first place.
>
>> + }
>>
>> - if (p->con_id) {
>> - if (!con_id || strcmp(p->con_id, con_id))
>> - continue;
>> + mutex_unlock(&gpio_lookup_lock);
>>
>> - match += 1;
>> - }
>> + return NULL;
>> +}
--
With Best Regards,
Andy Shevchenko
--
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