linux/drivers/platform
Paul Bolle a471e58e8c eeepc-laptop: simplify parse_arg()
commit 95369a73a9 upstream.

parse_arg() has three possible return values:
    -EINVAL if sscanf(), in short, fails;
    zero if "count" is zero; and
    "count" in all other cases

But "count" will never be zero. See, parse_arg() is called by the
various store functions. And the callchain of these functions starts
with sysfs_kf_write(). And that function checks for a zero "count". So
we can stop checking for a zero "count", drop the "count" argument
entirely, and transform parse_arg() into a function that returns zero on
success or a negative error. That, in turn, allows to make those store
functions just return "count" on success. The net effect is that the
code becomes a bit easier to understand.

A nice side effect is that this GCC warning is silenced too:
    drivers/platform/x86/eeepc-laptop.c: In function ‘store_sys_acpi’:
    drivers/platform/x86/eeepc-laptop.c:279:10: warning: ‘value’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      int rv, value;

Which is, of course, the reason to have a look at parse_arg().

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-11-20 18:04:45 +00:00
..
chrome platform/chrome: Add support for the acer c720p touchscreen. 2015-01-15 10:44:57 +00:00
goldfish goldfish: Sanitize the broken interrupt handler 2017-06-05 21:17:09 +01:00
olpc drivers/platform/olpc/olpc-ec.c: initialise earlier 2013-08-23 09:51:22 -07:00
x86 eeepc-laptop: simplify parse_arg() 2018-11-20 18:04:45 +00:00
Kconfig platform: add chrome platform directory 2013-11-20 18:51:03 -05:00
Makefile platform: add chrome platform directory 2013-11-20 18:51:03 -05:00