Commit 7a834ba5 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid

Pull HID fixes from Jiri Kosina:

 - fix for bounds limit calculation in uclogic driver, by Dan Carpenter

 - fix for use-after-free during device removal, by Krzysztof Kozlowski

 - fix for userspace regression (that became apparent only with shiny
   new libinput, so it's not that bad, but I still consider it 4.2
   material), in wacom driver, by Jason Gerecke

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid:
  HID: wacom: Report correct device resolution when using the wireless adapater
  HID: hid-input: Fix accessing freed memory during device disconnect
  HID: uclogic: fix limit in uclogic_tablet_enable()
parents 2b9bea03 0be01712
...@@ -462,12 +462,15 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, ...@@ -462,12 +462,15 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
static void hidinput_cleanup_battery(struct hid_device *dev) static void hidinput_cleanup_battery(struct hid_device *dev)
{ {
const struct power_supply_desc *psy_desc;
if (!dev->battery) if (!dev->battery)
return; return;
psy_desc = dev->battery->desc;
power_supply_unregister(dev->battery); power_supply_unregister(dev->battery);
kfree(dev->battery->desc->name); kfree(psy_desc->name);
kfree(dev->battery->desc); kfree(psy_desc);
dev->battery = NULL; dev->battery = NULL;
} }
#else /* !CONFIG_HID_BATTERY_STRENGTH */ #else /* !CONFIG_HID_BATTERY_STRENGTH */
......
...@@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev) ...@@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev)
for (p = drvdata->rdesc; for (p = drvdata->rdesc;
p <= drvdata->rdesc + drvdata->rsize - 4;) { p <= drvdata->rdesc + drvdata->rsize - 4;) {
if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D && if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D &&
p[3] < sizeof(params)) { p[3] < ARRAY_SIZE(params)) {
v = params[p[3]]; v = params[p[3]];
put_unaligned(cpu_to_le32(v), (s32 *)p); put_unaligned(cpu_to_le32(v), (s32 *)p);
p += 4; p += 4;
......
...@@ -1284,6 +1284,39 @@ static int wacom_register_inputs(struct wacom *wacom) ...@@ -1284,6 +1284,39 @@ static int wacom_register_inputs(struct wacom *wacom)
return error; return error;
} }
/*
* Not all devices report physical dimensions from HID.
* Compute the default from hardcoded logical dimension
* and resolution before driver overwrites them.
*/
static void wacom_set_default_phy(struct wacom_features *features)
{
if (features->x_resolution) {
features->x_phy = (features->x_max * 100) /
features->x_resolution;
features->y_phy = (features->y_max * 100) /
features->y_resolution;
}
}
static void wacom_calculate_res(struct wacom_features *features)
{
/* set unit to "100th of a mm" for devices not reported by HID */
if (!features->unit) {
features->unit = 0x11;
features->unitExpo = -3;
}
features->x_resolution = wacom_calc_hid_res(features->x_max,
features->x_phy,
features->unit,
features->unitExpo);
features->y_resolution = wacom_calc_hid_res(features->y_max,
features->y_phy,
features->unit,
features->unitExpo);
}
static void wacom_wireless_work(struct work_struct *work) static void wacom_wireless_work(struct work_struct *work)
{ {
struct wacom *wacom = container_of(work, struct wacom, work); struct wacom *wacom = container_of(work, struct wacom, work);
...@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work) ...@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work)
if (wacom_wac1->features.type != INTUOSHT && if (wacom_wac1->features.type != INTUOSHT &&
wacom_wac1->features.type != BAMBOO_PT) wacom_wac1->features.type != BAMBOO_PT)
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
wacom_set_default_phy(&wacom_wac1->features);
wacom_calculate_res(&wacom_wac1->features);
snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
wacom_wac1->features.name); wacom_wac1->features.name);
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
...@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work) ...@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_wac2->features = wacom_wac2->features =
*((struct wacom_features *)id->driver_data); *((struct wacom_features *)id->driver_data);
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
wacom_set_default_phy(&wacom_wac2->features);
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
wacom_calculate_res(&wacom_wac2->features);
snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
"%s (WL) Finger",wacom_wac2->features.name); "%s (WL) Finger",wacom_wac2->features.name);
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
...@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work) ...@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work)
} }
} }
/*
* Not all devices report physical dimensions from HID.
* Compute the default from hardcoded logical dimension
* and resolution before driver overwrites them.
*/
static void wacom_set_default_phy(struct wacom_features *features)
{
if (features->x_resolution) {
features->x_phy = (features->x_max * 100) /
features->x_resolution;
features->y_phy = (features->y_max * 100) /
features->y_resolution;
}
}
static void wacom_calculate_res(struct wacom_features *features)
{
/* set unit to "100th of a mm" for devices not reported by HID */
if (!features->unit) {
features->unit = 0x11;
features->unitExpo = -3;
}
features->x_resolution = wacom_calc_hid_res(features->x_max,
features->x_phy,
features->unit,
features->unitExpo);
features->y_resolution = wacom_calc_hid_res(features->y_max,
features->y_phy,
features->unit,
features->unitExpo);
}
static size_t wacom_compute_pktlen(struct hid_device *hdev) static size_t wacom_compute_pktlen(struct hid_device *hdev)
{ {
struct hid_report_enum *report_enum; struct hid_report_enum *report_enum;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment