lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <961ec8d9-d96e-2dce-f2d0-b10299e10afb@vaisala.com>
Date:   Mon, 24 May 2021 11:25:28 +0300
From:   Tomas Melin <tomas.melin@...sala.com>
To:     Clark Wang <xiaoning.wang@....com>, broonie@...nel.org,
        shawnguo@...nel.org, s.hauer@...gutronix.de, festevam@...il.com
Cc:     kernel@...gutronix.de, linux-imx@....com,
        linux-spi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] spi: imx: add 16/32 bits per word support for slave mode

Hi,

On 4/8/21 1:33 PM, Clark Wang wrote:
> Enable 16/32 bits per word support for spi-imx slave mode.
> It only support 8 bits per word in slave mode before.
>
> Signed-off-by: Clark Wang <xiaoning.wang@....com>
> Reviewed-by: Haibo Chen <haibo.chen@....com>
> ---
>   drivers/spi/spi-imx.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> index 4fe767acaca7..24ba7ab1b05d 100644
> --- a/drivers/spi/spi-imx.c
> +++ b/drivers/spi/spi-imx.c
> @@ -386,7 +386,12 @@ static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx)
>   
>   static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx)
>   {
> -	u32 val = be32_to_cpu(readl(spi_imx->base + MXC_CSPIRXDATA));
> +	u32 val = readl(spi_imx->base + MXC_CSPIRXDATA);
> +
> +	if (spi_imx->bits_per_word <= 8)
> +		val = be32_to_cpu(val);
> +	else if (spi_imx->bits_per_word <= 16)
> +		val = (val << 16) | (val >> 16);

Would it be good to use available

     spi_imx_buf_rx_u32

     spi_imx_buf_rx_u16

     spi_imx_buf_rx_u8

helpers here?

thanks,

Tomas


>   
>   	if (spi_imx->rx_buf) {
>   		int n_bytes = spi_imx->slave_burst % sizeof(val);
> @@ -415,7 +420,11 @@ static void mx53_ecspi_tx_slave(struct spi_imx_data *spi_imx)
>   	if (spi_imx->tx_buf) {
>   		memcpy(((u8 *)&val) + sizeof(val) - n_bytes,
>   		       spi_imx->tx_buf, n_bytes);
> -		val = cpu_to_be32(val);
> +		if (spi_imx->bits_per_word <= 8)
> +			val = cpu_to_be32(val);
> +		else if (spi_imx->bits_per_word <= 16)
> +			val = (val << 16) | (val >> 16);
> +
>   		spi_imx->tx_buf += n_bytes;
>   	}
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