aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-fsl-spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-fsl-spi.c')
-rw-r--r--drivers/spi/spi-fsl-spi.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 9452f6740997..590f31bc0aba 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -425,16 +425,16 @@ static int fsl_spi_setup(struct spi_device *spi)
425 struct fsl_spi_reg *reg_base; 425 struct fsl_spi_reg *reg_base;
426 int retval; 426 int retval;
427 u32 hw_mode; 427 u32 hw_mode;
428 struct spi_mpc8xxx_cs *cs = spi->controller_state; 428 struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
429 429
430 if (!spi->max_speed_hz) 430 if (!spi->max_speed_hz)
431 return -EINVAL; 431 return -EINVAL;
432 432
433 if (!cs) { 433 if (!cs) {
434 cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); 434 cs = kzalloc(sizeof(*cs), GFP_KERNEL);
435 if (!cs) 435 if (!cs)
436 return -ENOMEM; 436 return -ENOMEM;
437 spi->controller_state = cs; 437 spi_set_ctldata(spi, cs);
438 } 438 }
439 mpc8xxx_spi = spi_master_get_devdata(spi->master); 439 mpc8xxx_spi = spi_master_get_devdata(spi->master);
440 440
@@ -496,9 +496,13 @@ static int fsl_spi_setup(struct spi_device *spi)
496static void fsl_spi_cleanup(struct spi_device *spi) 496static void fsl_spi_cleanup(struct spi_device *spi)
497{ 497{
498 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); 498 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
499 struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
499 500
500 if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio)) 501 if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio))
501 gpio_free(spi->cs_gpio); 502 gpio_free(spi->cs_gpio);
503
504 kfree(cs);
505 spi_set_ctldata(spi, NULL);
502} 506}
503 507
504static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) 508static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)