All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] sh-pfc: handle pin array holes in sh_pfc_map_pins()
Date: Wed, 03 Jun 2015 23:57:55 +0300	[thread overview]
Message-ID: <556F6A53.9010601@cogentembedded.com> (raw)
In-Reply-To: <CAMuHMdWU1WK+M+Mz3CBgXkbtYC9=D03Jrs4425BWrv22ARLdqA@mail.gmail.com>

Hello.

On 05/27/2015 11:52 AM, Geert Uytterhoeven wrote:

>>>> The  pin array handled by sh_pfc_map_pins() may contain holes
>>>> representing
>>>> non- existing pins. We have to first count the valid pins in order to
>>>> calculate the size  of the memory to be allocated, then to skip over the
>>>> non-existing pins when  initializing the allocated arrays, and then to
>>>> return the number of valid pins  from sh_pfc_map_pins() instead of 0 on
>>>> success.

>>>> As we have to touch devm_kzalloc() calls anyway, use more fitting
>>>> devm_kcalloc() instead which additionally checks the array size. And
>>>> since
>>>> PINMUX_TYPE_NONE is #define'd as 0, stop re-initializing already zeroed
>>>> out 'pmx->configs' array.

>>> I agree with this optimization, but I think it deserves a comment in the
>>> source code that explicitly mentions PINMUX_TYPE_NONE, to make sure any
>>> later
>>> rework changing the PINMUX_TYPE_NONE value would catch this.

>>     Note that this is not just "drove by" optimization, I was trying to avoid
>> the very need to explicitly initialize 'pmx->configs' array to
>> PINMUX_TYPE_NONE...

>>>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

>> [...]

>>>> @@ -622,7 +628,7 @@ int sh_pfc_register_pinctrl(struct sh_pf
>>>>          pmx->pctl_desc.pmxops = &sh_pfc_pinmux_ops;
>>>>          pmx->pctl_desc.confops = &sh_pfc_pinconf_ops;
>>>>          pmx->pctl_desc.pins = pmx->pins;
>>>> -       pmx->pctl_desc.npins = pfc->info->nr_pins;
>>>> +       pmx->pctl_desc.npins = ret;
>>>>
>>>>          pmx->pctl = pinctrl_register(&pmx->pctl_desc, pfc->dev, pmx);
>>>>          if (pmx->pctl == NULL)

>>> Shouldn't you also fix sh_pfc_init_ranges() ? It includes the following
>>> code
>>> that doesn't seem to handle holes properly.

>>>           for (i = 1, nr_ranges = 1; i < pfc->info->nr_pins; ++i) {
>>>                   if (pfc->info->pins[i-1].pin != pfc->info->pins[i].pin -
>>> 1)
>>>                           nr_ranges++;
>>>           }

>>> Please make sure that sh_pfc_get_pin_index() doesn't start blowing up
>>> afterwards though.

>>     I think I'm seeing a problem with this function (and it's not due to my
>> changes). Its result is often used to index 'pfc->info->pins' array. While
>> this is working now, when the holes are not yet allowed, it's going to break
>> when we start supporting the holes since that array couldn't be indexed this
>> way anymore (via ranges). This function is good only for 'pmx->configs' and
>> the like where we have already removed the holes. It looks like this holes
>> thing is going to be too complex, so how about leaving things as they are?
>> :-)

> Any conclusion on this?

    I did overestimate the complexity, it seems. :-)
    I have just removed the calls to sh_pfc_get_pin_index() on 
'pfc->info->pins' and its alias.

> If yes, please resend, incl. the r8a7794 pfc patches that depend on it.

    Will repost the patches RSN.

> Gr{oetje,eeting}s,
>                          Geert

WBR, Sergei


WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] sh-pfc: handle pin array holes in sh_pfc_map_pins()
Date: Wed, 03 Jun 2015 20:57:55 +0000	[thread overview]
Message-ID: <556F6A53.9010601@cogentembedded.com> (raw)
In-Reply-To: <CAMuHMdWU1WK+M+Mz3CBgXkbtYC9=D03Jrs4425BWrv22ARLdqA@mail.gmail.com>

Hello.

On 05/27/2015 11:52 AM, Geert Uytterhoeven wrote:

>>>> The  pin array handled by sh_pfc_map_pins() may contain holes
>>>> representing
>>>> non- existing pins. We have to first count the valid pins in order to
>>>> calculate the size  of the memory to be allocated, then to skip over the
>>>> non-existing pins when  initializing the allocated arrays, and then to
>>>> return the number of valid pins  from sh_pfc_map_pins() instead of 0 on
>>>> success.

