aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-09-09 18:08:45 -0400
committerDarren Hart <dvhart@linux.intel.com>2015-09-10 12:07:04 -0400
commit85b4e4eb2f9ac29ee8ec47f1f055f251cb251a3c (patch)
tree353667b0c891bf1f3bd6559db4358f63e8d07a35 /drivers/platform
parent8901c18b6cafa51f7985f1031968bbfe9dc47735 (diff)
wmi: Remove private %pUL implementation
The work performed by wmi_gtoa is equivalent to simply sprintf(out, "%pUL", in), so one could replace its body by this. However, most users feed the result directly as a %s argument to some other function which also understands the %p extensions (they all ultimately use vsnprintf), so we can eliminate some stack buffers and quite a bit of code by just using %pUL directly. In wmi_dev_uevent I'm not sure whether there's room for a nul-terminator in env->buf, so I've just replaced wmi_gtoa with the equivalent sprintf call. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/wmi.c51
1 files changed, 6 insertions, 45 deletions
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index aac47573f9ed..eb391a281833 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -194,34 +194,6 @@ static bool wmi_parse_guid(const u8 *src, u8 *dest)
194 return true; 194 return true;
195} 195}
196 196
197/*
198 * Convert a raw GUID to the ACII string representation
199 */
200static int wmi_gtoa(const char *in, char *out)
201{
202 int i;
203
204 for (i = 3; i >= 0; i--)
205 out += sprintf(out, "%02X", in[i] & 0xFF);
206
207 out += sprintf(out, "-");
208 out += sprintf(out, "%02X", in[5] & 0xFF);
209 out += sprintf(out, "%02X", in[4] & 0xFF);
210 out += sprintf(out, "-");
211 out += sprintf(out, "%02X", in[7] & 0xFF);
212 out += sprintf(out, "%02X", in[6] & 0xFF);
213 out += sprintf(out, "-");
214 out += sprintf(out, "%02X", in[8] & 0xFF);
215 out += sprintf(out, "%02X", in[9] & 0xFF);
216 out += sprintf(out, "-");
217
218 for (i = 10; i <= 15; i++)
219 out += sprintf(out, "%02X", in[i] & 0xFF);
220
221 *out = '\0';
222 return 0;
223}
224
225static bool find_guid(const char *guid_string, struct wmi_block **out) 197static bool find_guid(const char *guid_string, struct wmi_block **out)
226{ 198{
227 char tmp[16], guid_input[16]; 199 char tmp[16], guid_input[16];
@@ -457,11 +429,7 @@ EXPORT_SYMBOL_GPL(wmi_set_block);
457 429
458static void wmi_dump_wdg(const struct guid_block *g) 430static void wmi_dump_wdg(const struct guid_block *g)
459{ 431{
460 char guid_string[37]; 432 pr_info("%pUL:\n", g->guid);
461
462 wmi_gtoa(g->guid, guid_string);
463
464 pr_info("%s:\n", guid_string);
465 pr_info("\tobject_id: %c%c\n", g->object_id[0], g->object_id[1]); 433 pr_info("\tobject_id: %c%c\n", g->object_id[0], g->object_id[1]);
466 pr_info("\tnotify_id: %02X\n", g->notify_id); 434 pr_info("\tnotify_id: %02X\n", g->notify_id);
467 pr_info("\treserved: %02X\n", g->reserved); 435 pr_info("\treserved: %02X\n", g->reserved);
@@ -661,7 +629,6 @@ EXPORT_SYMBOL_GPL(wmi_has_guid);
661static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 629static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
662 char *buf) 630 char *buf)
663{ 631{
664 char guid_string[37];
665 struct wmi_block *wblock; 632 struct wmi_block *wblock;
666 633
667 wblock = dev_get_drvdata(dev); 634 wblock = dev_get_drvdata(dev);
@@ -670,9 +637,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
670 return strlen(buf); 637 return strlen(buf);
671 } 638 }
672 639
673 wmi_gtoa(wblock->gblock.guid, guid_string); 640 return sprintf(buf, "wmi:%pUL\n", wblock->gblock.guid);
674
675 return sprintf(buf, "wmi:%s\n", guid_string);
676} 641}
677static DEVICE_ATTR_RO(modalias); 642static DEVICE_ATTR_RO(modalias);
678 643
@@ -695,7 +660,7 @@ static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
695 if (!wblock) 660 if (!wblock)
696 return -ENOMEM; 661 return -ENOMEM;
697 662
698 wmi_gtoa(wblock->gblock.guid, guid_string); 663 sprintf(guid_string, "%pUL", wblock->gblock.guid);
699 664
700 strcpy(&env->buf[env->buflen - 1], "wmi:"); 665 strcpy(&env->buf[env->buflen - 1], "wmi:");
701 memcpy(&env->buf[env->buflen - 1 + 4], guid_string, 36); 666 memcpy(&env->buf[env->buflen - 1 + 4], guid_string, 36);
@@ -721,12 +686,9 @@ static struct class wmi_class = {
721static int wmi_create_device(const struct guid_block *gblock, 686static int wmi_create_device(const struct guid_block *gblock,
722 struct wmi_block *wblock, acpi_handle handle) 687 struct wmi_block *wblock, acpi_handle handle)
723{ 688{
724 char guid_string[37];
725
726 wblock->dev.class = &wmi_class; 689 wblock->dev.class = &wmi_class;
727 690
728 wmi_gtoa(gblock->guid, guid_string); 691 dev_set_name(&wblock->dev, "%pUL", gblock->guid);
729 dev_set_name(&wblock->dev, "%s", guid_string);
730 692
731 dev_set_drvdata(&wblock->dev, wblock); 693 dev_set_drvdata(&wblock->dev, wblock);
732 694
@@ -877,7 +839,6 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
877 struct guid_block *block; 839 struct guid_block *block;
878 struct wmi_block *wblock; 840 struct wmi_block *wblock;
879 struct list_head *p; 841 struct list_head *p;
880 char guid_string[37];
881 842
882 list_for_each(p, &wmi_block_list) { 843 list_for_each(p, &wmi_block_list) {
883 wblock = list_entry(p, struct wmi_block, list); 844 wblock = list_entry(p, struct wmi_block, list);
@@ -888,8 +849,8 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
888 if (wblock->handler) 849 if (wblock->handler)
889 wblock->handler(event, wblock->handler_data); 850 wblock->handler(event, wblock->handler_data);
890 if (debug_event) { 851 if (debug_event) {
891 wmi_gtoa(wblock->gblock.guid, guid_string); 852 pr_info("DEBUG Event GUID: %pUL\n",
892 pr_info("DEBUG Event GUID: %s\n", guid_string); 853 wblock->gblock.guid);
893 } 854 }
894 855
895 acpi_bus_generate_netlink_event( 856 acpi_bus_generate_netlink_event(