Input RMI4 - rename rmi_function_container to rmi_function
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/4 Input RMI4 - rename rmi_function_container to rmi_function
To save my old fingers...
---
It looks like this driver(s) need some love and I might have some time so I will refresh my "synaptics" branch with the patches you have sent and start working off it. If you have updates I would appreciate if you also make them available relative to that branch. When we are ready we'll squash them all together and apply to the official branch.
Thanks.
drivers/input/rmi4/rmi_driver.c | 158 +++++++++++---------- drivers/input/rmi4/rmi_driver.h | 4 +- drivers/input/rmi4/rmi_f01.c | 298 ++++++++++++++++++++-------------------- drivers/input/rmi4/rmi_f11.c | 258 +++++++++++++++++----------------- include/linux/rmi.h | 22 ++- 5 files changed, 368 insertions(+), 372 deletions(-)
drivers/input/rmi4/rmi_driver.c +78 -80
@@ -594,7 +594,7 @@ static struct device_attribute bsr_attribute = __ATTR(bsr, RMI_RW_ATTR,static void rmi_free_function_list (struct rmi_device *rmi_dev) { -struct rmi_function_container *entry, *n; +struct rmi_function *entry, *n;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);if (!data) {
@@ -613,44 +613,44 @@ static void rmi_free_function_list(struct rmi_device *rmi_dev) } } -static void release_fc_device (struct device *dev) +static void release_function_device (struct device *dev) {dev_dbg (dev,"REMOVING KOBJ!" );kobject_put (&dev->kobj); } -static int reset_one_function (struct rmi_function_container *fc) +static int reset_one_function (struct rmi_function *fn) {struct rmi_function_handler *fh;int retval =0 ; -if (!fc || !fc->dev.driver) +if (!fn || !fn->dev.driver)return 0 ; - fh =to_rmi_function_handler (fc->dev.driver); + fh =to_rmi_function_handler (fn->dev.driver);if (fh->reset) { - retval = fh->reset (fc); + retval = fh->reset (fn);if (retval <0 ) -dev_err (&fc->dev,"Reset failed with code %d.\n" , +dev_err (&fn->dev,"Reset failed with code %d.\n" , retval); }return retval; } -static int configure_one_function (struct rmi_function_container *fc) +static int configure_one_function (struct rmi_function *fn) {struct rmi_function_handler *fh;int retval =0 ; -if (!fc || !fc->dev.driver) +if (!fn || !fn->dev.driver)return 0 ; - fh =to_rmi_function_handler (fc->dev.driver); + fh =to_rmi_function_handler (fn->dev.driver);if (fh->config) { - retval = fh->config (fc); + retval = fh->config (fn);if (retval <0 ) -dev_err (&fc->dev,"Config failed with code %d.\n" , +dev_err (&fn->dev,"Config failed with code %d.\n" , retval); }
@@ -660,7 +660,7 @@ static int configure_one_function(struct rmi_function_container *fc)static int rmi_driver_process_reset_requests (struct rmi_device *rmi_dev) {struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); -struct rmi_function_container *entry; +struct rmi_function *entry;int retval;if (list_empty (&data->rmi_functions.list))
@@ -678,7 +678,7 @@ static int rmi_driver_process_reset_requests(struct rmi_device *rmi_dev)static int rmi_driver_process_config_requests (struct rmi_device *rmi_dev) {struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); -struct rmi_function_container *entry; +struct rmi_function *entry;int retval;if (list_empty (&data->rmi_functions.list))
@@ -693,30 +693,29 @@ static int rmi_driver_process_config_requests(struct rmi_device *rmi_dev)return 0 ; } -static void process_one_interrupt (struct rmi_function_container *fc, +static void process_one_interrupt (struct rmi_function *fn,unsigned long *irq_status,struct rmi_driver_data *data) {struct rmi_function_handler *fh;DECLARE_BITMAP (irq_bits, data->num_of_irq_regs); -if (!fc || !fc->dev.driver) +if (!fn || !fn->dev.driver)return ; - fh =to_rmi_function_handler (fc->dev.driver); -if (fc->irq_mask && fh->attention) { -bitmap_and (irq_bits, irq_status, fc->irq_mask, + fh =to_rmi_function_handler (fn->dev.driver); +if (fn->irq_mask && fh->attention) { +bitmap_and (irq_bits, irq_status, fn->irq_mask, data->irq_count);if (!bitmap_empty (irq_bits, data->irq_count)) - fh->attention (fc, irq_bits); + fh->attention (fn, irq_bits); } - }static int process_interrupt_requests (struct rmi_device *rmi_dev) {struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);struct device *dev = &rmi_dev->dev; -struct rmi_function_container *entry; +struct rmi_function *entry;int error; error = rmi_read_block(rmi_dev,
@@ -904,65 +903,65 @@ static int rmi_driver_reset_handler(struct rmi_device *rmi_dev)* Construct a function's IRQ mask. This should be called once and stored. */ int rmi_driver_irq_get_mask (struct rmi_device *rmi_dev, -struct rmi_function_container *fc) { +struct rmi_function *fn) {int i;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);/* call devm_kcalloc when it will be defined in kernel in future */ - fc->irq_mask =devm_kzalloc (&rmi_dev->dev, + fn->irq_mask =devm_kzalloc (&rmi_dev->dev,BITS_TO_LONGS (data->irq_count)*sizeof (unsigned long ),GFP_KERNEL ); -if (fc->irq_mask) { -for (i =0 ; i < fc->num_of_irqs; i++) -set_bit (fc->irq_pos+i, fc->irq_mask); +if (fn->irq_mask) { +for (i =0 ; i < fn->num_of_irqs; i++) +set_bit (fn->irq_pos+i, fn->irq_mask);return 0 ; }else return -ENOMEM ; }static int init_function_device (struct rmi_device *rmi_dev, -struct rmi_function_container *fc) +struct rmi_function *fn) {int retval;/* This memset might not be what we want to do... */ -memset (&(fc->dev),0 ,sizeof (struct device )); -dev_set_name (&(fc->dev),"%s.fn%02x" ,dev_name (&rmi_dev->dev), - fc->fd.function_number); - fc->dev.release = release_fc_device; - - fc->dev.parent = &rmi_dev->dev; - fc->dev.type = &rmi_function_type; - fc->dev.bus = &rmi_bus_type; -dev_dbg (&rmi_dev->dev,"Register F%02X.\n" , fc->fd.function_number); - retval =device_register (&fc->dev); +memset (&fn->dev,0 ,sizeof (struct device )); +dev_set_name (&fn->dev,"%s.fn%02x" ,dev_name (&rmi_dev->dev), + fn->fd.function_number); + fn->dev.release = release_function_device; + + fn->dev.parent = &rmi_dev->dev; + fn->dev.type = &rmi_function_type; + fn->dev.bus = &rmi_bus_type; +dev_dbg (&rmi_dev->dev,"Register F%02X.\n" , fn->fd.function_number); + retval =device_register (&fn->dev);if (retval) {dev_err (&rmi_dev->dev,"Failed device_register for F%02X.\n" , - fc->fd.function_number); + fn->fd.function_number);return retval; }if (IS_ENABLED (CONFIG_RMI4_DEBUG )) {char dirname[12 ]; -snprintf (dirname,12 ,"F%02X" , fc->fd.function_number); - fc->debugfs_root =debugfs_create_dir (dirname, +snprintf (dirname,12 ,"F%02X" , fn->fd.function_number); + fn->debugfs_root =debugfs_create_dir (dirname, rmi_dev->debugfs_root); -if (!fc->debugfs_root) -dev_warn (&fc->dev,"Failed to create debugfs dir.\n" ); +if (!fn->debugfs_root) +dev_warn (&fn->dev,"Failed to create debugfs dir.\n" ); }return 0 ; } -static int create_function_container (struct rmi_device *rmi_dev, +static int create_function (struct rmi_device *rmi_dev,struct pdt_entry *pdt_ptr,int *current_irq_count,u16 page_start) {struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev); -struct rmi_function_container *fc =NULL ; +struct rmi_function *fn =NULL ;int retval =0 ;struct device *dev = &rmi_dev->dev;struct rmi_device_platform_data *pdata;
@@ -972,37 +971,37 @@ static int create_function_container(struct rmi_device *rmi_dev,dev_dbg (dev,"Initializing F%02X for %s.\n" , pdt_ptr->function_number, pdata->sensor_name); - fc =devm_kzalloc (dev,sizeof (struct rmi_function_container ), + fn =devm_kzalloc (dev,sizeof (struct rmi_function ),GFP_KERNEL ); -if (!fc) { +if (!fn) {dev_err (dev,"Failed to allocate F%02X container.\n" , pdt_ptr->function_number);return -ENOMEM ; } -copy_pdt_entry_to_fd (pdt_ptr, &fc->fd, page_start); +copy_pdt_entry_to_fd (pdt_ptr, &fn->fd, page_start); - fc->rmi_dev = rmi_dev; - fc->num_of_irqs = pdt_ptr->interrupt_source_count; + fn->rmi_dev = rmi_dev; + fn->num_of_irqs = pdt_ptr->interrupt_source_count; - fc->irq_pos = *current_irq_count; - *current_irq_count += fc->num_of_irqs; + fn->irq_pos = *current_irq_count; + *current_irq_count += fn->num_of_irqs; - retval =init_function_device (rmi_dev, fc); + retval =init_function_device (rmi_dev, fn);if (retval <0 ) {dev_err (dev,"Failed to initialize F%02X device.\n" , pdt_ptr->function_number); goto error_free_data; } -INIT_LIST_HEAD (&fc->list); +INIT_LIST_HEAD (&fn->list);/* we need to ensure that F01 is at the head of the list. */ if (pdt_ptr->function_number ==0x01 ) { -list_add (&fc->list, &data->rmi_functions.list); - data->f01_container = fc; +list_add (&fn->list, &data->rmi_functions.list); + data->f01_container = fn; }else -list_add_tail (&fc->list, &data->rmi_functions.list); +list_add_tail (&fn->list, &data->rmi_functions.list);return 0 ; error_free_data:
@@ -1032,7 +1031,6 @@ static void check_bootloader_mode(struct rmi_device *rmi_dev,if (device_status.flash_prog)dev_warn (&rmi_dev->dev,"WARNING: RMI4 device is in bootloader mode!\n" ); - }/*
@@ -1203,7 +1201,7 @@ static int rmi_scan_pdt(struct rmi_device *rmi_dev) page_start); - retval =create_function_container (rmi_dev, + retval =create_function (rmi_dev, &pdt_entry, &irq_count, page_start);if (retval)
@@ -1228,23 +1226,23 @@ static int f01_notifier_call(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; -struct rmi_function_container *fc; +struct rmi_function *fn;if (dev->type != &rmi_function_type)return 0 ; - fc =to_rmi_function_container (dev); -if (fc->fd.function_number !=0x01 ) + fn =to_rmi_function (dev); +if (fn->fd.function_number !=0x01 )return 0 ;switch (action) {case BUS_NOTIFY_BOUND_DRIVER :dev_dbg (dev,"%s: F01 driver bound.\n" , __func__); -enable_sensor (fc->rmi_dev); +enable_sensor (fn->rmi_dev);break ;case BUS_NOTIFY_UNBIND_DRIVER :dev_dbg (dev,"%s: F01 driver going away.\n" , __func__); -disable_sensor (fc->rmi_dev); +disable_sensor (fn->rmi_dev);break ; }return 0 ;
@@ -1255,20 +1253,20 @@ static struct notifier_block rmi_bus_notifier = { };#ifdef CONFIG_PM -static int suspend_one_device (struct rmi_function_container *fc) +static int suspend_one_device (struct rmi_function *fn) {struct rmi_function_handler *fh;int retval =0 ; -if (!fc->dev.driver) +if (!fn->dev.driver)return 0 ; - fh =to_rmi_function_handler (fc->dev.driver); + fh =to_rmi_function_handler (fn->dev.driver);if (fh->suspend) { - retval = fh->suspend (fc); + retval = fh->suspend (fn);if (retval <0 ) -dev_err (&fc->dev,"Suspend failed, code: %d" , +dev_err (&fn->dev,"Suspend failed, code: %d" , retval); }
@@ -1278,7 +1276,7 @@ static int suspend_one_device(struct rmi_function_container *fc)static int rmi_driver_suspend (struct device *dev) {struct rmi_driver_data *data; -struct rmi_function_container *entry; +struct rmi_function *entry;int retval =0 ;struct rmi_device *rmi_dev =to_rmi_device (dev);
@@ -1311,20 +1309,20 @@ exit:return retval; } -static int resume_one_device (struct rmi_function_container *fc) +static int resume_one_device (struct rmi_function *fn) {struct rmi_function_handler *fh;int retval =0 ; -if (!fc->dev.driver) +if (!fn->dev.driver)return 0 ; - fh =to_rmi_function_handler (fc->dev.driver); + fh =to_rmi_function_handler (fn->dev.driver);if (fh->resume) { - retval = fh->resume (fc); + retval = fh->resume (fn);if (retval <0 ) -dev_err (&fc->dev,"Resume failed, code: %d" , +dev_err (&fn->dev,"Resume failed, code: %d" , retval); }
@@ -1334,7 +1332,7 @@ static int resume_one_device(struct rmi_function_container *fc)static int rmi_driver_resume (struct device *dev) {struct rmi_driver_data *data; -struct rmi_function_container *entry; +struct rmi_function *entry;int retval =0 ;struct rmi_device *rmi_dev =to_rmi_device (dev);
@@ -1399,7 +1397,7 @@ static int __devinit rmi_driver_probe(struct device *dev) {struct rmi_driver *rmi_driver;struct rmi_driver_data *data =NULL ; -struct rmi_function_container *fc; +struct rmi_function *fn;struct rmi_device_platform_data *pdata;int retval =0 ;int attr_count =0 ;
@@ -1467,8 +1465,8 @@ static int __devinit rmi_driver_probe(struct device *dev) goto err_free_data; } -list_for_each_entry (fc, &data->rmi_functions.list, list) { - retval =rmi_driver_irq_get_mask (rmi_dev, fc); +list_for_each_entry (fn, &data->rmi_functions.list, list) { + retval =rmi_driver_irq_get_mask (rmi_dev, fn);if (retval <0 ) {dev_err (dev,"%s: Failed to create irq_mask.\n" , __func__);
@@ -1573,7 +1571,7 @@ static int __devinit rmi_driver_probe(struct device *dev)if (IS_ENABLED (CONFIG_RMI4_DEBUG )) { retval =setup_debugfs (rmi_dev);if (retval <0 ) -dev_warn (&fc->dev,"Failed to setup debugfs. Code: %d.\n" , +dev_warn (&fn->dev,"Failed to setup debugfs. Code: %d.\n" , retval); }
drivers/input/rmi4/rmi_driver.h +2 -2
@@ -44,10 +44,10 @@ struct pdt_properties { } __attribute__((__packed__));struct rmi_driver_data { -struct rmi_function_container rmi_functions; +struct rmi_function rmi_functions;struct rmi_device *rmi_dev; -struct rmi_function_container *f01_container; +struct rmi_function *f01_container;bool f01_bootloader_mode;atomic_t attn_count;
drivers/input/rmi4/rmi_f01.c +149 -149
830 lines not on this page · raw message
drivers/input/rmi4/rmi_f11.c +129 -129
776 lines not on this page · raw message
include/linux/rmi.h +10 -12
@@ -338,7 +338,7 @@ struct rmi_function_descriptor {u8 function_version; }; -struct rmi_function_container ; +struct rmi_function ;struct rmi_device ;/**
@@ -365,13 +365,12 @@ struct rmi_function_handler {struct device_driver driver;u8 func; -int (*config)(struct rmi_function_container *fc); -int (*reset)(struct rmi_function_container *fc); -int (*attention)(struct rmi_function_container *fc, -unsigned long *irq_bits); +int (*config)(struct rmi_function *fn); +int (*reset)(struct rmi_function *fn); +int (*attention)(struct rmi_function *fn,unsigned long *irq_bits);#ifdef CONFIG_PM -int (*suspend)(struct rmi_function_container *fc); -int (*resume)(struct rmi_function_container *fc); +int (*suspend)(struct rmi_function *fn); +int (*resume)(struct rmi_function *fn);#endif };
@@ -379,7 +378,7 @@ struct rmi_function_handler { container_of(d, struct rmi_function_handler, driver)/** -* struct rmi_function_container - represents the implementation of an RMI4 +* struct rmi_function - represents the implementation of an RMI4 * function for a particular device (basically, a driver for that RMI4 function) * * @fd: The function descriptor of the RMI function
@@ -396,8 +395,7 @@ struct rmi_function_handler {* @debugfs_root: used during debugging * */ -struct rmi_function_container { - +struct rmi_function {struct rmi_function_descriptor fd;struct rmi_device *rmi_dev;struct device dev;
@@ -412,8 +410,8 @@ struct rmi_function_container {#endif }; -#define to_rmi_function_container (d) \ - container_of(d, struct rmi_function_container, dev) +#define to_rmi_function (d) \ + container_of(d, struct rmi_function, dev)/** * struct rmi_driver - driver for an RMI4 sensor on the RMI bus.
Signature · 1 line
1.7.11.7
Dmitry Torokhov
maintainerPATCH 3/4 Input: RMI4 - move function registration into the core
This saves on boilerplate code that is needed in individual modules implementing function handlers.
Also converted bool bitfields back to u8.
--- drivers/input/rmi4/rmi_bus.c | 189 ++++++++++++++++++++++-------- drivers/input/rmi4/rmi_driver.c | 2 +- drivers/input/rmi4/rmi_driver.h | 6 +- drivers/input/rmi4/rmi_f01.c | 57 ++------- drivers/input/rmi4/rmi_f11.c | 250 +++++++++++++++++----------------------- include/linux/rmi.h | 9 ++ 6 files changed, 271 insertions(+), 242 deletions(-)
drivers/input/rmi4/rmi_bus.c +140 -49
@@ -73,51 +73,6 @@ static atomic_t physical_device_count = ATOMIC_INIT(0);static struct dentry *rmi_debugfs_root;#endif -#ifdef CONFIG_PM -static int rmi_bus_suspend (struct device *dev) -{ -struct device_driver *driver = dev->driver; -const struct dev_pm_ops *pm; - -if (!driver) -return 0 ; - - pm = driver->pm; -if (pm && pm->suspend) -return pm->suspend (dev); -if (driver->suspend) -return driver->suspend (dev,PMSG_SUSPEND ); - -return 0 ; -} - -static int rmi_bus_resume (struct device *dev) -{ -struct device_driver *driver = dev->driver; -const struct dev_pm_ops *pm; - -if (!driver) -return 0 ; - - pm = driver->pm; -if (pm && pm->resume) -return pm->resume (dev); -if (driver->resume) -return driver->resume (dev); - -return 0 ; -} -#endif - -static SIMPLE_DEV_PM_OPS(rmi_bus_pm_ops, - rmi_bus_suspend, rmi_bus_resume); - -struct bus_type rmi_bus_type = { - .name ="rmi" , - .pm = &rmi_bus_pm_ops -}; -EXPORT_SYMBOL_GPL (rmi_bus_type); -static void release_rmidev_device (struct device *dev) {device_unregister (dev);
@@ -184,6 +139,142 @@ void rmi_unregister_phys_device(struct rmi_phys_device *phys)EXPORT_SYMBOL (rmi_unregister_phys_device);/** +* rmi_register_function_handler - register a handler for an RMI function +* @handler: RMI handler that should be registered. +* @module: pointer to module that implements the handler +* @mod_name: name of the module implementing the handler +* +* This function performs additional setup of RMI function handler and +* registers it with the RMI core so that it can be bound to +* RMI function devices. +*/ +int __rmi_register_function_handler (struct rmi_function_handler *handler, +struct module *owner, +const char *mod_name) +{ +int error; + + handler->driver.bus = &rmi_bus_type; + handler->driver.owner = owner; + handler->driver.mod_name = mod_name; + + error =driver_register (&handler->driver); +if (error) { +pr_err ("driver_register() failed for %s, error: %d\n" , + handler->driver.name, error); +return error; + } + +return 0 ; +} +EXPORT_SYMBOL (__rmi_register_function_handler); + +/** +* rmi_unregister_function_handler - unregister given RMI function handler +* @handler: RMI handler that should be unregistered. +* +* This function unregisters given function handler from RMI core which +* causes it to be unbound from the function devices. +*/ +void rmi_unregister_function_handler (struct rmi_function_handler *handler) +{ +driver_unregister (&handler->driver); +} +EXPORT_SYMBOL (rmi_unregister_function_handler); + + +static int rmi_function_match (struct device *dev,struct device_driver *drv) +{ +struct rmi_function_handler *handler; +struct rmi_function *fn; + +if (dev->type != &rmi_function_type) +return 0 ; + +if (drv == &rmi_sensor_driver.driver) +return 0 ; + + fn =to_rmi_function (dev); + handler =to_rmi_function_handler (drv); + +return fn->fd.function_number == handler->func; +} + +static int rmi_function_probe (struct device *dev) +{ +struct rmi_function *fn =to_rmi_function (dev); +struct rmi_function_handler *handler = +to_rmi_function_handler (dev->driver); +int error; + +if (handler->probe) { + error = handler->probe (fn); +return error; + } + +return 0 ; +} + +static int rmi_function_remove (struct device *dev) +{ +struct rmi_function *fn =to_rmi_function (dev); +struct rmi_function_handler *handler = +to_rmi_function_handler (dev->driver); + +if (handler->remove) + handler->remove (fn); + +return 0 ; +} + +#ifdef CONFIG_PM +static int rmi_bus_suspend (struct device *dev) +{ +struct device_driver *driver = dev->driver; +const struct dev_pm_ops *pm; + +if (!driver) +return 0 ; + + pm = driver->pm; +if (pm && pm->suspend) +return pm->suspend (dev); +if (driver->suspend) +return driver->suspend (dev,PMSG_SUSPEND ); + +return 0 ; +} + +static int rmi_bus_resume (struct device *dev) +{ +struct device_driver *driver = dev->driver; +const struct dev_pm_ops *pm; + +if (!driver) +return 0 ; + + pm = driver->pm; +if (pm && pm->resume) +return pm->resume (dev); +if (driver->resume) +return driver->resume (dev); + +return 0 ; +} +#endif + +static SIMPLE_DEV_PM_OPS(rmi_bus_pm_ops, + rmi_bus_suspend, rmi_bus_resume); + +struct bus_type rmi_bus_type = { + .match = rmi_function_match, + .probe = rmi_function_probe, + .remove = rmi_function_remove, + .name ="rmi" , + .pm = &rmi_bus_pm_ops, +}; + +/** * rmi_for_each_dev - provides a way for other parts of the system to enumerate * the devices on the RMI bus. *
@@ -198,7 +289,7 @@ int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data))mutex_unlock (&rmi_bus_mutex);return retval; } -EXPORT_SYMBOL_GPL (rmi_for_each_dev); +EXPORT_SYMBOL (rmi_for_each_dev);static int __init rmi_bus_init (void ) {
@@ -213,7 +304,7 @@ static int __init rmi_bus_init(void)return error; } - error =rmi_register_f01_handler (); + error =rmi_register_function_handler (&rmi_f01_handler);if (error) {pr_err ("%s: error registering the RMI F01 handler: %d\n" , __func__, error);
@@ -242,7 +333,7 @@ static int __init rmi_bus_init(void)return 0 ; err_unregister_f01: -rmi_unregister_f01_handler (); +rmi_unregister_function_handler (&rmi_f01_handler); err_unregister_bus:bus_unregister (&rmi_bus_type);return error;
@@ -258,7 +349,7 @@ static void __exit rmi_bus_exit(void)debugfs_remove (rmi_debugfs_root);rmi_unregister_sensor_driver (); -rmi_unregister_f01_handler (); +rmi_unregister_function_handler (&rmi_f01_handler);bus_unregister (&rmi_bus_type); }
drivers/input/rmi4/rmi_driver.c +1 -1
@@ -1608,7 +1608,7 @@ static int __devinit rmi_driver_probe(struct device *dev) static UNIVERSAL_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume, NULL); -static struct rmi_driver rmi_sensor_driver = { +struct rmi_driver rmi_sensor_driver = { .driver = { .owner =THIS_MODULE , .name ="rmi_generic" ,
drivers/input/rmi4/rmi_driver.h +3 -3
@@ -136,10 +136,10 @@ extern void rmi4_fw_update(struct rmi_device *rmi_dev,#define rmi4_fw_update (rmi_dev, f01_pdt, f34_pdt)#endif +extern struct rmi_driver rmi_sensor_driver; +extern struct rmi_function_handler rmi_f01_handler; +int rmi_register_sensor_driver (void );void rmi_unregister_sensor_driver (void ); -int rmi_register_f01_handler (void ); -void rmi_unregister_f01_handler (void ); -#endif
drivers/input/rmi4/rmi_f01.c +12 -45
95 lines not on this page · raw message
drivers/input/rmi4/rmi_f11.c +106 -144
403 lines not on this page · raw message
include/linux/rmi.h +9 -0
@@ -365,6 +365,8 @@ struct rmi_function_handler {struct device_driver driver;u8 func; +int (*probe)(struct rmi_function *fn); +void (*remove)(struct rmi_function *fn);int (*config)(struct rmi_function *fn);int (*reset)(struct rmi_function *fn);int (*attention)(struct rmi_function *fn,unsigned long *irq_bits);
@@ -377,6 +379,13 @@ struct rmi_function_handler {#define to_rmi_function_handler (d) \ container_of(d, struct rmi_function_handler, driver) +int __must_check __rmi_register_function_handler (struct rmi_function_handler *, +struct module *,const char *); +#define rmi_register_function_handler (handler) \ + __rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME) + +void rmi_unregister_function_handler (struct rmi_function_handler *); +/** * struct rmi_function - represents the implementation of an RMI4 * function for a particular device (basically, a driver for that RMI4 function)
Signature · 1 line
1.7.11.7
Dmitry Torokhov
maintainerPATCH 4/4 Input: RMI4 - introduce rmi_module_driver() macro
In reply to Dmitry TorokhovThis also allows us to cut down on the boilerplate code in the function handler modules.
--- drivers/input/rmi4/rmi_f11.c | 13 +------------ include/linux/rmi.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-)
drivers/input/rmi4/rmi_f11.c +1 -12
@@ -2756,18 +2756,7 @@ static struct rmi_function_handler rmi_f11_handler = {#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ }; -static int __init rmi_f11_module_init (void ) -{ -return rmi_register_function_handler (&rmi_f11_handler); -} - -static void __exit rmi_f11_module_exit(void) -{ -rmi_unregister_function_handler (&rmi_f11_handler); -} - -module_init (rmi_f11_module_init); -module_exit (rmi_f11_module_exit); +module_rmi_driver (rmi_f11_handler);MODULE_AUTHOR ("Christopher Heiny <[email protected]" );MODULE_DESCRIPTION ("RMI F11 module" );
include/linux/rmi.h +14 -0
@@ -600,4 +600,18 @@ int rmi_register_phys_device(struct rmi_phys_device *phys);void rmi_unregister_phys_device (struct rmi_phys_device *phys);int rmi_for_each_dev (void *data,int (*func)(struct device *dev,void *data)); +/** +* module_serio_driver() - Helper macro for registering a serio driver +* @__serio_driver: serio_driver struct +* +* Helper macro for serio drivers which do not do anything special in +* module init/exit. This eliminates a lot of boilerplate. Each module +* may only use this macro once, and calling it replaces module_init() +* and module_exit(). +*/ +#define module_rmi_driver (__rmi_driver) \ + module_driver(__rmi_driver, \ + rmi_register_function_handler, \ + rmi_unregister_function_handler) +#endif
Signature · 1 line
1.7.11.7
Dmitry Torokhov
maintainerPATCH 2/4 Input: RMI4 - move sensor driver and F01 handler into the core
In reply to Dmitry TorokhovThere is no point in having the sensor driver and F01 handler separate from the RMI core since it is not useful without them and having them all together simplifies initialization among other things.
--- drivers/input/rmi4/Kconfig | 23 ++++++----------------- drivers/input/rmi4/Makefile | 10 +++++++--- drivers/input/rmi4/rmi_bus.c | 41 ++++++++++++++++++++++++++++++++--------- drivers/input/rmi4/rmi_driver.c | 36 ++++++++++++++---------------------- drivers/input/rmi4/rmi_driver.h | 6 ++++++ drivers/input/rmi4/rmi_f01.c | 22 +++------------------- 6 files changed, 68 insertions(+), 70 deletions(-)
drivers/input/rmi4/Kconfig +6 -17
@@ -1,8 +1,8 @@ # # RMI4 configuration # -config RMI4_BUS - bool "Synaptics RMI4 bus support" +config RMI4_CORE + tristate "Synaptics RMI4 bus support" help Say Y here if you want to support the Synaptics RMI4 bus. This is required for all RMI4 device support.
@@ -13,7 +13,7 @@ config RMI4_BUS config RMI4_DEBUG bool "RMI4 Debugging" - depends on RMI4_BUS + depends on RMI4_CORE select DEBUG_FS help Say Y here to enable debug feature in the RMI4 driver.
@@ -26,8 +26,8 @@ config RMI4_DEBUG If unsure, say N. config RMI4_I2C - bool "RMI4 I2C Support" - depends on RMI4_BUS && I2C + tristate "RMI4 I2C Support" + depends on RMI4_CORE && I2C help Say Y here if you want to support RMI4 devices connected to an I2C bus.
@@ -36,20 +36,9 @@ config RMI4_I2C This feature is not currently available as a loadable module. -config RMI4_GENERIC - bool "RMI4 Generic driver" - depends on RMI4_BUS - help - Say Y here if you want to support generic RMI4 devices. - - This is pretty much required if you want to do anything useful with - your RMI device. - - This feature is not currently available as a loadable module. - config RMI4_F11 tristate "RMI4 Function 11 (2D pointing)" - depends on RMI4_BUS && RMI4_GENERIC + depends on RMI4_CORE help Say Y here if you want to add support for RMI4 function 11.
drivers/input/rmi4/Makefile +7 -3
@@ -1,8 +1,12 @@ -obj-$(CONFIG_RMI4_BUS) += rmi_bus.o -obj-$(CONFIG_RMI4_I2C) += rmi_i2c.o -obj-$(CONFIG_RMI4_GENERIC) += rmi_driver.o rmi_f01.o +obj-$(CONFIG_RMI4_CORE) += rmi_core.o +rmi_core-y := rmi_bus.o rmi_driver.o rmi_f01.o + +# Function drivers obj-$(CONFIG_RMI4_F11) += rmi_f11.o +# Transports +obj-$(CONFIG_RMI4_I2C) += rmi_i2c.o + ccflags-$(CONFIG_RMI4_DEBUG) += -DDEBUG ifeq ($(KERNELRELEASE),)
drivers/input/rmi4/rmi_bus.c +32 -9
62 lines not on this page · raw message
drivers/input/rmi4/rmi_driver.c +14 -22
@@ -1608,7 +1608,7 @@ static int __devinit rmi_driver_probe(struct device *dev) static UNIVERSAL_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume, NULL); -static struct rmi_driver sensor_driver = { +static struct rmi_driver rmi_sensor_driver = { .driver = { .owner =THIS_MODULE , .name ="rmi_generic" ,
@@ -1624,38 +1624,30 @@ static struct rmi_driver sensor_driver = { .set_input_params = rmi_driver_set_input_params, }; -static int __init rmi_driver_init (void ) +int __init rmi_register_sensor_driver (void ) { -int retval; +int error; - retval =driver_register (&sensor_driver.driver); -if (retval) { + error =driver_register (&rmi_sensor_driver.driver); +if (error) {pr_err ("%s: driver register failed, code=%d.\n" , __func__, - retval); -return retval; + error); +return error; }/* Ask the bus to let us know when drivers are bound to devices. */ - retval =bus_register_notifier (&rmi_bus_type, &rmi_bus_notifier); -if (retval) { + error =bus_register_notifier (&rmi_bus_type, &rmi_bus_notifier); +if (error) {pr_err ("%s: failed to register bus notifier, code=%d.\n" , - __func__, retval); -return retval; + __func__, error); +return error; } -return retval; +return 0 ; } -static void __exit rmi_driver_exit(void) +void __exit rmi_unregister_sensor_driver(void) {bus_unregister_notifier (&rmi_bus_type, &rmi_bus_notifier); -driver_unregister (&sensor_driver.driver); +driver_unregister (&rmi_sensor_driver.driver); } - -module_init (rmi_driver_init); -module_exit (rmi_driver_exit); - -MODULE_AUTHOR ("Christopher Heiny <[email protected]" ); -MODULE_DESCRIPTION ("RMI generic driver" ); -MODULE_LICENSE ("GPL" ); -MODULE_VERSION (RMI_DRIVER_VERSION );
drivers/input/rmi4/rmi_driver.h +6 -0
@@ -136,4 +136,10 @@ extern void rmi4_fw_update(struct rmi_device *rmi_dev,#define rmi4_fw_update (rmi_dev, f01_pdt, f34_pdt)#endif +int rmi_register_sensor_driver (void ); +void rmi_unregister_sensor_driver (void ); + +int rmi_register_f01_handler (void ); +void rmi_unregister_f01_handler (void ); +#endif
drivers/input/rmi4/rmi_f01.c +3 -19
@@ -1265,28 +1265,12 @@ static struct rmi_function_handler function_handler = {#endif /* CONFIG_PM */ }; -static int __init rmi_f01_module_init (void ) +int __init rmi_register_f01_handler (void ) { -int error; - - error =driver_register (&function_handler.driver); -if (error <0 ) { -pr_err ("%s: register failed!\n" , __func__); -return error; - } - -return 0 ; +return driver_register (&function_handler.driver); } -static void __exit rmi_f01_module_exit(void) +void __exit rmi_unregister_f01_handler(void) {driver_unregister (&function_handler.driver); } - -module_init (rmi_f01_module_init); -module_exit (rmi_f01_module_exit); - -MODULE_AUTHOR ("Christopher Heiny <[email protected]>" ); -MODULE_DESCRIPTION ("RMI F01 module" ); -MODULE_LICENSE ("GPL" ); -MODULE_VERSION (RMI_DRIVER_VERSION );
Signature · 1 line
1.7.11.7
Quoted 10 lines · Dmitry Torokhov
To save my old fingers...
Signed-off-by Dmitry Torokhov<[email protected]>---
It looks like this driver(s) need some love and I might have some time so I will refresh my "synaptics" branch with the patches you have sent and start working off it. If you have updates I would appreciate if you also make them available relative to that branch. When we are ready we'll squash them all together and apply to the official branch.
No problem - let me know which branch/tag to work with, and we'll be happy to patch against that for the next round.
Quoted 24 lines
Thanks.
drivers/input/rmi4/rmi_driver.c | 158 +++++++++++---------- drivers/input/rmi4/rmi_driver.h | 4 +- drivers/input/rmi4/rmi_f01.c | 298 ++++++++++++++++++++-------------------- drivers/input/rmi4/rmi_f11.c | 258 +++++++++++++++++----------------- include/linux/rmi.h | 22 ++- 5 files changed, 368 insertions(+), 372 deletions(-)drivers/input/rmi4/rmi_driver.c +1
-1@@ -594,7 +594,7 @@ static struct device_attribute bsr_attribute = __ATTR(bsr, RMI_RW_ATTR,static void rmi_free_function_list (struct rmi_device *rmi_dev) { -struct rmi_function_container *entry, *n; +struct rmi_function *entry, *n;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);if (!data) {
drivers/input/rmi4/rmi_driver.c static void rmi_free_function_list(struct rmi_device *rmi_dev) · line 620
Quoted 9 lines
drivers/input/rmi4/rmi_driver.c +1
-1@@ -613,44 +613,44 @@ static void rmi_free_function_list(struct rmi_device *rmi_dev) } } -static void release_fc_device (struct device *dev) +static void release_function_device (struct device *dev) {dev_dbg (dev,"REMOVING KOBJ!" );kobject_put (&dev->kobj); }
Hmmm. Since rmi_function_container has evolved into a child device of the RMI4 module, maybe it would be better renamed rmi_function_device or rmi_function_dev? I find this clearer, but can live with just rmi_function if you prefer that.
Similarly, rmi_function_handler has evolved into a driver for such devices, so perhaps it should be renamed rmi_function_driver?
[snip]
Re: [PATCH 4/4] Input: RMI4 - introduce rmi_module_driver() macro
In reply to Dmitry TorokhovQuoted 2 lines · Dmitry Torokhov
This also allows us to cut down on the boilerplate code in the function handler modules.
I like this idea a lot. We'll adopt it.
Thanks!
Chris
Quoted 55 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/rmi4/rmi_f11.c | 13 +------------ include/linux/rmi.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-)drivers/input/rmi4/rmi_f11.c +1
-12@@ -2756,18 +2756,7 @@ static struct rmi_function_handler rmi_f11_handler = {#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */ }; -static int __init rmi_f11_module_init (void ) -{ -return rmi_register_function_handler (&rmi_f11_handler); -} - -static void __exit rmi_f11_module_exit(void) -{ -rmi_unregister_function_handler (&rmi_f11_handler); -} - -module_init (rmi_f11_module_init); -module_exit (rmi_f11_module_exit); +module_rmi_driver (rmi_f11_handler);MODULE_AUTHOR ("Christopher Heiny <[email protected]" );MODULE_DESCRIPTION ("RMI F11 module" );include/linux/rmi.h +14
-0@@ -600,4 +600,18 @@ int rmi_register_phys_device(struct rmi_phys_device *phys);void rmi_unregister_phys_device (struct rmi_phys_device *phys);int rmi_for_each_dev (void *data,int (*func)(struct device *dev,void *data)); +/** +* module_serio_driver() - Helper macro for registering a serio driver +* @__serio_driver: serio_driver struct +* +* Helper macro for serio drivers which do not do anything special in +* module init/exit. This eliminates a lot of boilerplate. Each module +* may only use this macro once, and calling it replaces module_init() +* and module_exit(). +*/ +#define module_rmi_driver (__rmi_driver) \ + module_driver(__rmi_driver, \ + rmi_register_function_handler, \ + rmi_unregister_function_handler) +#endif
Signature · 3 lines
Christopher Heiny Senior Staff Firmware Engineer Synaptics Incorporated
Dmitry Torokhov
maintainerQuoted 6 lines · Christopher Heiny
Quoted 5 lines · Dmitry Torokhov
To save my old fingers...
Signed-off-by Dmitry Torokhov<[email protected]>---
Quoted 8 lines
Quoted 5 lines
It looks like this driver(s) need some love and I might have some time so I will refresh my "synaptics" branch with the patches you have sent and start working off it. If you have updates I would appreciate if you also make them available relative to that branch. When we are ready we'll squash them all together and apply to the official branch.
No problem - let me know which branch/tag to work with, and we'll be happy to patch against that for the next round.
synaptics-rmi4. It is based off 3.7-rc6.
Quoted 28 lines
Quoted 28 lines
Thanks.
drivers/input/rmi4/rmi_driver.c | 158 +++++++++++---------- drivers/input/rmi4/rmi_driver.h | 4 +- drivers/input/rmi4/rmi_f01.c | 298 ++++++++++++++++++++-------------------- drivers/input/rmi4/rmi_f11.c | 258 +++++++++++++++++----------------- include/linux/rmi.h | 22 ++- 5 files changed, 368 insertions(+), 372 deletions(-)drivers/input/rmi4/rmi_driver.c +1
-1@@ -594,7 +594,7 @@ static struct device_attribute bsr_attribute = __ATTR(bsr, RMI_RW_ATTR,static void rmi_free_function_list (struct rmi_device *rmi_dev) { -struct rmi_function_container *entry, *n; +struct rmi_function *entry, *n;struct rmi_driver_data *data =dev_get_drvdata (&rmi_dev->dev);if (!data) {@@ -613,44 +613,44 @@ static void rmi_free_function_list(struct rmi_device *rmi_dev) } }
Quoted 11 lines
drivers/input/rmi4/rmi_driver.c static void rmi_free_function_list(struct rmi_device *rmi_dev) · line 620
Quoted 6 lines
drivers/input/rmi4/rmi_driver.c +1
-1-static void release_fc_device (struct device *dev) +static void release_function_device (struct device *dev) {dev_dbg (dev,"REMOVING KOBJ!" );kobject_put (&dev->kobj); }Hmmm. Since
rmi_function_containerhas evolved into a child device of the RMI4 module, maybe it would be better renamedrmi_function_deviceorrmi_function_dev? I find this clearer, but can live with justrmi_functionif you prefer that.
I just prefer something reasonably short so I still like rmi_function or something of similar length.
Quoted 4 lines
Similarly,
rmi_function_handlerhas evolved into a driver for such devices, so perhaps it should be renamedrmi_function_driver?
No preference here.
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH 2/4] Input: RMI4 - move sensor driver and F01 handler into the core
In reply to Dmitry TorokhovQuoted 3 lines · Dmitry Torokhov
There is no point in having the sensor driver and F01 handler separate from the RMI core since it is not useful without them and having them all together simplifies initialization among other things.
Hi Dmitry,
I've been looking at this patch as well as your patch 3/4 changes, and I'm not sure it's for the better.
One thing that confuses me is that these appear to go against the advice we've been getting over the past months to rely more on standard kernel bus and driver implementations, instead of the "roll-your-own" implementation we had been using before.
More importantly, the patches inextricably link the sensor driver implementation and the F01 driver implementation to the bus implementation, and means that any given system can have only one way of managing F01. As you observed, a sensor is pretty much useless without an F01 handler, but I am reasonably sure that there will be future systems that have more than one RMI4 sensor in them, and there is a strong possibility that these sensors may have different requirements for handling F01. In the near future, then, these changes will have to be refactored back to something more like the structure of our 2012/11/16 patch set.
Additionally, having F01 as a special case means that when we start implementing things such as support for request_firmware(), there will have to be a bunch of special case code to deal with F01, since it's no longer "just another function driver". That seems to go in exactly the opposite direction of the simplification that you're trying to achieve.
I fully agree that there's a lot of boilerplate that could be (and must be) consolidated and/or eliminated, and that some of the F01 handling during initialization can be simplified. I'm just not sure that this is the right way to go about doing that.
If you'd like me to address this inline in the patches, let me know. I just thought it would be better to address design issues up top. Alternatively, I could submit a patch that tries to address your concerns from another approach.
Of course, it's entirely possible that I'm full of fertilizer here - I trust that you will let me know in detail if that is the case. :-)
Thanks very much,
Chris
Quoted 273 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/input/rmi4/Kconfig | 23 ++++++----------------- drivers/input/rmi4/Makefile | 10 +++++++--- drivers/input/rmi4/rmi_bus.c | 41 ++++++++++++++++++++++++++++++++--------- drivers/input/rmi4/rmi_driver.c | 36 ++++++++++++++---------------------- drivers/input/rmi4/rmi_driver.h | 6 ++++++ drivers/input/rmi4/rmi_f01.c | 22 +++------------------- 6 files changed, 68 insertions(+), 70 deletions(-)drivers/input/rmi4/Kconfig +6
-17@@ -1,8 +1,8 @@ # # RMI4 configuration # -config RMI4_BUS - bool "Synaptics RMI4 bus support" +config RMI4_CORE + tristate "Synaptics RMI4 bus support" help Say Y here if you want to support the Synaptics RMI4 bus. This is required for all RMI4 device support.@@ -13,7 +13,7 @@ config RMI4_BUS config RMI4_DEBUG bool "RMI4 Debugging" - depends on RMI4_BUS + depends on RMI4_CORE select DEBUG_FS help Say Y here to enable debug feature in the RMI4 driver.@@ -26,8 +26,8 @@ config RMI4_DEBUG If unsure, say N. config RMI4_I2C - bool "RMI4 I2C Support" - depends on RMI4_BUS && I2C + tristate "RMI4 I2C Support" + depends on RMI4_CORE && I2C help Say Y here if you want to support RMI4 devices connected to an I2C bus.@@ -36,20 +36,9 @@ config RMI4_I2C This feature is not currently available as a loadable module. -config RMI4_GENERIC - bool "RMI4 Generic driver" - depends on RMI4_BUS - help - Say Y here if you want to support generic RMI4 devices. - - This is pretty much required if you want to do anything useful with - your RMI device. - - This feature is not currently available as a loadable module. - config RMI4_F11 tristate "RMI4 Function 11 (2D pointing)" - depends on RMI4_BUS && RMI4_GENERIC + depends on RMI4_CORE help Say Y here if you want to add support for RMI4 function 11.drivers/input/rmi4/Makefile +7
-3@@ -1,8 +1,12 @@ -obj-$(CONFIG_RMI4_BUS) += rmi_bus.o -obj-$(CONFIG_RMI4_I2C) += rmi_i2c.o -obj-$(CONFIG_RMI4_GENERIC) += rmi_driver.o rmi_f01.o +obj-$(CONFIG_RMI4_CORE) += rmi_core.o +rmi_core-y := rmi_bus.o rmi_driver.o rmi_f01.o + +# Function drivers obj-$(CONFIG_RMI4_F11) += rmi_f11.o +# Transports +obj-$(CONFIG_RMI4_I2C) += rmi_i2c.o + ccflags-$(CONFIG_RMI4_DEBUG) += -DDEBUG ifeq ($(KERNELRELEASE),)drivers/input/rmi4/rmi_bus.c +32
-9@@ -206,6 +206,27 @@ static int __init rmi_bus_init(void)mutex_init (&rmi_bus_mutex); + error =bus_register (&rmi_bus_type); +if (error) { +pr_err ("%s: error registering the RMI bus: %d\n" , + __func__, error); +return error; + } + + error =rmi_register_f01_handler (); +if (error) { +pr_err ("%s: error registering the RMI F01 handler: %d\n" , + __func__, error); + goto err_unregister_bus; + } + + error =rmi_register_sensor_driver (); +if (error) { +pr_err ("%s: error registering the RMI sensor driver: %d\n" , + __func__, error); + goto err_unregister_f01; + } +if (IS_ENABLED (CONFIG_RMI4_DEBUG )) { rmi_debugfs_root =debugfs_create_dir (rmi_bus_type.name,NULL );if (!rmi_debugfs_root)@@ -218,24 +239,26 @@ static int __init rmi_bus_init(void) } } - error =bus_register (&rmi_bus_type); -if (error <0 ) { -pr_err ("%s: error registering the RMI bus: %d\n" , __func__, - error); -return error; - } -pr_debug ("%s: successfully registered RMI bus.\n" , __func__); -return 0 ; + +err_unregister_f01: +rmi_unregister_f01_handler (); +err_unregister_bus: +bus_unregister (&rmi_bus_type); +return error; } static void __exit rmi_bus_exit(void) { -/* We should only ever get here if all drivers are unloaded, so +/* +* We should only ever get here if all drivers are unloaded, so * all we have to do at this point is unregister ourselves. */ if (IS_ENABLED (CONFIG_RMI4_DEBUG ) && rmi_debugfs_root)debugfs_remove (rmi_debugfs_root); + +rmi_unregister_sensor_driver (); +rmi_unregister_f01_handler ();bus_unregister (&rmi_bus_type); }drivers/input/rmi4/rmi_driver.c +14
-22@@ -1608,7 +1608,7 @@ static int __devinit rmi_driver_probe(struct device *dev) static UNIVERSAL_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume, NULL); -static struct rmi_driver sensor_driver = { +static struct rmi_driver rmi_sensor_driver = { .driver = { .owner =THIS_MODULE , .name ="rmi_generic" ,@@ -1624,38 +1624,30 @@ static struct rmi_driver sensor_driver = { .set_input_params = rmi_driver_set_input_params, }; -static int __init rmi_driver_init (void ) +int __init rmi_register_sensor_driver (void ) { -int retval; +int error; - retval =driver_register (&sensor_driver.driver); -if (retval) { + error =driver_register (&rmi_sensor_driver.driver); +if (error) {pr_err ("%s: driver register failed, code=%d.\n" , __func__, - retval); -return retval; + error); +return error; }/* Ask the bus to let us know when drivers are bound to devices. */ - retval =bus_register_notifier (&rmi_bus_type, &rmi_bus_notifier); -if (retval) { + error =bus_register_notifier (&rmi_bus_type, &rmi_bus_notifier); +if (error) {pr_err ("%s: failed to register bus notifier, code=%d.\n" , - __func__, retval); -return retval; + __func__, error); +return error; } -return retval; +return 0 ; } -static void __exit rmi_driver_exit(void) +void __exit rmi_unregister_sensor_driver(void) {bus_unregister_notifier (&rmi_bus_type, &rmi_bus_notifier); -driver_unregister (&sensor_driver.driver); +driver_unregister (&rmi_sensor_driver.driver); } - -module_init (rmi_driver_init); -module_exit (rmi_driver_exit); - -MODULE_AUTHOR ("Christopher Heiny <[email protected]" ); -MODULE_DESCRIPTION ("RMI generic driver" ); -MODULE_LICENSE ("GPL" ); -MODULE_VERSION (RMI_DRIVER_VERSION );drivers/input/rmi4/rmi_driver.h +6
-0@@ -136,4 +136,10 @@ extern void rmi4_fw_update(struct rmi_device *rmi_dev,#define rmi4_fw_update (rmi_dev, f01_pdt, f34_pdt)#endif +int rmi_register_sensor_driver (void ); +void rmi_unregister_sensor_driver (void ); + +int rmi_register_f01_handler (void ); +void rmi_unregister_f01_handler (void ); +#endif drivers/input/rmi4/rmi_f01.c +3
-19@@ -1265,28 +1265,12 @@ static struct rmi_function_handler function_handler = {#endif /* CONFIG_PM */ }; -static int __init rmi_f01_module_init (void ) +int __init rmi_register_f01_handler (void ) { -int error; - - error =driver_register (&function_handler.driver); -if (error <0 ) { -pr_err ("%s: register failed!\n" , __func__); -return error; - } - -return 0 ; +return driver_register (&function_handler.driver); } -static void __exit rmi_f01_module_exit(void) +void __exit rmi_unregister_f01_handler(void) {driver_unregister (&function_handler.driver); } - -module_init (rmi_f01_module_init); -module_exit (rmi_f01_module_exit); - -MODULE_AUTHOR ("Christopher Heiny <[email protected]>" ); -MODULE_DESCRIPTION ("RMI F01 module" ); -MODULE_LICENSE ("GPL" ); -MODULE_VERSION (RMI_DRIVER_VERSION );
Signature · 3 lines
Christopher Heiny Senior Staff Firmware Engineer Synaptics Incorporated
Dmitry Torokhov
maintainerRe: [PATCH 2/4] Input: RMI4 - move sensor driver and F01 handler into the core
Hi Chris,
Quoted 26 lines · Christopher Heiny
Quoted 3 lines · Dmitry Torokhov
There is no point in having the sensor driver and F01 handler separate from the RMI core since it is not useful without them and having them all together simplifies initialization among other things.
Hi Dmitry,
I've been looking at this patch as well as your patch 3/4 changes, and I'm not sure it's for the better.
One thing that confuses me is that these appear to go against the advice we've been getting over the past months to rely more on standard kernel bus and driver implementations, instead of the "roll-your-own" implementation we had been using before.
More importantly, the patches inextricably link the sensor driver implementation and the F01 driver implementation to the bus implementation, and means that any given system can have only one way of managing F01. As you observed, a sensor is pretty much useless without an F01 handler, but I am reasonably sure that there will be future systems that have more than one RMI4 sensor in them, and there is a strong possibility that these sensors may have different requirements for handling F01. In the near future, then, these changes will have to be refactored back to something more like the structure of our 2012/11/16 patch set.
Quoted 6 lines
Additionally, having F01 as a special case means that when we start implementing things such as support for
request_firmware(), there will have to be a bunch of special case code to deal with F01, since it's no longer "just another function driver". That seems to go in exactly the opposite direction of the simplification that you're trying to achieve.
But F01 continues to being "just another function driver" even with my changes. It is still registered as rmi_fucntion_handler and uses standard matching mechanisms to bind to rmi_functions registered by the sensor driver. What I changed is the fact that rmi_f01 is no longer a separate module which could be loaded after loading rmi_bus and it can't be unloaded without unloading rmi_bus. This simplifies things and makes it easier to have rmi core compiled as a module.
Also I do not quite follow your idea that devices might have different requirements for handling F01. If that is true then be _can't_ implement "F01" as "another function driver"... But that is orthogonal for the 3/4 change we are discussing here.
Thanks.
Signature · 1 line
Dmitry
RE: [PATCH 2/4] Input: RMI4 - move sensor driver and F01 handler into the core
Sorry for top posting this - I forgot to email while still at work.
I've been poking at this, and think (a) it's possible that I'm being too paranoid, and (b) it looks like it'll work with some of the future stuff. So I'll back off my objections for the moment, and give these changes a try, possibly with some slight modifications.
Thanks!
Chris
________________________________________
From: [email protected] [[email protected]] on behalf of Dmitry Torokhov [[email protected]]
Sent: Thursday, November 29, 2012 9:21 AM
To: Christopher Heiny
Cc: Linus Walleij; Linux Input; Linux Kernel; Allie Xiong; Vivian Ly; Daniel Rosenberg; Alexandra Chin; Joerie de Gram; Wolfram Sang; Mathieu Poirier
Subject: Re: [PATCH 2/4] Input: RMI4 - move sensor driver and F01 handler into the core
Hi Chris,
Quoted 26 lines · Christopher Heiny
Quoted 3 lines · Dmitry Torokhov
There is no point in having the sensor driver and F01 handler separate from the RMI core since it is not useful without them and having them all together simplifies initialization among other things.
Hi Dmitry,
I've been looking at this patch as well as your patch 3/4 changes, and I'm not sure it's for the better.
One thing that confuses me is that these appear to go against the advice we've been getting over the past months to rely more on standard kernel bus and driver implementations, instead of the "roll-your-own" implementation we had been using before.
More importantly, the patches inextricably link the sensor driver implementation and the F01 driver implementation to the bus implementation, and means that any given system can have only one way of managing F01. As you observed, a sensor is pretty much useless without an F01 handler, but I am reasonably sure that there will be future systems that have more than one RMI4 sensor in them, and there is a strong possibility that these sensors may have different requirements for handling F01. In the near future, then, these changes will have to be refactored back to something more like the structure of our 2012/11/16 patch set.
Quoted 6 lines
Additionally, having F01 as a special case means that when we start implementing things such as support for
request_firmware(), there will have to be a bunch of special case code to deal with F01, since it's no longer "just another function driver". That seems to go in exactly the opposite direction of the simplification that you're trying to achieve.
But F01 continues to being "just another function driver" even with my changes. It is still registered as rmi_fucntion_handler and uses standard matching mechanisms to bind to rmi_functions registered by the sensor driver. What I changed is the fact that rmi_f01 is no longer a separate module which could be loaded after loading rmi_bus and it can't be unloaded without unloading rmi_bus. This simplifies things and makes it easier to have rmi core compiled as a module.
Also I do not quite follow your idea that devices might have different requirements for handling F01. If that is true then be _can't_ implement "F01" as "another function driver"... But that is orthogonal for the 3/4 change we are discussing here.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html