From: Prashant Malani <pmalani@chromium.org>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Tim Wawrzynczak <twawrzynczak@chromium.org>,
Benson Leung <bleung@chromium.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>, Guenter Roeck <groeck@chromium.org>,
Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH 2/2] platform/chrome: typec: Register Type C switches
Date: Wed, 29 Apr 2020 16:02:25 -0700 [thread overview]
Message-ID: <CACeCKadOzR++ctpG52ZBZZewXFRz39crHotsTC9+MjSWBoE_Dg@mail.gmail.com> (raw)
In-Reply-To: <12b56c9e-d8c7-82fa-57c8-7a33236ba188@collabora.com>
Hi Enric,
Thanks for your review. Kindly see inline:
On Wed, Apr 29, 2020 at 3:22 PM Enric Balletbo i Serra
<enric.balletbo@collabora.com> wrote:
>
> Hi Prashant,
>
> Thank you for your patch.
>
> On 23/4/20 0:22, Prashant Malani wrote:
> > Register Type C mux and switch handles, when provided via firmware
> > bindings. These will allow the cros-ec-typec driver, and also alternate
> > mode drivers to configure connected Muxes correctly, according to PD
> > information retrieved from the Chrome OS EC.
> >
> > Signed-off-by: Prashant Malani <pmalani@chromium.org>
> > ---
> > drivers/platform/chrome/cros_ec_typec.c | 47 +++++++++++++++++++++++++
> > 1 file changed, 47 insertions(+)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> > index eda57db26f8d..324ead297c4d 100644
> > --- a/drivers/platform/chrome/cros_ec_typec.c
> > +++ b/drivers/platform/chrome/cros_ec_typec.c
> > @@ -14,6 +14,8 @@
> > #include <linux/platform_data/cros_usbpd_notify.h>
> > #include <linux/platform_device.h>
> > #include <linux/usb/typec.h>
> > +#include <linux/usb/typec_mux.h>
> > +#include <linux/usb/role.h>
> >
> > #define DRV_NAME "cros-ec-typec"
> >
> > @@ -25,6 +27,9 @@ struct cros_typec_port {
> > struct typec_partner *partner;
> > /* Port partner PD identity info. */
> > struct usb_pd_identity p_identity;
> > + struct typec_switch *ori_sw;
> > + struct typec_mux *mux;
> > + struct usb_role_switch *role_sw;
> > };
> >
> > /* Platform-specific data for the Chrome OS EC Type C controller. */
> > @@ -84,6 +89,40 @@ static int cros_typec_parse_port_props(struct typec_capability *cap,
> > return 0;
> > }
> >
> > +static int cros_typec_get_switch_handles(struct cros_typec_port *port,
> > + struct fwnode_handle *fwnode,
> > + struct device *dev)
> > +{
> > + port->mux = fwnode_typec_mux_get(fwnode, NULL);
> > + if (IS_ERR(port->mux)) {
>
> Should you return an error if NULL is returned (IS_ERR_OR_NULL) ? I think that
> fwnode_typec_mux_get can return NULL too.
I think returning NULL can be considered "not an error" for devices
that don't have kernel-controlled muxes (which won't have this
property defined).
So this check should be fine as is.
>
>
> > + dev_info(dev, "Mux handle not found.\n");
> > + goto mux_err;
> > + }
> > +
> > + port->ori_sw = fwnode_typec_switch_get(fwnode);
> > + if (IS_ERR(port->ori_sw)) {
>
> ditto
>
> > + dev_info(dev, "Orientation switch handle not found.\n");
> > + goto ori_sw_err;
> > + }
> > +
> > + port->role_sw = fwnode_usb_role_switch_get(fwnode);
> > + if (IS_ERR(port->role_sw)) {
>
> ditto
>
> > + dev_info(dev, "USB role switch handle not found.\n");
> > + goto role_sw_err;
> > + }
> > +
> > + return 0;
> > +
> > +role_sw_err:
> > + usb_role_switch_put(port->role_sw);
> > +ori_sw_err:
> > + typec_switch_put(port->ori_sw);
> > +mux_err:
> > + typec_mux_put(port->mux);
> > +
> > + return -ENODEV;
> > +}
> > +
> > static void cros_unregister_ports(struct cros_typec_data *typec)
> > {
> > int i;
> > @@ -91,6 +130,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
> > for (i = 0; i < typec->num_ports; i++) {
> > if (!typec->ports[i])
> > continue;
> > + usb_role_switch_put(typec->ports[i]->role_sw);
> > + typec_switch_put(typec->ports[i]->ori_sw);
> > + typec_mux_put(typec->ports[i]->mux);
> > typec_unregister_port(typec->ports[i]->port);
> > }
> > }
> > @@ -153,6 +195,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
> > ret = PTR_ERR(cros_port->port);
> > goto unregister_ports;
> > }
> > +
> > + ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
> > + if (ret)
> > + dev_info(dev, "No switch control for port %d\n",
> > + port_num);
>
> When drivers are working, they should not spit out any messages, make
> this dev_dbg() at the most. Be quiet, please.
Ack. Will update this in the next version.
>
>
> > }
> >
> > return 0;
> >
next prev parent reply other threads:[~2020-04-29 23:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 22:22 [PATCH 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
2020-04-22 22:22 ` [PATCH 2/2] platform/chrome: typec: Register Type C switches Prashant Malani
2020-04-24 11:36 ` Heikki Krogerus
2020-04-29 22:22 ` Enric Balletbo i Serra
2020-04-29 23:02 ` Prashant Malani [this message]
2020-04-29 23:20 ` Enric Balletbo i Serra
2020-04-29 22:25 ` Enric Balletbo i Serra
2020-05-18 7:19 ` Prashant Malani
2020-04-23 2:59 ` [PATCH 1/2] dt-bindings: chrome: Add cros-ec-typec mux props Prashant Malani
2020-04-29 22:13 ` Enric Balletbo i Serra
2020-05-06 18:06 ` Benson Leung
2020-05-11 18:03 ` Prashant Malani
2020-05-11 19:28 ` Rob Herring
2020-05-11 20:46 ` Prashant Malani
2020-05-12 13:41 ` Heikki Krogerus
2020-05-14 18:16 ` Prashant Malani
2020-05-29 21:54 ` Rob Herring
2020-05-29 23:30 ` Prashant Malani
2020-06-09 20:30 ` Rob Herring
2020-06-09 23:57 ` Prashant Malani
2020-06-10 15:33 ` Heikki Krogerus
2020-06-10 16:53 ` Rob Herring
2020-06-10 17:48 ` Prashant Malani
2020-06-11 20:00 ` Rob Herring
2020-06-12 17:34 ` Prashant Malani
2020-06-15 13:22 ` Heikki Krogerus
2020-06-18 18:59 ` Prashant Malani
2020-06-29 20:41 ` Prashant Malani
2020-07-10 8:51 ` Prashant Malani
2020-07-17 18:04 ` Prashant Malani
2020-06-12 12:46 ` Heikki Krogerus
2020-06-12 14:20 ` Rob Herring
2020-06-15 10:24 ` 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=CACeCKadOzR++ctpG52ZBZZewXFRz39crHotsTC9+MjSWBoE_Dg@mail.gmail.com \
--to=pmalani@chromium.org \
--cc=bleung@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=enric.balletbo@collabora.com \
--cc=groeck@chromium.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=twawrzynczak@chromium.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).