Lines Matching refs:data
52 static struct pmi_data *data;
59 spin_lock(&data->pmi_spinlock);
61 type = ioread8(data->pmi_reg + PMI_READ_TYPE);
64 if (type & PMI_ACK && !data->completion) {
70 if (data->completion && !(type & PMI_ACK)) {
76 data->msg.type = type;
77 data->msg.data0 = ioread8(data->pmi_reg + PMI_READ_DATA0);
78 data->msg.data1 = ioread8(data->pmi_reg + PMI_READ_DATA1);
79 data->msg.data2 = ioread8(data->pmi_reg + PMI_READ_DATA2);
82 spin_unlock(&data->pmi_spinlock);
89 if (data->msg.type & PMI_ACK) {
90 complete(data->completion);
95 schedule_work(&data->work);
115 spin_lock(&data->handler_spinlock);
116 list_for_each_entry(handler, &data->handler, node) {
118 if (handler->type == data->msg.type)
119 handler->handle_pmi_message(data->msg);
121 spin_unlock(&data->handler_spinlock);
130 if (data) {
136 data = kzalloc(sizeof(struct pmi_data), GFP_KERNEL);
137 if (!data) {
143 data->pmi_reg = of_iomap(np, 0);
144 if (!data->pmi_reg) {
150 INIT_LIST_HEAD(&data->handler);
152 mutex_init(&data->msg_mutex);
153 spin_lock_init(&data->pmi_spinlock);
154 spin_lock_init(&data->handler_spinlock);
156 INIT_WORK(&data->work, pmi_notify_handlers);
158 data->dev = dev;
160 data->irq = irq_of_parse_and_map(np, 0);
161 if (data->irq == NO_IRQ) {
167 rc = request_irq(data->irq, pmi_irq_handler, 0, "pmi", NULL);
170 data->irq, rc);
174 printk(KERN_INFO "pmi: found pmi device at addr %p.\n", data->pmi_reg);
179 iounmap(data->pmi_reg);
182 kfree(data);
192 free_irq(data->irq, NULL);
193 iounmap(data->pmi_reg);
195 spin_lock(&data->handler_spinlock);
197 list_for_each_entry_safe(handler, tmp, &data->handler, node)
200 spin_unlock(&data->handler_spinlock);
202 kfree(data);
203 data = NULL;
235 if (!data)
238 mutex_lock(&data->msg_mutex);
240 data->msg = msg;
243 data->completion = &completion;
245 spin_lock_irqsave(&data->pmi_spinlock, flags);
246 iowrite8(msg.data0, data->pmi_reg + PMI_WRITE_DATA0);
247 iowrite8(msg.data1, data->pmi_reg + PMI_WRITE_DATA1);
248 iowrite8(msg.data2, data->pmi_reg + PMI_WRITE_DATA2);
249 iowrite8(msg.type, data->pmi_reg + PMI_WRITE_TYPE);
250 spin_unlock_irqrestore(&data->pmi_spinlock, flags);
254 wait_for_completion_interruptible_timeout(data->completion,
257 data->completion = NULL;
259 mutex_unlock(&data->msg_mutex);
267 if (!data)
270 spin_lock(&data->handler_spinlock);
271 list_add_tail(&handler->node, &data->handler);
272 spin_unlock(&data->handler_spinlock);
280 if (!data)
285 spin_lock(&data->handler_spinlock);
287 spin_unlock(&data->handler_spinlock);