drivers/w1/slaves/w1_ds2430.c
Source file repositories/reference/linux-study-clean/drivers/w1/slaves/w1_ds2430.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/w1/slaves/w1_ds2430.c- Extension
.c- Size
- 6953 bytes
- Lines
- 296
- Domain
- Driver Families
- Bucket
- drivers/w1
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/moduleparam.hlinux/device.hlinux/types.hlinux/delay.hlinux/w1.h
Detected Declarations
function Copyrightfunction w1_f14_readblockfunction eeprom_readfunction w1_f14_writefunction eeprom_write
Annotated Snippet
if (len < W1_F14_SCRATCH_SIZE || addr & W1_F14_SCRATCH_MASK) {
char tmp[W1_F14_SCRATCH_SIZE];
/* read the block and update the parts to be written */
if (w1_f14_readblock(sl, addr & ~W1_F14_SCRATCH_MASK,
W1_F14_SCRATCH_SIZE, tmp)) {
count = -EIO;
goto out_up;
}
/* copy at most to the boundary of the PAGE or len */
copy = W1_F14_SCRATCH_SIZE -
(addr & W1_F14_SCRATCH_MASK);
if (copy > len)
copy = len;
memcpy(&tmp[addr & W1_F14_SCRATCH_MASK], buf, copy);
if (w1_f14_write(sl, addr & ~W1_F14_SCRATCH_MASK,
W1_F14_SCRATCH_SIZE, tmp) < 0) {
count = -EIO;
goto out_up;
}
} else {
copy = W1_F14_SCRATCH_SIZE;
if (w1_f14_write(sl, addr, copy, buf) < 0) {
count = -EIO;
goto out_up;
}
}
buf += copy;
addr += copy;
len -= copy;
}
out_up:
mutex_unlock(&sl->master->bus_mutex);
return count;
}
static const BIN_ATTR_RW(eeprom, W1_F14_EEPROM_SIZE);
static const struct bin_attribute *const w1_f14_bin_attrs[] = {
&bin_attr_eeprom,
NULL,
};
static const struct attribute_group w1_f14_group = {
.bin_attrs = w1_f14_bin_attrs,
};
static const struct attribute_group *w1_f14_groups[] = {
&w1_f14_group,
NULL,
};
static const struct w1_family_ops w1_f14_fops = {
.groups = w1_f14_groups,
};
static struct w1_family w1_family_14 = {
.fid = W1_EEPROM_DS2430,
.fops = &w1_f14_fops,
};
module_w1_family(w1_family_14);
MODULE_AUTHOR("Angelo Dureghello <angelo.dureghello@timesys.com>");
MODULE_DESCRIPTION("w1 family 14 driver for DS2430, 256b EEPROM");
MODULE_LICENSE("GPL");
MODULE_ALIAS("w1-family-" __stringify(W1_EEPROM_DS2430));
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/device.h`, `linux/types.h`, `linux/delay.h`, `linux/w1.h`.
- Detected declarations: `function Copyright`, `function w1_f14_readblock`, `function eeprom_read`, `function w1_f14_write`, `function eeprom_write`.
- Atlas domain: Driver Families / drivers/w1.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.