drivers/iio/pressure/bmp280-core.c

Source file repositories/reference/linux-study-clean/drivers/iio/pressure/bmp280-core.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/pressure/bmp280-core.c
Extension
.c
Size
90197 bytes
Lines
3344
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.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (chan->type) {
		case IIO_HUMIDITYRELATIVE:
			ret = data->chip_info->read_humid(data, &chan_value);
			if (ret)
				return ret;

			*val = data->chip_info->humid_coeffs[0] * chan_value;
			*val2 = data->chip_info->humid_coeffs[1];
			return data->chip_info->humid_coeffs_type;
		case IIO_PRESSURE:
			ret = data->chip_info->read_press(data, &chan_value);
			if (ret)
				return ret;

			*val = data->chip_info->press_coeffs[0] * chan_value;
			*val2 = data->chip_info->press_coeffs[1];
			return data->chip_info->press_coeffs_type;
		case IIO_TEMP:
			ret = data->chip_info->read_temp(data, &chan_value);
			if (ret)
				return ret;

			*val = data->chip_info->temp_coeffs[0] * chan_value;
			*val2 = data->chip_info->temp_coeffs[1];
			return data->chip_info->temp_coeffs_type;
		default:
			return -EINVAL;
		}
	case IIO_CHAN_INFO_RAW:
		ret = data->chip_info->set_mode(data, BMP280_FORCED);
		if (ret)
			return ret;

		ret = data->chip_info->wait_conv(data);
		if (ret)
			return ret;

		switch (chan->type) {
		case IIO_HUMIDITYRELATIVE:
			ret = data->chip_info->read_humid(data, &chan_value);
			if (ret)
				return ret;

			*val = chan_value;
			return IIO_VAL_INT;
		case IIO_PRESSURE:
			ret = data->chip_info->read_press(data, &chan_value);
			if (ret)
				return ret;

			*val = chan_value;
			return IIO_VAL_INT;
		case IIO_TEMP:
			ret = data->chip_info->read_temp(data, &chan_value);
			if (ret)
				return ret;

			*val = chan_value;
			return IIO_VAL_INT;
		default:
			return -EINVAL;
		}
	case IIO_CHAN_INFO_SCALE:
		switch (chan->type) {
		case IIO_HUMIDITYRELATIVE:
			*val = data->chip_info->humid_coeffs[0];
			*val2 = data->chip_info->humid_coeffs[1];
			return data->chip_info->humid_coeffs_type;
		case IIO_PRESSURE:
			*val = data->chip_info->press_coeffs[0];
			*val2 = data->chip_info->press_coeffs[1];
			return data->chip_info->press_coeffs_type;
		case IIO_TEMP:
			*val = data->chip_info->temp_coeffs[0];
			*val2 = data->chip_info->temp_coeffs[1];
			return data->chip_info->temp_coeffs_type;
		default:
			return -EINVAL;
		}
	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
		switch (chan->type) {
		case IIO_HUMIDITYRELATIVE:
			*val = 1 << data->oversampling_humid;
			return IIO_VAL_INT;
		case IIO_PRESSURE:
			*val = 1 << data->oversampling_press;
			return IIO_VAL_INT;
		case IIO_TEMP:
			*val = 1 << data->oversampling_temp;
			return IIO_VAL_INT;

Annotation

Implementation Notes