static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) { struct iio_bfin_timer_trigger_pdata *pdata = pdev->dev.platform_data; struct bfin_tmr_state *st; unsigned int config; int ret; st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL); if (st == NULL) return -ENOMEM; st->irq = platform_get_irq(pdev, 0); if (!st->irq) { dev_err(&pdev->dev, "No IRQs specified"); return -ENODEV; } ret = iio_bfin_tmr_get_number(st->irq); if (ret < 0) return ret; st->timer_num = ret; st->t = &iio_bfin_timer_code[st->timer_num]; st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num); if (!st->trig) return -ENOMEM; st->trig->ops = &iio_bfin_tmr_trigger_ops; st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups; iio_trigger_set_drvdata(st->trig, st); ret = iio_trigger_register(st->trig); if (ret) goto out; ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr, 0, st->trig->name, st); if (ret) { dev_err(&pdev->dev, "request IRQ-%d failed", st->irq); goto out1; } config = PWM_OUT | PERIOD_CNT | IRQ_ENA; if (pdata && pdata->output_enable) { unsigned long long val; st->output_enable = true; ret = peripheral_request(st->t->pin, st->trig->name); if (ret) goto out_free_irq; val = (unsigned long long)get_sclk() * pdata->duty_ns; do_div(val, NSEC_PER_SEC); st->duty = val; /** * The interrupt will be generated at the end of the period, * since we want the interrupt to be generated at end of the * pulse we invert both polarity and duty cycle, so that the * pulse will be generated directly before the interrupt. */ if (pdata->active_low) config |= PULSE_HI; } else { st->duty = 1; config |= OUT_DIS; } set_gptimer_config(st->t->id, config); dev_info(&pdev->dev, "iio trigger Blackfin TMR%d, IRQ-%d", st->timer_num, st->irq); platform_set_drvdata(pdev, st); return 0; out_free_irq: free_irq(st->irq, st); out1: iio_trigger_unregister(st->trig); out: iio_trigger_put(st->trig); return ret; }
void inv_mpu60x0_remove_trigger(struct inv_mpu60x0_state *st) { iio_trigger_unregister(st->trig); free_irq(st->client->irq, st->trig); iio_trigger_free(st->trig); }
static int optical_common_probe(struct iio_dev *indio_dev) { int err = 0; struct optical_data *adata = iio_priv(indio_dev); printk (KERN_ALERT "[%s]\n", __FUNCTION__); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &optical_info; #ifdef OPTICAL_SENSOR_DEBUG init_waitqueue_head(&proxWait); init_waitqueue_head(&lightWait); init_waitqueue_head(&hrWait); #endif err = optical_check_device_support(indio_dev, ARRAY_SIZE(optical_sensors), optical_sensors); if (err < 0) { goto st_press_common_probe_error; } adata->multiread_bit = adata->sensor->multi_read_bit; indio_dev->channels = adata->sensor->ch; indio_dev->num_channels = 2; err = optical_init_sensor(indio_dev); if (err < 0) { goto st_press_common_probe_error; } if (adata->get_irq_data_ready(indio_dev) > 0) { err = optical_allocate_ring(indio_dev); if (err < 0) { printk("vunggv error optical_allocate_ring-------"); goto st_press_common_probe_error; } err = optical_allocate_trigger(indio_dev,&optical_trigger_ops); if (err < 0) { printk("vunggv error optical_allocate_trigger------"); goto st_press_probe_trigger_error; } } err = iio_device_register(indio_dev); if (err) { printk("vunggv error iio_device_register------"); goto st_press_device_register_error; } err = iio_ring_buffer_register_ex(indio_dev->ring, 0, indio_dev->channels, indio_dev->num_channels); if (err) { printk("vunggv error iio_ring_register------"); goto st_press_device_register_error; } printk (KERN_ALERT "[%s OK]\n", __FUNCTION__); #ifdef OPTICAL_SENSOR_DEBUG optical_set_enable(indio_dev, true); #endif return err; st_press_device_register_error: if (adata->get_irq_data_ready(indio_dev) > 0) { // st_sensors_deallocate_trigger(indio_dev); //cho nay VungGV //Vung them iio_trigger_unregister(adata->trig); free_irq(adata->get_irq_data_ready(indio_dev), adata->trig); iio_free_trigger(adata->trig); } st_press_probe_trigger_error: if (adata->get_irq_data_ready(indio_dev) > 0) { optical_deallocate_ring(indio_dev); } st_press_common_probe_error: return err; }
static void mma8452_trigger_cleanup(struct iio_dev *indio_dev) { if (indio_dev->trig) iio_trigger_unregister(indio_dev->trig); }
static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev) { struct bfin_tmr_state *st; int ret; st = kzalloc(sizeof(*st), GFP_KERNEL); if (st == NULL) { ret = -ENOMEM; goto out; } st->irq = platform_get_irq(pdev, 0); if (!st->irq) { dev_err(&pdev->dev, "No IRQs specified"); ret = -ENODEV; goto out1; } ret = iio_bfin_tmr_get_number(st->irq); if (ret < 0) goto out1; st->timer_num = ret; st->t = &iio_bfin_timer_code[st->timer_num]; st->trig = iio_allocate_trigger("bfintmr%d", st->timer_num); if (!st->trig) { ret = -ENOMEM; goto out1; } st->trig->private_data = st; st->trig->ops = &iio_bfin_tmr_trigger_ops; st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups; ret = iio_trigger_register(st->trig); if (ret) goto out2; ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr, 0, st->trig->name, st); if (ret) { dev_err(&pdev->dev, "request IRQ-%d failed", st->irq); goto out4; } set_gptimer_config(st->t->id, OUT_DIS | PWM_OUT | PERIOD_CNT | IRQ_ENA); dev_info(&pdev->dev, "iio trigger Blackfin TMR%d, IRQ-%d", st->timer_num, st->irq); platform_set_drvdata(pdev, st); return 0; out4: iio_trigger_unregister(st->trig); out2: iio_put_trigger(st->trig); out1: kfree(st); out: return ret; }
void ssp_iio_remove_trigger(struct iio_trigger *trig) { iio_trigger_unregister(trig); iio_trigger_free(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 inv_mpu_remove_trigger(struct iio_dev *indio_dev) { struct inv_mpu_iio_s *st = iio_priv(indio_dev); iio_trigger_unregister(st->trig); iio_free_trigger(st->trig); }
void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) { iio_trigger_unregister(attrb->trigger); iio_trigger_free(attrb->trigger); }