[PATCH v2 4/4] Improve friendly display name values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The purpose of this patch is to improve the friendly display name for
few numbers of attributes associated with ‘Schedule Power-ON.’  BIOS
assign names such ‘Tuesday’ to an attribute. The name is correct, but
it is not descriptive enough for the user.  It is under those
conditions a portion of the path data value is append to the attribute
name to create a user-friendly display name.

For instance, the attribute name is ‘Tuesday,’ and the display name
value is ‘Schedule Power-ON – Tuesday’

Signed-off-by: Jorge Lopez <jorge.lopez2@xxxxxx>

---
Based on the latest platform-drivers-x86.git/for-next
---
 drivers/platform/x86/hp/bioscfg.c            | 18 ++++++++++++++++++
 drivers/platform/x86/hp/bioscfg.h            |  5 ++++-
 drivers/platform/x86/hp/enum-attributes.c    |  9 ++++++++-
 drivers/platform/x86/hp/int-attributes.c     |  8 ++++++++
 drivers/platform/x86/hp/ordered-attributes.c | 10 +++++++++-
 drivers/platform/x86/hp/string-attributes.c  | 10 ++++++++--
 6 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/hp/bioscfg.c b/drivers/platform/x86/hp/bioscfg.c
index 72dd963f29ae..ce3226d79696 100644
--- a/drivers/platform/x86/hp/bioscfg.c
+++ b/drivers/platform/x86/hp/bioscfg.c
@@ -542,6 +542,24 @@ inline int encode_outsize_for_pvsz(int outsize)
 	return 1;
 }
 
+/*
+ * Update friendly display name for several attributes associated to
+ * 'Schedule Power-On'
+ */
+void friendly_user_name_update(char *path, const char *attr_name,
+				char *attr_display, int attr_size)
+{
+	char *found = NULL;
+
+	found = strstr(path, SCHEDULE_POWER_ON);
+	if (found)
+		snprintf(attr_display,
+			 attr_size,
+			 "%s - %s",
+			 SCHEDULE_POWER_ON,
+			 attr_name);
+}
+
 /**
  * update_attribute_permissions() - Update attributes permissions when
  * isReadOnly value is 1
diff --git a/drivers/platform/x86/hp/bioscfg.h b/drivers/platform/x86/hp/bioscfg.h
index ff030399b3a2..4409481f84f2 100644
--- a/drivers/platform/x86/hp/bioscfg.h
+++ b/drivers/platform/x86/hp/bioscfg.h
@@ -33,7 +33,8 @@
 #define SETUP_PASSWD	"Setup Password"
 #define POWER_ON_PASSWD	"Power-On Password"
 
-#define LANG_CODE_STR	"en_US.UTF-8"
+#define LANG_CODE_STR		"en_US.UTF-8"
+#define SCHEDULE_POWER_ON	"Scheduled Power-On"
 
 /* Sure Admin Functions */
 
@@ -521,6 +522,8 @@ union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string);
 int get_instance_count(const char *guid_string);
 void strlcpy_attr(char *dest, char *src);
 void update_attribute_permissions(u32 isReadOnly, struct kobj_attribute *current_val);
+void friendly_user_name_update(char *path, const char *attr_name,
+				char *attr_display, int attr_size);
 
 /* String attributes */
 int populate_string_buffer_data(union acpi_object *str_obj,
diff --git a/drivers/platform/x86/hp/enum-attributes.c b/drivers/platform/x86/hp/enum-attributes.c
index f4fe6a583ca4..e67e7c397c12 100644
--- a/drivers/platform/x86/hp/enum-attributes.c
+++ b/drivers/platform/x86/hp/enum-attributes.c
@@ -192,7 +192,10 @@ int populate_enumeration_package_data(union acpi_object *enum_obj, int instance_
 	populate_enumeration_elements_from_package(enum_obj, instance_id, HPWMI_ENUMERATION_TYPE);
 	update_attribute_permissions(bioscfg_drv.enumeration_data[instance_id].is_readonly,
 				    &enumeration_current_val);
-
+	friendly_user_name_update(bioscfg_drv.enumeration_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.enumeration_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.enumeration_data[instance_id].display_name));
 	return sysfs_create_group(attr_name_kobj, &enumeration_attr_group);
 }
 
@@ -366,6 +369,10 @@ int populate_enumeration_buffer_data(union acpi_object *enum_obj, int instance_i
 	populate_enumeration_elements_from_buffer(enum_obj, instance_id, HPWMI_ENUMERATION_TYPE);
 	update_attribute_permissions(bioscfg_drv.enumeration_data[instance_id].is_readonly,
 				    &enumeration_current_val);
+	friendly_user_name_update(bioscfg_drv.enumeration_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.enumeration_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.enumeration_data[instance_id].display_name));
 
 	return sysfs_create_group(attr_name_kobj, &enumeration_attr_group);
 }
