@@ -52,21 +52,15 @@ static void skl_int3472_log_sensor_module_name(struct int3472_discrete_device *i
52
52
}
53
53
}
54
54
55
- static int skl_int3472_map_gpio_to_sensor (struct int3472_discrete_device * int3472 ,
56
- struct acpi_resource_gpio * agpio ,
57
- const char * func , u32 polarity )
55
+ static int skl_int3472_fill_gpiod_lookup (struct gpiod_lookup * table_entry ,
56
+ struct acpi_resource_gpio * agpio ,
57
+ const char * func , u32 polarity )
58
58
{
59
59
char * path = agpio -> resource_source .string_ptr ;
60
- struct gpiod_lookup * table_entry ;
61
60
struct acpi_device * adev ;
62
61
acpi_handle handle ;
63
62
acpi_status status ;
64
63
65
- if (int3472 -> n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS ) {
66
- dev_warn (int3472 -> dev , "Too many GPIOs mapped\n" );
67
- return - EINVAL ;
68
- }
69
-
70
64
status = acpi_get_handle (NULL , path , & handle );
71
65
if (ACPI_FAILURE (status ))
72
66
return - EINVAL ;
@@ -75,13 +69,31 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
75
69
if (!adev )
76
70
return - ENODEV ;
77
71
78
- table_entry = & int3472 -> gpios .table [int3472 -> n_sensor_gpios ];
79
72
table_entry -> key = acpi_dev_name (adev );
80
73
table_entry -> chip_hwnum = agpio -> pin_table [0 ];
81
74
table_entry -> con_id = func ;
82
75
table_entry -> idx = 0 ;
83
76
table_entry -> flags = polarity ;
84
77
78
+ return 0 ;
79
+ }
80
+
81
+ static int skl_int3472_map_gpio_to_sensor (struct int3472_discrete_device * int3472 ,
82
+ struct acpi_resource_gpio * agpio ,
83
+ const char * func , u32 polarity )
84
+ {
85
+ int ret ;
86
+
87
+ if (int3472 -> n_sensor_gpios >= INT3472_MAX_SENSOR_GPIOS ) {
88
+ dev_warn (int3472 -> dev , "Too many GPIOs mapped\n" );
89
+ return - EINVAL ;
90
+ }
91
+
92
+ ret = skl_int3472_fill_gpiod_lookup (& int3472 -> gpios .table [int3472 -> n_sensor_gpios ],
93
+ agpio , func , polarity );
94
+ if (ret )
95
+ return ret ;
96
+
85
97
int3472 -> n_sensor_gpios ++ ;
86
98
87
99
return 0 ;
0 commit comments