8 Sep
2022
8 Sep
'22
6:03 p.m.
On 19. 8. 2022, at 14:52, Richard Fitzgerald rf@opensource.cirrus.com 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@opensource.cirrus.com
+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;
+}