diff --git a/drivers/platform/x86/hp/int-attributes.c b/drivers/platform/x86/hp/int-attributes.c
index eaae4b065098..6564a7266e9e 100644
--- a/drivers/platform/x86/hp/int-attributes.c
+++ b/drivers/platform/x86/hp/int-attributes.c
@@ -170,6 +170,10 @@ int populate_integer_package_data(union acpi_object *elements, int instance_id,
 	populate_integer_elements_from_package(elements, instance_id, HPWMI_INTEGER_TYPE);
 	update_attribute_permissions(bioscfg_drv.integer_data[instance_id].is_readonly,
 				    &integer_current_val);
+	friendly_user_name_update(bioscfg_drv.integer_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.integer_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.integer_data[instance_id].display_name));
 	return sysfs_create_group(attr_name_kobj, &integer_attr_group);
 }
 
@@ -333,6 +337,10 @@ int populate_integer_buffer_data(union acpi_object *integer_obj, int instance_id
 	populate_integer_elements_from_buffer(integer_obj, instance_id, HPWMI_INTEGER_TYPE);
 	update_attribute_permissions(bioscfg_drv.integer_data[instance_id].is_readonly,
 				    &integer_current_val);
+	friendly_user_name_update(bioscfg_drv.integer_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.integer_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.integer_data[instance_id].display_name));
 
 	return sysfs_create_group(attr_name_kobj, &integer_attr_group);
 }
diff --git a/drivers/platform/x86/hp/ordered-attributes.c b/drivers/platform/x86/hp/ordered-attributes.c
index 723db9a0316d..603222c086a7 100644
--- a/drivers/platform/x86/hp/ordered-attributes.c
+++ b/drivers/platform/x86/hp/ordered-attributes.c
@@ -241,7 +241,10 @@ int populate_ordered_list_package_data(union acpi_object *order_obj, int instanc
 	populate_ordered_list_elements_from_package(order_obj, instance_id, HPWMI_ORDERED_LIST_TYPE);
 	update_attribute_permissions(bioscfg_drv.ordered_list_data[instance_id].is_readonly,
 				    &ordered_list_current_val);
-
+	friendly_user_name_update(bioscfg_drv.ordered_list_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.ordered_list_data[instance_id].display_name,
+				  sizeof(bioscfg_drv.ordered_list_data[instance_id].display_name));
 	return sysfs_create_group(attr_name_kobj, &ordered_list_attr_group);
 }
 
@@ -431,6 +434,11 @@ int populate_ordered_list_buffer_data(union acpi_object *order_obj, int instance
 	populate_ordered_list_elements_from_buffer(order_obj, instance_id, HPWMI_ORDERED_LIST_TYPE);
 	update_attribute_permissions(bioscfg_drv.ordered_list_data[instance_id].is_readonly,
 				    &ordered_list_current_val);
+	friendly_user_name_update(bioscfg_drv.ordered_list_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.ordered_list_data[instance_id].display_name,
+				  sizeof(bioscfg_drv.ordered_list_data[instance_id].display_name));
+
 	return sysfs_create_group(attr_name_kobj, &ordered_list_attr_group);
 }
 
diff --git a/drivers/platform/x86/hp/string-attributes.c b/drivers/platform/x86/hp/string-attributes.c
index a8e4f8b60dff..56ca02b00d1d 100644
--- a/drivers/platform/x86/hp/string-attributes.c
+++ b/drivers/platform/x86/hp/string-attributes.c
@@ -166,7 +166,10 @@ int populate_string_package_data(union acpi_object *elements, int instance_id,
 	populate_string_elements_from_package(elements, instance_id, HPWMI_STRING_TYPE);
 	update_attribute_permissions(bioscfg_drv.string_data[instance_id].is_readonly,
 				    &string_current_val);
-
+	friendly_user_name_update(bioscfg_drv.string_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.string_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.string_data[instance_id].display_name));
 	return sysfs_create_group(attr_name_kobj, &string_attr_group);
 }
 
@@ -325,7 +328,10 @@ int populate_string_buffer_data(union acpi_object *string_obj, int instance_id,
 	populate_string_elements_from_buffer(string_obj, instance_id, HPWMI_STRING_TYPE);
 	update_attribute_permissions(bioscfg_drv.string_data[instance_id].is_readonly,
 				    &string_current_val);
-
+	friendly_user_name_update(bioscfg_drv.string_data[instance_id].path,
+				  attr_name_kobj->name,
+				   bioscfg_drv.string_data[instance_id].display_name,
+				   sizeof(bioscfg_drv.string_data[instance_id].display_name));
 	return sysfs_create_group(attr_name_kobj, &string_attr_group);
 }
 
-- 
2.34.1




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux