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: <CAHp75VfpdJkDxwynHTaLbVKZ1fp7XZS=RUSC1OV_06cmpyoNAQ@mail.gmail.com>
Date:   Mon, 28 Dec 2020 16:16:17 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Hans de Goede <hdegoede@...hat.com>
Cc:     Lee Jones <lee.jones@...aro.org>,
        MyungJoo Ham <myungjoo.ham@...sung.com>,
        Chanwoo Choi <cw00.choi@...sung.com>,
        Cezary Rojewski <cezary.rojewski@...el.com>,
        Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
        Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
        Jie Yang <yang.jie@...ux.intel.com>,
        Mark Brown <broonie@...nel.org>, patches@...nsource.cirrus.com,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        ALSA Development Mailing List <alsa-devel@...a-project.org>
Subject: Re: [PATCH 10/14] extcon: arizona: Also report jack state through snd_soc_jack_report()

On Sun, Dec 27, 2020 at 11:16 PM Hans de Goede <hdegoede@...hat.com> wrote:
>
> The Linux Arizona driver uses the MFD framework to create several
> sub-devices for the Arizona codec and then uses a driver per function.
>
> The extcon-arizona driver handles jack-detect support and exports info
> about the jack state to userspace through the standard extcon sysfs
> class interface.
>
> Standard Linux userspace does not monitor/use the extcon sysfs interface
> for jack-detection, resulting in the jack-state not being taken into
> account by userspace.
>
> The ASoC machine-driver may have created a standard ASoC jack when
> registering the card. In this case also report the jack-state through the
> ASoC jack so that jack-detection works with standard Linux userspace.
>
> Signed-off-by: Hans de Goede <hdegoede@...hat.com>
> ---
>  drivers/extcon/extcon-arizona.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index d5b3231744f9..931a7d239aea 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -20,6 +20,7 @@
>  #include <linux/regulator/consumer.h>
>  #include <linux/extcon-provider.h>
>
> +#include <sound/jack.h>
>  #include <sound/soc.h>
>
>  #include <linux/mfd/arizona/core.h>
> @@ -598,11 +599,19 @@ static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading,
>  static void arizona_set_extcon_state(struct arizona_extcon_info *info,
>                                      unsigned int id, bool state)
>  {
> -       int ret;
> +       int ret, mask = 0;

I would rather prefer... drop  assignment here...

>         ret = extcon_set_state_sync(info->edev, id, state);
>         if (ret)
>                 dev_err(info->arizona->dev, "Failed to set extcon state: %d\n", ret);
> +
> +       switch (id) {
> +       case EXTCON_JACK_HEADPHONE:     mask = SND_JACK_HEADPHONE;      break;
> +       case EXTCON_JACK_MICROPHONE:    mask = SND_JACK_MICROPHONE;     break;

...introduce default here, which immediately bails out (return)...

> +       }
> +
> +       if (info->arizona->jack && mask)

...and drop mask check here.

> +               snd_soc_jack_report(info->arizona->jack, state ? mask : 0, mask);
>  }
>
>  static irqreturn_t arizona_hpdet_irq(int irq, void *data)
> --
> 2.28.0
>


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