ssp_iio_trigger.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2011, Samsung Electronics Co. Ltd. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #include "ssp.h"
  16. #include "../../staging/iio/iio.h"
  17. #include "../../staging/iio/sysfs.h"
  18. #include "../../staging/iio/trigger.h"
  19. /*
  20. * ssp_iio_data_rdy_trigger_set_state() set data ready interrupt state
  21. */
  22. static const struct iio_trigger_ops ssp_iio_trigger_ops = {
  23. .owner = THIS_MODULE,
  24. };
  25. int ssp_iio_probe_trigger(struct ssp_data *data, struct iio_dev *indio_dev, struct iio_trigger *trig)
  26. {
  27. int ret;
  28. trig = iio_allocate_trigger("%s-dev%d",
  29. indio_dev->name,
  30. indio_dev->id);
  31. if (trig == NULL)
  32. return -ENOMEM;
  33. trig->dev.parent = &data->client->dev;
  34. trig->private_data = indio_dev;
  35. trig->ops = &ssp_iio_trigger_ops;
  36. ret = iio_trigger_register(trig);
  37. if (ret) {
  38. iio_free_trigger(trig);
  39. return -EPERM;
  40. }
  41. indio_dev->trig = trig;
  42. return 0;
  43. }
  44. void ssp_iio_remove_trigger(struct iio_trigger *trig)
  45. {
  46. iio_trigger_unregister(trig);
  47. iio_free_trigger(trig);
  48. }