drivers/iio/chemical/scd30_i2c.c

Source file repositories/reference/linux-study-clean/drivers/iio/chemical/scd30_i2c.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/chemical/scd30_i2c.c
Extension
.c
Size
3288 bytes
Lines
141
Domain
Driver Families
Bucket
drivers/iio
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (crc != buf[i + 2]) {
			dev_err(state->dev, "data integrity check failed\n");
			return -EIO;
		}

		*rsp++ = buf[i];
		*rsp++ = buf[i + 1];
	}

	return 0;
}

static int scd30_i2c_probe(struct i2c_client *client)
{
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
		return -EOPNOTSUPP;

	crc8_populate_msb(scd30_i2c_crc8_tbl, SCD30_I2C_CRC8_POLYNOMIAL);

	return scd30_probe(&client->dev, client->irq, client->name, NULL, scd30_i2c_command);
}

static const struct of_device_id scd30_i2c_of_match[] = {
	{ .compatible = "sensirion,scd30" },
	{ }
};
MODULE_DEVICE_TABLE(of, scd30_i2c_of_match);

static struct i2c_driver scd30_i2c_driver = {
	.driver = {
		.name = KBUILD_MODNAME,
		.of_match_table = scd30_i2c_of_match,
		.pm = pm_sleep_ptr(&scd30_pm_ops),
	},
	.probe = scd30_i2c_probe,
};
module_i2c_driver(scd30_i2c_driver);

MODULE_AUTHOR("Tomasz Duszynski <tomasz.duszynski@octakon.com>");
MODULE_DESCRIPTION("Sensirion SCD30 carbon dioxide sensor i2c driver");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS("IIO_SCD30");

Annotation

Implementation Notes