Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l: mt9p031: Convert to the gpiod API

This simplifies platform data and DT integration.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
7c3be9f8 9012d088

+11 -22
+11 -20
drivers/media/i2c/mt9p031.c
··· 15 15 #include <linux/clk.h> 16 16 #include <linux/delay.h> 17 17 #include <linux/device.h> 18 - #include <linux/gpio.h> 18 + #include <linux/gpio/consumer.h> 19 19 #include <linux/i2c.h> 20 20 #include <linux/log2.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 - #include <linux/of_gpio.h> 24 23 #include <linux/of_graph.h> 25 24 #include <linux/pm.h> 26 25 #include <linux/regulator/consumer.h> ··· 135 136 struct aptina_pll pll; 136 137 unsigned int clk_div; 137 138 bool use_pll; 138 - int reset; 139 + struct gpio_desc *reset; 139 140 140 141 struct v4l2_ctrl_handler ctrls; 141 142 struct v4l2_ctrl *blc_auto; ··· 308 309 { 309 310 int ret; 310 311 311 - /* Ensure RESET_BAR is low */ 312 - if (gpio_is_valid(mt9p031->reset)) { 313 - gpio_set_value(mt9p031->reset, 0); 312 + /* Ensure RESET_BAR is active */ 313 + if (mt9p031->reset) { 314 + gpiod_set_value(mt9p031->reset, 1); 314 315 usleep_range(1000, 2000); 315 316 } 316 317 ··· 331 332 } 332 333 333 334 /* Now RESET_BAR must be high */ 334 - if (gpio_is_valid(mt9p031->reset)) { 335 - gpio_set_value(mt9p031->reset, 1); 335 + if (mt9p031->reset) { 336 + gpiod_set_value(mt9p031->reset, 0); 336 337 usleep_range(1000, 2000); 337 338 } 338 339 ··· 341 342 342 343 static void mt9p031_power_off(struct mt9p031 *mt9p031) 343 344 { 344 - if (gpio_is_valid(mt9p031->reset)) { 345 - gpio_set_value(mt9p031->reset, 0); 345 + if (mt9p031->reset) { 346 + gpiod_set_value(mt9p031->reset, 1); 346 347 usleep_range(1000, 2000); 347 348 } 348 349 ··· 1022 1023 if (!pdata) 1023 1024 goto done; 1024 1025 1025 - pdata->reset = of_get_named_gpio(client->dev.of_node, "reset-gpios", 0); 1026 1026 of_property_read_u32(np, "input-clock-frequency", &pdata->ext_freq); 1027 1027 of_property_read_u32(np, "pixel-clock-frequency", &pdata->target_freq); 1028 1028 ··· 1058 1060 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; 1059 1061 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; 1060 1062 mt9p031->model = did->driver_data; 1061 - mt9p031->reset = -1; 1062 1063 1063 1064 mt9p031->regulators[0].supply = "vdd"; 1064 1065 mt9p031->regulators[1].supply = "vdd_io"; ··· 1133 1136 mt9p031->format.field = V4L2_FIELD_NONE; 1134 1137 mt9p031->format.colorspace = V4L2_COLORSPACE_SRGB; 1135 1138 1136 - if (gpio_is_valid(pdata->reset)) { 1137 - ret = devm_gpio_request_one(&client->dev, pdata->reset, 1138 - GPIOF_OUT_INIT_LOW, "mt9p031_rst"); 1139 - if (ret < 0) 1140 - goto done; 1141 - 1142 - mt9p031->reset = pdata->reset; 1143 - } 1139 + mt9p031->reset = devm_gpiod_get_optional(&client->dev, "reset", 1140 + GPIOD_OUT_HIGH); 1144 1141 1145 1142 ret = mt9p031_clk_setup(mt9p031); 1146 1143 if (ret)
-2
include/media/mt9p031.h
··· 5 5 6 6 /* 7 7 * struct mt9p031_platform_data - MT9P031 platform data 8 - * @reset: Chip reset GPIO (set to -1 if not used) 9 8 * @ext_freq: Input clock frequency 10 9 * @target_freq: Pixel clock frequency 11 10 */ 12 11 struct mt9p031_platform_data { 13 - int reset; 14 12 int ext_freq; 15 13 int target_freq; 16 14 };