int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev) { int ret; struct inv_mpu6050_state *st = iio_priv(indio_dev); st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (st->trig == NULL) { ret = -ENOMEM; goto error_ret; } ret = request_irq(st->client->irq, &iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING, "inv_mpu", st->trig); if (ret) goto error_free_trig; st->trig->dev.parent = &st->client->dev; st->trig->private_data = indio_dev; st->trig->ops = &inv_mpu_trigger_ops; ret = iio_trigger_register(st->trig); if (ret) goto error_free_irq; indio_dev->trig = st->trig; return 0; error_free_irq: free_irq(st->client->irq, st->trig); error_free_trig: iio_trigger_free(st->trig); error_ret: return ret; }
/** * adis_probe_trigger() - Sets up trigger for a adis device * @adis: The adis device * @indio_dev: The IIO device * * Returns 0 on success or a negative error code * * adis_remove_trigger() should be used to free the trigger. */ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) { int ret; adis->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (adis->trig == NULL) return -ENOMEM; ret = request_irq(adis->spi->irq, &iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING, indio_dev->name, adis->trig); if (ret) goto error_free_trig; adis->trig->dev.parent = &adis->spi->dev; adis->trig->ops = &adis_trigger_ops; iio_trigger_set_drvdata(adis->trig, adis); ret = iio_trigger_register(adis->trig); indio_dev->trig = adis->trig; if (ret) goto error_free_irq; return 0; error_free_irq: free_irq(adis->spi->irq, adis->trig); error_free_trig: iio_trigger_free(adis->trig); return ret; }
static int iio_sysfs_trigger_remove(int id) { bool foundit = false; struct iio_sysfs_trig *t; mutex_lock(&iio_sysfs_trig_list_mut); list_for_each_entry(t, &iio_sysfs_trig_list, l) if (id == t->id) { foundit = true; break; } if (!foundit) { mutex_unlock(&iio_sysfs_trig_list_mut); return -EINVAL; } iio_trigger_unregister(t->trig); iio_trigger_free(t->trig); list_del(&t->l); kfree(t); module_put(THIS_MODULE); mutex_unlock(&iio_sysfs_trig_list_mut); return 0; }
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, struct hid_sensor_common *attrb) { int ret; struct iio_trigger *trig; trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id); if (trig == NULL) { dev_err(&indio_dev->dev, "Trigger Allocate Failed\n"); ret = -ENOMEM; goto error_ret; } trig->dev.parent = indio_dev->dev.parent; iio_trigger_set_drvdata(trig, attrb); trig->ops = &hid_sensor_trigger_ops; ret = iio_trigger_register(trig); if (ret) { dev_err(&indio_dev->dev, "Trigger Register Failed\n"); goto error_free_trig; } indio_dev->trig = attrb->trigger = trig; return ret; error_free_trig: iio_trigger_free(trig); error_ret: return ret; }
static void yas_remove_trigger(struct iio_dev *indio_dev) { struct yas_state *st = iio_priv(indio_dev); iio_trigger_unregister(st->trig); iio_trigger_free(st->trig); iio_dealloc_pollfunc(indio_dev->pollfunc); }
void inv_ak09911_remove_trigger(struct iio_dev *indio_dev) { struct inv_ak09911_state_s *st = iio_priv(indio_dev); iio_trigger_unregister(st->trig); iio_trigger_free(st->trig); }
static int yas_probe_trigger(struct iio_dev *indio_dev) { int ret; struct yas_state *st = iio_priv(indio_dev); indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, &yas_trigger_handler, IRQF_ONESHOT, indio_dev, "%s_consumer%d", indio_dev->name, indio_dev->id); if (indio_dev->pollfunc == NULL) { ret = -ENOMEM; goto error_ret; } st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (!st->trig) { ret = -ENOMEM; goto error_dealloc_pollfunc; } st->trig->dev.parent = &st->client->dev; st->trig->ops = &yas_trigger_ops; iio_trigger_set_drvdata(st->trig, indio_dev); ret = iio_trigger_register(st->trig); if (ret) goto error_free_trig; return 0; error_free_trig: iio_trigger_free(st->trig); error_dealloc_pollfunc: iio_dealloc_pollfunc(indio_dev->pollfunc); error_ret: return ret; }
int inv_ak09911_probe_trigger(struct iio_dev *indio_dev) { int ret; struct inv_ak09911_state_s *st = iio_priv(indio_dev); st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (st->trig == NULL) { ret = -ENOMEM; goto error_ret; } /* select default trigger */ st->trig->dev.parent = &st->i2c->dev; //st->trig->private_data = indio_dev; st->trig->ops = &inv_ak09911_trigger_ops; ret = iio_trigger_register(st->trig); /* select default trigger */ indio_dev->trig = st->trig; if (ret) goto error_free_trig; return 0; error_free_trig: iio_trigger_free(st->trig); error_ret: return ret; }
int inv_mpu_probe_trigger(struct iio_dev *indio_dev) { int ret; struct inv_mpu_state *st = iio_priv(indio_dev); #ifdef INV_KERNEL_3_10 st->trig = iio_trigger_alloc("%s-dev%d", #else st->trig = iio_allocate_trigger("%s-dev%d", #endif indio_dev->name, indio_dev->id); if (st->trig == NULL) return -ENOMEM; st->trig->dev.parent = &st->client->dev; #ifndef INV_KERNEL_3_10 st->trig->private_data = indio_dev; #endif st->trig->ops = &inv_mpu_trigger_ops; ret = iio_trigger_register(st->trig); if (ret) { #ifdef INV_KERNEL_3_10 iio_trigger_free(st->trig); #else iio_free_trigger(st->trig); #endif return -EPERM; } indio_dev->trig = st->trig; return 0; }
void inv_mpu_remove_trigger(struct iio_dev *indio_dev) { struct inv_mpu_state *st = iio_priv(indio_dev); iio_trigger_unregister(st->trig); iio_trigger_free(st->trig); }
void st_sensors_deallocate_trigger(struct iio_dev *indio_dev) { struct st_sensor_data *sdata = iio_priv(indio_dev); iio_trigger_unregister(sdata->trig); free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); iio_trigger_free(sdata->trig); }
void inv_mpu_remove_trigger(struct iio_dev *indio_dev) { struct inv_mpu_state *st = iio_priv(indio_dev); iio_trigger_unregister(st->trig); #ifdef INV_KERNEL_3_10 iio_trigger_free(st->trig); #else iio_free_trigger(st->trig); #endif }
int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, struct hid_sensor_common *attrb) { int ret; struct iio_trigger *trig; trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id); if (trig == NULL) { dev_err(&indio_dev->dev, "Trigger Allocate Failed\n"); ret = -ENOMEM; goto error_ret; } trig->dev.parent = indio_dev->dev.parent; iio_trigger_set_drvdata(trig, attrb); trig->ops = &hid_sensor_trigger_ops; ret = iio_trigger_register(trig); if (ret) { dev_err(&indio_dev->dev, "Trigger Register Failed\n"); goto error_free_trig; } attrb->trigger = trig; indio_dev->trig = iio_trigger_get(trig); ret = pm_runtime_set_active(&indio_dev->dev); if (ret) goto error_unreg_trigger; iio_device_set_drvdata(indio_dev, attrb); pm_suspend_ignore_children(&attrb->pdev->dev, true); pm_runtime_enable(&attrb->pdev->dev); /* Default to 3 seconds, but can be changed from sysfs */ pm_runtime_set_autosuspend_delay(&attrb->pdev->dev, 3000); pm_runtime_use_autosuspend(&attrb->pdev->dev); return ret; error_unreg_trigger: iio_trigger_unregister(trig); error_free_trig: iio_trigger_free(trig); error_ret: return ret; }
int st_sensors_allocate_trigger(struct iio_dev *indio_dev, const struct iio_trigger_ops *trigger_ops) { int err; struct st_sensor_data *sdata = iio_priv(indio_dev); sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name); if (sdata->trig == NULL) { err = -ENOMEM; dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n"); goto iio_trigger_alloc_error; } err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev), iio_trigger_generic_data_rdy_poll, NULL, IRQF_TRIGGER_RISING, sdata->trig->name, sdata->trig); if (err) goto request_irq_error; iio_trigger_set_drvdata(sdata->trig, indio_dev); sdata->trig->ops = trigger_ops; sdata->trig->dev.parent = sdata->dev; err = iio_trigger_register(sdata->trig); if (err < 0) { dev_err(&indio_dev->dev, "failed to register iio trigger.\n"); goto iio_trigger_register_error; } indio_dev->trig = sdata->trig; return 0; iio_trigger_register_error: free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); request_irq_error: iio_trigger_free(sdata->trig); iio_trigger_alloc_error: return err; }
int inv_mpu_probe_trigger(struct iio_dev *indio_dev) { int ret; struct inv_mpu_state *st = iio_priv(indio_dev); st->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (st->trig == NULL) return -ENOMEM; st->trig->dev.parent = &st->client->dev; st->trig->ops = &inv_mpu_trigger_ops; ret = iio_trigger_register(st->trig); if (ret) { iio_trigger_free(st->trig); return -EPERM; } indio_dev->trig = st->trig; return 0; }
int ssp_iio_probe_trigger(struct ssp_data *data, struct iio_dev *indio_dev, struct iio_trigger *trig) { int ret; trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); if (trig == NULL) return -ENOMEM; trig->dev.parent = &data->client->dev; // trig->private_data = indio_dev; trig->ops = &ssp_iio_trigger_ops; ret = iio_trigger_register(trig); if (ret) { iio_trigger_free(trig); return -EPERM; } indio_dev->trig = trig; return 0; }
void ssp_iio_remove_trigger(struct iio_trigger *trig) { iio_trigger_unregister(trig); iio_trigger_free(trig); }
int st_sensors_allocate_trigger(struct iio_dev *indio_dev, const struct iio_trigger_ops *trigger_ops) { int err, irq; struct st_sensor_data *sdata = iio_priv(indio_dev); unsigned long irq_trig; sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name); if (sdata->trig == NULL) { dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n"); return -ENOMEM; } irq = sdata->get_irq_data_ready(indio_dev); irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq)); /* * If the IRQ is triggered on falling edge, we need to mark the * interrupt as active low, if the hardware supports this. */ if (irq_trig == IRQF_TRIGGER_FALLING) { if (!sdata->sensor_settings->drdy_irq.addr_ihl) { dev_err(&indio_dev->dev, "falling edge specified for IRQ but hardware " "only support rising edge, will request " "rising edge\n"); irq_trig = IRQF_TRIGGER_RISING; } else { /* Set up INT active low i.e. falling edge */ err = st_sensors_write_data_with_mask(indio_dev, sdata->sensor_settings->drdy_irq.addr_ihl, sdata->sensor_settings->drdy_irq.mask_ihl, 1); if (err < 0) goto iio_trigger_free; dev_info(&indio_dev->dev, "interrupts on the falling edge\n"); } } else if (irq_trig == IRQF_TRIGGER_RISING) { dev_info(&indio_dev->dev, "interrupts on the rising edge\n"); } else { dev_err(&indio_dev->dev, "unsupported IRQ trigger specified (%lx), only " "rising and falling edges supported, enforce " "rising edge\n", irq_trig); irq_trig = IRQF_TRIGGER_RISING; } /* * If the interrupt pin is Open Drain, by definition this * means that the interrupt line may be shared with other * peripherals. But to do this we also need to have a status * register and mask to figure out if this sensor was firing * the IRQ or not, so we can tell the interrupt handle that * it was "our" interrupt. */ if (sdata->int_pin_open_drain && sdata->sensor_settings->drdy_irq.addr_stat_drdy) irq_trig |= IRQF_SHARED; err = request_threaded_irq(irq, iio_trigger_generic_data_rdy_poll, NULL, irq_trig, sdata->trig->name, sdata->trig); if (err) { dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n"); goto iio_trigger_free; } iio_trigger_set_drvdata(sdata->trig, indio_dev); sdata->trig->ops = trigger_ops; sdata->trig->dev.parent = sdata->dev; err = iio_trigger_register(sdata->trig); if (err < 0) { dev_err(&indio_dev->dev, "failed to register iio trigger.\n"); goto iio_trigger_register_error; } indio_dev->trig = iio_trigger_get(sdata->trig); return 0; iio_trigger_register_error: free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); iio_trigger_free: iio_trigger_free(sdata->trig); return err; }
/** * adis_remove_trigger() - Remove trigger for a adis devices * @adis: The adis device * * Removes the trigger previously registered with adis_probe_trigger(). */ void adis_remove_trigger(struct adis *adis) { iio_trigger_unregister(adis->trig); free_irq(adis->spi->irq, adis->trig); iio_trigger_free(adis->trig); }
void hid_sensor_remove_trigger(struct iio_dev *indio_dev) { iio_trigger_unregister(indio_dev->trig); iio_trigger_free(indio_dev->trig); indio_dev->trig = NULL; }
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) { iio_trigger_unregister(attrb->trigger); iio_trigger_free(attrb->trigger); }
void inv_mpu6050_remove_trigger(struct inv_mpu6050_state *st) { iio_trigger_unregister(st->trig); free_irq(st->client->irq, st->trig); iio_trigger_free(st->trig); }
int st_sensors_allocate_trigger(struct iio_dev *indio_dev, const struct iio_trigger_ops *trigger_ops) { int err, irq; struct st_sensor_data *sdata = iio_priv(indio_dev); unsigned long irq_trig; sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name); if (sdata->trig == NULL) { dev_err(&indio_dev->dev, "failed to allocate iio trigger.\n"); return -ENOMEM; } irq = sdata->get_irq_data_ready(indio_dev); irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq)); /* * If the IRQ is triggered on falling edge, we need to mark the * interrupt as active low, if the hardware supports this. */ if (irq_trig == IRQF_TRIGGER_FALLING) { if (!sdata->sensor_settings->drdy_irq.addr_ihl) { dev_err(&indio_dev->dev, "falling edge specified for IRQ but hardware " "only support rising edge, will request " "rising edge\n"); irq_trig = IRQF_TRIGGER_RISING; } else { /* Set up INT active low i.e. falling edge */ err = st_sensors_write_data_with_mask(indio_dev, sdata->sensor_settings->drdy_irq.addr_ihl, sdata->sensor_settings->drdy_irq.mask_ihl, 1); if (err < 0) goto iio_trigger_free; dev_info(&indio_dev->dev, "interrupts on the falling edge\n"); } } else if (irq_trig == IRQF_TRIGGER_RISING) { dev_info(&indio_dev->dev, "interrupts on the rising edge\n"); } else { dev_err(&indio_dev->dev, "unsupported IRQ trigger specified (%lx), only " "rising and falling edges supported, enforce " "rising edge\n", irq_trig); irq_trig = IRQF_TRIGGER_RISING; } err = request_threaded_irq(irq, iio_trigger_generic_data_rdy_poll, NULL, irq_trig, sdata->trig->name, sdata->trig); if (err) { dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n"); goto iio_trigger_free; } iio_trigger_set_drvdata(sdata->trig, indio_dev); sdata->trig->ops = trigger_ops; sdata->trig->dev.parent = sdata->dev; err = iio_trigger_register(sdata->trig); if (err < 0) { dev_err(&indio_dev->dev, "failed to register iio trigger.\n"); goto iio_trigger_register_error; } indio_dev->trig = iio_trigger_get(sdata->trig); return 0; iio_trigger_register_error: free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); iio_trigger_free: iio_trigger_free(sdata->trig); return err; }