drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c- Extension
.c- Size
- 2730 bytes
- Lines
- 97
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/dev_printk.hlinux/err.hlinux/module.hlinux/regulator/consumer.hlinux/iio/common/st_sensors.hlinux/iio/iio.hst_lsm9ds0.h
Detected Declarations
function Copyrightfunction st_lsm9ds0_probe_magnfunction st_lsm9ds0_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* STMicroelectronics LSM9DS0 IMU driver
*
* Copyright (C) 2021, Intel Corporation
*
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*/
#include <linux/array_size.h>
#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/iio/common/st_sensors.h>
#include <linux/iio/iio.h>
#include "st_lsm9ds0.h"
static int st_lsm9ds0_probe_accel(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
{
const struct st_sensor_settings *settings;
struct device *dev = lsm9ds0->dev;
struct st_sensor_data *data;
settings = st_accel_get_settings(lsm9ds0->name);
if (!settings)
return dev_err_probe(dev, -ENODEV, "device name %s not recognized.\n",
lsm9ds0->name);
lsm9ds0->accel = devm_iio_device_alloc(dev, sizeof(*data));
if (!lsm9ds0->accel)
return -ENOMEM;
lsm9ds0->accel->name = lsm9ds0->name;
data = iio_priv(lsm9ds0->accel);
data->sensor_settings = (struct st_sensor_settings *)settings;
data->irq = lsm9ds0->irq;
data->regmap = regmap;
return st_accel_common_probe(lsm9ds0->accel);
}
static int st_lsm9ds0_probe_magn(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
{
const struct st_sensor_settings *settings;
struct device *dev = lsm9ds0->dev;
struct st_sensor_data *data;
settings = st_magn_get_settings(lsm9ds0->name);
if (!settings)
return dev_err_probe(dev, -ENODEV, "device name %s not recognized.\n",
lsm9ds0->name);
lsm9ds0->magn = devm_iio_device_alloc(dev, sizeof(*data));
if (!lsm9ds0->magn)
return -ENOMEM;
lsm9ds0->magn->name = lsm9ds0->name;
data = iio_priv(lsm9ds0->magn);
data->sensor_settings = (struct st_sensor_settings *)settings;
data->irq = lsm9ds0->irq;
data->regmap = regmap;
return st_magn_common_probe(lsm9ds0->magn);
}
int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
{
struct device *dev = lsm9ds0->dev;
static const char * const regulator_names[] = { "vdd", "vddio" };
int ret;
/* Regulators not mandatory, but if requested we should enable them. */
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
regulator_names);
if (ret)
return dev_err_probe(dev, ret, "unable to enable Vdd supply\n");
/* Setup accelerometer device */
ret = st_lsm9ds0_probe_accel(lsm9ds0, regmap);
if (ret)
return ret;
/* Setup magnetometer device */
return st_lsm9ds0_probe_magn(lsm9ds0, regmap);
}
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/module.h`, `linux/regulator/consumer.h`, `linux/iio/common/st_sensors.h`, `linux/iio/iio.h`, `st_lsm9ds0.h`.
- Detected declarations: `function Copyright`, `function st_lsm9ds0_probe_magn`, `function st_lsm9ds0_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.