Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6

* 'next-spi' of git://git.secretlab.ca/git/linux-2.6:
spi/pl022: fix erroneous platform data in U300
spi: fixed odd static string conventions in core code
spi/bfin_spi: only request GPIO on first load
spi/bfin_spi: handle error/status changes after data interrupts
spi: enable spi_board_info to be registered after spi_master

+73 -52
+1 -1
arch/arm/mach-u300/spi.c
··· 67 67 .bus_num = 0, /* Only one bus on this chip */ 68 68 .chip_select = 0, 69 69 /* Means SPI_CS_HIGH, change if e.g low CS */ 70 - .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP, 70 + .mode = SPI_MODE_1 | SPI_LOOP, 71 71 }, 72 72 #endif 73 73 };
+52 -46
drivers/spi/spi.c
··· 29 29 #include <linux/spi/spi.h> 30 30 #include <linux/of_spi.h> 31 31 32 - 33 - /* SPI bustype and spi_master class are registered after board init code 34 - * provides the SPI device tables, ensuring that both are present by the 35 - * time controller driver registration causes spi_devices to "enumerate". 36 - */ 37 32 static void spidev_release(struct device *dev) 38 33 { 39 34 struct spi_device *spi = to_spi_device(dev); ··· 197 202 198 203 struct boardinfo { 199 204 struct list_head list; 200 - unsigned n_board_info; 201 - struct spi_board_info board_info[0]; 205 + struct spi_board_info board_info; 202 206 }; 203 207 204 208 static LIST_HEAD(board_list); 209 + static LIST_HEAD(spi_master_list); 210 + 211 + /* 212 + * Used to protect add/del opertion for board_info list and 213 + * spi_master list, and their matching process 214 + */ 205 215 static DEFINE_MUTEX(board_lock); 206 216 207 217 /** ··· 300 300 */ 301 301 status = spi_setup(spi); 302 302 if (status < 0) { 303 - dev_err(dev, "can't %s %s, status %d\n", 304 - "setup", dev_name(&spi->dev), status); 303 + dev_err(dev, "can't setup %s, status %d\n", 304 + dev_name(&spi->dev), status); 305 305 goto done; 306 306 } 307 307 308 308 /* Device may be bound to an active driver when this returns */ 309 309 status = device_add(&spi->dev); 310 310 if (status < 0) 311 - dev_err(dev, "can't %s %s, status %d\n", 312 - "add", dev_name(&spi->dev), status); 311 + dev_err(dev, "can't add %s, status %d\n", 312 + dev_name(&spi->dev), status); 313 313 else 314 314 dev_dbg(dev, "registered child %s\n", dev_name(&spi->dev)); 315 315 ··· 371 371 } 372 372 EXPORT_SYMBOL_GPL(spi_new_device); 373 373 374 + static void spi_match_master_to_boardinfo(struct spi_master *master, 375 + struct spi_board_info *bi) 376 + { 377 + struct spi_device *dev; 378 + 379 + if (master->bus_num != bi->bus_num) 380 + return; 381 + 382 + dev = spi_new_device(master, bi); 383 + if (!dev) 384 + dev_err(master->dev.parent, "can't create new device for %s\n", 385 + bi->modalias); 386 + } 387 + 374 388 /** 375 389 * spi_register_board_info - register SPI devices for a given board 376 390 * @info: array of chip descriptors ··· 407 393 int __init 408 394 spi_register_board_info(struct spi_board_info const *info, unsigned n) 409 395 { 410 - struct boardinfo *bi; 396 + struct boardinfo *bi; 397 + int i; 411 398 412 - bi = kmalloc(sizeof(*bi) + n * sizeof *info, GFP_KERNEL); 399 + bi = kzalloc(n * sizeof(*bi), GFP_KERNEL); 413 400 if (!bi) 414 401 return -ENOMEM; 415 - bi->n_board_info = n; 416 - memcpy(bi->board_info, info, n * sizeof *info); 417 402 418 - mutex_lock(&board_lock); 419 - list_add_tail(&bi->list, &board_list); 420 - mutex_unlock(&board_lock); 421 - return 0; 422 - } 403 + for (i = 0; i < n; i++, bi++, info++) { 404 + struct spi_master *master; 423 405 424 - /* FIXME someone should add support for a __setup("spi", ...) that 425 - * creates board info from kernel command lines 426 - */ 427 - 428 - static void scan_boardinfo(struct spi_master *master) 429 - { 430 - struct boardinfo *bi; 431 - 432 - mutex_lock(&board_lock); 433 - list_for_each_entry(bi, &board_list, list) { 434 - struct spi_board_info *chip = bi->board_info; 435 - unsigned n; 436 - 437 - for (n = bi->n_board_info; n > 0; n--, chip++) { 438 - if (chip->bus_num != master->bus_num) 439 - continue; 440 - /* NOTE: this relies on spi_new_device to 441 - * issue diagnostics when given bogus inputs 442 - */ 443 - (void) spi_new_device(master, chip); 444 - } 406 + memcpy(&bi->board_info, info, sizeof(*info)); 407 + mutex_lock(&board_lock); 408 + list_add_tail(&bi->list, &board_list); 409 + list_for_each_entry(master, &spi_master_list, list) 410 + spi_match_master_to_boardinfo(master, &bi->board_info); 411 + mutex_unlock(&board_lock); 445 412 } 446 - mutex_unlock(&board_lock); 413 + 414 + return 0; 447 415 } 448 416 449 417 /*-------------------------------------------------------------------------*/ ··· 508 512 { 509 513 static atomic_t dyn_bus_id = ATOMIC_INIT((1<<15) - 1); 510 514 struct device *dev = master->dev.parent; 515 + struct boardinfo *bi; 511 516 int status = -ENODEV; 512 517 int dynamic = 0; 513 518 ··· 544 547 dev_dbg(dev, "registered master %s%s\n", dev_name(&master->dev), 545 548 dynamic ? " (dynamic)" : ""); 546 549 547 - /* populate children from any spi device tables */ 548 - scan_boardinfo(master); 550 + mutex_lock(&board_lock); 551 + list_add_tail(&master->list, &spi_master_list); 552 + list_for_each_entry(bi, &board_list, list) 553 + spi_match_master_to_boardinfo(master, &bi->board_info); 554 + mutex_unlock(&board_lock); 555 + 549 556 status = 0; 550 557 551 558 /* Register devices from the device tree */ ··· 580 579 { 581 580 int dummy; 582 581 583 - dummy = device_for_each_child(&master->dev, NULL, __unregister); 582 + mutex_lock(&board_lock); 583 + list_del(&master->list); 584 + mutex_unlock(&board_lock); 585 + 586 + dummy = device_for_each_child(master->dev.parent, &master->dev, 587 + __unregister); 584 588 device_unregister(&master->dev); 585 589 } 586 590 EXPORT_SYMBOL_GPL(spi_unregister_master); ··· 658 652 */ 659 653 bad_bits = spi->mode & ~spi->master->mode_bits; 660 654 if (bad_bits) { 661 - dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", 655 + dev_err(&spi->dev, "setup: unsupported mode bits %x\n", 662 656 bad_bits); 663 657 return -EINVAL; 664 658 }
+17 -5
drivers/spi/spi_bfin5xx.c
··· 504 504 "in dma_irq_handler dmastat:0x%x spistat:0x%x\n", 505 505 dmastat, spistat); 506 506 507 + if (drv_data->rx != NULL) { 508 + u16 cr = read_CTRL(drv_data); 509 + /* discard old RX data and clear RXS */ 510 + bfin_spi_dummy_read(drv_data); 511 + write_CTRL(drv_data, cr & ~BIT_CTL_ENABLE); /* Disable SPI */ 512 + write_CTRL(drv_data, cr & ~BIT_CTL_TIMOD); /* Restore State */ 513 + write_STAT(drv_data, BIT_STAT_CLR); /* Clear Status */ 514 + } 515 + 507 516 clear_dma_irqstat(drv_data->dma_channel); 508 517 509 518 /* ··· 1108 1099 } 1109 1100 1110 1101 if (chip->chip_select_num >= MAX_CTRL_CS) { 1111 - ret = gpio_request(chip->cs_gpio, spi->modalias); 1112 - if (ret) { 1113 - dev_err(&spi->dev, "gpio_request() error\n"); 1114 - goto pin_error; 1102 + /* Only request on first setup */ 1103 + if (spi_get_ctldata(spi) == NULL) { 1104 + ret = gpio_request(chip->cs_gpio, spi->modalias); 1105 + if (ret) { 1106 + dev_err(&spi->dev, "gpio_request() error\n"); 1107 + goto pin_error; 1108 + } 1109 + gpio_direction_output(chip->cs_gpio, 1); 1115 1110 } 1116 - gpio_direction_output(chip->cs_gpio, 1); 1117 1111 } 1118 1112 1119 1113 dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d\n",
+3
include/linux/spi/spi.h
··· 204 204 /** 205 205 * struct spi_master - interface to SPI master controller 206 206 * @dev: device interface to this driver 207 + * @list: link with the global spi_master list 207 208 * @bus_num: board-specific (and often SOC-specific) identifier for a 208 209 * given SPI controller. 209 210 * @num_chipselect: chipselects are used to distinguish individual ··· 238 237 */ 239 238 struct spi_master { 240 239 struct device dev; 240 + 241 + struct list_head list; 241 242 242 243 /* other than negative (== assign one dynamically), bus_num is fully 243 244 * board-specific. usually that simplifies to being SOC-specific.