include/linux/w1.h

Source file repositories/reference/linux-study-clean/include/linux/w1.h

File Facts

System
Linux kernel
Corpus path
include/linux/w1.h
Extension
.h
Size
9141 bytes
Lines
326
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct device_driver	*driver;
	struct device		dev;

	struct w1_bus_master	*bus_master;

	u32			seq;
};

int w1_add_master_device(struct w1_bus_master *master);
void w1_remove_master_device(struct w1_bus_master *master);

/**
 * struct w1_family_ops - operations for a family type
 * @add_slave: add_slave
 * @remove_slave: remove_slave
 * @groups: sysfs group
 * @chip_info: pointer to struct hwmon_chip_info
 */
struct w1_family_ops {
	int  (*add_slave)(struct w1_slave *sl);
	void (*remove_slave)(struct w1_slave *sl);
	const struct attribute_group **groups;
	const struct hwmon_chip_info *chip_info;
};

/**
 * struct w1_family - reference counted family structure.
 * @family_entry:	family linked list
 * @fid:		8 bit family identifier
 * @fops:		operations for this family
 * @of_match_table: open firmware match table
 * @refcnt:		reference counter
 */
struct w1_family {
	struct list_head	family_entry;
	u8			fid;

	const struct w1_family_ops *fops;

	const struct of_device_id *of_match_table;

	atomic_t		refcnt;
};

int w1_register_family(struct w1_family *family);
void w1_unregister_family(struct w1_family *family);

/**
 * module_w1_family() - Helper macro for registering a 1-Wire families
 * @__w1_family: w1_family struct
 *
 * Helper macro for 1-Wire families which do not do anything special in module
 * init/exit. This eliminates a lot of boilerplate. Each module may only
 * use this macro once, and calling it replaces module_init() and module_exit()
 */
#define module_w1_family(__w1_family) \
	module_driver(__w1_family, w1_register_family, \
			w1_unregister_family)

u8 w1_triplet(struct w1_master *dev, int bdir);
u8 w1_touch_bit(struct w1_master *dev, int bit);
void w1_write_8(struct w1_master *, u8);
u8 w1_read_8(struct w1_master *);
int w1_reset_bus(struct w1_master *);
u8 w1_calc_crc8(u8 *, int);
void w1_write_block(struct w1_master *, const u8 *, int);
void w1_touch_block(struct w1_master *, u8 *, int);
u8 w1_read_block(struct w1_master *, u8 *, int);
int w1_reset_select_slave(struct w1_slave *sl);
int w1_reset_resume_command(struct w1_master *);
void w1_next_pullup(struct w1_master *, int);

static inline struct w1_slave* dev_to_w1_slave(struct device *dev)
{
	return container_of(dev, struct w1_slave, dev);
}

static inline struct w1_slave* kobj_to_w1_slave(struct kobject *kobj)
{
	return dev_to_w1_slave(container_of(kobj, struct device, kobj));
}

static inline struct w1_master* dev_to_w1_master(struct device *dev)
{
	return container_of(dev, struct w1_master, dev);
}

#endif /* __KERNEL__ */

#endif /* __LINUX_W1_H */

Annotation

Implementation Notes