petc_input_filter: Fix grouping of subdevices
* Add petc_ prefix to clone device names
* Set phys and uniq in clone devices
* Set pat9126 dev phys
Bug: 296340867
Test: Manual
Change-Id: I9da7eace561927b3e07e9e6d32abff79500f19ea
Signed-off-by: Josh Thielen <jtln@google.com>
diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c
index a19967c..bb85126 100644
--- a/ots_pat9126/pat9126.c
+++ b/ots_pat9126/pat9126.c
@@ -1017,6 +1017,7 @@
i2c_set_clientdata(client, data);
input_set_drvdata(input, data);
input->name = PAT9126_DEV_NAME;
+ input->phys = PAT9126_DEV_PHYS;
input->open = pixart_input_open;
input->close = pixart_input_close;
diff --git a/ots_pat9126/pat9126.h b/ots_pat9126/pat9126.h
index 386d3ea..1d0036f 100644
--- a/ots_pat9126/pat9126.h
+++ b/ots_pat9126/pat9126.h
@@ -8,6 +8,7 @@
#define __PIXART_OTS_H_
#define PAT9126_DEV_NAME "pixart_pat9126"
+#define PAT9126_DEV_PHYS "input/rotary"
#define BUF_SIZE 2
#define RESET_DELAY_US 1000
#define VDD_VTG_MIN_UV 1800000
diff --git a/petc_input_filter/petc_input_filter.c b/petc_input_filter/petc_input_filter.c
index a76183a..7ec4101 100644
--- a/petc_input_filter/petc_input_filter.c
+++ b/petc_input_filter/petc_input_filter.c
@@ -31,6 +31,7 @@
#include "nanohub_exports.h"
#define WAKEUP_WAIT_MAX msecs_to_jiffies(500)
+#define PETC_PREFIX "petc_"
struct petc_input_event {
struct list_head node;
@@ -50,6 +51,7 @@
spinlock_t event_list_slock;
struct input_dev *clone_dev;
struct petc_if_drv_data *drv_data;
+ char *clone_name;
bool clone_registered;
};
@@ -303,6 +305,7 @@
error);
input_unregister_handle(&dev_data->handle);
input_free_device(dev_data->clone_dev);
+ kfree(dev_data->clone_name);
kfree(dev_data);
return;
}
@@ -318,6 +321,7 @@
cancel_delayed_work_sync(&dev_data->delayed_work);
petc_if_free_queued_events(dev_data);
input_unregister_device(dev_data->clone_dev);
+ kfree(dev_data->clone_name);
kfree(dev_data);
}
@@ -433,6 +437,7 @@
{
struct petc_if_dev_data *dev_data;
struct input_dev *clone_dev;
+ size_t clone_name_size;
int error;
pr_debug("[PETC_IF] device connected\n");
@@ -441,15 +446,27 @@
if (!dev_data)
return -ENOMEM;
+ clone_name_size = strlen(dev->name) + sizeof(PETC_PREFIX);
+ dev_data->clone_name = kzalloc(clone_name_size, GFP_KERNEL);
+ if (!dev_data->clone_name) {
+ pr_err("[PETC_IF] Failed to allocate clone_name\n");
+ error = -ENOMEM;
+ goto err_free_dev_data;
+ }
+ strncpy(dev_data->clone_name, PETC_PREFIX, clone_name_size);
+ strlcat(dev_data->clone_name, dev->name, clone_name_size);
+
clone_dev = input_allocate_device();
if (clone_dev == NULL) {
pr_err("[PETC_IF] Failed to allocate clone_dev\n");
error = -ENOMEM;
- goto err_free;
+ goto err_free_clone_name;
}
- clone_dev->name = dev->name;
+ clone_dev->name = dev_data->clone_name;
clone_dev->id.bustype = BUS_VIRTUAL;
+ clone_dev->uniq = dev->uniq;
+ clone_dev->phys = dev->phys;
clone_dev->open = petc_if_open_clone;
clone_dev->close = petc_if_close_clone;
@@ -497,7 +514,9 @@
err_free_device:
input_free_device(clone_dev);
-err_free:
+err_free_clone_name:
+ kfree(dev_data->clone_name);
+err_free_dev_data:
kfree(dev_data);
return error;
}