Re: [PATCH 09/12] ASoC: cs42l42: Split I2C identity into separate module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 19. 8. 2022, at 14:52, Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Split the I2C bus driver definition and probe()/remove() into a
> separate module so that a Soundwire build of CS42L42 support does
> not have a spurious dependency on I2C.
>
> Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
> ---


> +static int cs42l42_i2c_probe(struct i2c_client *i2c_client)
> +{
> +	struct device *dev = &i2c_client->dev;
> +	struct cs42l42_private *cs42l42;
> +	struct regmap *regmap;
> +	int ret;
> +
> +	cs42l42 = devm_kzalloc(dev, sizeof(*cs42l42), GFP_KERNEL);
> +	if (!cs42l42)
> +		return -ENOMEM;
> +
> +	regmap = devm_regmap_init_i2c(i2c_client, &cs42l42_regmap);
> +	if (IS_ERR(regmap)) {
> +		ret = PTR_ERR(regmap);
> +		dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
> +		return ret;
> +	}
> +
> +	cs42l42->dev = dev;
> +	cs42l42->regmap = regmap;
> +	cs42l42->irq = i2c_client->irq;
> +
> +	ret = cs42l42_common_probe(cs42l42, &cs42l42_soc_component, &cs42l42_dai);
> +	if (ret)
> +		return ret;
> +
> +	return cs42l42_init(cs42l42);

The common_remove should probably be called here if the init fails.

Best,
Martin

> +}
> +
> +static int cs42l42_i2c_remove(struct i2c_client *i2c_client)
> +{
> +	struct cs42l42_private *cs42l42 = dev_get_drvdata(&i2c_client->dev);
> +
> +	cs42l42_common_remove(cs42l42);
> +
> +	return 0;
> +}





[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux