[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YiYYa7GkknJ+CAuL@kuha.fi.intel.com>
Date: Mon, 7 Mar 2022 16:36:27 +0200
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Alvin Šipraga <alvin@...s.dk>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
�ipraga <alsi@...g-olufsen.dk>,
linux-usb@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] usb: typec: add TUSB320xA driver
Hi,
On Tue, Mar 01, 2022 at 02:20:07PM +0100, Alvin Šipraga wrote:
> From: Alvin Šipraga <alsi@...g-olufsen.dk>
>
> The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled
> non-PD Type-C port controllers. They support detection of cable
> orientation, port attachment state, and role, including Audio Accessory
> and Debug Accessory modes. Add a typec class driver for this family.
>
> Note that there already exists an extcon driver for the TUSB320 (a
> slightly older revision that does not support setting role preference or
> disabling the CC state machine). This driver is loosely based on that
> one.
This looked mostly OK to me. There is one question below.
<snip>
> +static int tusb320xa_check_signature(struct tusb320xa *tusb)
> +{
> + static const char sig[] = { '\0', 'T', 'U', 'S', 'B', '3', '2', '0' };
> + unsigned int val;
> + int i, ret;
> +
> + mutex_lock(&tusb->lock);
> +
> + for (i = 0; i < sizeof(sig); i++) {
> + ret = regmap_read(tusb->regmap, sizeof(sig) - 1 - i, &val);
> + if (ret)
> + goto done;
> +
> + if (val != sig[i]) {
> + dev_err(tusb->dev, "signature mismatch!\n");
> + ret = -ENODEV;
> + goto done;
> + }
> + }
> +
> +done:
> + mutex_unlock(&tusb->lock);
> +
> + return ret;
> +}
Couldn't that be done with a single read?
char sig[8];
u64 val;
strcpy(sig, "TUSB320")
mutex_lock(&tusb->lock);
ret = regmap_raw_read(tusb->regmap, 0, &val, sizeof(val));
...
if (val != cpu_to_le64(*(u64 *)sig)) {
...
Something like that?
thanks,
--
heikki
Powered by blists - more mailing lists