ASoC: cs35l35: Add local variable for dev in probe

Tidy up the code a little by adding a local variable for i2c_client->dev
rather than referring to it explicitly everytime.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Charles Keepax 2017-03-08 16:42:50 +00:00 committed by Mark Brown
parent 8d45f2d238
commit 1f758cd9da
1 changed files with 26 additions and 40 deletions

View File

@ -1354,16 +1354,14 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct cs35l35_private *cs35l35; struct cs35l35_private *cs35l35;
struct cs35l35_platform_data *pdata = struct device *dev = &i2c_client->dev;
dev_get_platdata(&i2c_client->dev); struct cs35l35_platform_data *pdata = dev_get_platdata(dev);
int i; int i;
int ret; int ret;
unsigned int devid = 0; unsigned int devid = 0;
unsigned int reg; unsigned int reg;
cs35l35 = devm_kzalloc(&i2c_client->dev, cs35l35 = devm_kzalloc(dev, sizeof(struct cs35l35_private), GFP_KERNEL);
sizeof(struct cs35l35_private),
GFP_KERNEL);
if (!cs35l35) if (!cs35l35)
return -ENOMEM; return -ENOMEM;
@ -1371,7 +1369,7 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
cs35l35->regmap = devm_regmap_init_i2c(i2c_client, &cs35l35_regmap); cs35l35->regmap = devm_regmap_init_i2c(i2c_client, &cs35l35_regmap);
if (IS_ERR(cs35l35->regmap)) { if (IS_ERR(cs35l35->regmap)) {
ret = PTR_ERR(cs35l35->regmap); ret = PTR_ERR(cs35l35->regmap);
dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); dev_err(dev, "regmap_init() failed: %d\n", ret);
goto err; goto err;
} }
@ -1379,22 +1377,18 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
cs35l35->supplies[i].supply = cs35l35_supplies[i]; cs35l35->supplies[i].supply = cs35l35_supplies[i];
cs35l35->num_supplies = ARRAY_SIZE(cs35l35_supplies); cs35l35->num_supplies = ARRAY_SIZE(cs35l35_supplies);
ret = devm_regulator_bulk_get(&i2c_client->dev, ret = devm_regulator_bulk_get(dev, cs35l35->num_supplies,
cs35l35->num_supplies, cs35l35->supplies);
cs35l35->supplies);
if (ret != 0) { if (ret != 0) {
dev_err(&i2c_client->dev, dev_err(dev, "Failed to request core supplies: %d\n", ret);
"Failed to request core supplies: %d\n",
ret);
return ret; return ret;
} }
if (pdata) { if (pdata) {
cs35l35->pdata = *pdata; cs35l35->pdata = *pdata;
} else { } else {
pdata = devm_kzalloc(&i2c_client->dev, pdata = devm_kzalloc(dev, sizeof(struct cs35l35_platform_data),
sizeof(struct cs35l35_platform_data), GFP_KERNEL);
GFP_KERNEL);
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
if (i2c_client->dev.of_node) { if (i2c_client->dev.of_node) {
@ -1409,24 +1403,21 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
ret = regulator_bulk_enable(cs35l35->num_supplies, ret = regulator_bulk_enable(cs35l35->num_supplies,
cs35l35->supplies); cs35l35->supplies);
if (ret != 0) { if (ret != 0) {
dev_err(&i2c_client->dev, dev_err(dev, "Failed to enable core supplies: %d\n", ret);
"Failed to enable core supplies: %d\n",
ret);
return ret; return ret;
} }
/* returning NULL can be valid if in stereo mode */ /* returning NULL can be valid if in stereo mode */
cs35l35->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, cs35l35->reset_gpio = devm_gpiod_get_optional(dev, "reset",
"reset", GPIOD_OUT_LOW); GPIOD_OUT_LOW);
if (IS_ERR(cs35l35->reset_gpio)) { if (IS_ERR(cs35l35->reset_gpio)) {
ret = PTR_ERR(cs35l35->reset_gpio); ret = PTR_ERR(cs35l35->reset_gpio);
if (ret == -EBUSY) { if (ret == -EBUSY) {
dev_info(&i2c_client->dev, dev_info(dev,
"Reset line busy, assuming shared reset\n"); "Reset line busy, assuming shared reset\n");
cs35l35->reset_gpio = NULL; cs35l35->reset_gpio = NULL;
} else { } else {
dev_err(&i2c_client->dev, dev_err(dev, "Failed to get reset GPIO: %d\n", ret);
"Failed to get reset GPIO: %d\n", ret);
goto err; goto err;
} }
} }
@ -1435,11 +1426,11 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
init_completion(&cs35l35->pdn_done); init_completion(&cs35l35->pdn_done);
ret = devm_request_threaded_irq(&i2c_client->dev, i2c_client->irq, NULL, ret = devm_request_threaded_irq(dev, i2c_client->irq, NULL, cs35l35_irq,
cs35l35_irq, IRQF_ONESHOT | IRQF_TRIGGER_LOW, IRQF_ONESHOT | IRQF_TRIGGER_LOW,
"cs35l35", cs35l35); "cs35l35", cs35l35);
if (ret != 0) { if (ret != 0) {
dev_err(&i2c_client->dev, "Failed to request IRQ: %d\n", ret); dev_err(dev, "Failed to request IRQ: %d\n", ret);
goto err; goto err;
} }
/* initialize codec */ /* initialize codec */
@ -1452,8 +1443,7 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
devid |= (reg & 0xF0) >> 4; devid |= (reg & 0xF0) >> 4;
if (devid != CS35L35_CHIP_ID) { if (devid != CS35L35_CHIP_ID) {
dev_err(&i2c_client->dev, dev_err(dev, "CS35L35 Device ID (%X). Expected ID %X\n",
"CS35L35 Device ID (%X). Expected ID %X\n",
devid, CS35L35_CHIP_ID); devid, CS35L35_CHIP_ID);
ret = -ENODEV; ret = -ENODEV;
goto err; goto err;
@ -1461,21 +1451,19 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
ret = regmap_read(cs35l35->regmap, CS35L35_REV_ID, &reg); ret = regmap_read(cs35l35->regmap, CS35L35_REV_ID, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(&i2c_client->dev, "Get Revision ID failed: %d\n", ret); dev_err(dev, "Get Revision ID failed: %d\n", ret);
goto err; goto err;
} }
ret = regmap_register_patch(cs35l35->regmap, cs35l35_errata_patch, ret = regmap_register_patch(cs35l35->regmap, cs35l35_errata_patch,
ARRAY_SIZE(cs35l35_errata_patch)); ARRAY_SIZE(cs35l35_errata_patch));
if (ret < 0) { if (ret < 0) {
dev_err(&i2c_client->dev, "Failed to apply errata patch: %d\n", dev_err(dev, "Failed to apply errata patch: %d\n", ret);
ret);
goto err; goto err;
} }
dev_info(&i2c_client->dev, dev_info(dev, "Cirrus Logic CS35L35 (%x), Revision: %02X\n",
"Cirrus Logic CS35L35 (%x), Revision: %02X\n", devid, devid, ret & 0xFF);
ret & 0xFF);
/* Set the INT Masks for critical errors */ /* Set the INT Masks for critical errors */
regmap_write(cs35l35->regmap, CS35L35_INT_MASK_1, regmap_write(cs35l35->regmap, CS35L35_INT_MASK_1,
@ -1507,12 +1495,10 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL,
CS35L35_AMP_MUTE_MASK, 1 << CS35L35_AMP_MUTE_SHIFT); CS35L35_AMP_MUTE_MASK, 1 << CS35L35_AMP_MUTE_SHIFT);
ret = snd_soc_register_codec(&i2c_client->dev, ret = snd_soc_register_codec(dev, &soc_codec_dev_cs35l35, cs35l35_dai,
&soc_codec_dev_cs35l35, cs35l35_dai, ARRAY_SIZE(cs35l35_dai));
ARRAY_SIZE(cs35l35_dai));
if (ret < 0) { if (ret < 0) {
dev_err(&i2c_client->dev, dev_err(dev, "Failed to register codec: %d\n", ret);
"Failed to register codec: %d\n", ret);
goto err; goto err;
} }