// SPDX-License-Identifier: GPL-2.0 /* * Functions corresponding to methods under BIOS interface GUID * for use with hp-bioscfg driver. * * Copyright (c) 2022 Hewlett-Packard Inc. */ #include <linux/wmi.h> #include "bioscfg.h" /* * struct bios_args buffer is dynamically allocated. New WMI command types * were introduced that exceeds 128-byte data size. Changes to handle * the data size allocation scheme were kept in hp_wmi_perform_query function. */ struct bios_args { … }; /** * 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) { … } /** * 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 * * returns zero on success * an HP WMI query specific error code (which is positive) * -EINVAL if the query was not successful at all * -EINVAL if the output buffer size exceeds buffersize * * Note: The buffersize must at least be the maximum of the input and output * size. E.g. Battery info query is defined to have 1 byte input * and 128 byte output. The caller would do: * buffer = kzalloc(128, GFP_KERNEL); * ret = hp_wmi_perform_query(HPWMI_BATTERY_QUERY, HPWMI_READ, * buffer, 1, 128) */ int hp_wmi_perform_query(int query, enum hp_wmi_command command, void *buffer, u32 insize, u32 outsize) { … } static void *utf16_empty_string(u16 *p) { … } /** * hp_ascii_to_utf16_unicode - Convert ascii string to UTF-16 unicode * * BIOS supports UTF-16 characters that are 2 bytes long. No variable * multi-byte language supported. * * @p: Unicode buffer address * @str: string to convert to unicode * * Returns a void pointer to the buffer string */ void *hp_ascii_to_utf16_unicode(u16 *p, const u8 *str) { … } /** * hp_wmi_set_bios_setting - Set setting's value in BIOS * * @input_buffer: Input buffer address * @input_size: Input buffer size * * Returns: Count of unicode characters written to BIOS if successful, otherwise * -ENOMEM unable to allocate memory * -EINVAL buffer not allocated or too small */ int hp_wmi_set_bios_setting(u16 *input_buffer, u32 input_size) { … } static int hp_attr_set_interface_probe(struct wmi_device *wdev, const void *context) { … } static void hp_attr_set_interface_remove(struct wmi_device *wdev) { … } static const struct wmi_device_id hp_attr_set_interface_id_table[] = …; static struct wmi_driver hp_attr_set_interface_driver = …; int hp_init_attr_set_interface(void) { … } void hp_exit_attr_set_interface(void) { … } MODULE_DEVICE_TABLE(wmi, hp_attr_set_interface_id_table);