Lines Matching +full:irq +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * dell-smo8800.c - Dell Latitude ACPI SMO88XX freefall sensor driver
23 u32 irq; /* acpi device irq */ member
26 unsigned long misc_opened; /* whether the device is open */
28 struct device *dev; /* acpi device */
31 static irqreturn_t smo8800_interrupt_quick(int irq, void *data) in smo8800_interrupt_quick() argument
35 atomic_inc(&smo8800->counter); in smo8800_interrupt_quick()
36 wake_up_interruptible(&smo8800->misc_wait); in smo8800_interrupt_quick()
40 static irqreturn_t smo8800_interrupt_thread(int irq, void *data) in smo8800_interrupt_thread() argument
44 dev_info(smo8800->dev, "detected free fall\n"); in smo8800_interrupt_thread()
51 struct smo8800_device *smo8800 = container_of(file->private_data, in smo8800_misc_read()
59 return -EINVAL; in smo8800_misc_read()
61 atomic_set(&smo8800->counter, 0); in smo8800_misc_read()
62 retval = wait_event_interruptible(smo8800->misc_wait, in smo8800_misc_read()
63 (data = atomic_xchg(&smo8800->counter, 0))); in smo8800_misc_read()
73 retval = -EFAULT; in smo8800_misc_read()
80 struct smo8800_device *smo8800 = container_of(file->private_data, in smo8800_misc_open()
83 if (test_and_set_bit(0, &smo8800->misc_opened)) in smo8800_misc_open()
84 return -EBUSY; /* already open */ in smo8800_misc_open()
86 atomic_set(&smo8800->counter, 0); in smo8800_misc_open()
92 struct smo8800_device *smo8800 = container_of(file->private_data, in smo8800_misc_release()
95 clear_bit(0, &smo8800->misc_opened); /* release the device */ in smo8800_misc_release()
106 static int smo8800_probe(struct platform_device *device) in smo8800_probe() argument
111 smo8800 = devm_kzalloc(&device->dev, sizeof(*smo8800), GFP_KERNEL); in smo8800_probe()
113 dev_err(&device->dev, "failed to allocate device data\n"); in smo8800_probe()
114 return -ENOMEM; in smo8800_probe()
117 smo8800->dev = &device->dev; in smo8800_probe()
118 smo8800->miscdev.minor = MISC_DYNAMIC_MINOR; in smo8800_probe()
119 smo8800->miscdev.name = "freefall"; in smo8800_probe()
120 smo8800->miscdev.fops = &smo8800_misc_fops; in smo8800_probe()
122 init_waitqueue_head(&smo8800->misc_wait); in smo8800_probe()
124 err = misc_register(&smo8800->miscdev); in smo8800_probe()
126 dev_err(&device->dev, "failed to register misc dev: %d\n", err); in smo8800_probe()
130 platform_set_drvdata(device, smo8800); in smo8800_probe()
132 err = platform_get_irq(device, 0); in smo8800_probe()
135 smo8800->irq = err; in smo8800_probe()
137 err = request_threaded_irq(smo8800->irq, smo8800_interrupt_quick, in smo8800_probe()
142 dev_err(&device->dev, in smo8800_probe()
143 "failed to request thread for IRQ %d: %d\n", in smo8800_probe()
144 smo8800->irq, err); in smo8800_probe()
148 dev_dbg(&device->dev, "device /dev/freefall registered with IRQ %d\n", in smo8800_probe()
149 smo8800->irq); in smo8800_probe()
153 misc_deregister(&smo8800->miscdev); in smo8800_probe()
157 static void smo8800_remove(struct platform_device *device) in smo8800_remove() argument
159 struct smo8800_device *smo8800 = platform_get_drvdata(device); in smo8800_remove()
161 free_irq(smo8800->irq, smo8800); in smo8800_remove()
162 misc_deregister(&smo8800->miscdev); in smo8800_remove()
163 dev_dbg(&device->dev, "device /dev/freefall unregistered\n"); in smo8800_remove()
166 /* NOTE: Keep this list in sync with drivers/i2c/busses/i2c-i801.c */