Commit 4740d387 authored by Hans-Christian Egtvedt's avatar Hans-Christian Egtvedt Committed by Linus Torvalds

[PATCH] spi: correct bus_num and buffer bug in spi core

Correct the following in driver/spi/spi.c in function spi_busnum_to_master:

 * must allow bus_num 0, the if is really not needed.
 * correct the name buffer which is too small for bus_num >= 10000. It

should be 9 bytes big, not 8.
Signed-off-by: default avatarHans-Christian Egtvedt <hcegtvedt@atmel.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ed2908f3
...@@ -465,15 +465,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master); ...@@ -465,15 +465,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
*/ */
struct spi_master *spi_busnum_to_master(u16 bus_num) struct spi_master *spi_busnum_to_master(u16 bus_num)
{ {
if (bus_num) { char name[9];
char name[8]; struct kobject *bus;
struct kobject *bus;
snprintf(name, sizeof name, "spi%u", bus_num);
snprintf(name, sizeof name, "spi%u", bus_num); bus = kset_find_obj(&spi_master_class.subsys.kset, name);
bus = kset_find_obj(&spi_master_class.subsys.kset, name); if (bus)
if (bus) return container_of(bus, struct spi_master, cdev.kobj);
return container_of(bus, struct spi_master, cdev.kobj);
}
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(spi_busnum_to_master); EXPORT_SYMBOL_GPL(spi_busnum_to_master);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment