From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "Alvin Šipraga" <alvin@pqrs.dk>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rob Herring" <robh+dt@kernel.org>,
�ipraga <alsi@bang-olufsen.dk>,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] usb: typec: add TUSB320xA driver
Date: Mon, 7 Mar 2022 16:36:27 +0200 [thread overview]
Message-ID: <YiYYa7GkknJ+CAuL@kuha.fi.intel.com> (raw)
In-Reply-To: <20220301132010.115258-4-alvin@pqrs.dk>
Hi,
On Tue, Mar 01, 2022 at 02:20:07PM +0100, Alvin Šipraga wrote:
> From: Alvin Šipraga <alsi@bang-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
next prev parent reply other threads:[~2022-03-07 14:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 13:20 [PATCH 0/4] usb: typec: add drivers for TUSB320xA and TS5USBA224 Alvin Šipraga
2022-03-01 13:20 ` [PATCH 1/4] dt-bindings: usb: add TUSB320xA Type-C port controller Alvin Šipraga
2022-03-02 18:16 ` Rob Herring
2022-03-01 13:20 ` [PATCH 2/4] dt-bindings: usb: add TS5USBA224 USB/Audio switch mux Alvin Šipraga
2022-03-02 18:21 ` Rob Herring
2022-03-02 18:58 ` Alvin Šipraga
2022-03-01 13:20 ` [PATCH 3/4] usb: typec: add TUSB320xA driver Alvin Šipraga
2022-03-01 16:58 ` kernel test robot
2022-03-01 17:20 ` Alvin Šipraga
2022-03-07 14:36 ` Heikki Krogerus [this message]
2022-03-07 22:17 ` Alvin Šipraga
2022-03-08 11:49 ` Heikki Krogerus
2022-03-08 12:30 ` Alvin Šipraga
2022-03-01 13:20 ` [PATCH 4/4] usb: typec: mux: add TS5USBA224 driver Alvin Šipraga
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=YiYYa7GkknJ+CAuL@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=alsi@bang-olufsen.dk \
--cc=alvin@pqrs.dk \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=robh+dt@kernel.org \
/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