From: Jack Pham <jackp@codeaurora.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Prashant Malani <pmalani@chromium.org>,
Benson Leung <bleung@google.com>,
Adam Thomson <Adam.Thomson.Opensource@diasemi.com>,
Guenter Roeck <linux@roeck-us.net>,
Badhri Jagan Sridharan <badhri@google.com>,
"Gopal, Saranya" <saranya.gopal@intel.com>,
"Regupathy, Rajaram" <rajaram.regupathy@intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/4] usb: typec: ucsi: Add support for PD cdev
Date: Tue, 26 Oct 2021 18:00:35 -0700 [thread overview]
Message-ID: <20211027010035.GA13345@jackp-linux.qualcomm.com> (raw)
In-Reply-To: <20211026143352.78387-4-heikki.krogerus@linux.intel.com>
On Tue, Oct 26, 2021 at 05:33:51PM +0300, Heikki Krogerus wrote:
>
> -static int ucsi_get_src_pdos(struct ucsi_connector *con)
> +int ucsi_read_pdos(struct ucsi_connector *con, int partner, int source, u32 *pdos)
> {
> + u32 pdo[PDO_MAX_OBJECTS];
> + int num_pdos;
> int ret;
>
> /* UCSI max payload means only getting at most 4 PDOs at a time */
> - ret = ucsi_get_pdos(con, 1, con->src_pdos, 0, UCSI_MAX_PDOS);
> + ret = ucsi_get_pdos(con, partner, source, pdo, 0, UCSI_MAX_PDOS);
> if (ret < 0)
> return ret;
>
> - con->num_pdos = ret / sizeof(u32); /* number of bytes to 32-bit PDOs */
> - if (con->num_pdos < UCSI_MAX_PDOS)
> - return 0;
> + num_pdos = ret / sizeof(u32); /* number of bytes to 32-bit PDOs */
> + if (num_pdos < UCSI_MAX_PDOS)
> + goto done;
>
> /* get the remaining PDOs, if any */
> - ret = ucsi_get_pdos(con, 1, con->src_pdos, UCSI_MAX_PDOS,
> + ret = ucsi_get_pdos(con, partner, source, pdo, UCSI_MAX_PDOS,
> PDO_MAX_OBJECTS - UCSI_MAX_PDOS);
> if (ret < 0)
> return ret;
>
> - con->num_pdos += ret / sizeof(u32);
> + num_pdos += ret / sizeof(u32);
> +done:
> + memcpy(pdos, pdo, num_pdos * sizeof(pdo));
> +
> + return num_pdos;
> +}
> +
> +static int ucsi_get_src_pdos(struct ucsi_connector *con)
> +{
> + int ret;
> +
> + ret = ucsi_read_pdos(con, 0, 1, con->src_pdos);
Second parameter should be 1 right? Original intent of get_src_pdos()
is to retrieve the partner's source capabilities in order to populate
the power_supply. Passing 0 as the partner param here changes the
behavior to retrieve the source PDOs of the port.
(BTW I'm going to send a quick patch for this to since this assumes that
port is sink and partner is source; when it's the other way around we
end up calling GET_PDOS on the sink partner when it might not even be
source capable).
Jack
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2021-10-27 1:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-26 14:33 [RFC PATCH 0/4] USB Power Delivery character device interface Heikki Krogerus
2021-10-26 14:33 ` [RFC PATCH 1/4] usb: pd: uapi header split Heikki Krogerus
2021-10-26 14:33 ` [RFC PATCH 2/4] usb: typec: Character device for USB Power Delivery devices Heikki Krogerus
2021-10-26 15:08 ` Greg KH
2021-10-28 1:03 ` Prashant Malani
2021-10-28 7:36 ` Heikki Krogerus
2021-11-09 0:27 ` Prashant Malani
2021-10-26 14:33 ` [RFC PATCH 3/4] usb: typec: ucsi: Add support for PD cdev Heikki Krogerus
2021-10-27 1:00 ` Jack Pham [this message]
2021-10-27 11:10 ` Heikki Krogerus
2021-10-26 14:33 ` [RFC PATCH 4/4] tools: usb: Hideous test tool for USB PD char device Heikki Krogerus
2021-10-26 15:06 ` [RFC PATCH 0/4] USB Power Delivery character device interface Greg KH
2021-10-27 11:02 ` Heikki Krogerus
2021-10-27 12:53 ` Greg KH
2021-10-28 7:17 ` Heikki Krogerus
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=20211027010035.GA13345@jackp-linux.qualcomm.com \
--to=jackp@codeaurora.org \
--cc=Adam.Thomson.Opensource@diasemi.com \
--cc=badhri@google.com \
--cc=bleung@google.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=pmalani@chromium.org \
--cc=rajaram.regupathy@intel.com \
--cc=saranya.gopal@intel.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