Re: [patch/rfc 2.6.25-git] gpio: sysfs interface

From: Andrew Morton
Date: Mon Apr 28 2008 - 22:56:50 EST


On Mon, 28 Apr 2008 16:28:13 -0700 David Brownell <david-b@xxxxxxxxxxx> wrote:

> > If we had a strcmp() variant which treats a \n in the first arg as a \0
> > the above would become
> >
> > if (sysfs_streq(buf, "high"))
> > status = gpio_direction_output(gpio, 1);
> > else if (sysfs_streq(buf, "out") || sysfs_streq(buf, "low"))
> > status = gpio_direction_output(gpio, 0);
> > else if (sysfs_streq(buf, "in"))
> > status = gpio_direction_input(gpio);
>
> That would indeed be better. Maybe I should whip up a sysfs
> patch adding that, and have this depend on that patch. (I've
> CC'd Greg in case he has comments on that...)

Yes, it would be a standalone patch. The sort which generates oceans of
useful feedback ;) The sort which also generates hundreds of
use-new-toy-to-clean-up-old-code patches for me to merge :(

> Alternatively: strict_streq(), analogy to strict_strto*()?

Yeah, I couldn't think of a decent name. I do think it should return true
on finding a match so callers don't need to use ! or ==0. So its name
shouldn't look anything like "strcmp".

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