drivers/w1/w1_io.c
Source file repositories/reference/linux-study-clean/drivers/w1/w1_io.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/w1/w1_io.c- Extension
.c- Size
- 11841 bytes
- Lines
- 450
- Domain
- Driver Families
- Bucket
- drivers/w1
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/io.hlinux/delay.hlinux/moduleparam.hlinux/module.hw1_internal.h
Detected Declarations
function w1_delayfunction w1_touch_bitfunction w1_write_bitfunction w1_pre_writefunction w1_post_writefunction w1_write_8function w1_read_bitfunction w1_tripletfunction w1_read_8function w1_write_blockfunction w1_touch_blockfunction w1_read_blockfunction w1_reset_busfunction w1_calc_crc8function w1_search_devicesfunction w1_reset_select_slavefunction w1_reset_resume_commandfunction w1_next_pullupexport w1_touch_bitexport w1_write_8export w1_tripletexport w1_read_8export w1_write_blockexport w1_touch_blockexport w1_read_blockexport w1_reset_busexport w1_calc_crc8export w1_reset_select_slaveexport w1_reset_resume_commandexport w1_next_pullup
Annotated Snippet
if (!id_bit && !comp_bit) {
/* Both bits are valid, take the direction given */
retval = bdir ? 0x04 : 0;
} else {
/* Only one bit is valid, take that direction */
bdir = id_bit;
retval = id_bit ? 0x05 : 0x02;
}
if (dev->bus_master->touch_bit)
w1_touch_bit(dev, bdir);
else
w1_write_bit(dev, bdir);
return retval;
}
}
EXPORT_SYMBOL_GPL(w1_triplet);
/**
* w1_read_8() - Reads 8 bits.
* @dev: the master device
*
* Return: the byte read
*/
u8 w1_read_8(struct w1_master *dev)
{
int i;
u8 res = 0;
if (dev->bus_master->read_byte)
res = dev->bus_master->read_byte(dev->bus_master->data);
else
for (i = 0; i < 8; ++i)
res |= (w1_touch_bit(dev,1) << i);
return res;
}
EXPORT_SYMBOL_GPL(w1_read_8);
/**
* w1_write_block() - Writes a series of bytes.
* @dev: the master device
* @buf: pointer to the data to write
* @len: the number of bytes to write
*/
void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
{
int i;
if (dev->bus_master->write_block) {
w1_pre_write(dev);
dev->bus_master->write_block(dev->bus_master->data, buf, len);
}
else
for (i = 0; i < len; ++i)
w1_write_8(dev, buf[i]); /* calls w1_pre_write */
w1_post_write(dev);
}
EXPORT_SYMBOL_GPL(w1_write_block);
/**
* w1_touch_block() - Touches a series of bytes.
* @dev: the master device
* @buf: pointer to the data to write
* @len: the number of bytes to write
*/
void w1_touch_block(struct w1_master *dev, u8 *buf, int len)
{
int i, j;
u8 tmp;
for (i = 0; i < len; ++i) {
tmp = 0;
for (j = 0; j < 8; ++j) {
if (j == 7)
w1_pre_write(dev);
tmp |= w1_touch_bit(dev, (buf[i] >> j) & 0x1) << j;
}
buf[i] = tmp;
}
}
EXPORT_SYMBOL_GPL(w1_touch_block);
/**
* w1_read_block() - Reads a series of bytes.
* @dev: the master device
* @buf: pointer to the buffer to fill
* @len: the number of bytes to read
* Return: the number of bytes read
Annotation
- Immediate include surface: `asm/io.h`, `linux/delay.h`, `linux/moduleparam.h`, `linux/module.h`, `w1_internal.h`.
- Detected declarations: `function w1_delay`, `function w1_touch_bit`, `function w1_write_bit`, `function w1_pre_write`, `function w1_post_write`, `function w1_write_8`, `function w1_read_bit`, `function w1_triplet`, `function w1_read_8`, `function w1_write_block`.
- Atlas domain: Driver Families / drivers/w1.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.