drivers/net/dsa/lan9303_i2c.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/lan9303_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/lan9303_i2c.c- Extension
.c- Size
- 2820 bytes
- Lines
- 118
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/kernel.hlinux/module.hlinux/i2c.hlinux/of.hlan9303.h
Detected Declarations
struct lan9303_i2cfunction lan9303_i2c_probefunction lan9303_i2c_removefunction lan9303_i2c_shutdown
Annotated Snippet
struct lan9303_i2c {
struct i2c_client *device;
struct lan9303 chip;
};
static const struct regmap_config lan9303_i2c_regmap_config = {
.reg_bits = 8,
.val_bits = 32,
.reg_stride = 1,
.can_multi_write = true,
.max_register = 0x0ff, /* address bits 0..1 are not used */
.reg_format_endian = REGMAP_ENDIAN_LITTLE,
.volatile_table = &lan9303_register_set,
.wr_table = &lan9303_register_set,
.rd_table = &lan9303_register_set,
.cache_type = REGCACHE_NONE,
};
static int lan9303_i2c_probe(struct i2c_client *client)
{
struct lan9303_i2c *sw_dev;
int ret;
sw_dev = devm_kzalloc(&client->dev, sizeof(struct lan9303_i2c),
GFP_KERNEL);
if (!sw_dev)
return -ENOMEM;
sw_dev->chip.regmap = devm_regmap_init_i2c(client,
&lan9303_i2c_regmap_config);
if (IS_ERR(sw_dev->chip.regmap)) {
ret = PTR_ERR(sw_dev->chip.regmap);
dev_err(&client->dev, "Failed to allocate register map: %d\n",
ret);
return ret;
}
/* link forward and backward */
sw_dev->device = client;
i2c_set_clientdata(client, sw_dev);
sw_dev->chip.dev = &client->dev;
sw_dev->chip.ops = &lan9303_indirect_phy_ops;
ret = lan9303_probe(&sw_dev->chip, client->dev.of_node);
if (ret != 0)
return ret;
dev_info(&client->dev, "LAN9303 I2C driver loaded successfully\n");
return 0;
}
static void lan9303_i2c_remove(struct i2c_client *client)
{
struct lan9303_i2c *sw_dev = i2c_get_clientdata(client);
if (!sw_dev)
return;
lan9303_remove(&sw_dev->chip);
}
static void lan9303_i2c_shutdown(struct i2c_client *client)
{
struct lan9303_i2c *sw_dev = i2c_get_clientdata(client);
if (!sw_dev)
return;
lan9303_shutdown(&sw_dev->chip);
i2c_set_clientdata(client, NULL);
}
/*-------------------------------------------------------------------------*/
static const struct i2c_device_id lan9303_i2c_id[] = {
{ .name = "lan9303" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(i2c, lan9303_i2c_id);
static const struct of_device_id lan9303_i2c_of_match[] = {
{ .compatible = "smsc,lan9303-i2c", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, lan9303_i2c_of_match);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/i2c.h`, `linux/of.h`, `lan9303.h`.
- Detected declarations: `struct lan9303_i2c`, `function lan9303_i2c_probe`, `function lan9303_i2c_remove`, `function lan9303_i2c_shutdown`.
- Atlas domain: Driver Families / drivers/net.
- 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.