aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi-dw.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 29f33143b795..b4508db2edcd 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -547,8 +547,7 @@ static int dw_spi_setup(struct spi_device *spi)
547 /* Only alloc on first setup */ 547 /* Only alloc on first setup */
548 chip = spi_get_ctldata(spi); 548 chip = spi_get_ctldata(spi);
549 if (!chip) { 549 if (!chip) {
550 chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data), 550 chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
551 GFP_KERNEL);
552 if (!chip) 551 if (!chip)
553 return -ENOMEM; 552 return -ENOMEM;
554 spi_set_ctldata(spi, chip); 553 spi_set_ctldata(spi, chip);
@@ -606,6 +605,14 @@ static int dw_spi_setup(struct spi_device *spi)
606 return 0; 605 return 0;
607} 606}
608 607
608static void dw_spi_cleanup(struct spi_device *spi)
609{
610 struct chip_data *chip = spi_get_ctldata(spi);
611
612 kfree(chip);
613 spi_set_ctldata(spi, NULL);
614}
615
609/* Restart the controller, disable all interrupts, clean rx fifo */ 616/* Restart the controller, disable all interrupts, clean rx fifo */
610static void spi_hw_init(struct dw_spi *dws) 617static void spi_hw_init(struct dw_spi *dws)
611{ 618{
@@ -661,6 +668,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
661 master->bus_num = dws->bus_num; 668 master->bus_num = dws->bus_num;
662 master->num_chipselect = dws->num_cs; 669 master->num_chipselect = dws->num_cs;
663 master->setup = dw_spi_setup; 670 master->setup = dw_spi_setup;
671 master->cleanup = dw_spi_cleanup;
664 master->transfer_one_message = dw_spi_transfer_one_message; 672 master->transfer_one_message = dw_spi_transfer_one_message;
665 master->max_speed_hz = dws->max_freq; 673 master->max_speed_hz = dws->max_freq;
666 674