--- zzzz-none-000/linux-3.10.107/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c 2021-02-04 17:41:59.000000000 +0000 @@ -116,40 +116,35 @@ 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); + st->trig = devm_iio_trigger_alloc(&indio_dev->dev, + "%s-dev%d", + indio_dev->name, + indio_dev->id); + if (!st->trig) + return -ENOMEM; + + ret = devm_request_irq(&indio_dev->dev, st->client->irq, + &iio_trigger_generic_data_rdy_poll, + IRQF_TRIGGER_RISING, + "inv_mpu", + st->trig); if (ret) - goto error_free_trig; + return ret; + st->trig->dev.parent = &st->client->dev; st->trig->ops = &inv_mpu_trigger_ops; iio_trigger_set_drvdata(st->trig, indio_dev); + ret = iio_trigger_register(st->trig); if (ret) - goto error_free_irq; + return ret; + indio_dev->trig = iio_trigger_get(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; } 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); }