summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Chen <rickctchen@google.com>2021-10-15 17:09:15 +0800
committerRick Chen <rickctchen@google.com>2021-10-18 14:53:01 +0800
commita3382f8776777857087a697e27fceade09272c5a (patch)
tree1ea8fb8b701514c39df9c0192ee3331639348638
parentef4b72763c3cff50dd2f5ec8e5bd7af51be9160a (diff)
downloadhall_sensor-a3382f8776777857087a697e27fceade09272c5a.tar.gz
Bug: 203044439 Test: Compile and load on P7. Hall sensor is enabled. Signed-off-by: Rick Chen <rickctchen@google.com> Change-Id: Ib59e3d9412b4f6cd1d12316b7f499f68f353b053
-rw-r--r--hall_sensor.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/hall_sensor.c b/hall_sensor.c
index 5031b03..ef717b1 100644
--- a/hall_sensor.c
+++ b/hall_sensor.c
@@ -90,14 +90,15 @@ static void hall_sensor_close(struct input_dev *input)
gpio_to_irq(hall_data->irq_gpio));
}
-static void create_input_device(struct hall_sensor_drv_data *hall_data) {
+static int create_input_device(struct hall_sensor_drv_data *hall_data) {
struct device *dev = hall_data->dev;
struct input_dev *input;
+ int ret;
input = devm_input_allocate_device(dev);
if (!input) {
dev_err(dev, "Failed to allocate input device\n");
- return;
+ return -ENOMEM;
}
hall_data->input = input;
@@ -116,13 +117,14 @@ static void create_input_device(struct hall_sensor_drv_data *hall_data) {
set_bit(EV_SYN, input->evbit);
input_set_capability(input, EV_SW, SW_LID);
- if (input_register_device(input)) {
+ ret = input_register_device(input);
+ if (ret) {
dev_err(dev, "Failed to register input device\n");
hall_data->input = NULL;
input_free_device(input);
}
- return;
+ return ret;
}
static void destroy_input_device(struct hall_sensor_drv_data *hall_data) {
@@ -249,6 +251,12 @@ static int hall_sensor_probe(struct platform_device *pdev) {
hall_data->irq_enabled = false;
hall_data->prev_state = -1;
+ ret = create_input_device(hall_data);
+ if (ret) {
+ dev_err(dev, "Failed to create input device with error %d.\n", ret);
+ return ret;
+ }
+
ret = sysfs_create_group(&dev->kobj, &attribute_group);
if (ret) {
dev_err(dev, "Failed to create sysfs with error %d.\n", ret);