Commit fbe14a12 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Mauro Carvalho Chehab

[media] si4713: switch reset gpio to devm_gpiod API

This updates the driver to use the managed gpiod interface
instead of the unmanged old GPIO API. This is a preperation
for the introduction of device tree support.
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
[hans.verkuil@cisco.com: fixed trivial compiler warning]
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent d4471dec
...@@ -383,9 +383,9 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -383,9 +383,9 @@ static int si4713_powerup(struct si4713_device *sdev)
} }
} }
if (gpio_is_valid(sdev->gpio_reset)) { if (!IS_ERR(sdev->gpio_reset)) {
udelay(50); udelay(50);
gpio_set_value(sdev->gpio_reset, 1); gpiod_set_value(sdev->gpio_reset, 1);
} }
if (client->irq) if (client->irq)
...@@ -407,8 +407,8 @@ static int si4713_powerup(struct si4713_device *sdev) ...@@ -407,8 +407,8 @@ static int si4713_powerup(struct si4713_device *sdev)
SI4713_STC_INT | SI4713_CTS); SI4713_STC_INT | SI4713_CTS);
return err; return err;
} }
if (gpio_is_valid(sdev->gpio_reset)) if (!IS_ERR(sdev->gpio_reset))
gpio_set_value(sdev->gpio_reset, 0); gpiod_set_value(sdev->gpio_reset, 0);
if (sdev->vdd) { if (sdev->vdd) {
...@@ -447,8 +447,8 @@ static int si4713_powerdown(struct si4713_device *sdev) ...@@ -447,8 +447,8 @@ static int si4713_powerdown(struct si4713_device *sdev)
v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n",
resp[0]); resp[0]);
v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
if (gpio_is_valid(sdev->gpio_reset)) if (!IS_ERR(sdev->gpio_reset))
gpio_set_value(sdev->gpio_reset, 0); gpiod_set_value(sdev->gpio_reset, 0);
if (sdev->vdd) { if (sdev->vdd) {
err = regulator_disable(sdev->vdd); err = regulator_disable(sdev->vdd);
...@@ -1446,7 +1446,6 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1446,7 +1446,6 @@ static int si4713_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct si4713_device *sdev; struct si4713_device *sdev;
struct si4713_platform_data *pdata = client->dev.platform_data;
struct v4l2_ctrl_handler *hdl; struct v4l2_ctrl_handler *hdl;
int rval; int rval;
...@@ -1457,17 +1456,18 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1457,17 +1456,18 @@ static int si4713_probe(struct i2c_client *client,
goto exit; goto exit;
} }
sdev->gpio_reset = -1; sdev->gpio_reset = devm_gpiod_get(&client->dev, "reset");
if (pdata && gpio_is_valid(pdata->gpio_reset)) { if (!IS_ERR(sdev->gpio_reset)) {
rval = gpio_request(pdata->gpio_reset, "si4713 reset"); gpiod_direction_output(sdev->gpio_reset, 0);
if (rval) { } else if (PTR_ERR(sdev->gpio_reset) == -ENOENT) {
dev_err(&client->dev, dev_dbg(&client->dev, "No reset GPIO assigned\n");
"Failed to request gpio: %d\n", rval); } else if (PTR_ERR(sdev->gpio_reset) == -ENOSYS) {
dev_dbg(&client->dev, "No reset GPIO support\n");
} else {
rval = PTR_ERR(sdev->gpio_reset);
dev_err(&client->dev, "Failed to request gpio: %d\n", rval);
goto free_sdev; goto free_sdev;
} }
sdev->gpio_reset = pdata->gpio_reset;
gpio_direction_output(sdev->gpio_reset, 0);
}
sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd"); sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd");
if (IS_ERR(sdev->vdd)) { if (IS_ERR(sdev->vdd)) {
...@@ -1614,8 +1614,6 @@ static int si4713_probe(struct i2c_client *client, ...@@ -1614,8 +1614,6 @@ static int si4713_probe(struct i2c_client *client,
free_irq(client->irq, sdev); free_irq(client->irq, sdev);
free_ctrls: free_ctrls:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
if (gpio_is_valid(sdev->gpio_reset))
gpio_free(sdev->gpio_reset);
free_sdev: free_sdev:
kfree(sdev); kfree(sdev);
exit: exit:
...@@ -1636,8 +1634,6 @@ static int si4713_remove(struct i2c_client *client) ...@@ -1636,8 +1634,6 @@ static int si4713_remove(struct i2c_client *client)
v4l2_device_unregister_subdev(sd); v4l2_device_unregister_subdev(sd);
v4l2_ctrl_handler_free(sd->ctrl_handler); v4l2_ctrl_handler_free(sd->ctrl_handler);
if (gpio_is_valid(sdev->gpio_reset))
gpio_free(sdev->gpio_reset);
kfree(sdev); kfree(sdev);
return 0; return 0;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define SI4713_I2C_H #define SI4713_I2C_H
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <media/v4l2-subdev.h> #include <media/v4l2-subdev.h>
#include <media/v4l2-ctrls.h> #include <media/v4l2-ctrls.h>
#include <media/si4713.h> #include <media/si4713.h>
...@@ -236,7 +237,7 @@ struct si4713_device { ...@@ -236,7 +237,7 @@ struct si4713_device {
struct completion work; struct completion work;
struct regulator *vdd; struct regulator *vdd;
struct regulator *vio; struct regulator *vio;
int gpio_reset; struct gpio_desc *gpio_reset;
u32 power_state; u32 power_state;
u32 rds_enabled; u32 rds_enabled;
u32 frequency; u32 frequency;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment