Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1731813 > unrolled thread

[PATCH v7 0/8] AC97 device/driver model revamp

Started byRobert Jarzmik <robert.jarzmik@free.fr>
First post2017-09-13 21:40 +0200
Last post2017-09-13 21:50 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v7 0/8] AC97 device/driver model revamp Robert Jarzmik <robert.jarzmik@free.fr> - 2017-09-13 21:40 +0200
    [PATCH v7 1/8] Input: wm97xx: split out touchscreen registering Robert Jarzmik <robert.jarzmik@free.fr> - 2017-09-13 21:50 +0200

#1731813 — [PATCH v7 0/8] AC97 device/driver model revamp

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-09-13 21:40 +0200
Subject[PATCH v7 0/8] AC97 device/driver model revamp
Message-ID<uplFT-37q-3@gated-at.bofh.it>
Hi Lars, Mark, Charles, Lee,

This is a revision for Lee and Charles, only targetted at wm97xx-core changes
(second round) suggested by Lee and codecs remove path for Charles.

I removed the leading 4 patches as Mark has already scheduled them.

For easier spotting, I included in [1] the diff from the last serie.

As before Charles, I think your ack is not granted anymore for codecs, could you have a look please ?

Cheers.

--
Robert

Robert Jarzmik (8):
  Input: wm97xx: split out touchscreen registering
  mfd: wm97xx-core: core support for wm97xx Codec
  Input: wm97xx: add new AC97 bus support
  ASoC: wm9713: add ac97 new bus support
  ASoC: wm9712: add ac97 new bus support
  ASoC: wm9705: add private structure
  ASoC: wm9705: add ac97 new bus support
  ASoC: pxa: switch to new ac97 bus support

 drivers/input/touchscreen/Kconfig       |   2 +-
 drivers/input/touchscreen/wm97xx-core.c | 252 +++++++++++++++-------
 drivers/mfd/Kconfig                     |  14 ++
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/wm97xx-core.c               | 366 ++++++++++++++++++++++++++++++++
 include/linux/mfd/wm97xx.h              |  25 +++
 sound/arm/Kconfig                       |   1 -
 sound/soc/codecs/Kconfig                |   9 +-
 sound/soc/codecs/wm9705.c               |  66 ++++--
 sound/soc/codecs/wm9712.c               |  44 ++--
 sound/soc/codecs/wm9713.c               |  39 ++--
 sound/soc/pxa/Kconfig                   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c             |  46 ++--
 13 files changed, 712 insertions(+), 158 deletions(-)
 create mode 100644 drivers/mfd/wm97xx-core.c
 create mode 100644 include/linux/mfd/wm97xx.h

-- 
2.11.0

[1] Diff from the previous serie
---8>---
diff --git a/drivers/mfd/wm97xx-core.c b/drivers/mfd/wm97xx-core.c
index 66e477fffd43..4141ee52a70b 100644
--- a/drivers/mfd/wm97xx-core.c
+++ b/drivers/mfd/wm97xx-core.c
@@ -109,12 +109,8 @@ static const struct regmap_config wm9705_regmap_config = {
 };
 
 static struct mfd_cell wm9705_cells[] = {
-	{
-		.name = "wm9705-codec",
-	},
-	{
-		.name = "wm97xx-ts",
-	},
+	{ .name = "wm9705-codec", },
+	{ .name = "wm97xx-ts", },
 };
 
 static bool wm9712_volatile_reg(struct device *dev, unsigned int reg)
