industrialio-trigger.c (171a70afbde9a3e7499d7d3efde8ca49f7e5f00d) | industrialio-trigger.c (6eaf9f6a2738789dedb1e962096f61aaddd81464) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* The industrial I/O core, trigger handling functions 3 * 4 * Copyright (c) 2008 Jonathan Cameron 5 */ 6 7#include <linux/kernel.h> 8#include <linux/idr.h> 9#include <linux/err.h> 10#include <linux/device.h> 11#include <linux/interrupt.h> 12#include <linux/list.h> 13#include <linux/slab.h> 14 15#include <linux/iio/iio.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* The industrial I/O core, trigger handling functions 3 * 4 * Copyright (c) 2008 Jonathan Cameron 5 */ 6 7#include <linux/kernel.h> 8#include <linux/idr.h> 9#include <linux/err.h> 10#include <linux/device.h> 11#include <linux/interrupt.h> 12#include <linux/list.h> 13#include <linux/slab.h> 14 15#include <linux/iio/iio.h> |
16#include <linux/iio/iio-opaque.h> |
|
16#include <linux/iio/trigger.h> 17#include "iio_core.h" 18#include "iio_core_trigger.h" 19#include <linux/iio/trigger_consumer.h> 20 21/* RFC - Question of approach 22 * Make the common case (single sensor single trigger) 23 * simple by starting trigger capture from when first sensors --- 211 unchanged lines hidden (view full) --- 235 * triggering device. 236 * This is not currently handled. Alternative of not enabling trigger unless 237 * the relevant function is in there may be the best option. 238 */ 239/* Worth protecting against double additions? */ 240int iio_trigger_attach_poll_func(struct iio_trigger *trig, 241 struct iio_poll_func *pf) 242{ | 17#include <linux/iio/trigger.h> 18#include "iio_core.h" 19#include "iio_core_trigger.h" 20#include <linux/iio/trigger_consumer.h> 21 22/* RFC - Question of approach 23 * Make the common case (single sensor single trigger) 24 * simple by starting trigger capture from when first sensors --- 211 unchanged lines hidden (view full) --- 236 * triggering device. 237 * This is not currently handled. Alternative of not enabling trigger unless 238 * the relevant function is in there may be the best option. 239 */ 240/* Worth protecting against double additions? */ 241int iio_trigger_attach_poll_func(struct iio_trigger *trig, 242 struct iio_poll_func *pf) 243{ |
244 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev); |
|
243 bool notinuse = 244 bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 245 int ret = 0; 246 247 /* Prevent the module from being removed whilst attached to a trigger */ | 245 bool notinuse = 246 bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 247 int ret = 0; 248 249 /* Prevent the module from being removed whilst attached to a trigger */ |
248 __module_get(pf->indio_dev->driver_module); | 250 __module_get(iio_dev_opaque->driver_module); |
249 250 /* Get irq number */ 251 pf->irq = iio_trigger_get_irq(trig); 252 if (pf->irq < 0) { 253 pr_err("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n", 254 trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 255 goto out_put_module; 256 } --- 22 unchanged lines hidden (view full) --- 279 280 return ret; 281 282out_free_irq: 283 free_irq(pf->irq, pf); 284out_put_irq: 285 iio_trigger_put_irq(trig, pf->irq); 286out_put_module: | 251 252 /* Get irq number */ 253 pf->irq = iio_trigger_get_irq(trig); 254 if (pf->irq < 0) { 255 pr_err("Could not find an available irq for trigger %s, CONFIG_IIO_CONSUMERS_PER_TRIGGER=%d limit might be exceeded\n", 256 trig->name, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 257 goto out_put_module; 258 } --- 22 unchanged lines hidden (view full) --- 281 282 return ret; 283 284out_free_irq: 285 free_irq(pf->irq, pf); 286out_put_irq: 287 iio_trigger_put_irq(trig, pf->irq); 288out_put_module: |
287 module_put(pf->indio_dev->driver_module); | 289 module_put(iio_dev_opaque->driver_module); |
288 return ret; 289} 290 291int iio_trigger_detach_poll_func(struct iio_trigger *trig, 292 struct iio_poll_func *pf) 293{ | 290 return ret; 291} 292 293int iio_trigger_detach_poll_func(struct iio_trigger *trig, 294 struct iio_poll_func *pf) 295{ |
296 struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev); |
|
294 bool no_other_users = 295 bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; 296 int ret = 0; 297 298 if (trig->ops && trig->ops->set_trigger_state && no_other_users) { 299 ret = trig->ops->set_trigger_state(trig, false); 300 if (ret) 301 return ret; 302 } 303 if (pf->indio_dev->dev.parent == trig->dev.parent) 304 trig->attached_own_device = false; 305 iio_trigger_put_irq(trig, pf->irq); 306 free_irq(pf->irq, pf); | 297 bool no_other_users = 298 bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; 299 int ret = 0; 300 301 if (trig->ops && trig->ops->set_trigger_state && no_other_users) { 302 ret = trig->ops->set_trigger_state(trig, false); 303 if (ret) 304 return ret; 305 } 306 if (pf->indio_dev->dev.parent == trig->dev.parent) 307 trig->attached_own_device = false; 308 iio_trigger_put_irq(trig, pf->irq); 309 free_irq(pf->irq, pf); |
307 module_put(pf->indio_dev->driver_module); | 310 module_put(iio_dev_opaque->driver_module); |
308 309 return ret; 310} 311 312irqreturn_t iio_pollfunc_store_time(int irq, void *p) 313{ 314 struct iio_poll_func *pf = p; 315 --- 393 unchanged lines hidden --- | 311 312 return ret; 313} 314 315irqreturn_t iio_pollfunc_store_time(int irq, void *p) 316{ 317 struct iio_poll_func *pf = p; 318 --- 393 unchanged lines hidden --- |