From: Michal Simek <michal.simek@xilinx.com>
To: Michal Simek <michal.simek@xilinx.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Michal Simek <monstr@monstr.eu>,
Greg KH <gregkh@linuxfoundation.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>, Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Subject: Re: [RESEND PATCH v3 1/2] of: base: Introduce of_alias_get_alias_list() to check alias IDs
Date: Mon, 8 Oct 2018 14:19:53 +0200 [thread overview]
Message-ID: <1520923c-2e16-cee3-7281-13082f90954c@xilinx.com> (raw)
In-Reply-To: <56c81d1a-e2f8-067e-4908-686cd83d478c@xilinx.com>
Hi Geert,
On 27.9.2018 09:22, Michal Simek wrote:
> On 27.9.2018 09:19, Geert Uytterhoeven wrote:
>> Hi Michal,
>>
>> On Wed, Sep 26, 2018 at 1:01 PM Michal Simek <michal.simek@xilinx.com> wrote:
>>> On 24.9.2018 09:41, Geert Uytterhoeven wrote:
>>>> On Thu, Sep 20, 2018 at 1:42 PM Michal Simek <michal.simek@xilinx.com> wrote:
>>>>> The function travels the lookup table to record alias ids for the given
>>>>> device match structures and alias stem.
>>>>> This function will be used by serial drivers to check if requested alias
>>>>> is allocated or free to use.
>>>>>
>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>> Reviewed-by: Rob Herring <robh@kernel.org>
>>>>
>>>> I know this has already been applied, it just drew my attention.
>>>>
>>>>> --- a/drivers/of/base.c
>>>>> +++ b/drivers/of/base.c
>>>>> @@ -16,6 +16,7 @@
>>>>>
>>>>> #define pr_fmt(fmt) "OF: " fmt
>>>>>
>>>>> +#include <linux/bitmap.h>
>>>>> #include <linux/console.h>
>>>>> #include <linux/ctype.h>
>>>>> #include <linux/cpu.h>
>>>>> @@ -1943,6 +1944,57 @@ int of_alias_get_id(struct device_node *np, const char *stem)
>>>>> EXPORT_SYMBOL_GPL(of_alias_get_id);
>>>>>
>>>>> /**
>>>>> + * of_alias_get_alias_list - Get alias list for the given device driver
>>>>> + * @matches: Array of OF device match structures to search in
>>>>> + * @stem: Alias stem of the given device_node
>>>>> + * @bitmap: Bitmap field pointer
>>>>> + * @nbits: Maximum number of alias ID which can be recorded it bitmap
>>>>
>>>> IDs
>>>>
>>>>> + *
>>>>> + * The function travels the lookup table to record alias ids for the given
>>>>> + * device match structures and alias stem.
>>>>> + *
>>>>> + * Return: 0 or -ENOSYS when !CONFIG_OF
>>>>> + */
>>>>> +int of_alias_get_alias_list(const struct of_device_id *matches,
>>>>> + const char *stem, unsigned long *bitmap,
>>>>> + unsigned int nbits)
>>>>> +{
>>>>> + struct alias_prop *app;
>>>>> +
>>>>> + /* Zero bitmap field to make sure that all the time it is clean */
>>>>> + bitmap_zero(bitmap, nbits);
>>>>> +
>>>>> + mutex_lock(&of_mutex);
>>>>> + pr_debug("%s: Looking for stem: %s\n", __func__, stem);
>>>>> + list_for_each_entry(app, &aliases_lookup, link) {
>>>>> + pr_debug("%s: stem: %s, id: %d\n",
>>>>> + __func__, app->stem, app->id);
>>>>> +
>>>>> + if (strcmp(app->stem, stem) != 0) {
>>>>> + pr_debug("%s: stem comparison doesn't passed %s\n",
>>>>
>>>> didn't pass?
>>>>
>>>>> + __func__, app->stem);
>>>>> + continue;
>>>>> + }
>>>>> +
>>>>> + if (app->id >= nbits) {
>>>>> + pr_debug("%s: ID %d greater then bitmap field %d\n",
>>>>
>>>> than
>>>> %u for unsigned int
>>>
>>> I won't fix this now because this can be done together with one change
>>> described below.
>>>
>>>>
>>>>> + __func__, app->id, nbits);
>>>>> + continue;
>>>>
>>>> Shouldn't this return an error, if of_match_node() below would have matched?
>>>
>>> IIRC Above check is for "serial" name.
>>> This one is for getting XX number from alias "serialXX".
>>> And below is checking compatible string.
>>>
>>> You are calling this function from uartps with 32 lines limit and there
>>> is serial33 alias poiting to uartlite (for example) then you don't want
>>> to break this call for that.
>>>
>>> What can be done is that compatible string is checked first and if this
>>> passed then ids are check and error can be returned or bit sets.
>>
>> That's what I meant: currently any serialN with N >= nbits is ignored, even
>> if the alias applies to the driver that called the function.
>
> ok. Let me create a patch and check compatible string first and then
> setup bit or fail if N >= nbits.
I have sent a patch with this change. Let's have discussion in that new
thread.
Thanks,
Michal
prev parent reply other threads:[~2018-10-08 12:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 11:41 [RESEND PATCH v3 1/2] of: base: Introduce of_alias_get_alias_list() to check alias IDs Michal Simek
2018-09-20 11:41 ` [RESEND PATCH v3 2/2] serial: uartps: Change uart ID port allocation Michal Simek
2018-09-24 7:37 ` Geert Uytterhoeven
2018-09-26 10:43 ` Michal Simek
2018-09-24 7:41 ` [RESEND PATCH v3 1/2] of: base: Introduce of_alias_get_alias_list() to check alias IDs Geert Uytterhoeven
2018-09-26 11:01 ` Michal Simek
2018-09-27 7:19 ` Geert Uytterhoeven
2018-09-27 7:22 ` Michal Simek
2018-10-08 12:19 ` Michal Simek [this message]
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=1520923c-2e16-cee3-7281-13082f90954c@xilinx.com \
--to=michal.simek@xilinx.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).