@@ -34,6 +34,7 @@ static struct dentry *rmi_debugfs_root;
static void rmi_release_device(struct device *dev)
{
struct rmi_device *rmi_dev = to_rmi_device(dev);
+
kfree(rmi_dev);
}
@@ -94,8 +95,7 @@ int rmi_register_transport_device(struct
rmi_transport_dev *xport)
return -EINVAL;
}
- rmi_dev = devm_kzalloc(xport->dev,
- sizeof(struct rmi_device), GFP_KERNEL);
+ rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
if (!rmi_dev)
return -ENOMEM;
@@ -112,8 +112,10 @@ int rmi_register_transport_device(struct
rmi_transport_dev *xport)
rmi_physical_setup_debugfs(rmi_dev);
error = device_register(&rmi_dev->dev);
- if (error)
+ if (error) {
+ put_device(&rmi_dev->dev);
return error;
+ }
dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
pdata->sensor_name, dev_name(&rmi_dev->dev));
@@ -142,6 +144,7 @@ EXPORT_SYMBOL(rmi_unregister_transport_device);
static void rmi_release_function(struct device *dev)
{
struct rmi_function *fn = to_rmi_function(dev);
+
kfree(fn);
}
@@ -240,16 +243,14 @@ int rmi_register_function(struct rmi_function *fn)
dev_err(&rmi_dev->dev,
"Failed device_register function device %s\n",
dev_name(&fn->dev));
- goto error_exit;
+ rmi_function_teardown_debugfs(fn);
+ put_device(&fn->dev);
+ return error;
}
dev_dbg(&rmi_dev->dev, "Registered F%02X.\n", fn->fd.function_number);
return 0;
-
-error_exit:
- rmi_function_teardown_debugfs(fn);
- return error;
}
void rmi_unregister_function(struct rmi_function *fn)
@@ -47,13 +47,13 @@ struct rmi_function {
struct device dev;
int num_of_irqs;
int irq_pos;
- unsigned long *irq_mask;
void *data;
struct list_head node;
#ifdef CONFIG_RMI4_DEBUG
struct dentry *debugfs_root;
#endif
+ unsigned long irq_mask[];
};
#define to_rmi_function(d) container_of(d, struct rmi_function, dev)
b/drivers/input/rmi4/rmi_driver.c
@@ -185,7 +185,6 @@ static void rmi_free_function_list(struct rmi_device
*rmi_dev)
list_for_each_entry_safe_reverse(fn, tmp,
&data->function_list, node) {
list_del(&fn->node);
- kfree(fn->irq_mask);
rmi_unregister_function(fn);
}