From: Guenter Roeck <linux@roeck-us.net>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 3/7] usb: typec: Separate the operations vector
Date: Sat, 5 Oct 2019 10:36:02 -0700 [thread overview]
Message-ID: <9f45326d-8667-25e0-755a-37d1a76e5b83@roeck-us.net> (raw)
In-Reply-To: <20191004150817.45413-4-heikki.krogerus@linux.intel.com>
On 10/4/19 8:08 AM, Heikki Krogerus wrote:
> Introducing struct typec_operations which has the same
> callbacks as struct typec_capability. The old callbacks are
> kept for now, but after all users have been converted, they
> will be removed.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/class.c | 39 +++++++++++++++++++++++++++++----------
> include/linux/usb/typec.h | 20 ++++++++++++++++++++
> 2 files changed, 49 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 89ffe370e426..f4972b7ee022 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -54,6 +54,7 @@ struct typec_port {
>
> const struct typec_capability *orig_cap; /* to be removed */
> const struct typec_capability *cap;
> + const struct typec_operations *ops;
> };
>
> #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev)
> @@ -956,7 +957,7 @@ preferred_role_store(struct device *dev, struct device_attribute *attr,
> return -EOPNOTSUPP;
> }
>
> - if (!port->cap->try_role) {
> + if (!port->cap->try_role || (!port->ops && !port->ops->try_role)) {
Even though it is only temporary, this should be
if (!port->cap->try_role && (!port->ops || !port->ops->try_role)) {
otherwise both cap->try_role and ops->try_role must exist. Also, there would
be a crash if port->cap->try_role and port->ops are both NULL. Same pretty
much everywhere below.
Guenter
next prev parent reply other threads:[~2019-10-05 17:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 15:08 [PATCH v2 0/7] usb: typec: Small API improvement Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 1/7] usb: typec: Copy everything from struct typec_capability during registration Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 2/7] usb: typec: Introduce typec_get_drvdata() Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 3/7] usb: typec: Separate the operations vector Heikki Krogerus
2019-10-04 15:17 ` Heikki Krogerus
2019-10-05 17:36 ` Guenter Roeck [this message]
2019-10-07 8:44 ` Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 4/7] usb: typec: tcpm: Start using struct typec_operations Heikki Krogerus
2019-10-05 17:39 ` Guenter Roeck
2019-10-04 15:08 ` [PATCH v2 5/7] usb: typec: tps6598x: " Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 6/7] usb: typec: ucsi: " Heikki Krogerus
2019-10-04 15:08 ` [PATCH v2 7/7] usb: typec: Remove the callback members from struct typec_capability Heikki Krogerus
2019-10-05 17:37 ` Guenter Roeck
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=9f45326d-8667-25e0-755a-37d1a76e5b83@roeck-us.net \
--to=linux@roeck-us.net \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-usb@vger.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;
as well as URLs for NNTP newsgroup(s).