drivers/acpi/acpica/utmath.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/utmath.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpica/utmath.c- Extension
.c- Size
- 12991 bytes
- Lines
- 495
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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
acpi/acpi.haccommon.h
Detected Declarations
function acpi_ut_short_multiplyfunction acpi_ut_short_shift_leftfunction acpi_ut_short_shift_rightfunction acpi_ut_short_multiplyfunction acpi_ut_short_shift_leftfunction acpi_ut_short_shift_rightfunction acpi_ut_short_dividefunction acpi_ut_dividefunction acpi_ut_short_dividefunction acpi_ut_divide
Annotated Snippet
if (partial3.part.hi == 0) {
if (partial3.part.lo >= dividend.part.hi) {
if (partial3.part.lo == dividend.part.hi) {
if (partial2.part.lo > dividend.part.lo) {
quotient.part.lo--;
remainder.full -= divisor.full;
}
} else {
quotient.part.lo--;
remainder.full -= divisor.full;
}
}
remainder.full = remainder.full - dividend.full;
remainder.part.hi = (u32)-((s32)remainder.part.hi);
remainder.part.lo = (u32)-((s32)remainder.part.lo);
if (remainder.part.lo) {
remainder.part.hi--;
}
}
}
/* Return only what was requested */
if (out_quotient) {
*out_quotient = quotient.full;
}
if (out_remainder) {
*out_remainder = remainder.full;
}
return_ACPI_STATUS(AE_OK);
}
#else
/*******************************************************************************
*
* FUNCTION: acpi_ut_short_divide, acpi_ut_divide
*
* PARAMETERS: See function headers above
*
* DESCRIPTION: Native versions of the ut_divide functions. Use these if either
* 1) The target is a 64-bit platform and therefore 64-bit
* integer math is supported directly by the machine.
* 2) The target is a 32-bit or 16-bit platform, and the
* double-precision integer math library is available to
* perform the divide.
*
******************************************************************************/
acpi_status
acpi_ut_short_divide(u64 in_dividend,
u32 divisor, u64 *out_quotient, u32 *out_remainder)
{
ACPI_FUNCTION_TRACE(ut_short_divide);
/* Always check for a zero divisor */
if (divisor == 0) {
ACPI_ERROR((AE_INFO, "Divide by zero"));
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
}
/* Return only what was requested */
if (out_quotient) {
*out_quotient = in_dividend / divisor;
}
if (out_remainder) {
*out_remainder = (u32) (in_dividend % divisor);
}
return_ACPI_STATUS(AE_OK);
}
acpi_status
acpi_ut_divide(u64 in_dividend,
u64 in_divisor, u64 *out_quotient, u64 *out_remainder)
{
ACPI_FUNCTION_TRACE(ut_divide);
/* Always check for a zero divisor */
if (in_divisor == 0) {
ACPI_ERROR((AE_INFO, "Divide by zero"));
return_ACPI_STATUS(AE_AML_DIVIDE_BY_ZERO);
}
Annotation
- Immediate include surface: `acpi/acpi.h`, `accommon.h`.
- Detected declarations: `function acpi_ut_short_multiply`, `function acpi_ut_short_shift_left`, `function acpi_ut_short_shift_right`, `function acpi_ut_short_multiply`, `function acpi_ut_short_shift_left`, `function acpi_ut_short_shift_right`, `function acpi_ut_short_divide`, `function acpi_ut_divide`, `function acpi_ut_short_divide`, `function acpi_ut_divide`.
- Atlas domain: Driver Families / drivers/acpi.
- 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.