Commit 75aca1c7 authored by Martin Kepplinger's avatar Martin Kepplinger Committed by Dorota Czaplejewicz
Browse files

hi846: cleanup gpio handling

since there's only one
parent e5db3074
......@@ -624,11 +624,6 @@ struct hi846_gpio {
int level;
};
enum hi846_gpio_id {
RST,
NUM_GPIOS,
};
struct hi846_datafmt {
u32 code;
enum v4l2_colorspace colorspace;
......@@ -644,7 +639,7 @@ struct hi846_reg_list debug_regstable_list = {
};
struct hi846 {
struct hi846_gpio gpios[NUM_GPIOS];
struct hi846_gpio rst_gpio;
struct regulator *vdd1_regulator;
struct regulator *vdd_regulator;
struct clk *clock;
......@@ -1459,9 +1454,10 @@ static const struct v4l2_subdev_internal_ops hi846_internal_ops = {
.open = hi846_open,
};
static void hi846_gpio_assert(struct hi846 *hi846, int id, bool on)
static void hi846_rst_gpio_assert(struct hi846 *hi846, bool on)
{
struct hi846_gpio *gpio = &hi846->gpios[id];
struct hi846_gpio *gpio = &hi846->rst_gpio;
if (gpio == 0)
return;
......@@ -1471,25 +1467,19 @@ static void hi846_gpio_assert(struct hi846 *hi846, int id, bool on)
gpio_set_value(gpio->gpio, !gpio->level);
}
static int hi846_parse_gpios(struct hi846_gpio *gpios, struct device *dev)
static int hi846_parse_gpio(struct hi846_gpio *gpio, struct device *dev)
{
static const char * const names[] = {
"rst-gpios",
};
struct device_node *node = dev->of_node;
enum of_gpio_flags flags;
int ret, i;
int ret;
for (i = 0; i < NUM_GPIOS; ++i) {
ret = of_get_named_gpio_flags(node, names[i], 0, &flags);
if (ret < 0) {
dev_err(dev, "no %s GPIO pin provided: %d\n", names[i],
ret);
return ret;
}
gpios[i].gpio = ret;
gpios[i].level = !(flags & OF_GPIO_ACTIVE_LOW);
ret = of_get_named_gpio_flags(node, "rst-gpios", 0, &flags);
if (ret < 0) {
dev_err(dev, "no rst-gpios provided: %d\n", ret);
return ret;
}
gpio->gpio = ret;
gpio->level = !(flags & OF_GPIO_ACTIVE_LOW);
return 0;
}
......@@ -1645,9 +1635,9 @@ static int hi846_probe(struct i2c_client *client)
v4l2_i2c_subdev_init(&hi846->sd, client, &hi846_subdev_ops);
ret = hi846_parse_gpios(hi846->gpios, &client->dev);
ret = hi846_parse_gpio(&hi846->rst_gpio, &client->dev);
if (ret < 0) {
dev_err(&client->dev, "parse gpios failed: %d\n", ret);
dev_err(&client->dev, "parse gpio failed: %d\n", ret);
return ret;
}
......@@ -1678,7 +1668,7 @@ static int hi846_probe(struct i2c_client *client)
msleep(100);
hi846_gpio_assert(hi846, RST, true);
hi846_rst_gpio_assert(hi846, true);
ret = hi846_identify_module(hi846);
if (ret) {
......
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