9
9
#include <linux/clk.h>
10
10
#include <linux/delay.h>
11
11
#include <linux/device.h>
12
+ #include <linux/err.h>
12
13
#include <linux/errno.h>
13
- #include <linux/gpio.h>
14
+ #include <linux/gpio/consumer .h>
14
15
#include <linux/i2c.h>
15
16
#include <linux/kernel.h>
16
17
#include <linux/module.h>
17
- #include <linux/of_gpio.h>
18
18
#include <linux/pm_runtime.h>
19
19
#include <linux/regulator/consumer.h>
20
20
#include <linux/slab.h>
@@ -59,7 +59,7 @@ struct s5k6a3 {
59
59
struct v4l2_subdev subdev ;
60
60
struct media_pad pad ;
61
61
struct regulator_bulk_data supplies [S5K6A3_NUM_SUPPLIES ];
62
- int gpio_reset ;
62
+ struct gpio_desc * gpio_reset ;
63
63
struct mutex lock ;
64
64
struct v4l2_mbus_framefmt format ;
65
65
struct clk * clock ;
@@ -216,11 +216,11 @@ static int __s5k6a3_power_on(struct s5k6a3 *sensor)
216
216
goto error_clk ;
217
217
}
218
218
219
- gpio_set_value (sensor -> gpio_reset , 1 );
219
+ gpiod_set_value_cansleep (sensor -> gpio_reset , 0 );
220
220
usleep_range (600 , 800 );
221
- gpio_set_value (sensor -> gpio_reset , 0 );
221
+ gpiod_set_value_cansleep (sensor -> gpio_reset , 1 );
222
222
usleep_range (600 , 800 );
223
- gpio_set_value (sensor -> gpio_reset , 1 );
223
+ gpiod_set_value_cansleep (sensor -> gpio_reset , 0 );
224
224
225
225
/* Delay needed for the sensor initialization */
226
226
msleep (20 );
@@ -240,7 +240,7 @@ static int __s5k6a3_power_off(struct s5k6a3 *sensor)
240
240
{
241
241
int i ;
242
242
243
- gpio_set_value (sensor -> gpio_reset , 0 );
243
+ gpiod_set_value_cansleep (sensor -> gpio_reset , 1 );
244
244
245
245
for (i = S5K6A3_NUM_SUPPLIES - 1 ; i >= 0 ; i -- )
246
246
regulator_disable (sensor -> supplies [i ].consumer );
@@ -285,32 +285,24 @@ static int s5k6a3_probe(struct i2c_client *client)
285
285
struct device * dev = & client -> dev ;
286
286
struct s5k6a3 * sensor ;
287
287
struct v4l2_subdev * sd ;
288
- int gpio , i , ret ;
288
+ int i , ret ;
289
289
290
290
sensor = devm_kzalloc (dev , sizeof (* sensor ), GFP_KERNEL );
291
291
if (!sensor )
292
292
return - ENOMEM ;
293
293
294
294
mutex_init (& sensor -> lock );
295
- sensor -> gpio_reset = - EINVAL ;
296
- sensor -> clock = ERR_PTR (- EINVAL );
297
295
sensor -> dev = dev ;
298
296
299
297
sensor -> clock = devm_clk_get (sensor -> dev , S5K6A3_CLK_NAME );
300
298
if (IS_ERR (sensor -> clock ))
301
299
return PTR_ERR (sensor -> clock );
302
300
303
- gpio = of_get_gpio_flags (dev -> of_node , 0 , NULL );
304
- if (!gpio_is_valid (gpio ))
305
- return gpio ;
306
-
307
- ret = devm_gpio_request_one (dev , gpio , GPIOF_OUT_INIT_LOW ,
308
- S5K6A3_DRV_NAME );
309
- if (ret < 0 )
301
+ sensor -> gpio_reset = devm_gpiod_get (dev , NULL , GPIOD_OUT_HIGH );
302
+ ret = PTR_ERR_OR_ZERO (sensor -> gpio_reset );
303
+ if (ret )
310
304
return ret ;
311
305
312
- sensor -> gpio_reset = gpio ;
313
-
314
306
if (of_property_read_u32 (dev -> of_node , "clock-frequency" ,
315
307
& sensor -> clock_frequency )) {
316
308
sensor -> clock_frequency = S5K6A3_DEFAULT_CLK_FREQ ;
0 commit comments