drivers/iio/light/rohm-bu27034.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/rohm-bu27034.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/rohm-bu27034.c- Extension
.c- Size
- 33424 bytes
- Lines
- 1330
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bits.hlinux/cleanup.hlinux/device.hlinux/i2c.hlinux/module.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/units.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/iio-gts-helper.hlinux/iio/kfifo_buf.h
Detected Declarations
struct bu27034_datastruct bu27034_gain_checkstruct bu27034_lx_coefffunction bu27034_get_gain_selfunction bu27034_get_gainfunction bu27034_get_int_timefunction _bu27034_get_scalefunction bu27034_get_scalefunction bu27034_write_gain_selfunction bu27034_set_gainfunction bu27034_set_int_timefunction bu27034_try_set_int_timefunction bu27034_set_scalefunction gain_mul_div_helperfunction bu27034_fixp_calc_t1_64bitfunction bu27034_fixp_calc_t1function bu27034_fixp_calc_t23function bu27034_fixp_calc_lxfunction bu27034_has_valid_samplefunction bu27034_invalidate_read_datafunction bu27034_read_resultfunction bu27034_get_result_unlockedfunction bu27034_meas_setfunction bu27034_get_single_resultfunction Iffunction bu27034_get_mluxfunction bu27034_read_rawfunction bu27034_write_raw_get_fmtfunction bu27034_write_rawfunction bu27034_read_availfunction bu27034_chip_initfunction bu27034_wait_for_datafunction bu27034_buffer_threadfunction bu27034_buffer_enablefunction bu27034_buffer_disablefunction bu27034_probe
Annotated Snippet
struct bu27034_data {
struct regmap *regmap;
struct device *dev;
/*
* Protect gain and time during scale adjustment and data reading.
* Protect measurement enabling/disabling.
*/
struct mutex mutex;
struct iio_gts gts;
struct task_struct *task;
__le16 raw[BU27034_NUM_HW_DATA_CHANS];
struct {
u32 mlux;
__le16 channels[BU27034_NUM_HW_DATA_CHANS];
aligned_s64 ts;
} scan;
};
static const struct regmap_range bu27034_volatile_ranges[] = {
{
.range_min = BU27034_REG_SYSTEM_CONTROL,
.range_max = BU27034_REG_SYSTEM_CONTROL,
}, {
.range_min = BU27034_REG_MODE_CONTROL4,
.range_max = BU27034_REG_MODE_CONTROL4,
}, {
.range_min = BU27034_REG_DATA0_LO,
.range_max = BU27034_REG_DATA1_HI,
},
};
static const struct regmap_access_table bu27034_volatile_regs = {
.yes_ranges = &bu27034_volatile_ranges[0],
.n_yes_ranges = ARRAY_SIZE(bu27034_volatile_ranges),
};
static const struct regmap_range bu27034_read_only_ranges[] = {
{
.range_min = BU27034_REG_DATA0_LO,
.range_max = BU27034_REG_DATA1_HI,
}, {
.range_min = BU27034_REG_MANUFACTURER_ID,
.range_max = BU27034_REG_MANUFACTURER_ID,
}
};
static const struct regmap_access_table bu27034_ro_regs = {
.no_ranges = &bu27034_read_only_ranges[0],
.n_no_ranges = ARRAY_SIZE(bu27034_read_only_ranges),
};
static const struct regmap_config bu27034_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = BU27034_REG_MAX,
.cache_type = REGCACHE_RBTREE,
.volatile_table = &bu27034_volatile_regs,
.wr_table = &bu27034_ro_regs,
};
struct bu27034_gain_check {
int old_gain;
int new_gain;
int chan;
};
static int bu27034_get_gain_sel(struct bu27034_data *data, int chan)
{
int reg[] = {
[BU27034_CHAN_DATA0] = BU27034_REG_MODE_CONTROL2,
[BU27034_CHAN_DATA1] = BU27034_REG_MODE_CONTROL3,
};
int ret, val;
ret = regmap_read(data->regmap, reg[chan], &val);
if (ret)
return ret;
return FIELD_GET(BU27034_MASK_D01_GAIN, val);
}
static int bu27034_get_gain(struct bu27034_data *data, int chan, int *gain)
{
int ret, sel;
ret = bu27034_get_gain_sel(data, chan);
if (ret < 0)
return ret;
sel = ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/device.h`, `linux/i2c.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`.
- Detected declarations: `struct bu27034_data`, `struct bu27034_gain_check`, `struct bu27034_lx_coeff`, `function bu27034_get_gain_sel`, `function bu27034_get_gain`, `function bu27034_get_int_time`, `function _bu27034_get_scale`, `function bu27034_get_scale`, `function bu27034_write_gain_sel`, `function bu27034_set_gain`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.