@@ -181,12 +177,8 @@ static const struct regmap_config wm9712_regmap_config = {
 };
 
 static struct mfd_cell wm9712_cells[] = {
-	{
-		.name = "wm9712-codec",
-	},
-	{
-		.name = "wm97xx-ts",
-	},
+	{ .name = "wm9712-codec", },
+	{ .name = "wm97xx-ts", },
 };
 
 static const struct reg_default wm9713_reg_defaults[] = {
@@ -256,12 +248,8 @@ static const struct regmap_config wm9713_regmap_config = {
 };
 
 static struct mfd_cell wm9713_cells[] = {
-	{
-		.name = "wm9713-codec",
-	},
-	{
-		.name = "wm97xx-ts",
-	},
+	{ .name = "wm9713-codec", },
+	{ .name = "wm97xx-ts", },
 };
 
 static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
@@ -270,7 +258,7 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 	const struct regmap_config *config;
 	struct wm97xx_platform_data *codec_pdata;
 	struct mfd_cell *cells;
-	int ret = 0, nb_cells, i;
+	int ret = -ENODEV, nb_cells, i;
 	struct wm97xx_pdata *pdata = snd_ac97_codec_get_platdata(adev);
 
 	wm97xx = devm_kzalloc(ac97_codec_dev2dev(adev),
@@ -309,7 +297,7 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 		nb_cells = ARRAY_SIZE(wm9713_cells);
 		break;
 	default:
-		config = NULL;
+		goto err_free_compat;
 	}
 
 	for (i = 0; i < nb_cells; i++) {
@@ -317,23 +305,22 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 		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);
-	} else {
-		ret = -ENODEV;
+	codec_pdata->regmap = devm_regmap_init_ac97(wm97xx->ac97, config);
+	if (IS_ERR(codec_pdata->regmap)) {
+		ret = PTR_ERR(codec_pdata->regmap);
+		goto err_free_compat;
 	}
 
-	if (!ret)
-		ret = devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE,
-					   cells, nb_cells, NULL, 0, NULL);
-
+	ret = devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE,
+				   cells, nb_cells, NULL, 0, NULL);
 	if (ret)
-		snd_ac97_compat_release(wm97xx->ac97);
+		goto err_free_compat;
 
 	return ret;
+
+err_free_compat:
+	snd_ac97_compat_release(wm97xx->ac97);
+	return ret;
 }
 
 static int wm97xx_ac97_remove(struct ac97_codec_device *adev)
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 46b5a77c53e4..68c204e3599f 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -354,11 +354,14 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
 
 static int wm9705_soc_remove(struct snd_soc_codec *codec)
 {
+#ifdef CONFIG_SND_SOC_AC97_BUS
 	struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
 
-	snd_soc_codec_exit_regmap(codec);
-	if (!wm9705->mfd_pdata)
+	if (!wm9705->mfd_pdata) {
+		snd_soc_codec_exit_regmap(codec);
 		snd_soc_free_ac97_codec(wm9705->ac97);
+	}
+#endif
 	return 0;
 }
 
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 7ebbb48b18c5..1e228bf9f1ae 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -674,11 +674,14 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
 
 static int wm9712_soc_remove(struct snd_soc_codec *codec)
 {
+#ifdef CONFIG_SND_SOC_AC97_BUS
 	struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
 
-	snd_soc_codec_exit_regmap(codec);
-	if (!wm9712->mfd_pdata)
+	if (!wm9712->mfd_pdata) {
+		snd_soc_codec_exit_regmap(codec);
 		snd_soc_free_ac97_codec(wm9712->ac97);
+	}
+#endif
 	return 0;
 }
 
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 3df2c01d751d..df7220656d98 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -1238,14 +1238,14 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
 
 static int wm9713_soc_remove(struct snd_soc_codec *codec)
 {
+#ifdef CONFIG_SND_SOC_AC97_BUS
 	struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec);
 
 	if (!wm9713->mfd_pdata) {
 		snd_soc_codec_exit_regmap(codec);
-#ifdef CONFIG_SND_SOC_AC97_BUS
 		snd_soc_free_ac97_codec(wm9713->ac97);
-#endif
 	}
+#endif
 	return 0;
 }
 

[toc] | [next] | [standalone]


#1731816 — [PATCH v7 1/8] Input: wm97xx: split out touchscreen registering

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-09-13 21:50 +0200
Subject[PATCH v7 1/8] Input: wm97xx: split out touchscreen registering
Message-ID<uplPz-3aF-5@gated-at.bofh.it>
In reply to#1731813
wm97xx-core does several things in it initialization :
 - touchscreen input device setup
 - battery device creation

As the wm97xx is actually a multi-function device handling an audio
codec, a touchscreen, a gpio block and an ADC, reshape the probing to
isolate what is truly input/touchscreen specific from the remaining
part.

This is only code shuffling, there is no functional change.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Since v1:
 - took into account Charles's comment
---
 drivers/input/touchscreen/wm97xx-core.c | 196 +++++++++++++++++++-------------
 1 file changed, 115 insertions(+), 81 deletions(-)

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index c9d1c91e1887..39869ffdc4fa 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -581,27 +581,85 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 		wm->codec->acc_enable(wm, 0);
 }
 
