@@ -1145,18 +1145,6 @@ struct gpio_device *gpio_device_find_by_label(const char *label)
1145
1145
}
1146
1146
EXPORT_SYMBOL_GPL (gpio_device_find_by_label );
1147
1147
1148
- static int gpiochip_match_name (struct gpio_chip * gc , void * data )
1149
- {
1150
- const char * name = data ;
1151
-
1152
- return !strcmp (gc -> label , name );
1153
- }
1154
-
1155
- static struct gpio_chip * find_chip_by_name (const char * name )
1156
- {
1157
- return gpiochip_find ((void * )name , gpiochip_match_name );
1158
- }
1159
-
1160
1148
/**
1161
1149
* gpio_device_get() - Increase the reference count of this GPIO device
1162
1150
* @gdev: GPIO device to increase the refcount for
@@ -3908,7 +3896,6 @@ EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);
3908
3896
*/
3909
3897
void gpiod_add_hogs (struct gpiod_hog * hogs )
3910
3898
{
3911
- struct gpio_chip * gc ;
3912
3899
struct gpiod_hog * hog ;
3913
3900
3914
3901
mutex_lock (& gpio_machine_hogs_mutex );
@@ -3920,9 +3907,10 @@ void gpiod_add_hogs(struct gpiod_hog *hogs)
3920
3907
* The chip may have been registered earlier, so check if it
3921
3908
* exists and, if so, try to hog the line now.
3922
3909
*/
3923
- gc = find_chip_by_name (hog -> chip_label );
3924
- if (gc )
3925
- gpiochip_machine_hog (gc , hog );
3910
+ struct gpio_device * gdev __free (gpio_device_put ) =
3911
+ gpio_device_find_by_label (hog -> chip_label );
3912
+ if (gdev )
3913
+ gpiochip_machine_hog (gpio_device_get_chip (gdev ), hog );
3926
3914
}
3927
3915
3928
3916
mutex_unlock (& gpio_machine_hogs_mutex );
@@ -3972,6 +3960,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
3972
3960
struct gpio_desc * desc = ERR_PTR (- ENOENT );
3973
3961
struct gpiod_lookup_table * table ;
3974
3962
struct gpiod_lookup * p ;
3963
+ struct gpio_chip * gc ;
3975
3964
3976
3965
guard (mutex )(& gpio_lookup_lock );
3977
3966
@@ -3980,8 +3969,6 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
3980
3969
return desc ;
3981
3970
3982
3971
for (p = & table -> table [0 ]; p -> key ; p ++ ) {
3983
- struct gpio_chip * gc ;
3984
-
3985
3972
/* idx must always match exactly */
3986
3973
if (p -> idx != idx )
3987
3974
continue ;
@@ -4002,9 +3989,9 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
4002
3989
return ERR_PTR (- EPROBE_DEFER );
4003
3990
}
4004
3991
4005
- gc = find_chip_by_name ( p -> key );
4006
-
4007
- if (!gc ) {
3992
+ struct gpio_device * gdev __free ( gpio_device_put ) =
3993
+ gpio_device_find_by_label ( p -> key );
3994
+ if (!gdev ) {
4008
3995
/*
4009
3996
* As the lookup table indicates a chip with
4010
3997
* p->key should exist, assume it may
@@ -4017,6 +4004,8 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
4017
4004
return ERR_PTR (- EPROBE_DEFER );
4018
4005
}
4019
4006
4007
+ gc = gpio_device_get_chip (gdev );
4008
+
4020
4009
if (gc -> ngpio <= p -> chip_hwnum ) {
4021
4010
dev_err (dev ,
4022
4011
"requested GPIO %u (%u) is out of range [0..%u] for chip %s\n" ,
@@ -4025,7 +4014,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
4025
4014
return ERR_PTR (- EINVAL );
4026
4015
}
4027
4016
4028
- desc = gpiochip_get_desc ( gc , p -> chip_hwnum );
4017
+ desc = gpio_device_get_desc ( gdev , p -> chip_hwnum );
4029
4018
* flags = p -> flags ;
4030
4019
4031
4020
return desc ;
0 commit comments