21
21
#include <linux/pm.h>
22
22
#include <linux/slab.h>
23
23
#include <linux/of.h>
24
+ #include <linux/irqdomain.h>
24
25
#include <uapi/linux/input.h>
25
26
#include <linux/rmi.h>
26
27
#include "rmi_bus.h"
@@ -127,28 +128,11 @@ static int rmi_driver_process_config_requests(struct rmi_device *rmi_dev)
127
128
return 0 ;
128
129
}
129
130
130
- static void process_one_interrupt (struct rmi_driver_data * data ,
131
- struct rmi_function * fn )
132
- {
133
- struct rmi_function_handler * fh ;
134
-
135
- if (!fn || !fn -> dev .driver )
136
- return ;
137
-
138
- fh = to_rmi_function_handler (fn -> dev .driver );
139
- if (fh -> attention ) {
140
- bitmap_and (data -> fn_irq_bits , data -> irq_status , fn -> irq_mask ,
141
- data -> irq_count );
142
- if (!bitmap_empty (data -> fn_irq_bits , data -> irq_count ))
143
- fh -> attention (fn , data -> fn_irq_bits );
144
- }
145
- }
146
-
147
131
static int rmi_process_interrupt_requests (struct rmi_device * rmi_dev )
148
132
{
149
133
struct rmi_driver_data * data = dev_get_drvdata (& rmi_dev -> dev );
150
134
struct device * dev = & rmi_dev -> dev ;
151
- struct rmi_function * entry ;
135
+ int i ;
152
136
int error ;
153
137
154
138
if (!data )
@@ -173,16 +157,8 @@ static int rmi_process_interrupt_requests(struct rmi_device *rmi_dev)
173
157
*/
174
158
mutex_unlock (& data -> irq_mutex );
175
159
176
- /*
177
- * It would be nice to be able to use irq_chip to handle these
178
- * nested IRQs. Unfortunately, most of the current customers for
179
- * this driver are using older kernels (3.0.x) that don't support
180
- * the features required for that. Once they've shifted to more
181
- * recent kernels (say, 3.3 and higher), this should be switched to
182
- * use irq_chip.
183
- */
184
- list_for_each_entry (entry , & data -> function_list , node )
185
- process_one_interrupt (data , entry );
160
+ for_each_set_bit (i , data -> irq_status , data -> irq_count )
161
+ handle_nested_irq (irq_find_mapping (data -> irqdomain , i ));
186
162
187
163
if (data -> input )
188
164
input_sync (data -> input );
@@ -1000,9 +976,13 @@ EXPORT_SYMBOL_GPL(rmi_driver_resume);
1000
976
static int rmi_driver_remove (struct device * dev )
1001
977
{
1002
978
struct rmi_device * rmi_dev = to_rmi_device (dev );
979
+ struct rmi_driver_data * data = dev_get_drvdata (& rmi_dev -> dev );
1003
980
1004
981
rmi_disable_irq (rmi_dev , false);
1005
982
983
+ irq_domain_remove (data -> irqdomain );
984
+ data -> irqdomain = NULL ;
985
+
1006
986
rmi_f34_remove_sysfs (rmi_dev );
1007
987
rmi_free_function_list (rmi_dev );
1008
988
@@ -1034,7 +1014,8 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1034
1014
{
1035
1015
struct rmi_device * rmi_dev = data -> rmi_dev ;
1036
1016
struct device * dev = & rmi_dev -> dev ;
1037
- int irq_count ;
1017
+ struct fwnode_handle * fwnode = rmi_dev -> xport -> dev -> fwnode ;
1018
+ int irq_count = 0 ;
1038
1019
size_t size ;
1039
1020
int retval ;
1040
1021
@@ -1045,7 +1026,6 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1045
1026
* being accessed.
1046
1027
*/
1047
1028
rmi_dbg (RMI_DEBUG_CORE , dev , "%s: Counting IRQs.\n" , __func__ );
1048
- irq_count = 0 ;
1049
1029
data -> bootloader_mode = false;
1050
1030
1051
1031
retval = rmi_scan_pdt (rmi_dev , & irq_count , rmi_count_irqs );
@@ -1057,6 +1037,15 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
1057
1037
if (data -> bootloader_mode )
1058
1038
dev_warn (dev , "Device in bootloader mode.\n" );
1059
1039
1040
+ /* Allocate and register a linear revmap irq_domain */
1041
+ data -> irqdomain = irq_domain_create_linear (fwnode , irq_count ,
1042
+ & irq_domain_simple_ops ,
1043
+ data );
1044
+ if (!data -> irqdomain ) {
1045
+ dev_err (& rmi_dev -> dev , "Failed to create IRQ domain\n" );
1046
+ return PTR_ERR (data -> irqdomain );
1047
+ }
1048
+
1060
1049
data -> irq_count = irq_count ;
1061
1050
data -> num_of_irq_regs = (data -> irq_count + 7 ) / 8 ;
1062
1051
@@ -1079,10 +1068,9 @@ int rmi_init_functions(struct rmi_driver_data *data)
1079
1068
{
1080
1069
struct rmi_device * rmi_dev = data -> rmi_dev ;
1081
1070
struct device * dev = & rmi_dev -> dev ;
1082
- int irq_count ;
1071
+ int irq_count = 0 ;
1083
1072
int retval ;
1084
1073
1085
- irq_count = 0 ;
1086
1074
rmi_dbg (RMI_DEBUG_CORE , dev , "%s: Creating functions.\n" , __func__ );
1087
1075
retval = rmi_scan_pdt (rmi_dev , & irq_count , rmi_create_function );
1088
1076
if (retval < 0 ) {
0 commit comments