drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c
Extension
.c
Size
5349 bytes
Lines
178
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Functions corresponding to string type attributes under BIOS String GUID for use with
 * dell-wmi-sysman
 *
 *  Copyright (c) 2020 Dell Inc.
 */

#include "dell-wmi-sysman.h"

enum string_properties {MIN_LEN = 6, MAX_LEN};

get_instance_id(str);

static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
	int instance_id = get_str_instance_id(kobj);
	union acpi_object *obj;
	ssize_t ret;

	if (instance_id < 0)
		return -EIO;

	/* need to use specific instance_id and guid combination to get right data */
	obj = get_wmiobj_pointer(instance_id, DELL_WMI_BIOS_STRING_ATTRIBUTE_GUID);
	if (!obj)
		return -EIO;
	if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count < STR_MIN_ELEMENTS ||
	    obj->package.elements[CURRENT_VAL].type != ACPI_TYPE_STRING) {
		kfree(obj);
		return -EIO;
	}
	ret = snprintf(buf, PAGE_SIZE, "%s\n", obj->package.elements[CURRENT_VAL].string.pointer);
	kfree(obj);
	return ret;
}

/**
 * validate_str_input() - Validate input of current_value against min and max lengths
 * @instance_id: The instance on which input is validated
 * @buf: Input value
 */
static int validate_str_input(int instance_id, const char *buf)
{
	int in_len = strlen(buf);

	if ((in_len < wmi_priv.str_data[instance_id].min_length) ||
			(in_len > wmi_priv.str_data[instance_id].max_length))
		return -EINVAL;

	return 0;
}

attribute_s_property_show(display_name_language_code, str);
static struct kobj_attribute str_displ_langcode =
		__ATTR_RO(display_name_language_code);

attribute_s_property_show(display_name, str);
static struct kobj_attribute str_displ_name =
		__ATTR_RO(display_name);

attribute_s_property_show(default_value, str);
static struct kobj_attribute str_default_val =
		__ATTR_RO(default_value);

attribute_property_store(current_value, str);
static struct kobj_attribute str_current_val =
		__ATTR_RW_MODE(current_value, 0600);

attribute_s_property_show(dell_modifier, str);
static struct kobj_attribute str_modifier =
		__ATTR_RO(dell_modifier);

attribute_n_property_show(min_length, str);
static struct kobj_attribute str_min_length =
		__ATTR_RO(min_length);

attribute_n_property_show(max_length, str);
static struct kobj_attribute str_max_length =
		__ATTR_RO(max_length);

static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{
	return sprintf(buf, "string\n");
}
static struct kobj_attribute str_type =
	__ATTR_RO(type);

static struct attribute *str_attrs[] = {

Annotation

Implementation Notes