lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdTiTo3S8rrooh8z5fQVgngE14s17ByHgPi5UfeF63hfA@mail.gmail.com>
Date:   Fri, 21 Apr 2017 21:54:24 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Hans de Goede <hdegoede@...hat.com>,
        "Krogerus, Heikki" <heikki.krogerus@...ux.intel.com>
Cc:     MyungJoo Ham <myungjoo.ham@...sung.com>,
        Chanwoo Choi <cw00.choi@...sung.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/5] extcon: intel-cht-wc: Add new cht_wc_extcon_set_state helper

+Cc: Heikki.

It looks like you better Cc him with entire series.

On Fri, Apr 21, 2017 at 4:01 PM, Hans de Goede <hdegoede@...hat.com> wrote:
> This allows a nice cleanup of cht_wc_extcon_pwrsrc_event, getting rid
> of all the gotos in there.
>
> This also is a preparation patch for adding USB Type-C controller
> monitoring.
>
> Signed-off-by: Hans de Goede <hdegoede@...hat.com>
> ---
>  drivers/extcon/extcon-intel-cht-wc.c | 54 ++++++++++++++++++------------------
>  1 file changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/extcon/extcon-intel-cht-wc.c b/drivers/extcon/extcon-intel-cht-wc.c
> index 8806427e..684f6b2 100644
> --- a/drivers/extcon/extcon-intel-cht-wc.c
> +++ b/drivers/extcon/extcon-intel-cht-wc.c
> @@ -196,20 +196,40 @@ static void cht_wc_extcon_set_5v_boost(struct cht_wc_extcon_data *ext,
>  }
>
>  /* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */
> -static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext,
> -                                   unsigned int cable, bool state)
> +static void cht_wc_extcon_set_cable_state(struct cht_wc_extcon_data *ext,
> +                                         unsigned int cable, bool state)
>  {
>         extcon_set_state_sync(ext->edev, cable, state);
>         if (cable == EXTCON_CHG_USB_SDP)
>                 extcon_set_state_sync(ext->edev, EXTCON_USB, state);
>  }
>
> +static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext,
> +                                   unsigned int new_cable)
> +{
> +       if (new_cable == EXTCON_NONE && !ext->usb_host) {
> +               /* Route D+ and D- to PMIC for future charger detection */
> +               cht_wc_extcon_set_phymux(ext, MUX_SEL_PMIC);
> +       } else {
> +               /* Route D+ and D- to SoC for the host or gadget controller */
> +               cht_wc_extcon_set_phymux(ext, MUX_SEL_SOC);
> +       }
> +
> +       if (new_cable != ext->previous_cable) {
> +               cht_wc_extcon_set_cable_state(ext, new_cable, true);
> +               cht_wc_extcon_set_cable_state(ext, ext->previous_cable, false);
> +               ext->previous_cable = new_cable;
> +       }
> +
> +       extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
> +}
> +
>  static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
>  {
>         int ret, pwrsrc_sts, id;
>         unsigned int cable = EXTCON_NONE;
>         /* Ignore errors in host mode, as the 5v boost converter is on then */
> -       bool ignore_get_charger_errors = ext->usb_host;
> +       bool ignore_get_charger_err = ext->usb_host;
>
>         ret = regmap_read(ext->regmap, CHT_WC_PWRSRC_STS, &pwrsrc_sts);
>         if (ret) {
> @@ -218,33 +238,13 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
>         }
>
>         id = cht_wc_extcon_get_id(ext, pwrsrc_sts);
> -       if (id == USB_ID_GND) {
> -               /* The 5v boost causes a false VBUS / SDP detect, skip */
> -               goto charger_det_done;
> -       }
> -
> -       /* Plugged into a host/charger or not connected? */
> -       if (!(pwrsrc_sts & CHT_WC_PWRSRC_VBUS)) {
> -               /* Route D+ and D- to PMIC for future charger detection */
> -               cht_wc_extcon_set_phymux(ext, MUX_SEL_PMIC);
> -               goto set_state;
> -       }
> -
> -       cable = cht_wc_extcon_get_charger(ext, ignore_get_charger_errors);
>
> -charger_det_done:
> -       /* Route D+ and D- to SoC for the host or gadget controller */
> -       cht_wc_extcon_set_phymux(ext, MUX_SEL_SOC);
> -
> -set_state:
> -       if (cable != ext->previous_cable) {
> -               cht_wc_extcon_set_state(ext, cable, true);
> -               cht_wc_extcon_set_state(ext, ext->previous_cable, false);
> -               ext->previous_cable = cable;
> -       }
> +       /* When id == gnd the 5v boost causes a false VBUS detect */
> +       if (id != USB_ID_GND && (pwrsrc_sts & CHT_WC_PWRSRC_VBUS))
> +               cable = cht_wc_extcon_get_charger(ext, ignore_get_charger_err);
>
>         ext->usb_host = ((id == USB_ID_GND) || (id == USB_RID_A));
> -       extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
> +       cht_wc_extcon_set_state(ext, cable);
>  }
>
>  static irqreturn_t cht_wc_extcon_isr(int irq, void *data)
> --
> 2.9.3
>



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