aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_bfin5xx.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-09-23 21:27:47 -0400
committerMike Frysinger <vapier@gentoo.org>2010-10-18 02:49:34 -0400
commitb9f139a7a6a8b24e61ad94c3334eb26f34a4cb63 (patch)
tree0797f78e99033ea6f547a948437ff7b644b4a2ae /drivers/spi/spi_bfin5xx.c
parent9c4542c7a3082bf74f00145355ef407ac82c0b3f (diff)
spi/bfin_spi: convert struct names to something more logical
The current structure names are a bit confusing as to what they represent, so use better names. Reported-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/spi/spi_bfin5xx.c')
-rw-r--r--drivers/spi/spi_bfin5xx.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index b0de61a014f5..9a1801b8bf00 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -42,15 +42,15 @@ MODULE_LICENSE("GPL");
42#define DONE_STATE ((void *)2) 42#define DONE_STATE ((void *)2)
43#define ERROR_STATE ((void *)-1) 43#define ERROR_STATE ((void *)-1)
44 44
45struct driver_data; 45struct master_data;
46 46
47struct transfer_ops { 47struct transfer_ops {
48 void (*write) (struct driver_data *); 48 void (*write) (struct master_data *);
49 void (*read) (struct driver_data *); 49 void (*read) (struct master_data *);
50 void (*duplex) (struct driver_data *); 50 void (*duplex) (struct master_data *);
51}; 51};
52 52
53struct driver_data { 53struct master_data {
54 /* Driver model hookup */ 54 /* Driver model hookup */
55 struct platform_device *pdev; 55 struct platform_device *pdev;
56 56
@@ -80,7 +80,7 @@ struct driver_data {
80 /* Current message transfer state info */ 80 /* Current message transfer state info */
81 struct spi_message *cur_msg; 81 struct spi_message *cur_msg;
82 struct spi_transfer *cur_transfer; 82 struct spi_transfer *cur_transfer;
83 struct chip_data *cur_chip; 83 struct slave_data *cur_chip;
84 size_t len_in_bytes; 84 size_t len_in_bytes;
85 size_t len; 85 size_t len;
86 void *tx; 86 void *tx;
@@ -105,7 +105,7 @@ struct driver_data {
105 const struct transfer_ops *ops; 105 const struct transfer_ops *ops;
106}; 106};
107 107
108struct chip_data { 108struct slave_data {
109 u16 ctl_reg; 109 u16 ctl_reg;
110 u16 baud; 110 u16 baud;
111 u16 flag; 111 u16 flag;
@@ -123,9 +123,9 @@ struct chip_data {
123}; 123};
124 124
125#define DEFINE_SPI_REG(reg, off) \ 125#define DEFINE_SPI_REG(reg, off) \
126static inline u16 read_##reg(struct driver_data *drv_data) \ 126static inline u16 read_##reg(struct master_data *drv_data) \
127 { return bfin_read16(drv_data->regs_base + off); } \ 127 { return bfin_read16(drv_data->regs_base + off); } \
128static inline void write_##reg(struct driver_data *drv_data, u16 v) \ 128static inline void write_##reg(struct master_data *drv_data, u16 v) \
129 { bfin_write16(drv_data->regs_base + off, v); } 129 { bfin_write16(drv_data->regs_base + off, v); }
130 130
131DEFINE_SPI_REG(CTRL, 0x00) 131DEFINE_SPI_REG(CTRL, 0x00)
@@ -136,7 +136,7 @@ DEFINE_SPI_REG(RDBR, 0x10)
136DEFINE_SPI_REG(BAUD, 0x14) 136DEFINE_SPI_REG(BAUD, 0x14)
137DEFINE_SPI_REG(SHAW, 0x18) 137DEFINE_SPI_REG(SHAW, 0x18)
138 138
139static void bfin_spi_enable(struct driver_data *drv_data) 139static void bfin_spi_enable(struct master_data *drv_data)
140{ 140{
141 u16 cr; 141 u16 cr;
142 142
@@ -144,7 +144,7 @@ static void bfin_spi_enable(struct driver_data *drv_data)
144 write_CTRL(drv_data, (cr | BIT_CTL_ENABLE)); 144 write_CTRL(drv_data, (cr | BIT_CTL_ENABLE));
145} 145}
146 146
147static void bfin_spi_disable(struct driver_data *drv_data) 147static void bfin_spi_disable(struct master_data *drv_data)
148{ 148{
149 u16 cr; 149 u16 cr;
150 150
@@ -167,7 +167,7 @@ static u16 hz_to_spi_baud(u32 speed_hz)
167 return spi_baud; 167 return spi_baud;
168} 168}
169 169
170static int bfin_spi_flush(struct driver_data *drv_data) 170static int bfin_spi_flush(struct master_data *drv_data)
171{ 171{
172 unsigned long limit = loops_per_jiffy << 1; 172 unsigned long limit = loops_per_jiffy << 1;
173 173
@@ -181,7 +181,7 @@ static int bfin_spi_flush(struct driver_data *drv_data)
181} 181}
182 182
183/* Chip select operation functions for cs_change flag */ 183/* Chip select operation functions for cs_change flag */
184static void bfin_spi_cs_active(struct driver_data *drv_data, struct chip_data *chip) 184static void bfin_spi_cs_active(struct master_data *drv_data, struct slave_data *chip)
185{ 185{
186 if (likely(chip->chip_select_num)) { 186 if (likely(chip->chip_select_num)) {
187 u16 flag = read_FLAG(drv_data); 187 u16 flag = read_FLAG(drv_data);
@@ -194,7 +194,7 @@ static void bfin_spi_cs_active(struct driver_data *drv_data, struct chip_data *c
194 } 194 }
195} 195}
196 196
197static void bfin_spi_cs_deactive(struct driver_data *drv_data, struct chip_data *chip) 197static void bfin_spi_cs_deactive(struct master_data *drv_data, struct slave_data *chip)
198{ 198{
199 if (likely(chip->chip_select_num)) { 199 if (likely(chip->chip_select_num)) {
200 u16 flag = read_FLAG(drv_data); 200 u16 flag = read_FLAG(drv_data);
@@ -212,7 +212,7 @@ static void bfin_spi_cs_deactive(struct driver_data *drv_data, struct chip_data
212} 212}
213 213
214/* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */ 214/* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */
215static inline void bfin_spi_cs_enable(struct driver_data *drv_data, struct chip_data *chip) 215static inline void bfin_spi_cs_enable(struct master_data *drv_data, struct slave_data *chip)
216{ 216{
217 u16 flag = read_FLAG(drv_data); 217 u16 flag = read_FLAG(drv_data);
218 218
@@ -221,7 +221,7 @@ static inline void bfin_spi_cs_enable(struct driver_data *drv_data, struct chip_
221 write_FLAG(drv_data, flag); 221 write_FLAG(drv_data, flag);
222} 222}
223 223
224static inline void bfin_spi_cs_disable(struct driver_data *drv_data, struct chip_data *chip) 224static inline void bfin_spi_cs_disable(struct master_data *drv_data, struct slave_data *chip)
225{ 225{
226 u16 flag = read_FLAG(drv_data); 226 u16 flag = read_FLAG(drv_data);
227 227
@@ -231,9 +231,9 @@ static inline void bfin_spi_cs_disable(struct driver_data *drv_data, struct chip
231} 231}
232 232
233/* stop controller and re-config current chip*/ 233/* stop controller and re-config current chip*/
234static void bfin_spi_restore_state(struct driver_data *drv_data) 234static void bfin_spi_restore_state(struct master_data *drv_data)
235{ 235{
236 struct chip_data *chip = drv_data->cur_chip; 236 struct slave_data *chip = drv_data->cur_chip;
237 237
238 /* Clear status and disable clock */ 238 /* Clear status and disable clock */
239 write_STAT(drv_data, BIT_STAT_CLR); 239 write_STAT(drv_data, BIT_STAT_CLR);
@@ -249,12 +249,12 @@ static void bfin_spi_restore_state(struct driver_data *drv_data)
249} 249}
250 250
251/* used to kick off transfer in rx mode and read unwanted RX data */ 251/* used to kick off transfer in rx mode and read unwanted RX data */
252static inline void bfin_spi_dummy_read(struct driver_data *drv_data) 252static inline void bfin_spi_dummy_read(struct master_data *drv_data)
253{ 253{
254 (void) read_RDBR(drv_data); 254 (void) read_RDBR(drv_data);
255} 255}
256 256
257static void bfin_spi_u8_writer(struct driver_data *drv_data) 257static void bfin_spi_u8_writer(struct master_data *drv_data)
258{ 258{
259 /* clear RXS (we check for RXS inside the loop) */ 259 /* clear RXS (we check for RXS inside the loop) */
260 bfin_spi_dummy_read(drv_data); 260 bfin_spi_dummy_read(drv_data);
@@ -270,7 +270,7 @@ static void bfin_spi_u8_writer(struct driver_data *drv_data)
270 } 270 }
271} 271}
272 272
273static void bfin_spi_u8_reader(struct driver_data *drv_data) 273static void bfin_spi_u8_reader(struct master_data *drv_data)
274{ 274{
275 u16 tx_val = drv_data->cur_chip->idle_tx_val; 275 u16 tx_val = drv_data->cur_chip->idle_tx_val;
276 276
@@ -285,7 +285,7 @@ static void bfin_spi_u8_reader(struct driver_data *drv_data)
285 } 285 }
286} 286}
287 287
288static void bfin_spi_u8_duplex(struct driver_data *drv_data) 288static void bfin_spi_u8_duplex(struct master_data *drv_data)
289{ 289{
290 /* discard old RX data and clear RXS */ 290 /* discard old RX data and clear RXS */
291 bfin_spi_dummy_read(drv_data); 291 bfin_spi_dummy_read(drv_data);
@@ -304,7 +304,7 @@ static const struct transfer_ops bfin_transfer_ops_u8 = {
304 .duplex = bfin_spi_u8_duplex, 304 .duplex = bfin_spi_u8_duplex,
305}; 305};
306 306
307static void bfin_spi_u16_writer(struct driver_data *drv_data) 307static void bfin_spi_u16_writer(struct master_data *drv_data)
308{ 308{
309 /* clear RXS (we check for RXS inside the loop) */ 309 /* clear RXS (we check for RXS inside the loop) */
310 bfin_spi_dummy_read(drv_data); 310 bfin_spi_dummy_read(drv_data);
@@ -321,7 +321,7 @@ static void bfin_spi_u16_writer(struct driver_data *drv_data)
321 } 321 }
322} 322}
323 323
324static void bfin_spi_u16_reader(struct driver_data *drv_data) 324static void bfin_spi_u16_reader(struct master_data *drv_data)
325{ 325{
326 u16 tx_val = drv_data->cur_chip->idle_tx_val; 326 u16 tx_val = drv_data->cur_chip->idle_tx_val;
327 327
@@ -337,7 +337,7 @@ static void bfin_spi_u16_reader(struct driver_data *drv_data)
337 } 337 }
338} 338}
339 339
340static void bfin_spi_u16_duplex(struct driver_data *drv_data) 340static void bfin_spi_u16_duplex(struct master_data *drv_data)
341{ 341{
342 /* discard old RX data and clear RXS */ 342 /* discard old RX data and clear RXS */
343 bfin_spi_dummy_read(drv_data); 343 bfin_spi_dummy_read(drv_data);
@@ -359,7 +359,7 @@ static const struct transfer_ops bfin_transfer_ops_u16 = {
359}; 359};
360 360
361/* test if ther is more transfer to be done */ 361/* test if ther is more transfer to be done */
362static void *bfin_spi_next_transfer(struct driver_data *drv_data) 362static void *bfin_spi_next_transfer(struct master_data *drv_data)
363{ 363{
364 struct spi_message *msg = drv_data->cur_msg; 364 struct spi_message *msg = drv_data->cur_msg;
365 struct spi_transfer *trans = drv_data->cur_transfer; 365 struct spi_transfer *trans = drv_data->cur_transfer;
@@ -378,9 +378,9 @@ static void *bfin_spi_next_transfer(struct driver_data *drv_data)
378 * caller already set message->status; 378 * caller already set message->status;
379 * dma and pio irqs are blocked give finished message back 379 * dma and pio irqs are blocked give finished message back
380 */ 380 */
381static void bfin_spi_giveback(struct driver_data *drv_data) 381static void bfin_spi_giveback(struct master_data *drv_data)
382{ 382{
383 struct chip_data *chip = drv_data->cur_chip; 383 struct slave_data *chip = drv_data->cur_chip;
384 struct spi_transfer *last_transfer; 384 struct spi_transfer *last_transfer;
385 unsigned long flags; 385 unsigned long flags;
386 struct spi_message *msg; 386 struct spi_message *msg;
@@ -412,8 +412,8 @@ static void bfin_spi_giveback(struct driver_data *drv_data)
412/* spi data irq handler */ 412/* spi data irq handler */
413static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id) 413static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
414{ 414{
415 struct driver_data *drv_data = dev_id; 415 struct master_data *drv_data = dev_id;
416 struct chip_data *chip = drv_data->cur_chip; 416 struct slave_data *chip = drv_data->cur_chip;
417 struct spi_message *msg = drv_data->cur_msg; 417 struct spi_message *msg = drv_data->cur_msg;
418 int n_bytes = drv_data->n_bytes; 418 int n_bytes = drv_data->n_bytes;
419 419
@@ -484,8 +484,8 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
484 484
485static irqreturn_t bfin_spi_dma_irq_handler(int irq, void *dev_id) 485static irqreturn_t bfin_spi_dma_irq_handler(int irq, void *dev_id)
486{ 486{
487 struct driver_data *drv_data = dev_id; 487 struct master_data *drv_data = dev_id;
488 struct chip_data *chip = drv_data->cur_chip; 488 struct slave_data *chip = drv_data->cur_chip;
489 struct spi_message *msg = drv_data->cur_msg; 489 struct spi_message *msg = drv_data->cur_msg;
490 unsigned long timeout; 490 unsigned long timeout;
491 unsigned short dmastat = get_dma_curr_irqstat(drv_data->dma_channel); 491 unsigned short dmastat = get_dma_curr_irqstat(drv_data->dma_channel);
@@ -548,11 +548,11 @@ static irqreturn_t bfin_spi_dma_irq_handler(int irq, void *dev_id)
548 548
549static void bfin_spi_pump_transfers(unsigned long data) 549static void bfin_spi_pump_transfers(unsigned long data)
550{ 550{
551 struct driver_data *drv_data = (struct driver_data *)data; 551 struct master_data *drv_data = (struct master_data *)data;
552 struct spi_message *message = NULL; 552 struct spi_message *message = NULL;
553 struct spi_transfer *transfer = NULL; 553 struct spi_transfer *transfer = NULL;
554 struct spi_transfer *previous = NULL; 554 struct spi_transfer *previous = NULL;
555 struct chip_data *chip = NULL; 555 struct slave_data *chip = NULL;
556 u8 width; 556 u8 width;
557 u16 cr, dma_width, dma_config; 557 u16 cr, dma_width, dma_config;
558 u32 tranf_success = 1; 558 u32 tranf_success = 1;
@@ -872,10 +872,10 @@ static void bfin_spi_pump_transfers(unsigned long data)
872/* pop a msg from queue and kick off real transfer */ 872/* pop a msg from queue and kick off real transfer */
873static void bfin_spi_pump_messages(struct work_struct *work) 873static void bfin_spi_pump_messages(struct work_struct *work)
874{ 874{
875 struct driver_data *drv_data; 875 struct master_data *drv_data;
876 unsigned long flags; 876 unsigned long flags;
877 877
878 drv_data = container_of(work, struct driver_data, pump_messages); 878 drv_data = container_of(work, struct master_data, pump_messages);
879 879
880 /* Lock queue and check for queue work */ 880 /* Lock queue and check for queue work */
881 spin_lock_irqsave(&drv_data->lock, flags); 881 spin_lock_irqsave(&drv_data->lock, flags);
@@ -929,7 +929,7 @@ static void bfin_spi_pump_messages(struct work_struct *work)
929 */ 929 */
930static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg) 930static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg)
931{ 931{
932 struct driver_data *drv_data = spi_master_get_devdata(spi->master); 932 struct master_data *drv_data = spi_master_get_devdata(spi->master);
933 unsigned long flags; 933 unsigned long flags;
934 934
935 spin_lock_irqsave(&drv_data->lock, flags); 935 spin_lock_irqsave(&drv_data->lock, flags);
@@ -974,8 +974,8 @@ static u16 ssel[][MAX_SPI_SSEL] = {
974static int bfin_spi_setup(struct spi_device *spi) 974static int bfin_spi_setup(struct spi_device *spi)
975{ 975{
976 struct bfin5xx_spi_chip *chip_info; 976 struct bfin5xx_spi_chip *chip_info;
977 struct chip_data *chip = NULL; 977 struct slave_data *chip = NULL;
978 struct driver_data *drv_data = spi_master_get_devdata(spi->master); 978 struct master_data *drv_data = spi_master_get_devdata(spi->master);
979 int ret = -EINVAL; 979 int ret = -EINVAL;
980 980
981 if (spi->bits_per_word != 8 && spi->bits_per_word != 16) 981 if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
@@ -1155,8 +1155,8 @@ static int bfin_spi_setup(struct spi_device *spi)
1155 */ 1155 */
1156static void bfin_spi_cleanup(struct spi_device *spi) 1156static void bfin_spi_cleanup(struct spi_device *spi)
1157{ 1157{
1158 struct chip_data *chip = spi_get_ctldata(spi); 1158 struct slave_data *chip = spi_get_ctldata(spi);
1159 struct driver_data *drv_data = spi_master_get_devdata(spi->master); 1159 struct master_data *drv_data = spi_master_get_devdata(spi->master);
1160 1160
1161 if (!chip) 1161 if (!chip)
1162 return; 1162 return;
@@ -1176,7 +1176,7 @@ static void bfin_spi_cleanup(struct spi_device *spi)
1176 spi_set_ctldata(spi, NULL); 1176 spi_set_ctldata(spi, NULL);
1177} 1177}
1178 1178
1179static inline int bfin_spi_init_queue(struct driver_data *drv_data) 1179static inline int bfin_spi_init_queue(struct master_data *drv_data)
1180{ 1180{
1181 INIT_LIST_HEAD(&drv_data->queue); 1181 INIT_LIST_HEAD(&drv_data->queue);
1182 spin_lock_init(&drv_data->lock); 1182 spin_lock_init(&drv_data->lock);
@@ -1198,7 +1198,7 @@ static inline int bfin_spi_init_queue(struct driver_data *drv_data)
1198 return 0; 1198 return 0;
1199} 1199}
1200 1200
1201static inline int bfin_spi_start_queue(struct driver_data *drv_data) 1201static inline int bfin_spi_start_queue(struct master_data *drv_data)
1202{ 1202{
1203 unsigned long flags; 1203 unsigned long flags;
1204 1204
@@ -1220,7 +1220,7 @@ static inline int bfin_spi_start_queue(struct driver_data *drv_data)
1220 return 0; 1220 return 0;
1221} 1221}
1222 1222
1223static inline int bfin_spi_stop_queue(struct driver_data *drv_data) 1223static inline int bfin_spi_stop_queue(struct master_data *drv_data)
1224{ 1224{
1225 unsigned long flags; 1225 unsigned long flags;
1226 unsigned limit = 500; 1226 unsigned limit = 500;
@@ -1249,7 +1249,7 @@ static inline int bfin_spi_stop_queue(struct driver_data *drv_data)
1249 return status; 1249 return status;
1250} 1250}
1251 1251
1252static inline int bfin_spi_destroy_queue(struct driver_data *drv_data) 1252static inline int bfin_spi_destroy_queue(struct master_data *drv_data)
1253{ 1253{
1254 int status; 1254 int status;
1255 1255
@@ -1267,14 +1267,14 @@ static int __init bfin_spi_probe(struct platform_device *pdev)
1267 struct device *dev = &pdev->dev; 1267 struct device *dev = &pdev->dev;
1268 struct bfin5xx_spi_master *platform_info; 1268 struct bfin5xx_spi_master *platform_info;
1269 struct spi_master *master; 1269 struct spi_master *master;
1270 struct driver_data *drv_data = 0; 1270 struct master_data *drv_data = 0;
1271 struct resource *res; 1271 struct resource *res;
1272 int status = 0; 1272 int status = 0;
1273 1273
1274 platform_info = dev->platform_data; 1274 platform_info = dev->platform_data;
1275 1275
1276 /* Allocate master with space for drv_data */ 1276 /* Allocate master with space for drv_data */
1277 master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); 1277 master = spi_alloc_master(dev, sizeof(struct master_data) + 16);
1278 if (!master) { 1278 if (!master) {
1279 dev_err(&pdev->dev, "can not alloc spi_master\n"); 1279 dev_err(&pdev->dev, "can not alloc spi_master\n");
1280 return -ENOMEM; 1280 return -ENOMEM;
@@ -1377,7 +1377,7 @@ out_error_get_res:
1377/* stop hardware and remove the driver */ 1377/* stop hardware and remove the driver */
1378static int __devexit bfin_spi_remove(struct platform_device *pdev) 1378static int __devexit bfin_spi_remove(struct platform_device *pdev)
1379{ 1379{
1380 struct driver_data *drv_data = platform_get_drvdata(pdev); 1380 struct master_data *drv_data = platform_get_drvdata(pdev);
1381 int status = 0; 1381 int status = 0;
1382 1382
1383 if (!drv_data) 1383 if (!drv_data)
@@ -1416,7 +1416,7 @@ static int __devexit bfin_spi_remove(struct platform_device *pdev)
1416#ifdef CONFIG_PM 1416#ifdef CONFIG_PM
1417static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state) 1417static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state)
1418{ 1418{
1419 struct driver_data *drv_data = platform_get_drvdata(pdev); 1419 struct master_data *drv_data = platform_get_drvdata(pdev);
1420 int status = 0; 1420 int status = 0;
1421 1421
1422 status = bfin_spi_stop_queue(drv_data); 1422 status = bfin_spi_stop_queue(drv_data);
@@ -1431,7 +1431,7 @@ static int bfin_spi_suspend(struct platform_device *pdev, pm_message_t state)
1431 1431
1432static int bfin_spi_resume(struct platform_device *pdev) 1432static int bfin_spi_resume(struct platform_device *pdev)
1433{ 1433{
1434 struct driver_data *drv_data = platform_get_drvdata(pdev); 1434 struct master_data *drv_data = platform_get_drvdata(pdev);
1435 int status = 0; 1435 int status = 0;
1436 1436
1437 /* Enable the SPI interface */ 1437 /* Enable the SPI interface */