drivers/iio/light/noa1305.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/noa1305.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/noa1305.c- Extension
.c- Size
- 8647 bytes
- Lines
- 338
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/err.hlinux/i2c.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.h
Detected Declarations
struct noa1305_privfunction noa1305_measurefunction noa1305_scalefunction noa1305_int_timefunction noa1305_read_availfunction noa1305_read_rawfunction noa1305_write_rawfunction noa1305_writable_regfunction noa1305_probe
Annotated Snippet
struct noa1305_priv {
struct i2c_client *client;
struct regmap *regmap;
};
static int noa1305_measure(struct noa1305_priv *priv, int *val)
{
__le16 data;
int ret;
ret = regmap_bulk_read(priv->regmap, NOA1305_REG_ALS_DATA_LSB, &data,
2);
if (ret < 0)
return ret;
*val = le16_to_cpu(data);
return IIO_VAL_INT;
}
static int noa1305_scale(struct noa1305_priv *priv, int *val, int *val2)
{
int data;
int ret;
ret = regmap_read(priv->regmap, NOA1305_REG_INTEGRATION_TIME, &data);
if (ret < 0)
return ret;
/*
* Lux = count / (<Integration Constant> * <Integration Time>)
*
* Integration Constant = 7.7
* Integration Time in Seconds
*/
data &= NOA1305_INTEGR_TIME_MASK;
*val = noa1305_scale_available[2 * data + 0];
*val2 = noa1305_scale_available[2 * data + 1];
return IIO_VAL_FRACTIONAL;
}
static int noa1305_int_time(struct noa1305_priv *priv, int *val, int *val2)
{
int data;
int ret;
ret = regmap_read(priv->regmap, NOA1305_REG_INTEGRATION_TIME, &data);
if (ret < 0)
return ret;
data &= NOA1305_INTEGR_TIME_MASK;
*val = noa1305_int_time_available[2 * data + 0];
*val2 = noa1305_int_time_available[2 * data + 1];
return IIO_VAL_INT_PLUS_MICRO;
}
static const struct iio_chan_spec noa1305_channels[] = {
{
.type = IIO_LIGHT,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME),
.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME),
}
};
static int noa1305_read_avail(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
const int **vals, int *type,
int *length, long mask)
{
if (chan->type != IIO_LIGHT)
return -EINVAL;
switch (mask) {
case IIO_CHAN_INFO_SCALE:
*vals = noa1305_scale_available;
*length = ARRAY_SIZE(noa1305_scale_available);
*type = IIO_VAL_FRACTIONAL;
return IIO_AVAIL_LIST;
case IIO_CHAN_INFO_INT_TIME:
*vals = noa1305_int_time_available;
*length = ARRAY_SIZE(noa1305_int_time_available);
*type = IIO_VAL_INT_PLUS_MICRO;
return IIO_AVAIL_LIST;
default:
return -EINVAL;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/i2c.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct noa1305_priv`, `function noa1305_measure`, `function noa1305_scale`, `function noa1305_int_time`, `function noa1305_read_avail`, `function noa1305_read_raw`, `function noa1305_write_raw`, `function noa1305_writable_reg`, `function noa1305_probe`.
- Atlas domain: Driver Families / drivers/iio.
- 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.