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

spi: sc18is602: Move checking chip_select for SC18IS602 to sc18is602_setup

So it will be checked when spi device is added onto the spi bus.
spi_add_device() calls spi_setup() which then calls spi->master->setup().
No need to check it every time sc18is602_transfer_one() is called.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Axel Lin and committed by
Mark Brown
c5c67e31 589f6a90

+12 -7
+12 -7
drivers/spi/spi-sc18is602.c
··· 205 205 struct spi_transfer *t; 206 206 int status = 0; 207 207 208 - /* SC18IS602 does not support CS2 */ 209 - if (hw->id == sc18is602 && spi->chip_select == 2) { 210 - status = -ENXIO; 211 - goto error; 212 - } 213 - 214 208 hw->tlen = 0; 215 209 list_for_each_entry(t, &m->transfers, transfer_list) { 216 210 u32 hz = t->speed_hz ? : spi->max_speed_hz; ··· 232 238 if (t->delay_usecs) 233 239 udelay(t->delay_usecs); 234 240 } 235 - error: 236 241 m->status = status; 237 242 spi_finalize_current_message(master); 238 243 239 244 return status; 245 + } 246 + 247 + static int sc18is602_setup(struct spi_device *spi) 248 + { 249 + struct sc18is602 *hw = spi_master_get_devdata(spi->master); 250 + 251 + /* SC18IS602 does not support CS2 */ 252 + if (hw->id == sc18is602 && spi->chip_select == 2) 253 + return -ENXIO; 254 + 255 + return 0; 240 256 } 241 257 242 258 static int sc18is602_probe(struct i2c_client *client, ··· 302 298 master->bus_num = client->adapter->nr; 303 299 master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST; 304 300 master->bits_per_word_mask = SPI_BPW_MASK(8); 301 + master->setup = sc18is602_setup; 305 302 master->transfer_one_message = sc18is602_transfer_one; 306 303 master->dev.of_node = np; 307 304