diff options
| -rw-r--r-- | drivers/spi/spi-fsl-espi.c | 15 | ||||
| -rw-r--r-- | drivers/spi/spi-fsl-spi.c | 10 |
2 files changed, 19 insertions, 6 deletions
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 8ebd724e4c59..429e11190265 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
| @@ -452,16 +452,16 @@ static int fsl_espi_setup(struct spi_device *spi) | |||
| 452 | int retval; | 452 | int retval; |
| 453 | u32 hw_mode; | 453 | u32 hw_mode; |
| 454 | u32 loop_mode; | 454 | u32 loop_mode; |
| 455 | struct spi_mpc8xxx_cs *cs = spi->controller_state; | 455 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); |
| 456 | 456 | ||
| 457 | if (!spi->max_speed_hz) | 457 | if (!spi->max_speed_hz) |
| 458 | return -EINVAL; | 458 | return -EINVAL; |
| 459 | 459 | ||
| 460 | if (!cs) { | 460 | if (!cs) { |
| 461 | cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); | 461 | cs = kzalloc(sizeof(*cs), GFP_KERNEL); |
| 462 | if (!cs) | 462 | if (!cs) |
| 463 | return -ENOMEM; | 463 | return -ENOMEM; |
| 464 | spi->controller_state = cs; | 464 | spi_set_ctldata(spi, cs); |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | mpc8xxx_spi = spi_master_get_devdata(spi->master); | 467 | mpc8xxx_spi = spi_master_get_devdata(spi->master); |
| @@ -496,6 +496,14 @@ static int fsl_espi_setup(struct spi_device *spi) | |||
| 496 | return 0; | 496 | return 0; |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | static void fsl_espi_cleanup(struct spi_device *spi) | ||
| 500 | { | ||
| 501 | struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); | ||
| 502 | |||
| 503 | kfree(cs); | ||
| 504 | spi_set_ctldata(spi, NULL); | ||
| 505 | } | ||
| 506 | |||
| 499 | void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) | 507 | void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) |
| 500 | { | 508 | { |
| 501 | struct fsl_espi_reg *reg_base = mspi->reg_base; | 509 | struct fsl_espi_reg *reg_base = mspi->reg_base; |
| @@ -605,6 +613,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev, | |||
| 605 | 613 | ||
| 606 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | 614 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); |
| 607 | master->setup = fsl_espi_setup; | 615 | master->setup = fsl_espi_setup; |
| 616 | master->cleanup = fsl_espi_cleanup; | ||
| 608 | 617 | ||
| 609 | mpc8xxx_spi = spi_master_get_devdata(master); | 618 | mpc8xxx_spi = spi_master_get_devdata(master); |
| 610 | mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; | 619 | mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg; |
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) | |||
| 496 | static void fsl_spi_cleanup(struct spi_device *spi) | 496 | static 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 | ||
| 504 | static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) | 508 | static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) |
