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