-static int wm97xx_probe(struct device *dev)
+static int wm97xx_register_touch(struct wm97xx *wm)
 {
-	struct wm97xx *wm;
-	struct wm97xx_pdata *pdata = dev_get_platdata(dev);
-	int ret = 0, id = 0;
+	struct wm97xx_pdata *pdata = dev_get_platdata(wm->dev);
+	int ret;
 
-	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
-	if (!wm)
+	wm->input_dev = devm_input_allocate_device(wm->dev);
+	if (wm->input_dev == NULL)
 		return -ENOMEM;
-	mutex_init(&wm->codec_mutex);
 
-	wm->dev = dev;
-	dev_set_drvdata(dev, wm);
-	wm->ac97 = to_ac97_t(dev);
+	/* set up touch configuration */
+	wm->input_dev->name = "wm97xx touchscreen";
+	wm->input_dev->phys = "wm97xx";
+	wm->input_dev->open = wm97xx_ts_input_open;
+	wm->input_dev->close = wm97xx_ts_input_close;
+
+	__set_bit(EV_ABS, wm->input_dev->evbit);
+	__set_bit(EV_KEY, wm->input_dev->evbit);
+	__set_bit(BTN_TOUCH, wm->input_dev->keybit);
+
+	input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
+			     abs_x[2], 0);
+	input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
+			     abs_y[2], 0);
+	input_set_abs_params(wm->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1],
+			     abs_p[2], 0);
+
+	input_set_drvdata(wm->input_dev, wm);
+	wm->input_dev->dev.parent = wm->dev;
+
+	ret = input_register_device(wm->input_dev);
+	if (ret)
+		return ret;
+
+	/*
+	 * register our extended touch device (for machine specific
+	 * extensions)
+	 */
+	wm->touch_dev = platform_device_alloc("wm97xx-touch", -1);
+	if (!wm->touch_dev) {
+		ret = -ENOMEM;
+		goto touch_err;
+	}
+	platform_set_drvdata(wm->touch_dev, wm);
+	wm->touch_dev->dev.parent = wm->dev;
+	wm->touch_dev->dev.platform_data = pdata;
+	ret = platform_device_add(wm->touch_dev);
+	if (ret < 0)
+		goto touch_reg_err;
+
+	return 0;
+touch_reg_err:
+	platform_device_put(wm->touch_dev);
+touch_err:
+	input_unregister_device(wm->input_dev);
+	wm->input_dev = NULL;
+
+	return ret;
+}
+
+static void wm97xx_unregister_touch(struct wm97xx *wm)
+{
+	platform_device_unregister(wm->touch_dev);
+	input_unregister_device(wm->input_dev);
+	wm->input_dev = NULL;
+}
+
+static int _wm97xx_probe(struct wm97xx *wm)
+{
+	int id = 0;
+
+	mutex_init(&wm->codec_mutex);
+	dev_set_drvdata(wm->dev, wm);
 
 	/* check that we have a supported codec */
 	id = wm97xx_reg_read(wm, AC97_VENDOR_ID1);
 	if (id != WM97XX_ID1) {
-		dev_err(dev, "Device with vendor %04x is not a wm97xx\n", id);
-		ret = -ENODEV;
-		goto alloc_err;
+		dev_err(wm->dev,
+			"Device with vendor %04x is not a wm97xx\n", id);
+		return -ENODEV;
 	}
 
 	wm->id = wm97xx_reg_read(wm, AC97_VENDOR_ID2);
@@ -629,8 +687,7 @@ static int wm97xx_probe(struct device *dev)
 	default:
 		dev_err(wm->dev, "Support for wm97%02x not compiled in.\n",
 			wm->id & 0xff);
-		ret = -ENODEV;
-		goto alloc_err;
+		return -ENODEV;
 	}
 
 	/* set up physical characteristics */
@@ -644,79 +701,58 @@ static int wm97xx_probe(struct device *dev)
 	wm->gpio[4] = wm97xx_reg_read(wm, AC97_GPIO_STATUS);
 	wm->gpio[5] = wm97xx_reg_read(wm, AC97_MISC_AFE);
 
