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

minor spi_butterfly cleanup

Simplify the spi_butterfly driver by removing incomplete/unused support for
the second SPI bus, implemented by the USI controller. This should make
this a clearer example of how to write a parport bitbang driver.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Brownell and committed by
Linus Torvalds
735ce95e fef92c30

+4 -58
+4 -58
drivers/spi/spi_butterfly.c
··· 40 40 * and use this custom parallel port cable. 41 41 */ 42 42 43 - #undef HAVE_USI /* nyet */ 44 - 45 43 46 44 /* DATA output bits (pins 2..9 == D0..D7) */ 47 45 #define butterfly_nreset (1 << 1) /* pin 3 */ ··· 47 49 #define spi_sck_bit (1 << 0) /* pin 2 */ 48 50 #define spi_mosi_bit (1 << 7) /* pin 9 */ 49 51 50 - #define usi_sck_bit (1 << 3) /* pin 5 */ 51 - #define usi_mosi_bit (1 << 4) /* pin 6 */ 52 - 53 52 #define vcc_bits ((1 << 6) | (1 << 5)) /* pins 7, 8 */ 54 53 55 54 /* STATUS input bits */ 56 55 #define spi_miso_bit PARPORT_STATUS_BUSY /* pin 11 */ 57 56 58 - #define usi_miso_bit PARPORT_STATUS_PAPEROUT /* pin 12 */ 59 - 60 57 /* CONTROL output bits */ 61 58 #define spi_cs_bit PARPORT_CONTROL_SELECT /* pin 17 */ 62 - /* USI uses no chipselect */ 63 59 64 60 65 61 66 62 static inline struct butterfly *spidev_to_pp(struct spi_device *spi) 67 63 { 68 64 return spi->controller_data; 69 - } 70 - 71 - static inline int is_usidev(struct spi_device *spi) 72 - { 73 - #ifdef HAVE_USI 74 - return spi->chip_select != 1; 75 - #else 76 - return 0; 77 - #endif 78 65 } 79 66 80 67 ··· 80 97 81 98 /*----------------------------------------------------------------------*/ 82 99 83 - /* 84 - * these routines may be slower than necessary because they're hiding 85 - * the fact that there are two different SPI busses on this cable: one 86 - * to the DataFlash chip (or AVR SPI controller), the other to the 87 - * AVR USI controller. 88 - */ 89 - 90 100 static inline void 91 101 setsck(struct spi_device *spi, int is_on) 92 102 { 93 103 struct butterfly *pp = spidev_to_pp(spi); 94 104 u8 bit, byte = pp->lastbyte; 95 105 96 - if (is_usidev(spi)) 97 - bit = usi_sck_bit; 98 - else 99 - bit = spi_sck_bit; 106 + bit = spi_sck_bit; 100 107 101 108 if (is_on) 102 109 byte |= bit; ··· 102 129 struct butterfly *pp = spidev_to_pp(spi); 103 130 u8 bit, byte = pp->lastbyte; 104 131 105 - if (is_usidev(spi)) 106 - bit = usi_mosi_bit; 107 - else 108 - bit = spi_mosi_bit; 132 + bit = spi_mosi_bit; 109 133 110 134 if (is_on) 111 135 byte |= bit; ··· 118 148 int value; 119 149 u8 bit; 120 150 121 - if (is_usidev(spi)) 122 - bit = usi_miso_bit; 123 - else 124 - bit = spi_miso_bit; 151 + bit = spi_miso_bit; 125 152 126 153 /* only STATUS_BUSY is NOT negated */ 127 154 value = !(parport_read_status(pp->port) & bit); ··· 132 165 /* set default clock polarity */ 133 166 if (value != BITBANG_CS_INACTIVE) 134 167 setsck(spi, spi->mode & SPI_CPOL); 135 - 136 - /* no chipselect on this USI link config */ 137 - if (is_usidev(spi)) 138 - return; 139 168 140 169 /* here, value == "activate or not"; 141 170 * most PARPORT_CONTROL_* bits are negated, so we must ··· 255 292 parport_frob_control(pp->port, spi_cs_bit, 0); 256 293 257 294 /* stabilize power with chip in reset (nRESET), and 258 - * both spi_sck_bit and usi_sck_bit clear (CPOL=0) 295 + * spi_sck_bit clear (CPOL=0) 259 296 */ 260 297 pp->lastbyte |= vcc_bits; 261 298 parport_write_data(pp->port, pp->lastbyte); ··· 288 325 if (pp->dataflash) 289 326 pr_debug("%s: dataflash at %s\n", p->name, 290 327 pp->dataflash->dev.bus_id); 291 - 292 - #ifdef HAVE_USI 293 - /* Bus 2 is only for talking to the AVR, and it can work no 294 - * matter who masters bus 1; needs appropriate AVR firmware. 295 - */ 296 - pp->info[1].max_speed_hz = 10 /* ?? */ * 1000 * 1000; 297 - strcpy(pp->info[1].modalias, "butterfly"); 298 - // pp->info[1].platform_data = ... TBD ... ; 299 - pp->info[1].chip_select = 2, 300 - pp->info[1].controller_data = pp; 301 - pp->butterfly = spi_new_device(pp->bitbang.master, &pp->info[1]); 302 - if (pp->butterfly) 303 - pr_debug("%s: butterfly at %s\n", p->name, 304 - pp->butterfly->dev.bus_id); 305 - 306 - /* FIXME setup ACK for the IRQ line ... */ 307 - #endif 308 328 309 329 // dev_info(_what?_, ...) 310 330 pr_info("%s: AVR Butterfly\n", p->name);