drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c- Extension
.c- Size
- 7752 bytes
- Lines
- 313
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/wmi.hbioscfg.h
Detected Declarations
struct bios_argsfunction hp_set_attributefunction hp_wmi_perform_queryfunction hp_wmi_set_bios_settingfunction hp_attr_set_interface_probefunction hp_attr_set_interface_removefunction hp_init_attr_set_interfacefunction hp_exit_attr_set_interface
Annotated Snippet
struct bios_args {
u32 signature;
u32 command;
u32 commandtype;
u32 datasize;
u8 data[] __counted_by(datasize);
};
/**
* hp_set_attribute
*
* @a_name: The attribute name
* @a_value: The attribute value
*
* Sets an attribute to new value
*
* Returns zero on success
* -ENODEV if device is not found
* -EINVAL if the instance of 'Setup Admin' password is not found.
* -ENOMEM unable to allocate memory
*/
int hp_set_attribute(const char *a_name, const char *a_value)
{
int security_area_size;
int a_name_size, a_value_size;
u16 *buffer = NULL;
u16 *start;
int buffer_size, instance, ret;
char *auth_token_choice;
mutex_lock(&bioscfg_drv.mutex);
instance = hp_get_password_instance_for_type(SETUP_PASSWD);
if (instance < 0) {
ret = -EINVAL;
goto out_set_attribute;
}
/* Select which auth token to use; password or [auth token] */
if (bioscfg_drv.spm_data.auth_token)
auth_token_choice = bioscfg_drv.spm_data.auth_token;
else
auth_token_choice = bioscfg_drv.password_data[instance].current_password;
a_name_size = hp_calculate_string_buffer(a_name);
a_value_size = hp_calculate_string_buffer(a_value);
security_area_size = hp_calculate_security_buffer(auth_token_choice);
buffer_size = a_name_size + a_value_size + security_area_size;
buffer = kmalloc(buffer_size + 1, GFP_KERNEL);
if (!buffer) {
ret = -ENOMEM;
goto out_set_attribute;
}
/* build variables to set */
start = buffer;
start = hp_ascii_to_utf16_unicode(start, a_name);
if (!start) {
ret = -EINVAL;
goto out_set_attribute;
}
start = hp_ascii_to_utf16_unicode(start, a_value);
if (!start) {
ret = -EINVAL;
goto out_set_attribute;
}
ret = hp_populate_security_buffer(start, auth_token_choice);
if (ret < 0)
goto out_set_attribute;
ret = hp_wmi_set_bios_setting(buffer, buffer_size);
out_set_attribute:
kfree(buffer);
mutex_unlock(&bioscfg_drv.mutex);
return ret;
}
/**
* hp_wmi_perform_query
*
* @query: The commandtype (enum hp_wmi_commandtype)
* @command: The command (enum hp_wmi_command)
* @buffer: Buffer used as input and/or output
* @insize: Size of input buffer
* @outsize: Size of output buffer
*
Annotation
- Immediate include surface: `linux/wmi.h`, `bioscfg.h`.
- Detected declarations: `struct bios_args`, `function hp_set_attribute`, `function hp_wmi_perform_query`, `function hp_wmi_set_bios_setting`, `function hp_attr_set_interface_probe`, `function hp_attr_set_interface_remove`, `function hp_init_attr_set_interface`, `function hp_exit_attr_set_interface`.
- Atlas domain: Driver Families / drivers/platform.
- 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.