-	wm->input_dev = input_allocate_device();
-	if (wm->input_dev == NULL) {
-		ret = -ENOMEM;
-		goto alloc_err;
-	}
-
-	/* set up touch configuration */
-	wm->input_dev->name = "wm97xx touchscreen";
-	wm->input_dev->phys = "wm97xx";
-	wm->input_dev->open = wm97xx_ts_input_open;
-	wm->input_dev->close = wm97xx_ts_input_close;
-
-	__set_bit(EV_ABS, wm->input_dev->evbit);
-	__set_bit(EV_KEY, wm->input_dev->evbit);
-	__set_bit(BTN_TOUCH, wm->input_dev->keybit);
-
-	input_set_abs_params(wm->input_dev, ABS_X, abs_x[0], abs_x[1],
-			     abs_x[2], 0);
-	input_set_abs_params(wm->input_dev, ABS_Y, abs_y[0], abs_y[1],
-			     abs_y[2], 0);
-	input_set_abs_params(wm->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1],
-			     abs_p[2], 0);
+	return wm97xx_register_touch(wm);
+}
 
-	input_set_drvdata(wm->input_dev, wm);
-	wm->input_dev->dev.parent = dev;
+static void wm97xx_remove_battery(struct wm97xx *wm)
+{
+	platform_device_unregister(wm->battery_dev);
+}
 
-	ret = input_register_device(wm->input_dev);
-	if (ret < 0)
-		goto dev_alloc_err;
+static int wm97xx_add_battery(struct wm97xx *wm,
+			      struct wm97xx_batt_pdata *pdata)
+{
+	int ret;
 
-	/* register our battery device */
 	wm->battery_dev = platform_device_alloc("wm97xx-battery", -1);
-	if (!wm->battery_dev) {
-		ret = -ENOMEM;
-		goto batt_err;
-	}
+	if (!wm->battery_dev)
+		return -ENOMEM;
+
 	platform_set_drvdata(wm->battery_dev, wm);
-	wm->battery_dev->dev.parent = dev;
-	wm->battery_dev->dev.platform_data = pdata ? pdata->batt_pdata : NULL;
+	wm->battery_dev->dev.parent = wm->dev;
+	wm->battery_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->battery_dev);
-	if (ret < 0)
-		goto batt_reg_err;
+	if (ret)
+		platform_device_put(wm->battery_dev);
 
-	/* register our extended touch device (for machine specific
-	 * extensions) */
-	wm->touch_dev = platform_device_alloc("wm97xx-touch", -1);
-	if (!wm->touch_dev) {
-		ret = -ENOMEM;
-		goto touch_err;
-	}
-	platform_set_drvdata(wm->touch_dev, wm);
-	wm->touch_dev->dev.parent = dev;
-	wm->touch_dev->dev.platform_data = pdata;
-	ret = platform_device_add(wm->touch_dev);
+	return ret;
+}
+
+static int wm97xx_probe(struct device *dev)
+{
+	struct wm97xx *wm;
+	int ret;
+	struct wm97xx_pdata *pdata = dev_get_platdata(dev);
+
+	wm = devm_kzalloc(dev, sizeof(struct wm97xx), GFP_KERNEL);
+	if (!wm)
+		return -ENOMEM;
+
+	wm->dev = dev;
+	wm->ac97 = to_ac97_t(dev);
+
+	ret =  _wm97xx_probe(wm);
+	if (ret)
+		return ret;
+
+	ret = wm97xx_add_battery(wm, pdata ? pdata->batt_pdata : NULL);
 	if (ret < 0)
-		goto touch_reg_err;
+		goto batt_err;
 
 	return ret;
 
- touch_reg_err:
-	platform_device_put(wm->touch_dev);
- touch_err:
-	platform_device_del(wm->battery_dev);
- batt_reg_err:
-	platform_device_put(wm->battery_dev);
- batt_err:
-	input_unregister_device(wm->input_dev);
-	wm->input_dev = NULL;
- dev_alloc_err:
-	input_free_device(wm->input_dev);
- alloc_err:
-	kfree(wm);
-
+batt_err:
+	wm97xx_unregister_touch(wm);
 	return ret;
 }
 
@@ -724,10 +760,8 @@ static int wm97xx_remove(struct device *dev)
 {
 	struct wm97xx *wm = dev_get_drvdata(dev);
 
-	platform_device_unregister(wm->battery_dev);
-	platform_device_unregister(wm->touch_dev);
-	input_unregister_device(wm->input_dev);
-	kfree(wm);
+	wm97xx_remove_battery(wm);
+	wm97xx_unregister_touch(wm);
 
 	return 0;
 }
-- 
2.11.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web