siox.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2015-2017 Pengutronix, Uwe Kleine-König <kernel@pengutronix.de>
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/kthread.h>
  7. #include <linux/siox.h>
  8. #define to_siox_master(_dev) container_of((_dev), struct siox_master, dev)
  9. struct siox_master {
  10. /* these fields should be initialized by the driver */
  11. int busno;
  12. int (*pushpull)(struct siox_master *smaster,
  13. size_t setbuf_len, const u8 setbuf[],
  14. size_t getbuf_len, u8 getbuf[]);
  15. /* might be initialized by the driver, if 0 it is set to HZ / 40 */
  16. unsigned long poll_interval; /* in jiffies */
  17. /* framework private stuff */
  18. struct mutex lock;
  19. bool active;
  20. struct module *owner;
  21. struct device dev;
  22. unsigned int num_devices;
  23. struct list_head devices;
  24. size_t setbuf_len, getbuf_len;
  25. size_t buf_len;
  26. u8 *buf;
  27. u8 status;
  28. unsigned long last_poll;
  29. struct task_struct *poll_thread;
  30. };
  31. static inline void *siox_master_get_devdata(struct siox_master *smaster)
  32. {
  33. return dev_get_drvdata(&smaster->dev);
  34. }
  35. struct siox_master *siox_master_alloc(struct device *dev, size_t size);
  36. static inline void siox_master_put(struct siox_master *smaster)
  37. {
  38. put_device(&smaster->dev);
  39. }
  40. int siox_master_register(struct siox_master *smaster);
  41. void siox_master_unregister(struct siox_master *smaster);