diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2018-01-28 23:22:08 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-14 17:53:06 +0100 |
commit | fb56d97df70e7c29c4072c02d1d756641891cee9 (patch) | |
tree | 767bd2041c40cc35be3e76f438e981290fb28ff6 /drivers/pps | |
parent | 823f7923833c6cc2b16e601546d607dcfb368004 (diff) | |
download | linux-fb56d97df70e7c29c4072c02d1d756641891cee9.tar.gz linux-fb56d97df70e7c29c4072c02d1d756641891cee9.tar.bz2 linux-fb56d97df70e7c29c4072c02d1d756641891cee9.zip |
pps: client: use new parport device model
Modify pps client driver to use the new parallel port device model.
In that process, added an index to mention the device number when we
have more than one parallel port.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pps')
-rw-r--r-- | drivers/pps/clients/pps_parport.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c index 83797d89c30f..4db824f88d00 100644 --- a/drivers/pps/clients/pps_parport.c +++ b/drivers/pps/clients/pps_parport.c @@ -49,6 +49,7 @@ MODULE_PARM_DESC(clear_wait, " zero turns clear edge capture off entirely"); module_param(clear_wait, uint, 0); +static DEFINE_IDA(pps_client_index); /* internal per port structure */ struct pps_client_pp { @@ -56,6 +57,7 @@ struct pps_client_pp { struct pps_device *pps; /* PPS device */ unsigned int cw; /* port clear timeout */ unsigned int cw_err; /* number of timeouts */ + int index; /* device number */ }; static inline int signal_is_set(struct parport *port) @@ -136,6 +138,8 @@ out_both: static void parport_attach(struct parport *port) { + struct pardev_cb pps_client_cb; + int index; struct pps_client_pp *device; struct pps_source_info info = { .name = KBUILD_MODNAME, @@ -154,8 +158,15 @@ static void parport_attach(struct parport *port) return; } - device->pardev = parport_register_device(port, KBUILD_MODNAME, - NULL, NULL, parport_irq, PARPORT_FLAG_EXCL, device); + index = ida_simple_get(&pps_client_index, 0, 0, GFP_KERNEL); + memset(&pps_client_cb, 0, sizeof(pps_client_cb)); + pps_client_cb.private = device; + pps_client_cb.irq_func = parport_irq; + pps_client_cb.flags = PARPORT_FLAG_EXCL; + device->pardev = parport_register_dev_model(port, + KBUILD_MODNAME, + &pps_client_cb, + index); if (!device->pardev) { pr_err("couldn't register with %s\n", port->name); goto err_free; @@ -176,6 +187,7 @@ static void parport_attach(struct parport *port) device->cw = clear_wait; port->ops->enable_irq(port); + device->index = index; pr_info("attached to %s\n", port->name); @@ -186,6 +198,7 @@ err_release_dev: err_unregister_dev: parport_unregister_device(device->pardev); err_free: + ida_simple_remove(&pps_client_index, index); kfree(device); } @@ -205,13 +218,15 @@ static void parport_detach(struct parport *port) pps_unregister_source(device->pps); parport_release(pardev); parport_unregister_device(pardev); + ida_simple_remove(&pps_client_index, device->index); kfree(device); } static struct parport_driver pps_parport_driver = { .name = KBUILD_MODNAME, - .attach = parport_attach, + .match_port = parport_attach, .detach = parport_detach, + .devmodel = true, }; /* module staff */ |