diff options
author | Jiri Kosina <jkosina@suse.cz> | 2013-09-06 05:59:53 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-09-06 05:59:53 -0400 |
commit | 4e5a494e4b4ba7e6aa1a8a285e98e3665fcb396e (patch) | |
tree | 04fcbf50c0a0b17e4604ddbea50485d38014c3bd | |
parent | 63faf15dba4a7d6fb18ed5c45670a152d0c5330b (diff) | |
parent | 7b0692f1c60a9551f8ad5fe706b79a23720a196c (diff) |
Merge branch 'for-3.12/sensor-hub' into for-linus
Conflicts:
drivers/hid/hid-sensor-hub.c
-rw-r--r-- | drivers/hid/hid-sensor-hub.c | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 6fca30eb377d..10e1581022cf 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
@@ -103,8 +103,7 @@ static int sensor_hub_get_physical_device_count( | |||
103 | 103 | ||
104 | list_for_each_entry(report, &report_enum->report_list, list) { | 104 | list_for_each_entry(report, &report_enum->report_list, list) { |
105 | field = report->field[0]; | 105 | field = report->field[0]; |
106 | if (report->maxfield && field && | 106 | if (report->maxfield && field && field->physical) |
107 | field->physical) | ||
108 | cnt++; | 107 | cnt++; |
109 | } | 108 | } |
110 | 109 | ||
@@ -192,12 +191,12 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | |||
192 | u32 field_index, s32 value) | 191 | u32 field_index, s32 value) |
193 | { | 192 | { |
194 | struct hid_report *report; | 193 | struct hid_report *report; |
195 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); | 194 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); |
196 | int ret = 0; | 195 | int ret = 0; |
197 | 196 | ||
198 | mutex_lock(&data->mutex); | 197 | mutex_lock(&data->mutex); |
199 | report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); | 198 | report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); |
200 | if (!report || (field_index >= report->maxfield)) { | 199 | if (!report || (field_index >= report->maxfield)) { |
201 | ret = -EINVAL; | 200 | ret = -EINVAL; |
202 | goto done_proc; | 201 | goto done_proc; |
203 | } | 202 | } |
@@ -216,12 +215,12 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, | |||
216 | u32 field_index, s32 *value) | 215 | u32 field_index, s32 *value) |
217 | { | 216 | { |
218 | struct hid_report *report; | 217 | struct hid_report *report; |
219 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); | 218 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); |
220 | int ret = 0; | 219 | int ret = 0; |
221 | 220 | ||
222 | mutex_lock(&data->mutex); | 221 | mutex_lock(&data->mutex); |
223 | report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); | 222 | report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT); |
224 | if (!report || (field_index >= report->maxfield) || | 223 | if (!report || (field_index >= report->maxfield) || |
225 | report->field[field_index]->report_count < 1) { | 224 | report->field[field_index]->report_count < 1) { |
226 | ret = -EINVAL; | 225 | ret = -EINVAL; |
227 | goto done_proc; | 226 | goto done_proc; |
@@ -242,7 +241,7 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, | |||
242 | u32 usage_id, | 241 | u32 usage_id, |
243 | u32 attr_usage_id, u32 report_id) | 242 | u32 attr_usage_id, u32 report_id) |
244 | { | 243 | { |
245 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); | 244 | struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev); |
246 | unsigned long flags; | 245 | unsigned long flags; |
247 | struct hid_report *report; | 246 | struct hid_report *report; |
248 | int ret_val = 0; | 247 | int ret_val = 0; |
@@ -303,7 +302,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, | |||
303 | 302 | ||
304 | /* Initialize with defaults */ | 303 | /* Initialize with defaults */ |
305 | info->usage_id = usage_id; | 304 | info->usage_id = usage_id; |
306 | info->attrib_id = attr_usage_id; | 305 | info->attrib_id = attr_usage_id; |
307 | info->report_id = -1; | 306 | info->report_id = -1; |
308 | info->index = -1; | 307 | info->index = -1; |
309 | info->units = -1; | 308 | info->units = -1; |
@@ -334,7 +333,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev, | |||
334 | if (field->usage[j].hid == | 333 | if (field->usage[j].hid == |
335 | attr_usage_id && | 334 | attr_usage_id && |
336 | field->usage[j].collection_index == | 335 | field->usage[j].collection_index == |
337 | collection_index) { | 336 | collection_index) { |
338 | sensor_hub_fill_attr_info(info, | 337 | sensor_hub_fill_attr_info(info, |
339 | i, report->id, | 338 | i, report->id, |
340 | field->unit, | 339 | field->unit, |
@@ -358,7 +357,7 @@ EXPORT_SYMBOL_GPL(sensor_hub_input_get_attribute_info); | |||
358 | #ifdef CONFIG_PM | 357 | #ifdef CONFIG_PM |
359 | static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message) | 358 | static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message) |
360 | { | 359 | { |
361 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); | 360 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); |
362 | struct hid_sensor_hub_callbacks_list *callback; | 361 | struct hid_sensor_hub_callbacks_list *callback; |
363 | 362 | ||
364 | hid_dbg(hdev, " sensor_hub_suspend\n"); | 363 | hid_dbg(hdev, " sensor_hub_suspend\n"); |
@@ -375,7 +374,7 @@ static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message) | |||
375 | 374 | ||
376 | static int sensor_hub_resume(struct hid_device *hdev) | 375 | static int sensor_hub_resume(struct hid_device *hdev) |
377 | { | 376 | { |
378 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); | 377 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); |
379 | struct hid_sensor_hub_callbacks_list *callback; | 378 | struct hid_sensor_hub_callbacks_list *callback; |
380 | 379 | ||
381 | hid_dbg(hdev, " sensor_hub_resume\n"); | 380 | hid_dbg(hdev, " sensor_hub_resume\n"); |
@@ -395,6 +394,7 @@ static int sensor_hub_reset_resume(struct hid_device *hdev) | |||
395 | return 0; | 394 | return 0; |
396 | } | 395 | } |
397 | #endif | 396 | #endif |
397 | |||
398 | /* | 398 | /* |
399 | * Handle raw report as sent by device | 399 | * Handle raw report as sent by device |
400 | */ | 400 | */ |
@@ -422,7 +422,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev, | |||
422 | spin_lock_irqsave(&pdata->lock, flags); | 422 | spin_lock_irqsave(&pdata->lock, flags); |
423 | 423 | ||
424 | for (i = 0; i < report->maxfield; ++i) { | 424 | for (i = 0; i < report->maxfield; ++i) { |
425 | |||
426 | hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n", | 425 | hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n", |
427 | i, report->field[i]->usage->collection_index, | 426 | i, report->field[i]->usage->collection_index, |
428 | report->field[i]->usage->hid, | 427 | report->field[i]->usage->hid, |
@@ -432,11 +431,10 @@ static int sensor_hub_raw_event(struct hid_device *hdev, | |||
432 | if (pdata->pending.status && pdata->pending.attr_usage_id == | 431 | if (pdata->pending.status && pdata->pending.attr_usage_id == |
433 | report->field[i]->usage->hid) { | 432 | report->field[i]->usage->hid) { |
434 | hid_dbg(hdev, "data was pending ...\n"); | 433 | hid_dbg(hdev, "data was pending ...\n"); |
435 | pdata->pending.raw_data = kmalloc(sz, GFP_ATOMIC); | 434 | pdata->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC); |
436 | if (pdata->pending.raw_data) { | 435 | if (pdata->pending.raw_data) |
437 | memcpy(pdata->pending.raw_data, ptr, sz); | 436 | pdata->pending.raw_size = sz; |
438 | pdata->pending.raw_size = sz; | 437 | else |
439 | } else | ||
440 | pdata->pending.raw_size = 0; | 438 | pdata->pending.raw_size = 0; |
441 | complete(&pdata->pending.ready); | 439 | complete(&pdata->pending.ready); |
442 | } | 440 | } |
@@ -479,16 +477,15 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
479 | struct hid_field *field; | 477 | struct hid_field *field; |
480 | int dev_cnt; | 478 | int dev_cnt; |
481 | 479 | ||
482 | sd = kzalloc(sizeof(struct sensor_hub_data), GFP_KERNEL); | 480 | sd = devm_kzalloc(&hdev->dev, sizeof(*sd), GFP_KERNEL); |
483 | if (!sd) { | 481 | if (!sd) { |
484 | hid_err(hdev, "cannot allocate Sensor data\n"); | 482 | hid_err(hdev, "cannot allocate Sensor data\n"); |
485 | return -ENOMEM; | 483 | return -ENOMEM; |
486 | } | 484 | } |
487 | sd->hsdev = kzalloc(sizeof(struct hid_sensor_hub_device), GFP_KERNEL); | 485 | sd->hsdev = devm_kzalloc(&hdev->dev, sizeof(*sd->hsdev), GFP_KERNEL); |
488 | if (!sd->hsdev) { | 486 | if (!sd->hsdev) { |
489 | hid_err(hdev, "cannot allocate hid_sensor_hub_device\n"); | 487 | hid_err(hdev, "cannot allocate hid_sensor_hub_device\n"); |
490 | ret = -ENOMEM; | 488 | return -ENOMEM; |
491 | goto err_free_hub; | ||
492 | } | 489 | } |
493 | hid_set_drvdata(hdev, sd); | 490 | hid_set_drvdata(hdev, sd); |
494 | sd->hsdev->hdev = hdev; | 491 | sd->hsdev->hdev = hdev; |
@@ -500,14 +497,14 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
500 | ret = hid_parse(hdev); | 497 | ret = hid_parse(hdev); |
501 | if (ret) { | 498 | if (ret) { |
502 | hid_err(hdev, "parse failed\n"); | 499 | hid_err(hdev, "parse failed\n"); |
503 | goto err_free; | 500 | return ret; |
504 | } | 501 | } |
505 | INIT_LIST_HEAD(&hdev->inputs); | 502 | INIT_LIST_HEAD(&hdev->inputs); |
506 | 503 | ||
507 | ret = hid_hw_start(hdev, 0); | 504 | ret = hid_hw_start(hdev, 0); |
508 | if (ret) { | 505 | if (ret) { |
509 | hid_err(hdev, "hw start failed\n"); | 506 | hid_err(hdev, "hw start failed\n"); |
510 | goto err_free; | 507 | return ret; |
511 | } | 508 | } |
512 | ret = hid_hw_open(hdev); | 509 | ret = hid_hw_open(hdev); |
513 | if (ret) { | 510 | if (ret) { |
@@ -540,7 +537,7 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
540 | field->physical) { | 537 | field->physical) { |
541 | name = kasprintf(GFP_KERNEL, "HID-SENSOR-%x", | 538 | name = kasprintf(GFP_KERNEL, "HID-SENSOR-%x", |
542 | field->physical); | 539 | field->physical); |
543 | if (name == NULL) { | 540 | if (name == NULL) { |
544 | hid_err(hdev, "Failed MFD device name\n"); | 541 | hid_err(hdev, "Failed MFD device name\n"); |
545 | ret = -ENOMEM; | 542 | ret = -ENOMEM; |
546 | goto err_free_names; | 543 | goto err_free_names; |
@@ -572,10 +569,6 @@ err_close: | |||
572 | hid_hw_close(hdev); | 569 | hid_hw_close(hdev); |
573 | err_stop_hw: | 570 | err_stop_hw: |
574 | hid_hw_stop(hdev); | 571 | hid_hw_stop(hdev); |
575 | err_free: | ||
576 | kfree(sd->hsdev); | ||
577 | err_free_hub: | ||
578 | kfree(sd); | ||
579 | 572 | ||
580 | return ret; | 573 | return ret; |
581 | } | 574 | } |
@@ -599,8 +592,6 @@ static void sensor_hub_remove(struct hid_device *hdev) | |||
599 | kfree(data->hid_sensor_hub_client_devs); | 592 | kfree(data->hid_sensor_hub_client_devs); |
600 | hid_set_drvdata(hdev, NULL); | 593 | hid_set_drvdata(hdev, NULL); |
601 | mutex_destroy(&data->mutex); | 594 | mutex_destroy(&data->mutex); |
602 | kfree(data->hsdev); | ||
603 | kfree(data); | ||
604 | } | 595 | } |
605 | 596 | ||
606 | static const struct hid_device_id sensor_hub_devices[] = { | 597 | static const struct hid_device_id sensor_hub_devices[] = { |
@@ -618,8 +609,8 @@ static struct hid_driver sensor_hub_driver = { | |||
618 | .raw_event = sensor_hub_raw_event, | 609 | .raw_event = sensor_hub_raw_event, |
619 | #ifdef CONFIG_PM | 610 | #ifdef CONFIG_PM |
620 | .suspend = sensor_hub_suspend, | 611 | .suspend = sensor_hub_suspend, |
621 | .resume = sensor_hub_resume, | 612 | .resume = sensor_hub_resume, |
622 | .reset_resume = sensor_hub_reset_resume, | 613 | .reset_resume = sensor_hub_reset_resume, |
623 | #endif | 614 | #endif |
624 | }; | 615 | }; |
625 | module_hid_driver(sensor_hub_driver); | 616 | module_hid_driver(sensor_hub_driver); |