diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2017-09-17 07:46:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-18 19:40:25 -0400 |
commit | ca444073a2de97809d63e613d01203f4f4644cfb (patch) | |
tree | 52653bc516e1f1798c8f185debf282f8fc69b258 | |
parent | 2df9d6730215db85f7306f0bda03b7391e392837 (diff) |
hamradio: baycom: use new parport device model
Modify baycom driver to use the new parallel port device model.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Acked-By: Thomas Sailer <t.sailer@alumni.ethz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/hamradio/baycom_epp.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 1503f10122f7..1e62d00732f2 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c | |||
@@ -840,6 +840,7 @@ static int epp_open(struct net_device *dev) | |||
840 | unsigned char tmp[128]; | 840 | unsigned char tmp[128]; |
841 | unsigned char stat; | 841 | unsigned char stat; |
842 | unsigned long tstart; | 842 | unsigned long tstart; |
843 | struct pardev_cb par_cb; | ||
843 | 844 | ||
844 | if (!pp) { | 845 | if (!pp) { |
845 | printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr); | 846 | printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr); |
@@ -859,8 +860,21 @@ static int epp_open(struct net_device *dev) | |||
859 | return -EIO; | 860 | return -EIO; |
860 | } | 861 | } |
861 | memset(&bc->modem, 0, sizeof(bc->modem)); | 862 | memset(&bc->modem, 0, sizeof(bc->modem)); |
862 | bc->pdev = parport_register_device(pp, dev->name, NULL, epp_wakeup, | 863 | memset(&par_cb, 0, sizeof(par_cb)); |
863 | NULL, PARPORT_DEV_EXCL, dev); | 864 | par_cb.wakeup = epp_wakeup; |
865 | par_cb.private = (void *)dev; | ||
866 | par_cb.flags = PARPORT_DEV_EXCL; | ||
867 | for (i = 0; i < NR_PORTS; i++) | ||
868 | if (baycom_device[i] == dev) | ||
869 | break; | ||
870 | |||
871 | if (i == NR_PORTS) { | ||
872 | pr_err("%s: no device found\n", bc_drvname); | ||
873 | parport_put_port(pp); | ||
874 | return -ENODEV; | ||
875 | } | ||
876 | |||
877 | bc->pdev = parport_register_dev_model(pp, dev->name, &par_cb, i); | ||
864 | parport_put_port(pp); | 878 | parport_put_port(pp); |
865 | if (!bc->pdev) { | 879 | if (!bc->pdev) { |
866 | printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base); | 880 | printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base); |
@@ -1185,6 +1199,23 @@ MODULE_LICENSE("GPL"); | |||
1185 | 1199 | ||
1186 | /* --------------------------------------------------------------------- */ | 1200 | /* --------------------------------------------------------------------- */ |
1187 | 1201 | ||
1202 | static int baycom_epp_par_probe(struct pardevice *par_dev) | ||
1203 | { | ||
1204 | struct device_driver *drv = par_dev->dev.driver; | ||
1205 | int len = strlen(drv->name); | ||
1206 | |||
1207 | if (strncmp(par_dev->name, drv->name, len)) | ||
1208 | return -ENODEV; | ||
1209 | |||
1210 | return 0; | ||
1211 | } | ||
1212 | |||
1213 | static struct parport_driver baycom_epp_par_driver = { | ||
1214 | .name = "bce", | ||
1215 | .probe = baycom_epp_par_probe, | ||
1216 | .devmodel = true, | ||
1217 | }; | ||
1218 | |||
1188 | static void __init baycom_epp_dev_setup(struct net_device *dev) | 1219 | static void __init baycom_epp_dev_setup(struct net_device *dev) |
1189 | { | 1220 | { |
1190 | struct baycom_state *bc = netdev_priv(dev); | 1221 | struct baycom_state *bc = netdev_priv(dev); |
@@ -1204,10 +1235,15 @@ static void __init baycom_epp_dev_setup(struct net_device *dev) | |||
1204 | 1235 | ||
1205 | static int __init init_baycomepp(void) | 1236 | static int __init init_baycomepp(void) |
1206 | { | 1237 | { |
1207 | int i, found = 0; | 1238 | int i, found = 0, ret; |
1208 | char set_hw = 1; | 1239 | char set_hw = 1; |
1209 | 1240 | ||
1210 | printk(bc_drvinfo); | 1241 | printk(bc_drvinfo); |
1242 | |||
1243 | ret = parport_register_driver(&baycom_epp_par_driver); | ||
1244 | if (ret) | ||
1245 | return ret; | ||
1246 | |||
1211 | /* | 1247 | /* |
1212 | * register net devices | 1248 | * register net devices |
1213 | */ | 1249 | */ |
@@ -1241,7 +1277,12 @@ static int __init init_baycomepp(void) | |||
1241 | found++; | 1277 | found++; |
1242 | } | 1278 | } |
1243 | 1279 | ||
1244 | return found ? 0 : -ENXIO; | 1280 | if (found == 0) { |
1281 | parport_unregister_driver(&baycom_epp_par_driver); | ||
1282 | return -ENXIO; | ||
1283 | } | ||
1284 | |||
1285 | return 0; | ||
1245 | } | 1286 | } |
1246 | 1287 | ||
1247 | static void __exit cleanup_baycomepp(void) | 1288 | static void __exit cleanup_baycomepp(void) |
@@ -1260,6 +1301,7 @@ static void __exit cleanup_baycomepp(void) | |||
1260 | printk(paranoia_str, "cleanup_module"); | 1301 | printk(paranoia_str, "cleanup_module"); |
1261 | } | 1302 | } |
1262 | } | 1303 | } |
1304 | parport_unregister_driver(&baycom_epp_par_driver); | ||
1263 | } | 1305 | } |
1264 | 1306 | ||
1265 | module_init(init_baycomepp); | 1307 | module_init(init_baycomepp); |