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] [thread-next>] [day] [month] [year] [list]
Message-ID: <aa3c79a0-ecbc-4f12-b540-6570350a7909@sirena.org.uk>
Date: Fri, 5 Jul 2024 18:41:49 +0100
From: Mark Brown <broonie@...nel.org>
To: Johannes Thumshirn <jth@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-spi@...r.kernel.org
Subject: Re: [PATCH] spi: add ch341a usb2spi driver

On Fri, Jul 05, 2024 at 04:51:37PM +0200, Johannes Thumshirn wrote:

> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -1198,6 +1198,12 @@ config SPI_AMD
>  	help
>  	  Enables SPI controller driver for AMD SoC.
>  
> +config SPI_CH341
> +	tristate "CH341 USB2SPI adapter"
> +	depends on SPI_MASTER && USB
> +	help
> +	  Enables the SPI controller on the CH341a USB to serial chip
> +
>  #
>  # Add new SPI master controllers in alphabetical order above this line
>  #

Like the comment says please keep these files sorted (I appreciate
there's some things been missed).

> +++ b/drivers/spi/spi-ch341.c
> @@ -0,0 +1,236 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * QiHeng Electronics ch341a USB-to-SPI adapter driver
> + *
> + * Copyright (C) 2024 Johannes Thumshirn <jth@...nel.org>

Please make the entire comment block a C++ one so things look clearer.

> +static void ch341_set_cs(struct spi_device *spi, bool is_high)
> +{
> +	struct ch341_spi_dev *ch341 =
> +		spi_controller_get_devdata(spi->controller);
> +
> +	memset(ch341->tx_buf, 0, CH341_PACKET_LENGTH);
> +	ch341->tx_buf[0] = CH341A_CMD_UIO_STREAM;
> +	ch341->tx_buf[1] = CH341A_CMD_UIO_STM_OUT | (is_high ? 0x36 : 0x37);
> +
> +	if (is_high) {
> +		ch341->tx_buf[2] = CH341A_CMD_UIO_STM_DIR | 0x3f;
> +		ch341->tx_buf[3] = CH341A_CMD_UIO_STM_END;
> +	} else {
> +		ch341->tx_buf[2] = CH341A_CMD_UIO_STM_END;
> +	}
> +
> +	(void)usb_bulk_msg(ch341->udev, ch341->write_pipe, ch341->tx_buf,
> +			   (is_high ? 4 : 3), NULL, CH341_DEFAULT_TIMEOUT);

The cast to void here is very suspicious, what's it doing?

> +static int ch341_config_stream(struct ch341_spi_dev *ch341, int speed)
> +{
> +	memset(ch341->tx_buf, 0, CH341_PACKET_LENGTH);
> +	ch341->tx_buf[0] = CH341A_CMD_I2C_STREAM;
> +	ch341->tx_buf[1] = CH341A_CMD_I2C_STM_SET | (speed & 0x7);
> +	ch341->tx_buf[2] = CH341A_CMD_I2C_STM_END;
> +
> +	return usb_bulk_msg(ch341->udev, ch341->write_pipe, ch341->tx_buf, 3,
> +			    NULL, CH341_DEFAULT_TIMEOUT);

No validation of speed?

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