Re: [PATCH v2] extcon-intel-cht-wc: Don't reset USB data connection at probe

Yauhen Kharuzhy
2019-09-17T13:25:56Z

On Tue, Sep 17, 2019 at 02:13:22PM +0300, Andy Shevchenko wrote:
> On Tue, Sep 17, 2019 at 12:15:36AM +0300, Yauhen Kharuzhy wrote:
> > Intel Cherry Trail Whiskey Cove extcon driver connect USB data lines to
> > PMIC at driver probing for further charger detection. This causes reset of
> > USB data sessions and removing all devices from bus. If system was
> > booted from Live CD or USB dongle, this makes system unusable.
> >
> > Check if USB ID pin is floating and re-route data lines in this case
> > only, don't touch otherwise.
>
> > + ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts);
> > + if (ret) {
> > + dev_err(ext->dev, "Error reading pwrsrc status: %d\n", ret);
> > + goto disable_sw_control;
> > + }
> > +
> > + id = cht_wc_extcon_get_id(ext, pwrsrc_sts);
>
> We have second implementation of this. Would it make sense to split to some
> helper?

Do you mean the combination of regmap_read(...CHT_WC_PWRSRC_STS,
&pwrsrc_sts) with cht_wc_extcon_get_id()?

In the cht_wc_extcon_pwrsrc_event() function the pwrsrc_sts is checked
for other bits also, so separation of PWRSRC_STS read and id calculation
to one routine will cause non-clear function calls like as
get_powersrc_and_check_id(..., &powersrc_sts, &id) which is not looks
better than current code duplication. Or we need to spend some time for
refactoring and testing of cht_wc_extcon_pwrsrc_event() code.

>
> > + /* If no USB host or device connected, route D+ and D- to PMIC for
> > + * initial charger detection
> > + */
>
> I'm not sure it's acceptable style of multi-line comment, but it's up to
> maintainer.
Argh, you are right, I fixed this in local copy but this is not
significant typo.

>
> > + if (id != INTEL_USB_ID_GND)
> > + cht_wc_extcon_set_phymux(ext, MUX_SEL_PMIC);
> >
> > /* Get initial state */
> > cht_wc_extcon_pwrsrc_event(ext);
> > --
> > 2.23.0.rc1
> >
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

--
Yauhen Kharuzhy