From: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
To: Stephen Boyd <swboyd@chromium.org>, <agross@kernel.org>,
<alsa-devel@alsa-project.org>, <bgoswami@codeaurora.org>,
<bjorn.andersson@linaro.org>, <broonie@kernel.org>,
<devicetree@vger.kernel.org>, <judyhsiao@chromium.org>,
<lgirdwood@gmail.com>, <linux-arm-msm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <perex@perex.cz>,
<quic_plai@quicinc.com>, <robh+dt@kernel.org>,
<rohitkr@codeaurora.org>, <srinivas.kandagatla@linaro.org>,
<tiwai@suse.com>
Cc: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Subject: Re: [PATCH 1/2] ASoC: codec: wcd938x: Add switch control for selecting CTIA/OMTP Headset
Date: Tue, 15 Feb 2022 10:13:39 +0530 [thread overview]
Message-ID: <cc99e97d-5256-b121-2785-1290505bc994@quicinc.com> (raw)
In-Reply-To: <CAE-0n52uBY7GzjtFwV67y5mfqZRoK9ooW-kT3=4sH=8NtVK7FQ@mail.gmail.com>
On 2/15/2022 3:17 AM, Stephen Boyd wrote:
Thanks for your time Stephen!!!
> Quoting Srinivasa Rao Mandadapu (2022-02-12 04:24:31)
>> diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
>> index eff200a..08d16a9 100644
>> --- a/sound/soc/codecs/wcd938x.c
>> +++ b/sound/soc/codecs/wcd938x.c
>> @@ -194,6 +194,7 @@ struct wcd938x_priv {
>> int ear_rx_path;
>> int variant;
>> int reset_gpio;
>> + int us_euro_gpio;
>> u32 micb1_mv;
>> u32 micb2_mv;
>> u32 micb3_mv;
>> @@ -4196,6 +4197,33 @@ static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_pri
>> dev_info(dev, "%s: Micbias4 DT property not found\n", __func__);
>> }
>>
>> +static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component, bool active)
>> +{
>> + int value;
>> +
>> + struct wcd938x_priv *wcd938x;
>> +
>> + if (!component) {
> So component is NULL
>
>> + dev_err(component->dev, "%s component is NULL\n", __func__);
> And now we deref component. Great NULL pointer exception Batman! Please
> test your code and remove useless checks. It makes the code harder to
> read and slows things down.
Okay. In last minute, changed from pr_err to dev_err and overlooked this
mistake. Will remove it.
>
>> + return false;
>> + }
>> +
>> + wcd938x = snd_soc_component_get_drvdata(component);
>> + if (!wcd938x) {
>> + dev_err(component->dev, "%s private data is NULL\n", __func__);
> Is this possible? I doubt it so can we just remove it?
Okay. Will remove it.
>
>> + return false;
>> + }
>> +
>> + value = gpio_get_value(wcd938x->us_euro_gpio);
>> +
>> + gpio_set_value(wcd938x->us_euro_gpio, !value);
>> + /* 20us sleep required after changing the gpio state*/
> Add a space before ending comment with */
Okay.
>
>> + usleep_range(20, 30);
>> +
>> + return true;
>> +}
>> +
>> +
>> static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device *dev)
>> {
>> struct wcd_mbhc_config *cfg = &wcd938x->mbhc_cfg;
>> @@ -4208,6 +4236,16 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
>> return wcd938x->reset_gpio;
>> }
>>
>> + wcd938x->us_euro_gpio = of_get_named_gpio(dev->of_node, "us-euro-gpios", 0);
> Why do we need to use of GPIO APIs here? Can this driver be converted to
> use GPIO descriptors via the gpiod APIs?
Okay. will look into it and proceed accordingly!!!
>
>> + if (wcd938x->us_euro_gpio < 0) {
>> + dev_err(dev, "Failed to get us-euro-gpios gpio: err = %d\n", wcd938x->us_euro_gpio);
>> + } else {
>> + cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;
>> + gpio_direction_output(wcd938x->us_euro_gpio, 0);
>> + /* 20us sleep required after pulling the reset gpio to LOW */
>> + usleep_range(20, 30);
>> + }
>> +
next prev parent reply other threads:[~2022-02-15 4:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 12:24 [PATCH 0/2] Add Euro Headset support for wcd938x codec Srinivasa Rao Mandadapu
2022-02-12 12:24 ` [PATCH 1/2] ASoC: codec: wcd938x: Add switch control for selecting CTIA/OMTP Headset Srinivasa Rao Mandadapu
2022-02-14 21:47 ` Stephen Boyd
2022-02-15 4:43 ` Srinivasa Rao Mandadapu [this message]
2022-02-12 12:24 ` [PATCH 2/2] ASoC: dt-bindings: wcd938x: Add gpio property for selecting CTIA/OMTP headset Srinivasa Rao Mandadapu
2022-02-14 16:27 ` [PATCH 0/2] Add Euro Headset support for wcd938x codec Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc99e97d-5256-b121-2785-1290505bc994@quicinc.com \
--to=quic_srivasam@quicinc.com \
--cc=agross@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=judyhsiao@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=quic_plai@quicinc.com \
--cc=quic_potturu@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=rohitkr@codeaurora.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=swboyd@chromium.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®