Re: [PATCH v4 3/9] pinctrl: convert to use match_string() helper

From: Andy Shevchenko
Date: Tue Feb 02 2016 - 03:10:32 EST


On Mon, 2016-02-01 at 22:02 -0800, Andrew Morton wrote:
> On Thu, 28 Jan 2016 15:14:19 +0200 Andy Shevchenko <andriy.shevchenko
> @linux.intel.com> wrote:
>
> > The new helper returns index of the mathing string in an array. We
> > would use it
> > here.
> >
> > --- a/drivers/pinctrl/pinmux.c
> > +++ b/drivers/pinctrl/pinmux.c
> > @@ -334,7 +334,6 @@ int pinmux_map_to_setting(struct pinctrl_map
> > const *map,
> > Â unsigned num_groups;
> > Â int ret;
> > Â const char *group;
> > - int i;
> > Â
> > Â if (!pmxops) {
> > Â dev_err(pctldev->dev, "does not support mux
> > function\n");
> > @@ -363,19 +362,13 @@ int pinmux_map_to_setting(struct pinctrl_map
> > const *map,
> > Â return -EINVAL;
> > Â }
> > Â if (map->data.mux.group) {
> > - bool found = false;
> > Â group = map->data.mux.group;
> > - for (i = 0; i < num_groups; i++) {
> > - if (!strcmp(group, groups[i])) {
> > - found = true;
> > - break;
> > - }
> > - }
> > - if (!found) {
> > + ret = match_string(groups, num_groups, group);
> > + if (ret < 0) {
> > Â dev_err(pctldev->dev,
> > Â "invalid group \"%s\" for function
> > \"%s\"\n",
> > Â group, map->data.mux.function);
> > - return -EINVAL;
> > + return ret;
>
> Changes the return value from -EINVAL to -ENODATA.

Yeah, Al is concerned about this as well [1]. That's why I emphasized
this in cover letter.

> ÂÂI'm not reeeeeealy
> sure what ENODATA means - it seems mostly a networking thing?ÂÂPeople
> use it in various places because it kinda sounds like whatever it is
> that just went wrong.
>
> But the question is: what will the end user think when this error
> comes
> out of the kernel?ÂÂGiven that he/she has just tried to misconfigure
> the pinctrl system, ENODATA will cause much head-scratching.ÂÂEINVAL
> is
> more appropriate?ÂÂ"You tried to do something invalid".

Yeah, my arguments still the same, our error reporting from 70s sucks.

Since few people are concerned about EINVAL vs. ENODATA, I will re-do
patches 1 and 2 to follow this default instead of ENODATA.

[1]Âhttp://www.spinics.net/lists/kernel/msg2157541.html

> > Â }
> > Â } else {
> > Â group = groups[0];

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy