linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Alexey Klimov" <alexey.klimov@linaro.org>
To: "Krzysztof Kozlowski" <krzk@kernel.org>
Cc: "Srinivas Kandagatla" <srini@kernel.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Stephen Boyd" <sboyd@kernel.org>, "Lee Jones" <lee@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>, <linux-arm-msm@vger.kernel.org>,
	<linux-sound@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
	"Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Subject: Re: [PATCH 3/3] ASoC: codecs: add new pm4125 audio codec driver
Date: Thu, 10 Jul 2025 16:37:39 +0100	[thread overview]
Message-ID: <DB8HJI3YCZ9X.282HCM2QSGY0D@linaro.org> (raw)
In-Reply-To: <rr2qf7hw7lkwqozguz3cv4tg7eewzk4jkxx5bieydukemjko2h@pwtrakslklvn>

On Thu Jun 26, 2025 at 7:19 AM BST, Krzysztof Kozlowski wrote:
> On Thu, Jun 26, 2025 at 12:50:31AM +0100, Alexey Klimov wrote:
>> +
>> +static int pm4125_add_slave_components(struct pm4125_priv *pm4125,
>> +				       struct device *dev,
>> +				       struct component_match **matchptr)
>> +{
>> +	struct device_node *np = dev->of_node;
>> +
>> +	pm4125->rxnode = of_parse_phandle(np, "qcom,rx-device", 0);
>> +	if (!pm4125->rxnode) {
>> +		dev_err(dev, "Couldn't parse phandle to qcom,rx-device!\n");
>> +		return -ENODEV;
>> +	}
>> +	of_node_get(pm4125->rxnode);
>
> Where  do you clean this up?

Please don't tell me that this is a bug that being copied from driver
to driver.

I changed it to such flow for the next version since it seems that reference
should be decremented after of_parse_phandle() returns with it incremented:

rxnode = of_parse_phandle();
if (!rxnode)
	return dev_err_probe(...);

component_match_add_release(..., rxnode);
of_node_put(rxnode);


>> +	component_match_add_release(dev, matchptr, component_release_of,
>> +				    component_compare_of, pm4125->rxnode);
>> +
>> +	pm4125->txnode = of_parse_phandle(np, "qcom,tx-device", 0);
>> +	if (!pm4125->txnode) {
>> +		dev_err(dev, "Couldn't parse phandle to qcom,tx-device\n");
>> +			return -ENODEV;
>
> Messed indent. This should be anyway just one line as always - return
> dev_err_probe.

I changed it for the next version as you suggested. Thanks.

>> +	}
>> +	of_node_get(pm4125->txnode);
>
> And this?
>
>> +	component_match_add_release(dev, matchptr, component_release_of,
>> +				    component_compare_of, pm4125->txnode);
>> +
>> +	return 0;
>> +}
>> +
>> +static int pm4125_probe(struct platform_device *pdev)
>> +{
>> +	struct component_match *match = NULL;
>> +	struct device *dev = &pdev->dev;
>> +	struct pm4125_priv *pm4125;
>> +	struct wcd_mbhc_config *cfg;
>> +	int ret;
>> +
>> +	pm4125 = devm_kzalloc(dev, sizeof(*pm4125), GFP_KERNEL);
>> +	if (!pm4125)
>> +		return -ENOMEM;
>> +
>> +	dev_set_drvdata(dev, pm4125);
>> +
>> +	cfg = &pm4125->mbhc_cfg;
>> +	cfg->swap_gnd_mic = pm4125_swap_gnd_mic;
>> +
>> +	pm4125->supplies[0].supply = "vdd-io";
>> +	pm4125->supplies[1].supply = "vdd-cp";
>> +	pm4125->supplies[2].supply = "vdd-mic-bias";
>> +	pm4125->supplies[3].supply = "vdd-pa-vpos";
>> +
>> +	ret = devm_regulator_bulk_get(dev, PM4125_MAX_BULK_SUPPLY, pm4125->supplies);
>> +	if (ret)
>> +		return dev_err_probe(dev, ret, "Failed to get supplies\n");
>> +
>> +	ret = regulator_bulk_enable(PM4125_MAX_BULK_SUPPLY, pm4125->supplies);
>> +	if (ret) {
>> +		regulator_bulk_free(PM4125_MAX_BULK_SUPPLY, pm4125->supplies);
>
> Double free.

Thanks.

>> +		return dev_err_probe(dev, ret, "Failed to enable supplies\n");
>> +	}
>> +
>> +	pm4125_dt_parse_micbias_info(dev, pm4125);
>> +
>> +	cfg->mbhc_micbias = MIC_BIAS_2;
>> +	cfg->anc_micbias = MIC_BIAS_2;
>> +	cfg->v_hs_max = WCD_MBHC_HS_V_MAX;
>> +	cfg->num_btn = PM4125_MBHC_MAX_BUTTONS;
>> +	cfg->micb_mv = pm4125->micb2_mv;
>> +	cfg->linein_th = 5000;
>> +	cfg->hs_thr = 1700;
>> +	cfg->hph_thr = 50;

[..]

>> +#if defined(CONFIG_OF)
>> +static const struct of_device_id pm4125_of_match[] = {
>> +	{ .compatible = "qcom,pm4125-codec" },
>> +	{ }
>> +};
>> +MODULE_DEVICE_TABLE(of, pm4125_of_match);
>> +#endif
>> +
>> +static struct platform_driver pm4125_codec_driver = {
>> +	.probe = pm4125_probe,
>> +	.remove = pm4125_remove,
>> +	.driver = {
>> +		.name = "pm4125_codec",
>> +		.of_match_table = of_match_ptr(pm4125_of_match),
>
> Drop of_match_ptr and #if. We just removed it (or trying to )
> everywhere, so why re-introducing it...

Will remove it. Thanks.

>> +		.suppress_bind_attrs = true,
>> +	},
>> +};
>> +
>> +module_platform_driver(pm4125_codec_driver);
>> +MODULE_DESCRIPTION("PM4125 audio codec driver");
>> +MODULE_LICENSE("GPL");
>> diff --git a/sound/soc/codecs/pm4125.h b/sound/soc/codecs/pm4125.h
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..2c5e8218202d92a0adc493413368991a406471b0
>> --- /dev/null
>> +++ b/sound/soc/codecs/pm4125.h

[...]

>> +const u8 pm4125_reg_access_analog[
>
> No, you cannot have data defined in the header. This is neither style of
> C, nor Linux kernel, nor makes any sense. What if this will be included
> by some other unit? This is some terrible downstream style.
>
> Heh... you actually do include it twice, so you would see all the
> duplicated data for no reason at all.

I pulled in the change that fixes this for the next version.
Thank you.

Best regards,
Alexey


  reply	other threads:[~2025-07-10 15:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 23:50 [PATCH 0/3] Add PM4125 audio codec driver Alexey Klimov
2025-06-25 23:50 ` [PATCH 1/3] dt-bindings: sound: add bindings for pm4125 audio codec Alexey Klimov
2025-06-26  1:30   ` Rob Herring (Arm)
2025-06-26 11:08     ` Alexey Klimov
2025-06-26  6:13   ` Krzysztof Kozlowski
2025-06-28 16:41     ` Alexey Klimov
2025-06-29 14:59       ` Dmitry Baryshkov
2025-06-30  8:21       ` Krzysztof Kozlowski
2025-07-01 23:30         ` Alexey Klimov
2025-07-02  6:22           ` Krzysztof Kozlowski
2025-06-25 23:50 ` [PATCH 2/3] dt-bindings: mfd: qcom,spmi-pmic: add " Alexey Klimov
2025-06-26  8:48   ` Krzysztof Kozlowski
2025-06-28 16:42     ` Alexey Klimov
2025-06-29 15:00       ` Dmitry Baryshkov
2025-06-30  8:18       ` Krzysztof Kozlowski
2025-06-25 23:50 ` [PATCH 3/3] ASoC: codecs: add new pm4125 audio codec driver Alexey Klimov
2025-06-26  6:19   ` Krzysztof Kozlowski
2025-07-10 15:37     ` Alexey Klimov [this message]
2025-06-26 11:56   ` Mark Brown
2025-07-01 19:35     ` Alexey Klimov
2025-07-01 21:04       ` Mark Brown
2025-07-10 14:45         ` Alexey Klimov
2025-06-28 20:24   ` Srinivas Kandagatla
2025-07-02  1:43     ` Alexey Klimov
2025-07-03 12:50       ` Srinivas Kandagatla

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=DB8HJI3YCZ9X.282HCM2QSGY0D@linaro.org \
    --to=alexey.klimov@linaro.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=srini@kernel.org \
    --cc=srinivas.kandagatla@oss.qualcomm.com \
    --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;
as well as URLs for NNTP newsgroup(s).