arch/powerpc/platforms/powernv/opal-sensor.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powernv/opal-sensor.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/powernv/opal-sensor.c- Extension
.c- Size
- 2649 bytes
- Lines
- 133
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/delay.hlinux/of.hlinux/of_platform.hlinux/platform_device.hasm/opal.hasm/machdep.h
Detected Declarations
function Copyrightfunction opal_get_sensor_data_u64function opal_sensor_initexport opal_get_sensor_dataexport opal_get_sensor_data_u64
Annotated Snippet
if (ret) {
pr_err("%s: Failed to wait for the async response, %d\n",
__func__, ret);
goto out;
}
ret = opal_error_code(opal_get_async_rc(msg));
*sensor_data = be32_to_cpu(data);
break;
case OPAL_SUCCESS:
ret = 0;
*sensor_data = be32_to_cpu(data);
break;
case OPAL_WRONG_STATE:
ret = -EIO;
break;
default:
ret = opal_error_code(ret);
break;
}
out:
opal_async_release_token(token);
return ret;
}
EXPORT_SYMBOL_GPL(opal_get_sensor_data);
int opal_get_sensor_data_u64(u32 sensor_hndl, u64 *sensor_data)
{
int ret, token;
struct opal_msg msg;
__be64 data;
if (!opal_check_token(OPAL_SENSOR_READ_U64)) {
u32 sdata;
ret = opal_get_sensor_data(sensor_hndl, &sdata);
if (!ret)
*sensor_data = sdata;
return ret;
}
token = opal_async_get_token_interruptible();
if (token < 0)
return token;
ret = opal_sensor_read_u64(sensor_hndl, token, &data);
switch (ret) {
case OPAL_ASYNC_COMPLETION:
ret = opal_async_wait_response(token, &msg);
if (ret) {
pr_err("%s: Failed to wait for the async response, %d\n",
__func__, ret);
goto out_token;
}
ret = opal_error_code(opal_get_async_rc(msg));
*sensor_data = be64_to_cpu(data);
break;
case OPAL_SUCCESS:
ret = 0;
*sensor_data = be64_to_cpu(data);
break;
case OPAL_WRONG_STATE:
ret = -EIO;
break;
default:
ret = opal_error_code(ret);
break;
}
out_token:
opal_async_release_token(token);
return ret;
}
EXPORT_SYMBOL_GPL(opal_get_sensor_data_u64);
int __init opal_sensor_init(void)
{
struct platform_device *pdev;
struct device_node *sensor;
sensor = of_find_node_by_path("/ibm,opal/sensors");
if (!sensor) {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `asm/opal.h`, `asm/machdep.h`.
- Detected declarations: `function Copyright`, `function opal_get_sensor_data_u64`, `function opal_sensor_init`, `export opal_get_sensor_data`, `export opal_get_sensor_data_u64`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.