spi.c (59c8231089be96165735585694a801ae58ec6c95) | spi.c (d1eba93bd0fcd3f699cb8d666bc97788ee85d557) |
---|---|
1/* 2 * SPI init/core code 3 * 4 * Copyright (C) 2005 David Brownell 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 70 unchanged lines hidden (view full) --- 79static struct device_attribute dev_attr_spi_master_##field = { \ 80 .attr = { .name = file, .mode = S_IRUGO }, \ 81 .show = spi_master_##field##_show, \ 82}; \ 83static ssize_t spi_device_##field##_show(struct device *dev, \ 84 struct device_attribute *attr, \ 85 char *buf) \ 86{ \ | 1/* 2 * SPI init/core code 3 * 4 * Copyright (C) 2005 David Brownell 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 70 unchanged lines hidden (view full) --- 79static struct device_attribute dev_attr_spi_master_##field = { \ 80 .attr = { .name = file, .mode = S_IRUGO }, \ 81 .show = spi_master_##field##_show, \ 82}; \ 83static ssize_t spi_device_##field##_show(struct device *dev, \ 84 struct device_attribute *attr, \ 85 char *buf) \ 86{ \ |
87 struct spi_device *spi = container_of(dev, \ 88 struct spi_device, dev); \ | 87 struct spi_device *spi = to_spi_device(dev); \ |
89 return spi_statistics_##field##_show(&spi->statistics, buf); \ 90} \ 91static struct device_attribute dev_attr_spi_device_##field = { \ 92 .attr = { .name = file, .mode = S_IRUGO }, \ 93 .show = spi_device_##field##_show, \ 94} 95 96#define SPI_STATISTICS_SHOW_NAME(name, file, field, format_string) \ --- 274 unchanged lines hidden (view full) --- 371{ 372 const struct spi_driver *sdrv = to_spi_driver(dev->driver); 373 374 sdrv->shutdown(to_spi_device(dev)); 375} 376 377/** 378 * __spi_register_driver - register a SPI driver | 88 return spi_statistics_##field##_show(&spi->statistics, buf); \ 89} \ 90static struct device_attribute dev_attr_spi_device_##field = { \ 91 .attr = { .name = file, .mode = S_IRUGO }, \ 92 .show = spi_device_##field##_show, \ 93} 94 95#define SPI_STATISTICS_SHOW_NAME(name, file, field, format_string) \ --- 274 unchanged lines hidden (view full) --- 370{ 371 const struct spi_driver *sdrv = to_spi_driver(dev->driver); 372 373 sdrv->shutdown(to_spi_device(dev)); 374} 375 376/** 377 * __spi_register_driver - register a SPI driver |
379 * @owner: owner module of the driver to register | |
380 * @sdrv: the driver to register 381 * Context: can sleep 382 * 383 * Return: zero on success, else a negative error code. 384 */ 385int __spi_register_driver(struct module *owner, struct spi_driver *sdrv) 386{ 387 sdrv->driver.owner = owner; --- 1312 unchanged lines hidden (view full) --- 1700 master = kzalloc(size + sizeof(*master), GFP_KERNEL); 1701 if (!master) 1702 return NULL; 1703 1704 device_initialize(&master->dev); 1705 master->bus_num = -1; 1706 master->num_chipselect = 1; 1707 master->dev.class = &spi_master_class; | 378 * @sdrv: the driver to register 379 * Context: can sleep 380 * 381 * Return: zero on success, else a negative error code. 382 */ 383int __spi_register_driver(struct module *owner, struct spi_driver *sdrv) 384{ 385 sdrv->driver.owner = owner; --- 1312 unchanged lines hidden (view full) --- 1698 master = kzalloc(size + sizeof(*master), GFP_KERNEL); 1699 if (!master) 1700 return NULL; 1701 1702 device_initialize(&master->dev); 1703 master->bus_num = -1; 1704 master->num_chipselect = 1; 1705 master->dev.class = &spi_master_class; |
1708 master->dev.parent = dev; | 1706 master->dev.parent = get_device(dev); |
1709 spi_master_set_devdata(master, &master[1]); 1710 1711 return master; 1712} 1713EXPORT_SYMBOL_GPL(spi_alloc_master); 1714 1715#ifdef CONFIG_OF 1716static int of_spi_register_master(struct spi_master *master) --- 409 unchanged lines hidden (view full) --- 2126 } 2127 2128 /** 2129 * Set transfer bits_per_word and max speed as spi device default if 2130 * it is not set for this transfer. 2131 * Set transfer tx_nbits and rx_nbits as single transfer default 2132 * (SPI_NBITS_SINGLE) if it is not set for this transfer. 2133 */ | 1707 spi_master_set_devdata(master, &master[1]); 1708 1709 return master; 1710} 1711EXPORT_SYMBOL_GPL(spi_alloc_master); 1712 1713#ifdef CONFIG_OF 1714static int of_spi_register_master(struct spi_master *master) --- 409 unchanged lines hidden (view full) --- 2124 } 2125 2126 /** 2127 * Set transfer bits_per_word and max speed as spi device default if 2128 * it is not set for this transfer. 2129 * Set transfer tx_nbits and rx_nbits as single transfer default 2130 * (SPI_NBITS_SINGLE) if it is not set for this transfer. 2131 */ |
2134 message->frame_length = 0; | |
2135 list_for_each_entry(xfer, &message->transfers, transfer_list) { 2136 message->frame_length += xfer->len; 2137 if (!xfer->bits_per_word) 2138 xfer->bits_per_word = spi->bits_per_word; 2139 2140 if (!xfer->speed_hz) 2141 xfer->speed_hz = spi->max_speed_hz; 2142 if (!xfer->speed_hz) --- 568 unchanged lines hidden --- | 2132 list_for_each_entry(xfer, &message->transfers, transfer_list) { 2133 message->frame_length += xfer->len; 2134 if (!xfer->bits_per_word) 2135 xfer->bits_per_word = spi->bits_per_word; 2136 2137 if (!xfer->speed_hz) 2138 xfer->speed_hz = spi->max_speed_hz; 2139 if (!xfer->speed_hz) --- 568 unchanged lines hidden --- |