Понедельник, 17 февраля 2014, 21:59 +08:00 от Axel Lin <[email protected]>:
> Convert to use default implementation of transfer_one_message() which provides
> standard handling of delays and chip select management.
> 
> Signed-off-by: Axel Lin <[email protected]>
> ---
> Hi Alexander,
> I don't have this hardware, can you help testing this patch.
> Thanks,
> Axel

OK, this will require about a week.

>  drivers/spi/spi-clps711x.c | 89 
> ++++++++++++++++++++--------------------------
>  1 file changed, 38 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
> index f973e97..6ae0cbf 100644
> --- a/drivers/spi/spi-clps711x.c
> +++ b/drivers/spi/spi-clps711x.c
> @@ -24,8 +24,6 @@
>  #define DRIVER_NAME  "spi-clps711x"
>  
>  struct spi_clps711x_data {
> -     struct completion       done;
> -
>       struct clk              *spi_clk;
>       u32                     max_speed_hz;
>  
> @@ -43,15 +41,6 @@ static int spi_clps711x_setup(struct spi_device *spi)
>       return 0;
>  }
>  
> -static void spi_clps711x_setup_mode(struct spi_device *spi)
> -{
> -     /* Setup edge for transfer */
> -     if (spi->mode & SPI_CPHA)
> -             clps_writew(clps_readw(SYSCON3) | SYSCON3_ADCCKNSEN, SYSCON3);
> -     else
> -             clps_writew(clps_readw(SYSCON3) & ~SYSCON3_ADCCKNSEN, SYSCON3);
> -}
> -
>  static void spi_clps711x_setup_xfer(struct spi_device *spi,
>                                   struct spi_transfer *xfer)
>  {
> @@ -73,55 +62,52 @@ static void spi_clps711x_setup_xfer(struct spi_device 
> *spi,
>                           SYSCON1_ADCKSEL(0), SYSCON1);
>  }
>  
> -static int spi_clps711x_transfer_one_message(struct spi_master *master,
> -                                          struct spi_message *msg)
> +static void spi_clps711x_set_cs(struct spi_device *spi, bool enable)
>  {
> -     struct spi_clps711x_data *hw = spi_master_get_devdata(master);
> -     struct spi_device *spi = msg->spi;
> -     struct spi_transfer *xfer;
> -
> -     spi_clps711x_setup_mode(spi);
> -
> -     list_for_each_entry(xfer, &msg->transfers, transfer_list) {
> -             u8 data;
> -
> -             spi_clps711x_setup_xfer(spi, xfer);
> -
> +     if (enable)
>               gpio_set_value(spi->cs_gpio, !!(spi->mode & SPI_CS_HIGH));
> +     else
> +             gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
> +}

You can eliminate spi_clps711x_set_cs() function entirely.
GPIOs can be handled by SPI core, see spi_set_cs() function.

---

Reply via email to