diff mbox series

[net-next] net: pse-pd: tps23881: Fix the device ID check

Message ID 20240730161032.3616000-1-kyle.swenson@est.tech (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: pse-pd: tps23881: Fix the device ID check | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 42 this patch: 42
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 43 this patch: 43
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 43 this patch: 43
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-07-30--21-00 (tests: 707)

Commit Message

Kyle Swenson July 30, 2024, 4:11 p.m. UTC
The DEVID register contains two pieces of information: the device ID in
the upper nibble, and the silicon revision number in the lower nibble.
The driver should work fine with any silicon revision, so let's mask
that out in the device ID check.

Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Kyle Swenson <kyle.swenson@est.tech>
---
 drivers/net/pse-pd/tps23881.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Petazzoni July 30, 2024, 4:18 p.m. UTC | #1
Hello Kyle,

On Tue, 30 Jul 2024 16:11:08 +0000
Kyle Swenson <kyle.swenson@est.tech> wrote:

> The DEVID register contains two pieces of information: the device ID in
> the upper nibble, and the silicon revision number in the lower nibble.
> The driver should work fine with any silicon revision, so let's mask
> that out in the device ID check.
> 
> Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
> Signed-off-by: Kyle Swenson <kyle.swenson@est.tech>
> ---
>  drivers/net/pse-pd/tps23881.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
> index 61f6ad9c1934..bff8402fb382 100644
> --- a/drivers/net/pse-pd/tps23881.c
> +++ b/drivers/net/pse-pd/tps23881.c
> @@ -748,11 +748,11 @@ static int tps23881_i2c_probe(struct i2c_client *client)
>  
>  	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
>  	if (ret < 0)
>  		return ret;
>  
> -	if (ret != 0x22) {
> +	if ((ret & 0xF0) != 0x20) {

Thanks for the patch! I believe it would make sense to use defines
here. At least for 0xF0, and perhaps for 0x20 as well.

Maybe:

#define TPS23881_REG_DEVID      		0x43
#define TPS23881_REG_DEVID_DEVID_MASK		0xF0
#define TPS23881_REG_DEVID_DEVID_VAL		0x2

and then:

	if (FIELD_GET(TPS23881_REG_DEVID_DEVID_MASK, ret) != 
            TPS23881_REG_DEVID_DEVID_VAL)

(totally untested, of course)

Best regards,

Thomas
Kyle Swenson July 30, 2024, 9:52 p.m. UTC | #2
Hello Thomas,

On Tue, Jul 30, 2024 at 06:18:12PM +0200, Thomas Petazzoni wrote:
> Hello Kyle,
> 
> On Tue, 30 Jul 2024 16:11:08 +0000
> Kyle Swenson <kyle.swenson@est.tech> wrote:
> 
> > The DEVID register contains two pieces of information: the device ID in
> > the upper nibble, and the silicon revision number in the lower nibble.
> > The driver should work fine with any silicon revision, so let's mask
> > that out in the device ID check.
> > 
> > Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
> > Signed-off-by: Kyle Swenson <kyle.swenson@est.tech>
> > ---
> >  drivers/net/pse-pd/tps23881.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
> > index 61f6ad9c1934..bff8402fb382 100644
> > --- a/drivers/net/pse-pd/tps23881.c
> > +++ b/drivers/net/pse-pd/tps23881.c
> > @@ -748,11 +748,11 @@ static int tps23881_i2c_probe(struct i2c_client *client)
> >  
> >  	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
> >  	if (ret < 0)
> >  		return ret;
> >  
> > -	if (ret != 0x22) {
> > +	if ((ret & 0xF0) != 0x20) {
> 
> Thanks for the patch! I believe it would make sense to use defines
> here. At least for 0xF0, and perhaps for 0x20 as well.
> 
> Maybe:
> 
> #define TPS23881_REG_DEVID      		0x43
> #define TPS23881_REG_DEVID_DEVID_MASK		0xF0
> #define TPS23881_REG_DEVID_DEVID_VAL		0x2

Ah, yes, I agree.  I'll make the changes and send out a V2 tomorrow.

> 
> and then:
> 
> 	if (FIELD_GET(TPS23881_REG_DEVID_DEVID_MASK, ret) != 
>             TPS23881_REG_DEVID_DEVID_VAL)
> 
> (totally untested, of course)
> 
> Best regards,
> 
> Thomas
> -- 
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com

Thanks so much for the review!

Cheers,
Kyle
diff mbox series

Patch

diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
index 61f6ad9c1934..bff8402fb382 100644
--- a/drivers/net/pse-pd/tps23881.c
+++ b/drivers/net/pse-pd/tps23881.c
@@ -748,11 +748,11 @@  static int tps23881_i2c_probe(struct i2c_client *client)
 
 	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
 	if (ret < 0)
 		return ret;
 
-	if (ret != 0x22) {
+	if ((ret & 0xF0) != 0x20) {
 		dev_err(dev, "Wrong device ID\n");
 		return -ENXIO;
 	}
 
 	ret = tps23881_flash_sram_fw(client);