>>>> As we have to touch devm_kzalloc() calls anyway, use more fitting
>>>> devm_kcalloc() instead which additionally checks the array size. And
>>>> since
>>>> PINMUX_TYPE_NONE is #define'd as 0, stop re-initializing already zeroed
>>>> out 'pmx->configs' array.

>>> I agree with this optimization, but I think it deserves a comment in the
>>> source code that explicitly mentions PINMUX_TYPE_NONE, to make sure any
>>> later
>>> rework changing the PINMUX_TYPE_NONE value would catch this.

>>     Note that this is not just "drove by" optimization, I was trying to avoid
>> the very need to explicitly initialize 'pmx->configs' array to
>> PINMUX_TYPE_NONE...

>>>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

>> [...]

>>>> @@ -622,7 +628,7 @@ int sh_pfc_register_pinctrl(struct sh_pf
>>>>          pmx->pctl_desc.pmxops = &sh_pfc_pinmux_ops;
>>>>          pmx->pctl_desc.confops = &sh_pfc_pinconf_ops;
>>>>          pmx->pctl_desc.pins = pmx->pins;
>>>> -       pmx->pctl_desc.npins = pfc->info->nr_pins;
>>>> +       pmx->pctl_desc.npins = ret;
>>>>
>>>>          pmx->pctl = pinctrl_register(&pmx->pctl_desc, pfc->dev, pmx);
>>>>          if (pmx->pctl = NULL)

>>> Shouldn't you also fix sh_pfc_init_ranges() ? It includes the following
>>> code
>>> that doesn't seem to handle holes properly.

>>>           for (i = 1, nr_ranges = 1; i < pfc->info->nr_pins; ++i) {
>>>                   if (pfc->info->pins[i-1].pin != pfc->info->pins[i].pin -
>>> 1)
>>>                           nr_ranges++;
>>>           }

>>> Please make sure that sh_pfc_get_pin_index() doesn't start blowing up
>>> afterwards though.

>>     I think I'm seeing a problem with this function (and it's not due to my
>> changes). Its result is often used to index 'pfc->info->pins' array. While
>> this is working now, when the holes are not yet allowed, it's going to break
>> when we start supporting the holes since that array couldn't be indexed this
>> way anymore (via ranges). This function is good only for 'pmx->configs' and
>> the like where we have already removed the holes. It looks like this holes
>> thing is going to be too complex, so how about leaving things as they are?
>> :-)

> Any conclusion on this?

    I did overestimate the complexity, it seems. :-)
    I have just removed the calls to sh_pfc_get_pin_index() on 
'pfc->info->pins' and its alias.

> If yes, please resend, incl. the r8a7794 pfc patches that depend on it.

    Will repost the patches RSN.

> Gr{oetje,eeting}s,
>                          Geert

WBR, Sergei


  reply	other threads:[~2015-06-03 20:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 23:39 [PATCH] sh-pfc: handle pin array holes in sh_pfc_map_pins() Sergei Shtylyov
2015-02-27 23:39 ` Sergei Shtylyov
2015-03-03  0:24 ` Laurent Pinchart
2015-03-03  0:24   ` Laurent Pinchart
2015-04-24 20:12   ` Sergei Shtylyov
2015-04-24 20:12     ` Sergei Shtylyov
2015-04-29 22:38   ` Sergei Shtylyov
2015-04-29 22:38     ` Sergei Shtylyov
2015-05-27  8:52     ` Geert Uytterhoeven
2015-05-27  8:52       ` Geert Uytterhoeven
2015-06-03 20:57       ` Sergei Shtylyov [this message]
2015-06-03 20:57         ` Sergei Shtylyov
2015-03-06 10:43 ` Linus Walleij
2015-03-06 10:43   ` Linus Walleij
2015-03-06 10:58   ` Laurent Pinchart
2015-03-06 10:58     ` Laurent Pinchart
2015-03-09 17:11     ` Linus Walleij
2015-03-09 17:11       ` Linus Walleij
2015-03-06 12:42   ` Sergei Shtylyov
2015-03-06 12:42     ` Sergei Shtylyov
2015-03-06 13:17     ` Laurent Pinchart
2015-03-06 13:17       ` Laurent Pinchart

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=556F6A53.9010601@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=geert@linux-m68k.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-sh@vger.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 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.