w1_internal.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2004 Evgeniy Polyakov <zbr@ioremap.net>
  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. #ifndef __W1_H
  15. #define __W1_H
  16. #include <linux/w1.h>
  17. #include <linux/completion.h>
  18. #include <linux/mutex.h>
  19. #define W1_SLAVE_ACTIVE 0
  20. #define W1_SLAVE_DETACH 1
  21. /**
  22. * struct w1_async_cmd - execute callback from the w1_process kthread
  23. * @async_entry: link entry
  24. * @cb: callback function, must list_del and destroy this list before
  25. * returning
  26. *
  27. * When inserted into the w1_master async_list, w1_process will execute
  28. * the callback. Embed this into the structure with the command details.
  29. */
  30. struct w1_async_cmd {
  31. struct list_head async_entry;
  32. void (*cb)(struct w1_master *dev, struct w1_async_cmd *async_cmd);
  33. };
  34. int w1_create_master_attributes(struct w1_master *master);
  35. void w1_destroy_master_attributes(struct w1_master *master);
  36. void w1_search(struct w1_master *dev, u8 search_type,
  37. w1_slave_found_callback cb);
  38. void w1_search_devices(struct w1_master *dev, u8 search_type,
  39. w1_slave_found_callback cb);
  40. /* call w1_unref_slave to release the reference counts w1_search_slave added */
  41. struct w1_slave *w1_search_slave(struct w1_reg_num *id);
  42. /*
  43. * decrements the reference on sl->master and sl, and cleans up if zero
  44. * returns the reference count after it has been decremented
  45. */
  46. int w1_unref_slave(struct w1_slave *sl);
  47. void w1_slave_found(struct w1_master *dev, u64 rn);
  48. void w1_search_process_cb(struct w1_master *dev, u8 search_type,
  49. w1_slave_found_callback cb);
  50. struct w1_slave *w1_slave_search_device(struct w1_master *dev,
  51. struct w1_reg_num *rn);
  52. struct w1_master *w1_search_master_id(u32 id);
  53. /* Disconnect and reconnect devices in the given family. Used for finding
  54. * unclaimed devices after a family has been registered or releasing devices
  55. * after a family has been unregistered. Set attach to 1 when a new family
  56. * has just been registered, to 0 when it has been unregistered.
  57. */
  58. void w1_reconnect_slaves(struct w1_family *f, int attach);
  59. int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn);
  60. /* 0 success, otherwise EBUSY */
  61. int w1_slave_detach(struct w1_slave *sl);
  62. void __w1_remove_master_device(struct w1_master *dev);
  63. void w1_family_put(struct w1_family *f);
  64. void __w1_family_get(struct w1_family *f);
  65. struct w1_family *w1_family_registered(u8 fid);
  66. extern struct device_driver w1_master_driver;
  67. extern struct device w1_master_device;
  68. extern int w1_max_slave_count;
  69. extern int w1_max_slave_ttl;
  70. extern struct list_head w1_masters;
  71. extern struct mutex w1_mlock;
  72. extern spinlock_t w1_flock;
  73. int w1_process_callbacks(struct w1_master *dev);
  74. int w1_process(void *data);
  75. #endif /* __W1_H */