aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 94f5e8ed83a7..1cea4a6799fe 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -338,18 +338,18 @@ static struct class spi_master_class = {
338 * spi_alloc_master - allocate SPI master controller 338 * spi_alloc_master - allocate SPI master controller
339 * @dev: the controller, possibly using the platform_bus 339 * @dev: the controller, possibly using the platform_bus
340 * @size: how much driver-private data to preallocate; the pointer to this 340 * @size: how much driver-private data to preallocate; the pointer to this
341 * memory is in the class_data field of the returned class_device, 341 * memory is in the class_data field of the returned class_device,
342 * accessible with spi_master_get_devdata(). 342 * accessible with spi_master_get_devdata().
343 * 343 *
344 * This call is used only by SPI master controller drivers, which are the 344 * This call is used only by SPI master controller drivers, which are the
345 * only ones directly touching chip registers. It's how they allocate 345 * only ones directly touching chip registers. It's how they allocate
346 * an spi_master structure, prior to calling spi_add_master(). 346 * an spi_master structure, prior to calling spi_register_master().
347 * 347 *
348 * This must be called from context that can sleep. It returns the SPI 348 * This must be called from context that can sleep. It returns the SPI
349 * master structure on success, else NULL. 349 * master structure on success, else NULL.
350 * 350 *
351 * The caller is responsible for assigning the bus number and initializing 351 * The caller is responsible for assigning the bus number and initializing
352 * the master's methods before calling spi_add_master(); and (after errors 352 * the master's methods before calling spi_register_master(); and (after errors
353 * adding the device) calling spi_master_put() to prevent a memory leak. 353 * adding the device) calling spi_master_put() to prevent a memory leak.
354 */ 354 */
355struct spi_master * __init_or_module 355struct spi_master * __init_or_module
@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(spi_alloc_master);
395int __init_or_module 395int __init_or_module
396spi_register_master(struct spi_master *master) 396spi_register_master(struct spi_master *master)
397{ 397{
398 static atomic_t dyn_bus_id = ATOMIC_INIT(0); 398 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<16) - 1);
399 struct device *dev = master->cdev.dev; 399 struct device *dev = master->cdev.dev;
400 int status = -ENODEV; 400 int status = -ENODEV;
401 int dynamic = 0; 401 int dynamic = 0;
@@ -404,7 +404,7 @@ spi_register_master(struct spi_master *master)
404 return -ENODEV; 404 return -ENODEV;
405 405
406 /* convention: dynamically assigned bus IDs count down from the max */ 406 /* convention: dynamically assigned bus IDs count down from the max */
407 if (master->bus_num == 0) { 407 if (master->bus_num < 0) {
408 master->bus_num = atomic_dec_return(&dyn_bus_id); 408 master->bus_num = atomic_dec_return(&dyn_bus_id);
409 dynamic = 1; 409 dynamic = 1;
410 } 410 }
@@ -522,7 +522,8 @@ int spi_sync(struct spi_device *spi, struct spi_message *message)
522} 522}
523EXPORT_SYMBOL_GPL(spi_sync); 523EXPORT_SYMBOL_GPL(spi_sync);
524 524
525#define SPI_BUFSIZ (SMP_CACHE_BYTES) 525/* portable code must never pass more than 32 bytes */
526#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
526 527
527static u8 *buf; 528static u8 *buf;
528 529