Re: [PATCH 4/4] ASoC: tpa6130a2: Add DAPM support

From: Peter Ujfalusi
Date: Mon Jun 20 2016 - 04:39:54 EST


On 06/18/2016 07:42 AM, Helen Koike wrote:
> Add DAPM support and updated rx51 accordingly.
> As a consequence:
> - the exported function tpa6130a2_stereo_enable is not needed anymore
> - the mutex is dealt in the DAPM
> - the power state is tracked by the DAPM
>
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> [koike: port for upstream]
> Signed-off-by: Helen Koike <helen.koike@xxxxxxxxxxxxxxx>
> ---
> sound/soc/codecs/tpa6130a2.c | 184 +++++++++++++++++--------------------------
> sound/soc/codecs/tpa6130a2.h | 11 +--
> sound/soc/omap/rx51.c | 22 ++----
> 3 files changed, 86 insertions(+), 131 deletions(-)
>
> diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
> index dc7bfc9..7cb5066 100644
> --- a/sound/soc/codecs/tpa6130a2.c
> +++ b/sound/soc/codecs/tpa6130a2.c
> @@ -41,79 +41,71 @@ enum tpa_model {
> TPA6140A2,
> };
>
> -static struct i2c_client *tpa6130a2_client;
> -
> /* This struct is used to save the context */
> struct tpa6130a2_data {
> - struct mutex mutex;
> struct regmap *regmap;
> struct regulator *supply;
> int power_gpio;
> - u8 power_state:1;
> enum tpa_model id;
> };
>
> -static int tpa6130a2_power(u8 power)
> +static int tpa6130a2_power(struct device *dev, bool enable)

I would rather add 'struct device *dev' to tpa6130a2_data and pass the pointer
to the private struct instead to the device.

> {
> - struct tpa6130a2_data *data;
> - int ret = 0;
> -
> - if (WARN_ON(!tpa6130a2_client))
> - return -EINVAL;
> - data = i2c_get_clientdata(tpa6130a2_client);
> -
> - mutex_lock(&data->mutex);
> - if (power == data->power_state)
> - goto exit;
> + struct tpa6130a2_data *data = dev_get_drvdata(dev);
> + int ret;
>
> - if (power) {
> + if (enable) {

--
Péter