netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: Kyle Swenson <kyle.swenson@est.tech>
Cc: "o.rempel@pengutronix.de" <o.rempel@pengutronix.de>,
	"kory.maincent@bootlin.com" <kory.maincent@bootlin.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] net: pse-pd: tps23881: Fix the device ID check
Date: Tue, 30 Jul 2024 18:18:12 +0200	[thread overview]
Message-ID: <20240730181812.5fc002fb@windsurf> (raw)
In-Reply-To: <20240730161032.3616000-1-kyle.swenson@est.tech>

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
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com

  reply	other threads:[~2024-07-30 16:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 16:11 [PATCH net-next] net: pse-pd: tps23881: Fix the device ID check Kyle Swenson
2024-07-30 16:18 ` Thomas Petazzoni [this message]
2024-07-30 21:52   ` Kyle Swenson

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=20240730181812.5fc002fb@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=kyle.swenson@est.tech \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    /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).