mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-06 03:36:39 +07:00
[media] s5c73m3: Convert to devm_gpio_request_one()
Use the devm_gpio_request_one() managed function to simplify cleanup code paths. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
736db646b6
commit
598d8d1e4c
@ -1511,59 +1511,40 @@ static const struct v4l2_subdev_ops oif_subdev_ops = {
|
||||
.video = &s5c73m3_oif_video_ops,
|
||||
};
|
||||
|
||||
static int s5c73m3_configure_gpio(int nr, int val, const char *name)
|
||||
{
|
||||
unsigned long flags = val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
|
||||
int ret;
|
||||
|
||||
if (!gpio_is_valid(nr))
|
||||
return 0;
|
||||
ret = gpio_request_one(nr, flags, name);
|
||||
if (!ret)
|
||||
gpio_export(nr, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int s5c73m3_free_gpios(struct s5c73m3 *state)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(state->gpio); i++) {
|
||||
if (!gpio_is_valid(state->gpio[i].gpio))
|
||||
continue;
|
||||
gpio_free(state->gpio[i].gpio);
|
||||
state->gpio[i].gpio = -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s5c73m3_configure_gpios(struct s5c73m3 *state,
|
||||
const struct s5c73m3_platform_data *pdata)
|
||||
{
|
||||
const struct s5c73m3_gpio *gpio = &pdata->gpio_stby;
|
||||
struct device *dev = &state->i2c_client->dev;
|
||||
const struct s5c73m3_gpio *gpio;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
state->gpio[STBY].gpio = -EINVAL;
|
||||
state->gpio[RST].gpio = -EINVAL;
|
||||
|
||||
ret = s5c73m3_configure_gpio(gpio->gpio, gpio->level, "S5C73M3_STBY");
|
||||
if (ret) {
|
||||
s5c73m3_free_gpios(state);
|
||||
return ret;
|
||||
gpio = &pdata->gpio_stby;
|
||||
if (gpio_is_valid(gpio->gpio)) {
|
||||
flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW)
|
||||
| GPIOF_EXPORT;
|
||||
ret = devm_gpio_request_one(dev, gpio->gpio, flags,
|
||||
"S5C73M3_STBY");
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
state->gpio[STBY] = *gpio;
|
||||
}
|
||||
state->gpio[STBY] = *gpio;
|
||||
if (gpio_is_valid(gpio->gpio))
|
||||
gpio_set_value(gpio->gpio, 0);
|
||||
|
||||
gpio = &pdata->gpio_reset;
|
||||
ret = s5c73m3_configure_gpio(gpio->gpio, gpio->level, "S5C73M3_RST");
|
||||
if (ret) {
|
||||
s5c73m3_free_gpios(state);
|
||||
return ret;
|
||||
if (gpio_is_valid(gpio->gpio)) {
|
||||
flags = (gpio->level ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW)
|
||||
| GPIOF_EXPORT;
|
||||
ret = devm_gpio_request_one(dev, gpio->gpio, flags,
|
||||
"S5C73M3_RST");
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
state->gpio[RST] = *gpio;
|
||||
}
|
||||
state->gpio[RST] = *gpio;
|
||||
if (gpio_is_valid(gpio->gpio))
|
||||
gpio_set_value(gpio->gpio, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1626,10 +1607,11 @@ static int s5c73m3_probe(struct i2c_client *client,
|
||||
|
||||
state->mclk_frequency = pdata->mclk_frequency;
|
||||
state->bus_type = pdata->bus_type;
|
||||
state->i2c_client = client;
|
||||
|
||||
ret = s5c73m3_configure_gpios(state, pdata);
|
||||
if (ret)
|
||||
goto out_err1;
|
||||
goto out_err;
|
||||
|
||||
for (i = 0; i < S5C73M3_MAX_SUPPLIES; i++)
|
||||
state->supplies[i].supply = s5c73m3_supply_names[i];
|
||||
@ -1638,12 +1620,12 @@ static int s5c73m3_probe(struct i2c_client *client,
|
||||
state->supplies);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to get regulators\n");
|
||||
goto out_err2;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
ret = s5c73m3_init_controls(state);
|
||||
if (ret)
|
||||
goto out_err2;
|
||||
goto out_err;
|
||||
|
||||
state->sensor_pix_size[RES_ISP] = &s5c73m3_isp_resolutions[1];
|
||||
state->sensor_pix_size[RES_JPEG] = &s5c73m3_jpeg_resolutions[1];
|
||||
@ -1659,16 +1641,12 @@ static int s5c73m3_probe(struct i2c_client *client,
|
||||
|
||||
ret = s5c73m3_register_spi_driver(state);
|
||||
if (ret < 0)
|
||||
goto out_err2;
|
||||
|
||||
state->i2c_client = client;
|
||||
goto out_err;
|
||||
|
||||
v4l2_info(sd, "%s: completed succesfully\n", __func__);
|
||||
return 0;
|
||||
|
||||
out_err2:
|
||||
s5c73m3_free_gpios(state);
|
||||
out_err1:
|
||||
out_err:
|
||||
media_entity_cleanup(&sd->entity);
|
||||
return ret;
|
||||
}
|
||||
@ -1688,7 +1666,6 @@ static int s5c73m3_remove(struct i2c_client *client)
|
||||
media_entity_cleanup(&sensor_sd->entity);
|
||||
|
||||
s5c73m3_unregister_spi_driver(state);
|
||||
s5c73m3_free_gpios(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user