Source
14
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
15
* GNU General Public License for more details.
16
16
*/
17
17
18
18
#include <linux/device.h>
19
19
#include <linux/i2c.h>
20
20
#include <linux/i2c-smbus.h>
21
21
#include <linux/interrupt.h>
22
22
#include <linux/kernel.h>
23
23
#include <linux/module.h>
24
+
#include <linux/of_irq.h>
24
25
#include <linux/slab.h>
25
26
#include <linux/workqueue.h>
26
27
27
28
struct i2c_smbus_alert {
28
29
struct work_struct alert;
29
30
struct i2c_client *ara; /* Alert response address */
30
31
};
31
32
32
33
struct alert_data {
33
34
unsigned short addr;
132
133
struct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev);
133
134
struct i2c_smbus_alert *alert;
134
135
struct i2c_adapter *adapter = ara->adapter;
135
136
int res, irq;
136
137
137
138
alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert),
138
139
GFP_KERNEL);
139
140
if (!alert)
140
141
return -ENOMEM;
141
142
142
-
irq = setup->irq;
143
+
if (setup) {
144
+
irq = setup->irq;
145
+
} else {
146
+
irq = of_irq_get_byname(adapter->dev.of_node, "smbus_alert");
147
+
if (irq <= 0)
148
+
return irq;
149
+
}
150
+
143
151
INIT_WORK(&alert->alert, smbalert_work);
144
152
alert->ara = ara;
145
153
146
154
if (irq > 0) {
147
155
res = devm_request_threaded_irq(&ara->dev, irq,
148
156
NULL, smbus_alert,
149
157
IRQF_SHARED | IRQF_ONESHOT,
150
158
"smbus_alert", alert);
151
159
if (res)
152
160
return res;