linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	linux-kernel@vger.kernel.org,
	"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Aswath Govindraju" <a-govindraju@ti.com>,
	"Vadym Kochan" <vadym.kochan@plvision.eu>,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 2/4] misc: eeprom_93xx46: set size and addrlen according to the dts
Date: Sat, 24 Apr 2021 15:17:19 +0200	[thread overview]
Message-ID: <YIQaXx9b2fGLOBmI@latitude> (raw)
In-Reply-To: <20210424123034.11755-3-linkmauve@linkmauve.fr>

[-- Attachment #1: Type: text/plain, Size: 2663 bytes --]

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@linkmauve.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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-04-24 13:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 12:30 [PATCH 0/4] eeprom-93xx46: Add support for Atmel AT93C56 and AT93C66 Emmanuel Gil Peyrot
2021-04-24 12:30 ` [PATCH 1/4] misc: eeprom_93xx46: Add new at93c56 and at93c66 compatible strings Emmanuel Gil Peyrot
2021-04-24 13:02   ` Jonathan Neuschäfer
2021-04-24 12:30 ` [PATCH 2/4] misc: eeprom_93xx46: set size and addrlen according to the dts Emmanuel Gil Peyrot
2021-04-24 13:17   ` Jonathan Neuschäfer [this message]
2021-04-24 16:13   ` kernel test robot
2021-04-24 12:30 ` [PATCH 3/4] misc: eeprom_93xx46: Compute bits based on addrlen Emmanuel Gil Peyrot
2021-04-24 13:34   ` Jonathan Neuschäfer
2021-04-24 12:30 ` [PATCH 4/4] misc: eeprom_93xx46: Switch based on word size, not addrlen Emmanuel Gil Peyrot
2021-04-24 13:42   ` Jonathan Neuschäfer
2021-04-24 21:25 ` [PATCH v2 0/3] eeprom-93xx46: Add support for Atmel AT93C56 and AT93C66 Emmanuel Gil Peyrot
2021-04-24 21:25   ` [PATCH v2 1/3] misc: eeprom_93xx46: Remove hardcoded bit lengths Emmanuel Gil Peyrot
2021-04-26  7:46     ` Jonathan Neuschäfer
2021-04-24 21:25   ` [PATCH v2 2/3] misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings Emmanuel Gil Peyrot
2021-04-26  7:56     ` Jonathan Neuschäfer
2021-04-24 21:25   ` [PATCH v2 3/3] dts: eeprom-93xx46: Add support for 93C46, 93C56 and 93C66 Emmanuel Gil Peyrot
2021-04-26  8:02     ` Jonathan Neuschäfer
2021-05-03 18:56     ` Rob Herring
2021-05-11 21:07   ` [PATCH v3 0/3] eeprom-93xx46: Add support for Atmel AT93C56 and AT93C66 Emmanuel Gil Peyrot
2021-05-11 21:07     ` [PATCH v3 1/3] misc: eeprom_93xx46: Remove hardcoded bit lengths Emmanuel Gil Peyrot
2021-05-11 21:07     ` [PATCH v3 2/3] misc: eeprom_93xx46: Add new 93c56 and 93c66 compatible strings Emmanuel Gil Peyrot
2021-05-11 21:07     ` [PATCH v3 3/3] dt-bindings: eeprom-93xx46: Add support for 93C46, 93C56 and 93C66 Emmanuel Gil Peyrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YIQaXx9b2fGLOBmI@latitude \
    --to=j.neuschaefer@gmx.net \
    --cc=a-govindraju@ti.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linkmauve@linkmauve.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vadym.kochan@plvision.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).