]> err.no Git - linux-2.6/commitdiff
[PATCH] spi: correct bus_num and buffer bug in spi core
authorHans-Christian Egtvedt <hcegtvedt@atmel.com>
Thu, 7 Dec 2006 04:36:17 +0000 (20:36 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Thu, 7 Dec 2006 16:39:32 +0000 (08:39 -0800)
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: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/spi/spi.c

index 1a3c963dc48a68f9ec4187a59d47a83f9579078d..7d215eaa137023aebd409d2d5bfa367668b747c6 100644 (file)
@@ -465,15 +465,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
  */
 struct spi_master *spi_busnum_to_master(u16 bus_num)
 {
-       if (bus_num) {
-               char                    name[8];
-               struct kobject          *bus;
-
-               snprintf(name, sizeof name, "spi%u", bus_num);
-               bus = kset_find_obj(&spi_master_class.subsys.kset, name);
-               if (bus)
-                       return container_of(bus, struct spi_master, cdev.kobj);
-       }
+       char                    name[9];
+       struct kobject          *bus;
+
+       snprintf(name, sizeof name, "spi%u", bus_num);
+       bus = kset_find_obj(&spi_master_class.subsys.kset, name);
+       if (bus)
+               return container_of(bus, struct spi_master, cdev.kobj);
        return NULL;
 }
 EXPORT_SYMBOL_GPL(spi_busnum_to_master);