@@ -3497,13 +3497,13 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value);
3497
3497
* @desc: gpio descriptor whose state need to be set.
3498
3498
* @value: Non-zero for setting it HIGH otherwise it will set to LOW.
3499
3499
*/
3500
- static void gpio_set_open_drain_value_commit (struct gpio_desc * desc , bool value )
3500
+ static int gpio_set_open_drain_value_commit (struct gpio_desc * desc , bool value )
3501
3501
{
3502
3502
int ret = 0 , offset = gpio_chip_hwgpio (desc );
3503
3503
3504
3504
CLASS (gpio_chip_guard , guard )(desc );
3505
3505
if (!guard .gc )
3506
- return ;
3506
+ return - ENODEV ;
3507
3507
3508
3508
if (value ) {
3509
3509
ret = gpiochip_direction_input (guard .gc , offset );
@@ -3517,20 +3517,22 @@ static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value)
3517
3517
gpiod_err (desc ,
3518
3518
"%s: Error in set_value for open drain err %d\n" ,
3519
3519
__func__ , ret );
3520
+
3521
+ return ret ;
3520
3522
}
3521
3523
3522
3524
/*
3523
3525
* _gpio_set_open_source_value() - Set the open source gpio's value.
3524
3526
* @desc: gpio descriptor whose state need to be set.
3525
3527
* @value: Non-zero for setting it HIGH otherwise it will set to LOW.
3526
3528
*/
3527
- static void gpio_set_open_source_value_commit (struct gpio_desc * desc , bool value )
3529
+ static int gpio_set_open_source_value_commit (struct gpio_desc * desc , bool value )
3528
3530
{
3529
3531
int ret = 0 , offset = gpio_chip_hwgpio (desc );
3530
3532
3531
3533
CLASS (gpio_chip_guard , guard )(desc );
3532
3534
if (!guard .gc )
3533
- return ;
3535
+ return - ENODEV ;
3534
3536
3535
3537
if (value ) {
3536
3538
ret = gpiochip_direction_output (guard .gc , offset , 1 );
@@ -3544,16 +3546,20 @@ static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value
3544
3546
gpiod_err (desc ,
3545
3547
"%s: Error in set_value for open source err %d\n" ,
3546
3548
__func__ , ret );
3549
+
3550
+ return ret ;
3547
3551
}
3548
3552
3549
- static void gpiod_set_raw_value_commit (struct gpio_desc * desc , bool value )
3553
+ static int gpiod_set_raw_value_commit (struct gpio_desc * desc , bool value )
3550
3554
{
3551
3555
CLASS (gpio_chip_guard , guard )(desc );
3552
3556
if (!guard .gc )
3553
- return ;
3557
+ return - ENODEV ;
3554
3558
3555
3559
trace_gpio_value (desc_to_gpio (desc ), 0 , value );
3556
3560
guard .gc -> set (guard .gc , gpio_chip_hwgpio (desc ), value );
3561
+
3562
+ return 0 ;
3557
3563
}
3558
3564
3559
3565
/*
@@ -3711,12 +3717,12 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
3711
3717
* This function can be called from contexts where we cannot sleep, and will
3712
3718
* complain if the GPIO chip functions potentially sleep.
3713
3719
*/
3714
- void gpiod_set_raw_value (struct gpio_desc * desc , int value )
3720
+ int gpiod_set_raw_value (struct gpio_desc * desc , int value )
3715
3721
{
3716
- VALIDATE_DESC_VOID (desc );
3722
+ VALIDATE_DESC (desc );
3717
3723
/* Should be using gpiod_set_raw_value_cansleep() */
3718
3724
WARN_ON (desc -> gdev -> can_sleep );
3719
- gpiod_set_raw_value_commit (desc , value );
3725
+ return gpiod_set_raw_value_commit (desc , value );
3720
3726
}
3721
3727
EXPORT_SYMBOL_GPL (gpiod_set_raw_value );
3722
3728
@@ -3729,16 +3735,17 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value);
3729
3735
* different semantic quirks like active low and open drain/source
3730
3736
* handling.
3731
3737
*/
3732
- static void gpiod_set_value_nocheck (struct gpio_desc * desc , int value )
3738
+ static int gpiod_set_value_nocheck (struct gpio_desc * desc , int value )
3733
3739
{
3734
3740
if (test_bit (FLAG_ACTIVE_LOW , & desc -> flags ))
3735
3741
value = !value ;
3742
+
3736
3743
if (test_bit (FLAG_OPEN_DRAIN , & desc -> flags ))
3737
- gpio_set_open_drain_value_commit (desc , value );
3744
+ return gpio_set_open_drain_value_commit (desc , value );
3738
3745
else if (test_bit (FLAG_OPEN_SOURCE , & desc -> flags ))
3739
- gpio_set_open_source_value_commit (desc , value );
3740
- else
3741
- gpiod_set_raw_value_commit (desc , value );
3746
+ return gpio_set_open_source_value_commit (desc , value );
3747
+
3748
+ return gpiod_set_raw_value_commit (desc , value );
3742
3749
}
3743
3750
3744
3751
/**
@@ -3752,12 +3759,12 @@ static void gpiod_set_value_nocheck(struct gpio_desc *desc, int value)
3752
3759
* This function can be called from contexts where we cannot sleep, and will
3753
3760
* complain if the GPIO chip functions potentially sleep.
3754
3761
*/
3755
- void gpiod_set_value (struct gpio_desc * desc , int value )
3762
+ int gpiod_set_value (struct gpio_desc * desc , int value )
3756
3763
{
3757
- VALIDATE_DESC_VOID (desc );
3764
+ VALIDATE_DESC (desc );
3758
3765
/* Should be using gpiod_set_value_cansleep() */
3759
3766
WARN_ON (desc -> gdev -> can_sleep );
3760
- gpiod_set_value_nocheck (desc , value );
3767
+ return gpiod_set_value_nocheck (desc , value );
3761
3768
}
3762
3769
EXPORT_SYMBOL_GPL (gpiod_set_value );
3763
3770
@@ -4176,11 +4183,11 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep);
4176
4183
*
4177
4184
* This function is to be called from contexts that can sleep.
4178
4185
*/
4179
- void gpiod_set_raw_value_cansleep (struct gpio_desc * desc , int value )
4186
+ int gpiod_set_raw_value_cansleep (struct gpio_desc * desc , int value )
4180
4187
{
4181
4188
might_sleep ();
4182
- VALIDATE_DESC_VOID (desc );
4183
- gpiod_set_raw_value_commit (desc , value );
4189
+ VALIDATE_DESC (desc );
4190
+ return gpiod_set_raw_value_commit (desc , value );
4184
4191
}
4185
4192
EXPORT_SYMBOL_GPL (gpiod_set_raw_value_cansleep );
4186
4193
@@ -4194,11 +4201,11 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value_cansleep);
4194
4201
*
4195
4202
* This function is to be called from contexts that can sleep.
4196
4203
*/
4197
- void gpiod_set_value_cansleep (struct gpio_desc * desc , int value )
4204
+ int gpiod_set_value_cansleep (struct gpio_desc * desc , int value )
4198
4205
{
4199
4206
might_sleep ();
4200
- VALIDATE_DESC_VOID (desc );
4201
- gpiod_set_value_nocheck (desc , value );
4207
+ VALIDATE_DESC (desc );
4208
+ return gpiod_set_value_nocheck (desc , value );
4202
4209
}
4203
4210
EXPORT_SYMBOL_GPL (gpiod_set_value_cansleep );
4204
4211
0 commit comments