diff options
| -rw-r--r-- | drivers/hid/hid-sensor-hub.c | 13 | ||||
| -rw-r--r-- | include/linux/hid-sensor-hub.h | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index c3f6f1e311ea..090a1ba0abb6 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -294,7 +294,7 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, | |||
| 294 | if (!report) | 294 | if (!report) |
| 295 | return -EINVAL; | 295 | return -EINVAL; |
| 296 | 296 | ||
| 297 | mutex_lock(&hsdev->mutex); | 297 | mutex_lock(hsdev->mutex_ptr); |
| 298 | if (flag == SENSOR_HUB_SYNC) { | 298 | if (flag == SENSOR_HUB_SYNC) { |
| 299 | memset(&hsdev->pending, 0, sizeof(hsdev->pending)); | 299 | memset(&hsdev->pending, 0, sizeof(hsdev->pending)); |
| 300 | init_completion(&hsdev->pending.ready); | 300 | init_completion(&hsdev->pending.ready); |
| @@ -328,7 +328,7 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev, | |||
| 328 | kfree(hsdev->pending.raw_data); | 328 | kfree(hsdev->pending.raw_data); |
| 329 | hsdev->pending.status = false; | 329 | hsdev->pending.status = false; |
| 330 | } | 330 | } |
| 331 | mutex_unlock(&hsdev->mutex); | 331 | mutex_unlock(hsdev->mutex_ptr); |
| 332 | 332 | ||
| 333 | return ret_val; | 333 | return ret_val; |
| 334 | } | 334 | } |
| @@ -667,7 +667,14 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
| 667 | hsdev->vendor_id = hdev->vendor; | 667 | hsdev->vendor_id = hdev->vendor; |
| 668 | hsdev->product_id = hdev->product; | 668 | hsdev->product_id = hdev->product; |
| 669 | hsdev->usage = collection->usage; | 669 | hsdev->usage = collection->usage; |
| 670 | mutex_init(&hsdev->mutex); | 670 | hsdev->mutex_ptr = devm_kzalloc(&hdev->dev, |
| 671 | sizeof(struct mutex), | ||
| 672 | GFP_KERNEL); | ||
| 673 | if (!hsdev->mutex_ptr) { | ||
| 674 | ret = -ENOMEM; | ||
| 675 | goto err_stop_hw; | ||
| 676 | } | ||
| 677 | mutex_init(hsdev->mutex_ptr); | ||
| 671 | hsdev->start_collection_index = i; | 678 | hsdev->start_collection_index = i; |
| 672 | if (last_hsdev) | 679 | if (last_hsdev) |
| 673 | last_hsdev->end_collection_index = i; | 680 | last_hsdev->end_collection_index = i; |
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 0408421d885f..0042bf330b99 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h | |||
| @@ -74,7 +74,7 @@ struct sensor_hub_pending { | |||
| 74 | * @usage: Usage id for this hub device instance. | 74 | * @usage: Usage id for this hub device instance. |
| 75 | * @start_collection_index: Starting index for a phy type collection | 75 | * @start_collection_index: Starting index for a phy type collection |
| 76 | * @end_collection_index: Last index for a phy type collection | 76 | * @end_collection_index: Last index for a phy type collection |
| 77 | * @mutex: synchronizing mutex. | 77 | * @mutex_ptr: synchronizing mutex pointer. |
| 78 | * @pending: Holds information of pending sync read request. | 78 | * @pending: Holds information of pending sync read request. |
| 79 | */ | 79 | */ |
| 80 | struct hid_sensor_hub_device { | 80 | struct hid_sensor_hub_device { |
| @@ -84,7 +84,7 @@ struct hid_sensor_hub_device { | |||
| 84 | u32 usage; | 84 | u32 usage; |
| 85 | int start_collection_index; | 85 | int start_collection_index; |
| 86 | int end_collection_index; | 86 | int end_collection_index; |
| 87 | struct mutex mutex; | 87 | struct mutex *mutex_ptr; |
| 88 | struct sensor_hub_pending pending; | 88 | struct sensor_hub_pending pending; |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
