Lines Matching refs:master

49 	if (spi->master->cleanup)  in spidev_release()
50 spi->master->cleanup(spi); in spidev_release()
52 spi_master_put(spi->master); in spidev_release()
75 struct spi_master *master = container_of(dev, \
77 return spi_statistics_##field##_show(&master->statistics, buf); \
242 struct spi_master *master) in spi_statistics_add_transfer_stats() argument
257 (xfer->tx_buf != master->dummy_tx)) in spi_statistics_add_transfer_stats()
260 (xfer->rx_buf != master->dummy_rx)) in spi_statistics_add_transfer_stats()
438 struct spi_device *spi_alloc_device(struct spi_master *master) in spi_alloc_device() argument
442 if (!spi_master_get(master)) in spi_alloc_device()
447 spi_master_put(master); in spi_alloc_device()
451 spi->master = master; in spi_alloc_device()
452 spi->dev.parent = &master->dev; in spi_alloc_device()
473 dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->master->dev), in spi_dev_set_name()
482 if (spi->master == new_spi->master && in spi_dev_check()
500 struct spi_master *master = spi->master; in spi_add_device() local
501 struct device *dev = master->dev.parent; in spi_add_device()
505 if (spi->chip_select >= master->num_chipselect) { in spi_add_device()
508 master->num_chipselect); in spi_add_device()
528 if (master->cs_gpios) in spi_add_device()
529 spi->cs_gpio = master->cs_gpios[spi->chip_select]; in spi_add_device()
570 struct spi_device *spi_new_device(struct spi_master *master, in spi_new_device() argument
583 proxy = spi_alloc_device(master); in spi_new_device()
608 static void spi_match_master_to_boardinfo(struct spi_master *master, in spi_match_master_to_boardinfo() argument
613 if (master->bus_num != bi->bus_num) in spi_match_master_to_boardinfo()
616 dev = spi_new_device(master, bi); in spi_match_master_to_boardinfo()
618 dev_err(master->dev.parent, "can't create new device for %s\n", in spi_match_master_to_boardinfo()
656 struct spi_master *master; in spi_register_board_info() local
661 list_for_each_entry(master, &spi_master_list, list) in spi_register_board_info()
662 spi_match_master_to_boardinfo(master, &bi->board_info); in spi_register_board_info()
678 else if (spi->master->set_cs) in spi_set_cs()
679 spi->master->set_cs(spi, !enable); in spi_set_cs()
683 static int spi_map_buf(struct spi_master *master, struct device *dev, in spi_map_buf() argument
699 desc_len = master->max_dma_len; in spi_map_buf()
743 static void spi_unmap_buf(struct spi_master *master, struct device *dev, in spi_unmap_buf() argument
752 static int __spi_map_msg(struct spi_master *master, struct spi_message *msg) in __spi_map_msg() argument
758 if (!master->can_dma) in __spi_map_msg()
761 if (master->dma_tx) in __spi_map_msg()
762 tx_dev = master->dma_tx->device->dev; in __spi_map_msg()
764 tx_dev = &master->dev; in __spi_map_msg()
766 if (master->dma_rx) in __spi_map_msg()
767 rx_dev = master->dma_rx->device->dev; in __spi_map_msg()
769 rx_dev = &master->dev; in __spi_map_msg()
772 if (!master->can_dma(master, msg->spi, xfer)) in __spi_map_msg()
776 ret = spi_map_buf(master, tx_dev, &xfer->tx_sg, in __spi_map_msg()
784 ret = spi_map_buf(master, rx_dev, &xfer->rx_sg, in __spi_map_msg()
788 spi_unmap_buf(master, tx_dev, &xfer->tx_sg, in __spi_map_msg()
795 master->cur_msg_mapped = true; in __spi_map_msg()
800 static int __spi_unmap_msg(struct spi_master *master, struct spi_message *msg) in __spi_unmap_msg() argument
805 if (!master->cur_msg_mapped || !master->can_dma) in __spi_unmap_msg()
808 if (master->dma_tx) in __spi_unmap_msg()
809 tx_dev = master->dma_tx->device->dev; in __spi_unmap_msg()
811 tx_dev = &master->dev; in __spi_unmap_msg()
813 if (master->dma_rx) in __spi_unmap_msg()
814 rx_dev = master->dma_rx->device->dev; in __spi_unmap_msg()
816 rx_dev = &master->dev; in __spi_unmap_msg()
819 if (!master->can_dma(master, msg->spi, xfer)) in __spi_unmap_msg()
822 spi_unmap_buf(master, rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE); in __spi_unmap_msg()
823 spi_unmap_buf(master, tx_dev, &xfer->tx_sg, DMA_TO_DEVICE); in __spi_unmap_msg()
829 static inline int __spi_map_msg(struct spi_master *master, in __spi_map_msg() argument
835 static inline int __spi_unmap_msg(struct spi_master *master, in __spi_unmap_msg() argument
842 static inline int spi_unmap_msg(struct spi_master *master, in spi_unmap_msg() argument
852 if (xfer->tx_buf == master->dummy_tx) in spi_unmap_msg()
854 if (xfer->rx_buf == master->dummy_rx) in spi_unmap_msg()
858 return __spi_unmap_msg(master, msg); in spi_unmap_msg()
861 static int spi_map_msg(struct spi_master *master, struct spi_message *msg) in spi_map_msg() argument
867 if (master->flags & (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX)) { in spi_map_msg()
872 if ((master->flags & SPI_MASTER_MUST_TX) && in spi_map_msg()
875 if ((master->flags & SPI_MASTER_MUST_RX) && in spi_map_msg()
881 tmp = krealloc(master->dummy_tx, max_tx, in spi_map_msg()
885 master->dummy_tx = tmp; in spi_map_msg()
890 tmp = krealloc(master->dummy_rx, max_rx, in spi_map_msg()
894 master->dummy_rx = tmp; in spi_map_msg()
901 xfer->tx_buf = master->dummy_tx; in spi_map_msg()
903 xfer->rx_buf = master->dummy_rx; in spi_map_msg()
908 return __spi_map_msg(master, msg); in spi_map_msg()
918 static int spi_transfer_one_message(struct spi_master *master, in spi_transfer_one_message() argument
925 struct spi_statistics *statm = &master->statistics; in spi_transfer_one_message()
936 spi_statistics_add_transfer_stats(statm, xfer, master); in spi_transfer_one_message()
937 spi_statistics_add_transfer_stats(stats, xfer, master); in spi_transfer_one_message()
940 reinit_completion(&master->xfer_completion); in spi_transfer_one_message()
942 ret = master->transfer_one(master, msg->spi, xfer); in spi_transfer_one_message()
958 ms = wait_for_completion_timeout(&master->xfer_completion, in spi_transfer_one_message()
1007 if (msg->status && master->handle_err) in spi_transfer_one_message()
1008 master->handle_err(master, msg); in spi_transfer_one_message()
1010 spi_finalize_current_message(master); in spi_transfer_one_message()
1023 void spi_finalize_current_transfer(struct spi_master *master) in spi_finalize_current_transfer() argument
1025 complete(&master->xfer_completion); in spi_finalize_current_transfer()
1042 static void __spi_pump_messages(struct spi_master *master, bool in_kthread) in __spi_pump_messages() argument
1049 spin_lock_irqsave(&master->queue_lock, flags); in __spi_pump_messages()
1052 if (master->cur_msg) { in __spi_pump_messages()
1053 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1058 if (master->idling) { in __spi_pump_messages()
1059 queue_kthread_work(&master->kworker, &master->pump_messages); in __spi_pump_messages()
1060 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1065 if (list_empty(&master->queue) || !master->running) { in __spi_pump_messages()
1066 if (!master->busy) { in __spi_pump_messages()
1067 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1073 queue_kthread_work(&master->kworker, in __spi_pump_messages()
1074 &master->pump_messages); in __spi_pump_messages()
1075 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1079 master->busy = false; in __spi_pump_messages()
1080 master->idling = true; in __spi_pump_messages()
1081 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1083 kfree(master->dummy_rx); in __spi_pump_messages()
1084 master->dummy_rx = NULL; in __spi_pump_messages()
1085 kfree(master->dummy_tx); in __spi_pump_messages()
1086 master->dummy_tx = NULL; in __spi_pump_messages()
1087 if (master->unprepare_transfer_hardware && in __spi_pump_messages()
1088 master->unprepare_transfer_hardware(master)) in __spi_pump_messages()
1089 dev_err(&master->dev, in __spi_pump_messages()
1091 if (master->auto_runtime_pm) { in __spi_pump_messages()
1092 pm_runtime_mark_last_busy(master->dev.parent); in __spi_pump_messages()
1093 pm_runtime_put_autosuspend(master->dev.parent); in __spi_pump_messages()
1095 trace_spi_master_idle(master); in __spi_pump_messages()
1097 spin_lock_irqsave(&master->queue_lock, flags); in __spi_pump_messages()
1098 master->idling = false; in __spi_pump_messages()
1099 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1104 master->cur_msg = in __spi_pump_messages()
1105 list_first_entry(&master->queue, struct spi_message, queue); in __spi_pump_messages()
1107 list_del_init(&master->cur_msg->queue); in __spi_pump_messages()
1108 if (master->busy) in __spi_pump_messages()
1111 master->busy = true; in __spi_pump_messages()
1112 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_pump_messages()
1114 if (!was_busy && master->auto_runtime_pm) { in __spi_pump_messages()
1115 ret = pm_runtime_get_sync(master->dev.parent); in __spi_pump_messages()
1117 dev_err(&master->dev, "Failed to power device: %d\n", in __spi_pump_messages()
1124 trace_spi_master_busy(master); in __spi_pump_messages()
1126 if (!was_busy && master->prepare_transfer_hardware) { in __spi_pump_messages()
1127 ret = master->prepare_transfer_hardware(master); in __spi_pump_messages()
1129 dev_err(&master->dev, in __spi_pump_messages()
1132 if (master->auto_runtime_pm) in __spi_pump_messages()
1133 pm_runtime_put(master->dev.parent); in __spi_pump_messages()
1138 trace_spi_message_start(master->cur_msg); in __spi_pump_messages()
1140 if (master->prepare_message) { in __spi_pump_messages()
1141 ret = master->prepare_message(master, master->cur_msg); in __spi_pump_messages()
1143 dev_err(&master->dev, in __spi_pump_messages()
1145 master->cur_msg->status = ret; in __spi_pump_messages()
1146 spi_finalize_current_message(master); in __spi_pump_messages()
1149 master->cur_msg_prepared = true; in __spi_pump_messages()
1152 ret = spi_map_msg(master, master->cur_msg); in __spi_pump_messages()
1154 master->cur_msg->status = ret; in __spi_pump_messages()
1155 spi_finalize_current_message(master); in __spi_pump_messages()
1159 ret = master->transfer_one_message(master, master->cur_msg); in __spi_pump_messages()
1161 dev_err(&master->dev, in __spi_pump_messages()
1173 struct spi_master *master = in spi_pump_messages() local
1176 __spi_pump_messages(master, true); in spi_pump_messages()
1179 static int spi_init_queue(struct spi_master *master) in spi_init_queue() argument
1183 master->running = false; in spi_init_queue()
1184 master->busy = false; in spi_init_queue()
1186 init_kthread_worker(&master->kworker); in spi_init_queue()
1187 master->kworker_task = kthread_run(kthread_worker_fn, in spi_init_queue()
1188 &master->kworker, "%s", in spi_init_queue()
1189 dev_name(&master->dev)); in spi_init_queue()
1190 if (IS_ERR(master->kworker_task)) { in spi_init_queue()
1191 dev_err(&master->dev, "failed to create message pump task\n"); in spi_init_queue()
1192 return PTR_ERR(master->kworker_task); in spi_init_queue()
1194 init_kthread_work(&master->pump_messages, spi_pump_messages); in spi_init_queue()
1203 if (master->rt) { in spi_init_queue()
1204 dev_info(&master->dev, in spi_init_queue()
1206 sched_setscheduler(master->kworker_task, SCHED_FIFO, &param); in spi_init_queue()
1222 struct spi_message *spi_get_next_queued_message(struct spi_master *master) in spi_get_next_queued_message() argument
1228 spin_lock_irqsave(&master->queue_lock, flags); in spi_get_next_queued_message()
1229 next = list_first_entry_or_null(&master->queue, struct spi_message, in spi_get_next_queued_message()
1231 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_get_next_queued_message()
1244 void spi_finalize_current_message(struct spi_master *master) in spi_finalize_current_message() argument
1250 spin_lock_irqsave(&master->queue_lock, flags); in spi_finalize_current_message()
1251 mesg = master->cur_msg; in spi_finalize_current_message()
1252 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_finalize_current_message()
1254 spi_unmap_msg(master, mesg); in spi_finalize_current_message()
1256 if (master->cur_msg_prepared && master->unprepare_message) { in spi_finalize_current_message()
1257 ret = master->unprepare_message(master, mesg); in spi_finalize_current_message()
1259 dev_err(&master->dev, in spi_finalize_current_message()
1264 spin_lock_irqsave(&master->queue_lock, flags); in spi_finalize_current_message()
1265 master->cur_msg = NULL; in spi_finalize_current_message()
1266 master->cur_msg_prepared = false; in spi_finalize_current_message()
1267 queue_kthread_work(&master->kworker, &master->pump_messages); in spi_finalize_current_message()
1268 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_finalize_current_message()
1278 static int spi_start_queue(struct spi_master *master) in spi_start_queue() argument
1282 spin_lock_irqsave(&master->queue_lock, flags); in spi_start_queue()
1284 if (master->running || master->busy) { in spi_start_queue()
1285 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_start_queue()
1289 master->running = true; in spi_start_queue()
1290 master->cur_msg = NULL; in spi_start_queue()
1291 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_start_queue()
1293 queue_kthread_work(&master->kworker, &master->pump_messages); in spi_start_queue()
1298 static int spi_stop_queue(struct spi_master *master) in spi_stop_queue() argument
1304 spin_lock_irqsave(&master->queue_lock, flags); in spi_stop_queue()
1312 while ((!list_empty(&master->queue) || master->busy) && limit--) { in spi_stop_queue()
1313 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_stop_queue()
1315 spin_lock_irqsave(&master->queue_lock, flags); in spi_stop_queue()
1318 if (!list_empty(&master->queue) || master->busy) in spi_stop_queue()
1321 master->running = false; in spi_stop_queue()
1323 spin_unlock_irqrestore(&master->queue_lock, flags); in spi_stop_queue()
1326 dev_warn(&master->dev, in spi_stop_queue()
1333 static int spi_destroy_queue(struct spi_master *master) in spi_destroy_queue() argument
1337 ret = spi_stop_queue(master); in spi_destroy_queue()
1346 dev_err(&master->dev, "problem destroying queue\n"); in spi_destroy_queue()
1350 flush_kthread_worker(&master->kworker); in spi_destroy_queue()
1351 kthread_stop(master->kworker_task); in spi_destroy_queue()
1360 struct spi_master *master = spi->master; in __spi_queued_transfer() local
1363 spin_lock_irqsave(&master->queue_lock, flags); in __spi_queued_transfer()
1365 if (!master->running) { in __spi_queued_transfer()
1366 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_queued_transfer()
1372 list_add_tail(&msg->queue, &master->queue); in __spi_queued_transfer()
1373 if (!master->busy && need_pump) in __spi_queued_transfer()
1374 queue_kthread_work(&master->kworker, &master->pump_messages); in __spi_queued_transfer()
1376 spin_unlock_irqrestore(&master->queue_lock, flags); in __spi_queued_transfer()
1392 static int spi_master_initialize_queue(struct spi_master *master) in spi_master_initialize_queue() argument
1396 master->transfer = spi_queued_transfer; in spi_master_initialize_queue()
1397 if (!master->transfer_one_message) in spi_master_initialize_queue()
1398 master->transfer_one_message = spi_transfer_one_message; in spi_master_initialize_queue()
1401 ret = spi_init_queue(master); in spi_master_initialize_queue()
1403 dev_err(&master->dev, "problem initializing queue\n"); in spi_master_initialize_queue()
1406 master->queued = true; in spi_master_initialize_queue()
1407 ret = spi_start_queue(master); in spi_master_initialize_queue()
1409 dev_err(&master->dev, "problem starting queue\n"); in spi_master_initialize_queue()
1416 spi_destroy_queue(master); in spi_master_initialize_queue()
1425 of_register_spi_device(struct spi_master *master, struct device_node *nc) in of_register_spi_device() argument
1432 spi = spi_alloc_device(master); in of_register_spi_device()
1434 dev_err(&master->dev, "spi_device alloc error for %s\n", in of_register_spi_device()
1444 dev_err(&master->dev, "cannot find modalias for %s\n", in of_register_spi_device()
1452 dev_err(&master->dev, "%s has no valid 'reg' property (%d)\n", in of_register_spi_device()
1482 dev_warn(&master->dev, in of_register_spi_device()
1500 dev_warn(&master->dev, in of_register_spi_device()
1510 dev_err(&master->dev, "%s has no valid 'spi-max-frequency' property (%d)\n", in of_register_spi_device()
1523 dev_err(&master->dev, "spi_device register error %s\n", in of_register_spi_device()
1542 static void of_register_spi_devices(struct spi_master *master) in of_register_spi_devices() argument
1547 if (!master->dev.of_node) in of_register_spi_devices()
1550 for_each_available_child_of_node(master->dev.of_node, nc) { in of_register_spi_devices()
1551 spi = of_register_spi_device(master, nc); in of_register_spi_devices()
1553 dev_warn(&master->dev, "Failed to create SPI device for %s\n", in of_register_spi_devices()
1558 static void of_register_spi_devices(struct spi_master *master) { } in of_register_spi_devices() argument
1595 struct spi_master *master = data; in acpi_spi_add_device() local
1606 spi = spi_alloc_device(master); in acpi_spi_add_device()
1608 dev_err(&master->dev, "failed to allocate SPI device for %s\n", in acpi_spi_add_device()
1630 dev_err(&master->dev, "failed to add SPI device %s from ACPI\n", in acpi_spi_add_device()
1638 static void acpi_register_spi_devices(struct spi_master *master) in acpi_register_spi_devices() argument
1643 handle = ACPI_HANDLE(master->dev.parent); in acpi_register_spi_devices()
1649 master, NULL); in acpi_register_spi_devices()
1651 dev_warn(&master->dev, "failed to enumerate SPI slaves\n"); in acpi_register_spi_devices()
1654 static inline void acpi_register_spi_devices(struct spi_master *master) {} in acpi_register_spi_devices() argument
1659 struct spi_master *master; in spi_master_release() local
1661 master = container_of(dev, struct spi_master, dev); in spi_master_release()
1662 kfree(master); in spi_master_release()
1695 struct spi_master *master; in spi_alloc_master() local
1700 master = kzalloc(size + sizeof(*master), GFP_KERNEL); in spi_alloc_master()
1701 if (!master) in spi_alloc_master()
1704 device_initialize(&master->dev); in spi_alloc_master()
1705 master->bus_num = -1; in spi_alloc_master()
1706 master->num_chipselect = 1; in spi_alloc_master()
1707 master->dev.class = &spi_master_class; in spi_alloc_master()
1708 master->dev.parent = dev; in spi_alloc_master()
1709 spi_master_set_devdata(master, &master[1]); in spi_alloc_master()
1711 return master; in spi_alloc_master()
1716 static int of_spi_register_master(struct spi_master *master) in of_spi_register_master() argument
1719 struct device_node *np = master->dev.of_node; in of_spi_register_master()
1725 master->num_chipselect = max_t(int, nb, master->num_chipselect); in of_spi_register_master()
1733 cs = devm_kzalloc(&master->dev, in of_spi_register_master()
1734 sizeof(int) * master->num_chipselect, in of_spi_register_master()
1736 master->cs_gpios = cs; in of_spi_register_master()
1738 if (!master->cs_gpios) in of_spi_register_master()
1741 for (i = 0; i < master->num_chipselect; i++) in of_spi_register_master()
1750 static int of_spi_register_master(struct spi_master *master) in of_spi_register_master() argument
1778 int spi_register_master(struct spi_master *master) in spi_register_master() argument
1781 struct device *dev = master->dev.parent; in spi_register_master()
1789 status = of_spi_register_master(master); in spi_register_master()
1796 if (master->num_chipselect == 0) in spi_register_master()
1799 if ((master->bus_num < 0) && master->dev.of_node) in spi_register_master()
1800 master->bus_num = of_alias_get_id(master->dev.of_node, "spi"); in spi_register_master()
1803 if (master->bus_num < 0) { in spi_register_master()
1807 master->bus_num = atomic_dec_return(&dyn_bus_id); in spi_register_master()
1811 INIT_LIST_HEAD(&master->queue); in spi_register_master()
1812 spin_lock_init(&master->queue_lock); in spi_register_master()
1813 spin_lock_init(&master->bus_lock_spinlock); in spi_register_master()
1814 mutex_init(&master->bus_lock_mutex); in spi_register_master()
1815 master->bus_lock_flag = 0; in spi_register_master()
1816 init_completion(&master->xfer_completion); in spi_register_master()
1817 if (!master->max_dma_len) in spi_register_master()
1818 master->max_dma_len = INT_MAX; in spi_register_master()
1823 dev_set_name(&master->dev, "spi%u", master->bus_num); in spi_register_master()
1824 status = device_add(&master->dev); in spi_register_master()
1827 dev_dbg(dev, "registered master %s%s\n", dev_name(&master->dev), in spi_register_master()
1831 if (master->transfer) in spi_register_master()
1834 status = spi_master_initialize_queue(master); in spi_register_master()
1836 device_del(&master->dev); in spi_register_master()
1841 spin_lock_init(&master->statistics.lock); in spi_register_master()
1844 list_add_tail(&master->list, &spi_master_list); in spi_register_master()
1846 spi_match_master_to_boardinfo(master, &bi->board_info); in spi_register_master()
1850 of_register_spi_devices(master); in spi_register_master()
1851 acpi_register_spi_devices(master); in spi_register_master()
1873 int devm_spi_register_master(struct device *dev, struct spi_master *master) in devm_spi_register_master() argument
1882 ret = spi_register_master(master); in devm_spi_register_master()
1884 *ptr = master; in devm_spi_register_master()
1910 void spi_unregister_master(struct spi_master *master) in spi_unregister_master() argument
1914 if (master->queued) { in spi_unregister_master()
1915 if (spi_destroy_queue(master)) in spi_unregister_master()
1916 dev_err(&master->dev, "queue remove failed\n"); in spi_unregister_master()
1920 list_del(&master->list); in spi_unregister_master()
1923 dummy = device_for_each_child(&master->dev, NULL, __unregister); in spi_unregister_master()
1924 device_unregister(&master->dev); in spi_unregister_master()
1928 int spi_master_suspend(struct spi_master *master) in spi_master_suspend() argument
1933 if (!master->queued) in spi_master_suspend()
1936 ret = spi_stop_queue(master); in spi_master_suspend()
1938 dev_err(&master->dev, "queue stop failed\n"); in spi_master_suspend()
1944 int spi_master_resume(struct spi_master *master) in spi_master_resume() argument
1948 if (!master->queued) in spi_master_resume()
1951 ret = spi_start_queue(master); in spi_master_resume()
1953 dev_err(&master->dev, "queue restart failed\n"); in spi_master_resume()
1983 struct spi_master *master = NULL; in spi_busnum_to_master() local
1988 master = container_of(dev, struct spi_master, dev); in spi_busnum_to_master()
1990 return master; in spi_busnum_to_master()
2001 static int __spi_validate_bits_per_word(struct spi_master *master, u8 bits_per_word) in __spi_validate_bits_per_word() argument
2003 if (master->bits_per_word_mask) { in __spi_validate_bits_per_word()
2007 if (!(master->bits_per_word_mask & in __spi_validate_bits_per_word()
2056 bad_bits = spi->mode & ~spi->master->mode_bits; in spi_setup()
2075 status = __spi_validate_bits_per_word(spi->master, spi->bits_per_word); in spi_setup()
2080 spi->max_speed_hz = spi->master->max_speed_hz; in spi_setup()
2082 if (spi->master->setup) in spi_setup()
2083 status = spi->master->setup(spi); in spi_setup()
2102 struct spi_master *master = spi->master; in __spi_validate() local
2114 if ((master->flags & SPI_MASTER_HALF_DUPLEX) in __spi_validate()
2116 unsigned flags = master->flags; in __spi_validate()
2143 xfer->speed_hz = master->max_speed_hz; in __spi_validate()
2145 if (master->max_speed_hz && in __spi_validate()
2146 xfer->speed_hz > master->max_speed_hz) in __spi_validate()
2147 xfer->speed_hz = master->max_speed_hz; in __spi_validate()
2149 if (__spi_validate_bits_per_word(master, xfer->bits_per_word)) in __spi_validate()
2167 if (xfer->speed_hz && master->min_speed_hz && in __spi_validate()
2168 xfer->speed_hz < master->min_speed_hz) in __spi_validate()
2213 struct spi_master *master = spi->master; in __spi_async() local
2217 SPI_STATISTICS_INCREMENT_FIELD(&master->statistics, spi_async); in __spi_async()
2222 return master->transfer(spi, message); in __spi_async()
2258 struct spi_master *master = spi->master; in spi_async() local
2266 spin_lock_irqsave(&master->bus_lock_spinlock, flags); in spi_async()
2268 if (master->bus_lock_flag) in spi_async()
2273 spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); in spi_async()
2312 struct spi_master *master = spi->master; in spi_async_locked() local
2320 spin_lock_irqsave(&master->bus_lock_spinlock, flags); in spi_async_locked()
2324 spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); in spi_async_locked()
2349 struct spi_master *master = spi->master; in __spi_sync() local
2360 SPI_STATISTICS_INCREMENT_FIELD(&master->statistics, spi_sync); in __spi_sync()
2364 mutex_lock(&master->bus_lock_mutex); in __spi_sync()
2371 if (master->transfer == spi_queued_transfer) { in __spi_sync()
2372 spin_lock_irqsave(&master->bus_lock_spinlock, flags); in __spi_sync()
2378 spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); in __spi_sync()
2384 mutex_unlock(&master->bus_lock_mutex); in __spi_sync()
2390 if (master->transfer == spi_queued_transfer) { in __spi_sync()
2391 SPI_STATISTICS_INCREMENT_FIELD(&master->statistics, in __spi_sync()
2395 __spi_pump_messages(master, false); in __spi_sync()
2469 int spi_bus_lock(struct spi_master *master) in spi_bus_lock() argument
2473 mutex_lock(&master->bus_lock_mutex); in spi_bus_lock()
2475 spin_lock_irqsave(&master->bus_lock_spinlock, flags); in spi_bus_lock()
2476 master->bus_lock_flag = 1; in spi_bus_lock()
2477 spin_unlock_irqrestore(&master->bus_lock_spinlock, flags); in spi_bus_lock()
2498 int spi_bus_unlock(struct spi_master *master) in spi_bus_unlock() argument
2500 master->bus_lock_flag = 0; in spi_bus_unlock()
2502 mutex_unlock(&master->bus_lock_mutex); in spi_bus_unlock()
2627 struct spi_master *master; in of_spi_notify() local
2632 master = of_find_spi_master_by_node(rd->dn->parent); in of_spi_notify()
2633 if (master == NULL) in of_spi_notify()
2636 spi = of_register_spi_device(master, rd->dn); in of_spi_notify()
2637 put_device(&master->dev); in of_spi_notify()