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: <YIQaXx9b2fGLOBmI@latitude>
Date:   Sat, 24 Apr 2021 15:17:19 +0200
From:   Jonathan Neuschäfer <j.neuschaefer@....net>
To:     Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
Cc:     Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
        Jonathan Neuschäfer <j.neuschaefer@....net>,
        Rob Herring <robh+dt@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Aswath Govindraju <a-govindraju@...com>,
        Vadym Kochan <vadym.kochan@...ision.eu>,
        devicetree@...r.kernel.org
Subject: Re: [PATCH 2/4] misc: eeprom_93xx46: set size and addrlen according
 to the dts

Hi,


> [PATCH 2/4] misc: eeprom_93xx46: set size and addrlen according to the dts

This patch doesn't really deal with the devicetree, so this subject line
seems a bit mismatched.

On Sat, Apr 24, 2021 at 02:30:31PM +0200, Emmanuel Gil Peyrot wrote:
> This can then be used by the rest of the driver to use the correct
> commands on 93c56 and 93c66.
> 
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
> ---

Ah hmmm. Does this mean that with the previous patch, the driver will be
instanciated for 93c56 and 93c66 but send the wrong commands? I think
you should avoid this pitfall by rearranging (or squashing) the patches.

>  drivers/misc/eeprom/eeprom_93xx46.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
> index 64dd76f66463..39375255e22a 100644
> --- a/drivers/misc/eeprom/eeprom_93xx46.c
> +++ b/drivers/misc/eeprom/eeprom_93xx46.c
> @@ -18,6 +18,7 @@
>  #include <linux/spi/spi.h>
>  #include <linux/nvmem-provider.h>
>  #include <linux/eeprom_93xx46.h>
> +#include <linux/log2.h>
>  
>  #define OP_START	0x4
>  #define OP_WRITE	(OP_START | 0x1)
> @@ -474,10 +475,22 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
>  	if (!edev)
>  		return -ENOMEM;
>  
> +	if (pd->flags & EE_SIZE1K)
> +		edev->size = 128;
> +	else if (pd->flags & EE_SIZE2K)
> +		edev->size = 256;
> +	else if (pd->flags & EE_SIZE4K)
> +		edev->size = 512;
> +	else {
> +		dev_err(&spi->dev, "unspecified size\n");
> +		err = -EINVAL;
> +		goto fail;
> +	}
> +
>  	if (pd->flags & EE_ADDR8)
> -		edev->addrlen = 7;
> +		edev->addrlen = ilog2(edev->size);
>  	else if (pd->flags & EE_ADDR16)
> -		edev->addrlen = 6;
> +		edev->addrlen = ilog2(edev->size) - 1;
>  	else {
>  		dev_err(&spi->dev, "unspecified address type\n");
>  		return -EINVAL;
> @@ -488,7 +501,6 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
>  	edev->spi = spi;
>  	edev->pdata = pd;
>  
> -	edev->size = 128;
>  	edev->nvmem_config.type = NVMEM_TYPE_EEPROM;
>  	edev->nvmem_config.name = dev_name(&spi->dev);
>  	edev->nvmem_config.dev = &spi->dev;
> @@ -508,8 +520,9 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
>  	if (IS_ERR(edev->nvmem))
>  		return PTR_ERR(edev->nvmem);
>  
> -	dev_info(&spi->dev, "%d-bit eeprom %s\n",
> +	dev_info(&spi->dev, "%d-bit eeprom containing %d bytes %s\n",
>  		(pd->flags & EE_ADDR8) ? 8 : 16,
> +		edev->size,
>  		(pd->flags & EE_READONLY) ? "(readonly)" : "");


The logic itself looks good though.

Thanks,
Jonathan

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