Skip to content

Commit c13411c

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: cy8c95x0: switch to using devm_regulator_get_enable()
The driver does not actively manage regulator state past probe() time, so we can use devm_regulator_get_enable() to simplify the code. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent b7e9fc3 commit c13411c

File tree

1 file changed

+11
-47
lines changed

1 file changed

+11
-47
lines changed

drivers/pinctrl/pinctrl-cy8c95x0.c

Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static const struct dmi_system_id cy8c95x0_dmi_acpi_irq_info[] = {
141141
* @nport: Number of Gports in this chip
142142
* @gpio_chip: gpiolib chip
143143
* @driver_data: private driver data
144-
* @regulator: Pointer to the regulator for the IC
145144
* @dev: struct device
146145
* @pctldev: pin controller device
147146
* @pinctrl_desc: pin controller description
@@ -163,7 +162,6 @@ struct cy8c95x0_pinctrl {
163162
int nport;
164163
struct gpio_chip gpio_chip;
165164
unsigned long driver_data;
166-
struct regulator *regulator;
167165
struct device *dev;
168166
struct pinctrl_dev *pctldev;
169167
struct pinctrl_desc pinctrl_desc;
@@ -1434,7 +1432,6 @@ static int cy8c95x0_probe(struct i2c_client *client)
14341432
struct cy8c95x0_pinctrl *chip;
14351433
struct regmap_config regmap_conf;
14361434
struct regmap_range_cfg regmap_range_conf;
1437-
struct regulator *reg;
14381435
int ret;
14391436

14401437
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
@@ -1448,8 +1445,6 @@ static int cy8c95x0_probe(struct i2c_client *client)
14481445
if (!chip->driver_data)
14491446
return -ENODEV;
14501447

1451-
i2c_set_clientdata(client, chip);
1452-
14531448
chip->tpin = chip->driver_data & CY8C95X0_GPIO_MASK;
14541449
chip->nport = DIV_ROUND_UP(CY8C95X0_PIN_TO_OFFSET(chip->tpin), BANK_SZ);
14551450

@@ -1472,26 +1467,15 @@ static int cy8c95x0_probe(struct i2c_client *client)
14721467
return -ENODEV;
14731468
}
14741469

1475-
reg = devm_regulator_get(&client->dev, "vdd");
1476-
if (IS_ERR(reg)) {
1477-
if (PTR_ERR(reg) == -EPROBE_DEFER)
1478-
return -EPROBE_DEFER;
1479-
} else {
1480-
ret = regulator_enable(reg);
1481-
if (ret) {
1482-
dev_err(&client->dev, "failed to enable regulator vdd: %d\n", ret);
1483-
return ret;
1484-
}
1485-
chip->regulator = reg;
1486-
}
1470+
ret = devm_regulator_get_enable(&client->dev, "vdd");
1471+
if (ret)
1472+
return dev_err_probe(&client->dev, ret, "failed to enable regulator vdd\n");
14871473

14881474
/* bring the chip out of reset if reset pin is provided */
14891475
chip->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
1490-
if (IS_ERR(chip->gpio_reset)) {
1491-
ret = dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset),
1492-
"Failed to get GPIO 'reset'\n");
1493-
goto err_exit;
1494-
} else if (chip->gpio_reset) {
1476+
if (IS_ERR(chip->gpio_reset))
1477+
return dev_err_probe(chip->dev, PTR_ERR(chip->gpio_reset), "Failed to get GPIO 'reset'\n");
1478+
if (chip->gpio_reset) {
14951479
usleep_range(1000, 2000);
14961480
gpiod_set_value_cansleep(chip->gpio_reset, 0);
14971481
usleep_range(250000, 300000);
@@ -1506,10 +1490,8 @@ static int cy8c95x0_probe(struct i2c_client *client)
15061490
regmap_conf.num_reg_defaults_raw = regmap_range_conf.range_max;
15071491

15081492
chip->regmap = devm_regmap_init_i2c(client, &regmap_conf);
1509-
if (IS_ERR(chip->regmap)) {
1510-
ret = PTR_ERR(chip->regmap);
1511-
goto err_exit;
1512-
}
1493+
if (IS_ERR(chip->regmap))
1494+
return PTR_ERR(chip->regmap);
15131495

15141496
bitmap_zero(chip->push_pull, MAX_LINE);
15151497
bitmap_zero(chip->shiftmask, MAX_LINE);
@@ -1525,31 +1507,14 @@ static int cy8c95x0_probe(struct i2c_client *client)
15251507
if (client->irq) {
15261508
ret = cy8c95x0_irq_setup(chip, client->irq);
15271509
if (ret)
1528-
goto err_exit;
1510+
return ret;
15291511
}
15301512

15311513
ret = cy8c95x0_setup_pinctrl(chip);
15321514
if (ret)
1533-
goto err_exit;
1534-
1535-
ret = cy8c95x0_setup_gpiochip(chip);
1536-
if (ret)
1537-
goto err_exit;
1538-
1539-
return 0;
1540-
1541-
err_exit:
1542-
if (!IS_ERR_OR_NULL(chip->regulator))
1543-
regulator_disable(chip->regulator);
1544-
return ret;
1545-
}
1546-
1547-
static void cy8c95x0_remove(struct i2c_client *client)
1548-
{
1549-
struct cy8c95x0_pinctrl *chip = i2c_get_clientdata(client);
1515+
return ret;
15501516

1551-
if (!IS_ERR_OR_NULL(chip->regulator))
1552-
regulator_disable(chip->regulator);
1517+
return cy8c95x0_setup_gpiochip(chip);
15531518
}
15541519

15551520
static const struct acpi_device_id cy8c95x0_acpi_ids[] = {
@@ -1565,7 +1530,6 @@ static struct i2c_driver cy8c95x0_driver = {
15651530
.acpi_match_table = cy8c95x0_acpi_ids,
15661531
},
15671532
.probe = cy8c95x0_probe,
1568-
.remove = cy8c95x0_remove,
15691533
.id_table = cy8c95x0_id,
15701534
.detect = cy8c95x0_detect,
15711535
};

0 commit comments

Comments
 (0)