Message ID | 20201106184104.939284-1-pmalani@chromium.org |
---|---|
Headers | show |
Series | platform/chrome: cros_ec_typec: Add cable | expand |
On Fri, Nov 06, 2020 at 10:40:59AM -0800, Prashant Malani wrote: > Change the disc_done flag, which indicates whether PD discovery is > complete, to sop_disc_done instead, since we will process SOP and SOP' > discovery data separately. > > Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > > Changes in v2: > - No changes. > > drivers/platform/chrome/cros_ec_typec.c | 19 +++++++------------ > 1 file changed, 7 insertions(+), 12 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index ce031a10eb1b..801c3d2c1fbd 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -57,8 +57,8 @@ struct cros_typec_port { > /* Port alt modes. */ > struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX]; > > - /* Flag indicating that PD discovery data parsing is completed. */ > - bool disc_done; > + /* Flag indicating that PD partner discovery data parsing is completed. */ > + bool sop_disc_done; > struct ec_response_typec_discovery *sop_disc; > struct list_head partner_mode_list; > }; > @@ -210,7 +210,7 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec, > typec_unregister_partner(port->partner); > port->partner = NULL; > memset(&port->p_identity, 0, sizeof(port->p_identity)); > - port->disc_done = false; > + port->sop_disc_done = false; > } > > static void cros_unregister_ports(struct cros_typec_data *typec) > @@ -727,18 +727,13 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num > return; > } > > - if (typec->ports[port_num]->disc_done) > - return; > - > /* Handle any events appropriately. */ > - if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE) { > + if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) { > ret = cros_typec_handle_sop_disc(typec, port_num); > - if (ret < 0) { > + if (ret < 0) > dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num); > - return; > - } > - > - typec->ports[port_num]->disc_done = true; > + else > + typec->ports[port_num]->sop_disc_done = true; > } > } > thanks,
On Fri, Nov 06, 2020 at 10:41:04AM -0800, Prashant Malani wrote: > Rename the sop_disc data struct which is used to store PD discovery data > to the more generic name of disc_data. It can then be re-used to store > and process cable discovery data. > > Signed-off-by: Prashant Malani <pmalani@chromium.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > > Changes in v2: > - No changes. > > drivers/platform/chrome/cros_ec_typec.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index f6d3c37c2c27..3c8ff07c8803 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -59,7 +59,7 @@ struct cros_typec_port { > > /* Flag indicating that PD partner discovery data parsing is completed. */ > bool sop_disc_done; > - struct ec_response_typec_discovery *sop_disc; > + struct ec_response_typec_discovery *disc_data; > struct list_head partner_mode_list; > }; > > @@ -323,8 +323,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) > > cros_typec_register_port_altmodes(typec, port_num); > > - cros_port->sop_disc = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL); > - if (!cros_port->sop_disc) { > + cros_port->disc_data = devm_kzalloc(dev, EC_PROTO2_MAX_RESPONSE_SIZE, GFP_KERNEL); > + if (!cros_port->disc_data) { > ret = -ENOMEM; > goto unregister_ports; > } > @@ -617,7 +617,7 @@ static int cros_typec_get_mux_info(struct cros_typec_data *typec, int port_num, > static int cros_typec_register_altmodes(struct cros_typec_data *typec, int port_num) > { > struct cros_typec_port *port = typec->ports[port_num]; > - struct ec_response_typec_discovery *sop_disc = port->sop_disc; > + struct ec_response_typec_discovery *sop_disc = port->disc_data; > struct cros_typec_altmode_node *node; > struct typec_altmode_desc desc; > struct typec_altmode *amode; > @@ -682,7 +682,7 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id, > static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) > { > struct cros_typec_port *port = typec->ports[port_num]; > - struct ec_response_typec_discovery *sop_disc = port->sop_disc; > + struct ec_response_typec_discovery *sop_disc = port->disc_data; > struct ec_params_typec_discovery req = { > .port = port_num, > .partner_type = TYPEC_PARTNER_SOP, > -- > 2.29.1.341.ge80a0c044ae-goog thanks,