drivers/rtc/rtc-ds1343.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-ds1343.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-ds1343.c- Extension
.c- Size
- 11313 bytes
- Lines
- 478
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/module.hlinux/interrupt.hlinux/device.hlinux/spi/spi.hlinux/regmap.hlinux/rtc.hlinux/bcd.hlinux/pm.hlinux/pm_wakeirq.hlinux/slab.h
Detected Declarations
struct ds1343_privfunction ds1343_show_glitchfilterfunction ds1343_store_glitchfilterfunction ds1343_nvram_writefunction ds1343_nvram_readfunction ds1343_show_tricklechargerfunction ds1343_read_timefunction ds1343_set_timefunction ds1343_read_alarmfunction ds1343_set_alarmfunction ds1343_alarm_irq_enablefunction ds1343_threadfunction ds1343_probefunction ds1343_suspendfunction ds1343_resume
Annotated Snippet
struct ds1343_priv {
struct rtc_device *rtc;
struct regmap *map;
int irq;
};
static ssize_t ds1343_show_glitchfilter(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int glitch_filt_status, data;
int res;
res = regmap_read(priv->map, DS1343_CONTROL_REG, &data);
if (res)
return res;
glitch_filt_status = !!(data & DS1343_EGFIL);
if (glitch_filt_status)
return sprintf(buf, "enabled\n");
else
return sprintf(buf, "disabled\n");
}
static ssize_t ds1343_store_glitchfilter(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int data = 0;
int res;
if (strncmp(buf, "enabled", 7) == 0)
data = DS1343_EGFIL;
else if (strncmp(buf, "disabled", 8))
return -EINVAL;
res = regmap_update_bits(priv->map, DS1343_CONTROL_REG,
DS1343_EGFIL, data);
if (res)
return res;
return count;
}
static DEVICE_ATTR(glitch_filter, S_IRUGO | S_IWUSR, ds1343_show_glitchfilter,
ds1343_store_glitchfilter);
static int ds1343_nvram_write(void *priv, unsigned int off, void *val,
size_t bytes)
{
struct ds1343_priv *ds1343 = priv;
return regmap_bulk_write(ds1343->map, DS1343_NVRAM + off, val, bytes);
}
static int ds1343_nvram_read(void *priv, unsigned int off, void *val,
size_t bytes)
{
struct ds1343_priv *ds1343 = priv;
return regmap_bulk_read(ds1343->map, DS1343_NVRAM + off, val, bytes);
}
static ssize_t ds1343_show_tricklecharger(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
int res, data;
char *diodes = "disabled", *resistors = " ";
res = regmap_read(priv->map, DS1343_TRICKLE_REG, &data);
if (res)
return res;
if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) {
switch (data & 0x0c) {
case DS1343_TRICKLE_DS1:
diodes = "one diode,";
break;
default:
diodes = "no diode,";
break;
}
switch (data & 0x03) {
case DS1343_TRICKLE_1K:
resistors = "1k Ohm";
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/interrupt.h`, `linux/device.h`, `linux/spi/spi.h`, `linux/regmap.h`, `linux/rtc.h`, `linux/bcd.h`.
- Detected declarations: `struct ds1343_priv`, `function ds1343_show_glitchfilter`, `function ds1343_store_glitchfilter`, `function ds1343_nvram_write`, `function ds1343_nvram_read`, `function ds1343_show_tricklecharger`, `function ds1343_read_time`, `function ds1343_set_time`, `function ds1343_read_alarm`, `function ds1343_set_alarm`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.