sound/soc/codecs/cs35l56-i2c.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs35l56-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs35l56-i2c.c- Extension
.c- Size
- 2713 bytes
- Lines
- 109
- Domain
- Driver Families
- Bucket
- sound/soc
- 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/acpi.hlinux/i2c.hlinux/module.hlinux/moduleparam.hlinux/regmap.hlinux/slab.hlinux/types.hcs35l56.h
Detected Declarations
function cs35l56_i2c_probefunction cs35l56_i2c_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
//
// CS35L56 ALSA SoC audio driver I2C binding
//
// Copyright (C) 2023 Cirrus Logic, Inc. and
// Cirrus Logic International Semiconductor Ltd.
#include <linux/acpi.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/types.h>
#include "cs35l56.h"
static int cs35l56_i2c_probe(struct i2c_client *client)
{
unsigned int id = (u32)(uintptr_t)i2c_get_match_data(client);
struct cs35l56_private *cs35l56;
struct device *dev = &client->dev;
const struct regmap_config *regmap_config;
int ret;
cs35l56 = devm_kzalloc(dev, sizeof(struct cs35l56_private), GFP_KERNEL);
if (!cs35l56)
return -ENOMEM;
cs35l56->base.dev = dev;
cs35l56->base.can_hibernate = true;
i2c_set_clientdata(client, cs35l56);
switch (id) {
case 0x3556:
regmap_config = &cs35l56_regmap_i2c;
cs35l56->base.type = 0x56;
break;
case 0x3563:
regmap_config = &cs35l63_regmap_i2c;
cs35l56->base.type = 0x63;
break;
default:
return -ENODEV;
}
cs35l56->base.regmap = devm_regmap_init_i2c(client, regmap_config);
if (IS_ERR(cs35l56->base.regmap)) {
ret = PTR_ERR(cs35l56->base.regmap);
return dev_err_probe(cs35l56->base.dev, ret, "Failed to allocate register map\n");
}
ret = cs35l56_common_probe(cs35l56);
if (ret != 0)
return ret;
ret = cs35l56_init(cs35l56);
if (ret == 0)
ret = cs35l56_irq_request(&cs35l56->base, client->irq);
if (ret < 0)
cs35l56_remove(cs35l56);
return ret;
}
static void cs35l56_i2c_remove(struct i2c_client *client)
{
struct cs35l56_private *cs35l56 = i2c_get_clientdata(client);
cs35l56_remove(cs35l56);
}
static const struct i2c_device_id cs35l56_id_i2c[] = {
{ .name = "cs35l56", .driver_data = 0x3556 },
{ .name = "cs35l63", .driver_data = 0x3563 },
{ }
};
MODULE_DEVICE_TABLE(i2c, cs35l56_id_i2c);
#ifdef CONFIG_ACPI
static const struct acpi_device_id cs35l56_asoc_acpi_match[] = {
{ "CSC355C", 0x3556 },
{ "CSC356C", 0x3563 },
{},
};
MODULE_DEVICE_TABLE(acpi, cs35l56_asoc_acpi_match);
#endif
static struct i2c_driver cs35l56_i2c_driver = {
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/i2c.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/regmap.h`, `linux/slab.h`, `linux/types.h`, `cs35l56.h`.
- Detected declarations: `function cs35l56_i2c_probe`, `function cs35l56_i2c_remove`.
- Atlas domain: Driver Families / sound/soc.
- 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.