HID: wacom: power_supply: provide the actual model_name
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 13 Jul 2016 16:06:17 +0000 (18:06 +0200)
committerJiri Kosina <jkosina@suse.cz>
Fri, 5 Aug 2016 11:39:23 +0000 (13:39 +0200)
Instead of displaying a generic "tablet", now g-c-c shows a pretty
"Wacom Intuos Pro S (WL)".

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/wacom.h
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.h

index 26a8a057b624849b34b68be26de342774b857ae7..b4800ea891cb88ff43c194efe8d98fe7837c580a 100644 (file)
@@ -134,6 +134,7 @@ struct wacom_group_leds {
 };
 
 struct wacom_battery {
+       struct wacom *wacom;
        struct power_supply_desc bat_desc;
        struct power_supply *battery;
        char bat_name[WACOM_NAME_MAX];
index d8f3d3dc2c8860ca4782d74a8f9175a8f771eaf1..edde8819e5060a20111aa1bbcd0c419b83a0ece4 100644 (file)
@@ -1336,6 +1336,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
 }
 
 static enum power_supply_property wacom_battery_props[] = {
+       POWER_SUPPLY_PROP_MODEL_NAME,
        POWER_SUPPLY_PROP_PRESENT,
        POWER_SUPPLY_PROP_STATUS,
        POWER_SUPPLY_PROP_SCOPE,
@@ -1350,6 +1351,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
        int ret = 0;
 
        switch (psp) {
+               case POWER_SUPPLY_PROP_MODEL_NAME:
+                       val->strval = battery->wacom->wacom_wac.name;
+                       break;
                case POWER_SUPPLY_PROP_PRESENT:
                        val->intval = battery->bat_connected;
                        break;
@@ -1392,6 +1396,8 @@ static int __wacom_initialize_battery(struct wacom *wacom,
        if (!devres_open_group(dev, bat_desc, GFP_KERNEL))
                return -ENOMEM;
 
+       battery->wacom = wacom;
+
        n = atomic_inc_return(&battery_no) - 1;
 
        bat_desc->properties = wacom_battery_props;
@@ -1863,6 +1869,9 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
                strlcpy(name, features->name, sizeof(name));
        }
 
+       snprintf(wacom_wac->name, sizeof(wacom_wac->name), "%s%s",
+                name, suffix);
+
        /* Append the device type to the name */
        snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name),
                "%s%s Pen", name, suffix);
@@ -2097,6 +2106,8 @@ static void wacom_wireless_work(struct work_struct *work)
                                goto fail;
                }
 
+               strlcpy(wacom_wac->name, wacom_wac1->name,
+                       sizeof(wacom_wac->name));
                error = wacom_initialize_battery(wacom);
                if (error)
                        goto fail;
index 8a8974c901cbc796971e2cc6abe3f3fa6c768404..745e2c91cb5519f4930b9bbf2be7f3ea1fdfe1e2 100644 (file)
@@ -226,6 +226,7 @@ struct wacom_remote_data {
 };
 
 struct wacom_wac {
+       char name[WACOM_NAME_MAX];
        char pen_name[WACOM_NAME_MAX];
        char touch_name[WACOM_NAME_MAX];
        char pad_name[WACOM_NAME_MAX];