drivers/auxdisplay/max6959.c
Source file repositories/reference/linux-study-clean/drivers/auxdisplay/max6959.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/auxdisplay/max6959.c- Extension
.c- Size
- 4843 bytes
- Lines
- 192
- Domain
- Driver Families
- Bucket
- drivers/auxdisplay
- 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.
- 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/array_size.hlinux/bitrev.hlinux/bits.hlinux/container_of.hlinux/device/devres.hlinux/err.hlinux/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/regmap.hlinux/types.hlinux/workqueue.hlinux/map_to_7segment.hline-display.h
Detected Declarations
struct max6959_privfunction max6959_disp_updatefunction max6959_linedisp_get_map_typefunction max6959_linedisp_updatefunction max6959_enablefunction max6959_power_offfunction max6959_power_onfunction max6959_i2c_probefunction max6959_i2c_removefunction max6959_suspendfunction max6959_resume
Annotated Snippet
struct max6959_priv {
struct linedisp linedisp;
struct delayed_work work;
struct regmap *regmap;
};
static void max6959_disp_update(struct work_struct *work)
{
struct max6959_priv *priv = container_of(work, struct max6959_priv, work.work);
struct linedisp *linedisp = &priv->linedisp;
struct linedisp_map *map = linedisp->map;
char *s = linedisp->buf;
u8 buf[4];
/* Map segments according to datasheet */
buf[0] = bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1;
buf[1] = bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1;
buf[2] = bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1;
buf[3] = bitrev8(map_to_seg7(&map->map.seg7, *s++)) >> 1;
regmap_bulk_write(priv->regmap, REG_DIGIT(0), buf, ARRAY_SIZE(buf));
}
static int max6959_linedisp_get_map_type(struct linedisp *linedisp)
{
struct max6959_priv *priv = container_of(linedisp, struct max6959_priv, linedisp);
INIT_DELAYED_WORK(&priv->work, max6959_disp_update);
return LINEDISP_MAP_SEG7;
}
static void max6959_linedisp_update(struct linedisp *linedisp)
{
struct max6959_priv *priv = container_of(linedisp, struct max6959_priv, linedisp);
schedule_delayed_work(&priv->work, 0);
}
static const struct linedisp_ops max6959_linedisp_ops = {
.get_map_type = max6959_linedisp_get_map_type,
.update = max6959_linedisp_update,
};
static int max6959_enable(struct max6959_priv *priv, bool enable)
{
return regmap_assign_bits(priv->regmap, REG_CONFIGURATION, REG_CONFIGURATION_S_BIT, enable);
}
static void max6959_power_off(void *priv)
{
max6959_enable(priv, false);
}
static int max6959_power_on(struct max6959_priv *priv)
{
struct device *dev = regmap_get_device(priv->regmap);
int ret;
ret = max6959_enable(priv, true);
if (ret)
return ret;
return devm_add_action_or_reset(dev, max6959_power_off, priv);
}
static const struct regmap_config max6959_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = REG_MAX,
.cache_type = REGCACHE_MAPLE,
};
static int max6959_i2c_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct max6959_priv *priv;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->regmap = devm_regmap_init_i2c(client, &max6959_regmap_config);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
ret = max6959_power_on(priv);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitrev.h`, `linux/bits.h`, `linux/container_of.h`, `linux/device/devres.h`, `linux/err.h`, `linux/i2c.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct max6959_priv`, `function max6959_disp_update`, `function max6959_linedisp_get_map_type`, `function max6959_linedisp_update`, `function max6959_enable`, `function max6959_power_off`, `function max6959_power_on`, `function max6959_i2c_probe`, `function max6959_i2c_remove`, `function max6959_suspend`.
- Atlas domain: Driver Families / drivers/auxdisplay.
- Implementation status: source 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.