提交 476b9547 编写于 作者: S Srinivas Pandruvada 提交者: Jonathan Cameron

HID RTC: Open sensor hub open close

Open sensor hub when module is loaded and close when module is removed.
This helps saving power by opening HID transport only when there is an
user.
Signed-off-by: NSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: NAlessandro Zummo <a.zummo@towertech.it>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 0a440ee9
...@@ -275,6 +275,12 @@ static int hid_time_probe(struct platform_device *pdev) ...@@ -275,6 +275,12 @@ static int hid_time_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = sensor_hub_device_open(hsdev);
if (ret) {
dev_err(&pdev->dev, "failed to open sensor hub device!\n");
goto err_open;
}
time_state->rtc = devm_rtc_device_register(&pdev->dev, time_state->rtc = devm_rtc_device_register(&pdev->dev,
"hid-sensor-time", &hid_time_rtc_ops, "hid-sensor-time", &hid_time_rtc_ops,
THIS_MODULE); THIS_MODULE);
...@@ -282,17 +288,24 @@ static int hid_time_probe(struct platform_device *pdev) ...@@ -282,17 +288,24 @@ static int hid_time_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(time_state->rtc)) { if (IS_ERR_OR_NULL(time_state->rtc)) {
ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV; ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV;
time_state->rtc = NULL; time_state->rtc = NULL;
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
dev_err(&pdev->dev, "rtc device register failed!\n"); dev_err(&pdev->dev, "rtc device register failed!\n");
goto err_rtc;
} }
return ret; return ret;
err_rtc:
sensor_hub_device_close(hsdev);
err_open:
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
return ret;
} }
static int hid_time_remove(struct platform_device *pdev) static int hid_time_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
sensor_hub_device_close(hsdev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册