public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	patches@opensource.wolfsonmicro.com, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6 06/12] mfd: wm97xx-core: core support for wm97xx Codec
Date: Tue, 5 Sep 2017 09:04:53 +0100	[thread overview]
Message-ID: <20170905080453.d624xdn7c3l4kpwv@dell> (raw)
In-Reply-To: <20170902195414.3699-7-robert.jarzmik@free.fr>

On Sat, 02 Sep 2017, Robert Jarzmik wrote:

> The WM9705, WM9712 and WM9713 are highly integrated codecs, with an
> audio codec, DAC and ADC, GPIO unit and a touchscreen interface.
> 
> Historically the support was spread across drivers/input/touchscreen and
> sound/soc/codecs. The sharing was done through ac97 bus sharing. This
> model will not withstand the new AC97 bus model, where codecs are
> discovered on runtime.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
> Since v3:
>  - added a "depends on AC97_BUS_NEW" Kconfig statement
>  - added default values for wm9705, wm9712 per Charles's comment
> Since v4:
>  - added Charles's ack
> Since v5:
>  - took into account Lee's comments
> ---
>  drivers/mfd/Kconfig        |  14 ++
>  drivers/mfd/Makefile       |   1 +
>  drivers/mfd/wm97xx-core.c  | 379 +++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/wm97xx.h |  25 +++
>  4 files changed, 419 insertions(+)
>  create mode 100644 drivers/mfd/wm97xx-core.c
>  create mode 100644 include/linux/mfd/wm97xx.h

[...]

> +static struct mfd_cell wm9705_cells[] = {
> +	{
> +		.name = "wm9705-codec",
> +	},
> +	{
> +		.name = "wm97xx-ts",
> +	},
> +};

Nit: These should be one line entries:

     {	   .name = "wm9705-codec"	},
     { 	   .name = "wm97xx-ts"		},

[...]

> +static struct mfd_cell wm9712_cells[] = {
> +	{
> +		.name = "wm9712-codec",
> +	},
> +	{
> +		.name = "wm97xx-ts",
> +	},
> +};

As above.

[...]

> +static struct mfd_cell wm9713_cells[] = {
> +	{
> +		.name = "wm9713-codec",
> +	},
> +	{
> +		.name = "wm97xx-ts",
> +	},
> +};

And again.

> +static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
> +{
> +	struct wm97xx_priv *wm97xx;
> +	const struct regmap_config *config;
> +	struct wm97xx_platform_data *codec_pdata;
> +	struct mfd_cell *cells;
> +	int ret = 0, nb_cells, i;
> +	struct wm97xx_pdata *pdata = snd_ac97_codec_get_platdata(adev);
> +
> +	wm97xx = devm_kzalloc(ac97_codec_dev2dev(adev),
> +			      sizeof(*wm97xx), GFP_KERNEL);
> +	if (!wm97xx)
> +		return -ENOMEM;
> +
> +	wm97xx->dev = ac97_codec_dev2dev(adev);
> +	wm97xx->ac97 = snd_ac97_compat_alloc(adev);
> +	if (IS_ERR(wm97xx->ac97))
> +		return PTR_ERR(wm97xx->ac97);
> +
> +
> +	ac97_set_drvdata(adev, wm97xx);
> +	dev_info(wm97xx->dev, "wm97xx core found, id=0x%x\n",
> +		 adev->vendor_id);
> +
> +	codec_pdata = &wm97xx->codec_pdata;
> +	codec_pdata->ac97 = wm97xx->ac97;
> +	codec_pdata->batt_pdata = pdata->batt_pdata;
> +
> +	switch (adev->vendor_id) {
> +	case WM9705_VENDOR_ID:
> +		config = &wm9705_regmap_config;
> +		cells = wm9705_cells;
> +		nb_cells = ARRAY_SIZE(wm9705_cells);
> +		break;
> +	case WM9712_VENDOR_ID:
> +		config = &wm9712_regmap_config;
> +		cells = wm9712_cells;
> +		nb_cells = ARRAY_SIZE(wm9712_cells);
> +		break;
> +	case WM9713_VENDOR_ID:
> +		config = &wm9713_regmap_config;
> +		cells = wm9713_cells;
> +		nb_cells = ARRAY_SIZE(wm9713_cells);
> +		break;
> +	default:
> +		config = NULL;

goto an error label here.

> +	}
> +
> +	for (i = 0; i < nb_cells; i++) {
> +		cells[i].platform_data = codec_pdata;
> +		cells[i].pdata_size = sizeof(*codec_pdata);
> +	}
> +
> +	if (config) {
> +		codec_pdata->regmap =
> +			devm_regmap_init_ac97(wm97xx->ac97, config);
> +		if (IS_ERR(codec_pdata->regmap))
> +			ret = PTR_ERR(codec_pdata->regmap);

Remove the if and do this regardless.

> +	} else {
> +		ret = -ENODEV;
> +	}

remove this.

> +	if (!ret)
> +		ret = devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE,
> +					   cells, nb_cells, NULL, 0, NULL);

Remove the if and do this regardless.

No need to allocate to a variable.  Just return the result directly.

> +	if (ret)
> +		snd_ac97_compat_release(wm97xx->ac97);

Place this in the error path, under the goto label.

> +	return ret;
> +}

Once fixed, please apply my:

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2017-09-05  8:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-02 19:54 [PATCH v6 00/12] AC97 device/driver model revamp Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 01/12] ALSA: ac97: split out the generic ac97 registers Robert Jarzmik
2017-09-03  7:15   ` [alsa-devel] " Takashi Iwai
2017-09-02 19:54 ` [PATCH v6 02/12] ALSA: ac97: add an ac97 bus Robert Jarzmik
2017-09-03  7:19   ` [alsa-devel] " Takashi Iwai
2017-09-02 19:54 ` [PATCH v6 03/12] ASoC: add new ac97 bus support Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 04/12] ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 05/12] Input: wm97xx: split out touchscreen registering Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 06/12] mfd: wm97xx-core: core support for wm97xx Codec Robert Jarzmik
2017-09-05  8:04   ` Lee Jones [this message]
2017-09-02 19:54 ` [PATCH v6 07/12] Input: wm97xx: add new AC97 bus support Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 08/12] ASoC: wm9713: add ac97 new " Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 09/12] ASoC: wm9712: " Robert Jarzmik
2017-09-04 10:18   ` Charles Keepax
2017-09-04 13:14     ` Robert Jarzmik
2017-09-04 16:42       ` Mark Brown
2017-09-02 19:54 ` [PATCH v6 10/12] ASoC: wm9705: add private structure Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 11/12] ASoC: wm9705: add ac97 new bus support Robert Jarzmik
2017-09-02 19:54 ` [PATCH v6 12/12] ASoC: pxa: switch to new ac97 " Robert Jarzmik

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=20170905080453.d624xdn7c3l4kpwv@dell \
    --to=lee.jones@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=daniel@zonque.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=perex@perex.cz \
    --cc=robert.jarzmik@free.fr \
    --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