Re: [PATCH v2 17/20] extcon: intel-cht-wc: Support devs with Micro-B / USB-2 only Type-C connectors

From: Andy Shevchenko
Date: Tue Nov 16 2021 - 06:31:53 EST


On Sun, Nov 14, 2021 at 7:04 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> So far the extcon-intel-cht-wc code has only been tested on devices with
> a Type-C connector with USB-PD, USB3 (superspeed) and DP-altmode support
> through a FUSB302 Type-C controller.
>
> Some devices with the intel-cht-wc PMIC however come with an USB-micro-B
> connector, or an USB-2 only Type-C connector without USB-PD.
>
> Which device-model we are running on can be identified with the new
> intel_cht_wc_get_model() helper and on models without a Type-C controller
> the extcon code must control the Vbus 5V boost converter and the USB role
> switch depending on the detected cable-type.

...

> config EXTCON_INTEL_CHT_WC
> tristate "Intel Cherrytrail Whiskey Cove PMIC extcon driver"
> - depends on INTEL_SOC_PMIC_CHTWC

> + depends on INTEL_SOC_PMIC_CHTWC && USB_SUPPORT

Having these two in one expression sounds a bit alogical to me, can
you just add a separate "depends on"?

> + select USB_ROLE_SWITCH

...

> + if (ext->vbus_boost && ext->vbus_boost_enabled != enable) {
> + if (enable)
> + ret = regulator_enable(ext->vbus_boost);
> + else
> + ret = regulator_disable(ext->vbus_boost);

Redundant blank line here (but it's up to you)

> + if (ret == 0)
> + ext->vbus_boost_enabled = enable;
> + else
> + dev_err(ext->dev, "Error updating Vbus boost regulator: %d\n", ret);

Why not a traditional pattern, i.e. error handling first?

> + }

...

> +/* Some boards require controlling the role-sw and vbus based on the id-pin */

Vbus ? VBUS? Here and there the inconsistency of some terms...

...

> + ext->vbus_boost = devm_regulator_get_optional(ext->dev, "vbus");
> + if (IS_ERR(ext->vbus_boost)) {
> + ret = PTR_ERR(ext->vbus_boost);
> + if (ret == -ENODEV)
> + ret = -EPROBE_DEFER;
> +
> + return dev_err_probe(ext->dev, ret, "getting vbus regulator");

Can be also written as

if (PTR_ERR(ext->vbus_boost) == -ENODEV ||
PTR_ERR(ext->vbus_boost) == -EPROBE_DEFER)
return dev_err_probe(ext->dev, -EPROBE_DEFER, "getting vbus regulator");

return PTR_ERR(ext->vbus_boost);

but up to you.

> + }

--
With Best Regards,
Andy Shevchenko