Skip to contentSkip to conversation

SPI dynamic busid generation bugfix

PATCH In review David Brownell 2 participants 4 messages Jun 1, 2007 3 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SPI dynamic busid generation bugfix

Fix SPI dynamic bus ID assignment to start at 2^15-1 rather than a negative number. Valid bus ids are supposed to be positive, and are (now) stored in an 's16' value.

drivers/spi/spi.c +1 -1
@@ -411,7 +411,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
  */
 int spi_register_master(struct spi_master *master)
 {
-	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
+	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<15) - 1);
 	struct device		*dev = master->cdev.dev;
 	int			status = -ENODEV;
 	int			dynamic = 0;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#2 lore raw
In reply to a message not in the archive
Quoted 9 lines · On Fri, 1 Jun 2007 16:12:19 -0700 David Brownell…

Fix SPI dynamic bus ID assignment to start at 2^15-1 rather than a negative number. Valid bus ids are supposed to be positive, and are (now) stored in an 's16' value.

drivers/spi/spi.c EXPORT_SYMBOL_GPL(spi_alloc_master); · line 417

Quoted 8 lines
drivers/spi/spi.c +1 -1
@@ -411,7 +411,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
  */
 int spi_register_master(struct spi_master *master)
 {
-	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
+	static atomic_t		dyn_bus_id = ATOMIC_INIT((1<<15) - 1);
 	struct device		*dev = master->cdev.dev;
 	int			status = -ENODEV;
 	int			dynamic = 0;

Is this going to underflow then malfunction after 32k modprobe+rmmods?

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#4 lore raw
In reply to a message not in the archive
Quoted 2 lines · Andrew Morton

Is this going to underflow then malfunction after 32k modprobe+rmmods?

Yes. A better fix will be needed, for the crazy people amongst us. Dynamic busids are quite uncommon though, so that's not pressing.

- Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#6 lore raw
In reply to a message not in the archive
Quoted 6 lines · On Fri, 1 Jun 2007 16:46:12 -0700 David Brownell…
Quoted 2 lines · Andrew Morton

Is this going to underflow then malfunction after 32k modprobe+rmmods?

Yes. A better fix will be needed, for the crazy people amongst us. Dynamic busids are quite uncommon though, so that's not pressing.

lib/idr.c can be used for this. There are patches in Greg's driver tree which make it better-suited.

The give-me-a-unique-integer thing is so common that we really should have a wrapper around idr which does just that.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/