From: Thomas Sailer <t.sailer@alumni.ethz.ch>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, linux-hams@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] hamradio: baycom: use new parport device model
Date: Sun, 17 Sep 2017 20:20:35 +0200 [thread overview]
Message-ID: <413aa4e4-8b23-80e9-055d-576c9128f069@alumni.ethz.ch> (raw)
In-Reply-To: <1505648780-4385-1-git-send-email-sudipm.mukherjee@gmail.com>
Acked-By: Thomas Sailer <t.sailer@alumni.ethz.ch>
Am 17.09.2017 um 13:46 schrieb Sudip Mukherjee:
> Modify baycom driver to use the new parallel port device model.
>
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> ---
>
> Not tested on real hardware, only tested on qemu and verified that the
> device is binding to the driver properly in epp_open but then unbinding
> as the device was not found.
>
> drivers/net/hamradio/baycom_epp.c | 50 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
> index 1503f10..1e62d00 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)
> unsigned char tmp[128];
> unsigned char stat;
> unsigned long tstart;
> + struct pardev_cb par_cb;
>
> if (!pp) {
> 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)
> return -EIO;
> }
> memset(&bc->modem, 0, sizeof(bc->modem));
> - bc->pdev = parport_register_device(pp, dev->name, NULL, epp_wakeup,
> - NULL, PARPORT_DEV_EXCL, dev);
> + memset(&par_cb, 0, sizeof(par_cb));
> + par_cb.wakeup = epp_wakeup;
> + par_cb.private = (void *)dev;
> + par_cb.flags = PARPORT_DEV_EXCL;
> + for (i = 0; i < NR_PORTS; i++)
> + if (baycom_device[i] == dev)
> + break;
> +
> + if (i == NR_PORTS) {
> + pr_err("%s: no device found\n", bc_drvname);
> + parport_put_port(pp);
> + return -ENODEV;
> + }
> +
> + bc->pdev = parport_register_dev_model(pp, dev->name, &par_cb, i);
> parport_put_port(pp);
> if (!bc->pdev) {
> printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base);
> @@ -1185,6 +1199,23 @@ MODULE_LICENSE("GPL");
>
> /* --------------------------------------------------------------------- */
>
> +static int baycom_epp_par_probe(struct pardevice *par_dev)
> +{
> + struct device_driver *drv = par_dev->dev.driver;
> + int len = strlen(drv->name);
> +
> + if (strncmp(par_dev->name, drv->name, len))
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> +static struct parport_driver baycom_epp_par_driver = {
> + .name = "bce",
> + .probe = baycom_epp_par_probe,
> + .devmodel = true,
> +};
> +
> static void __init baycom_epp_dev_setup(struct net_device *dev)
> {
> struct baycom_state *bc = netdev_priv(dev);
> @@ -1204,10 +1235,15 @@ static void __init baycom_epp_dev_setup(struct net_device *dev)
>
> static int __init init_baycomepp(void)
> {
> - int i, found = 0;
> + int i, found = 0, ret;
> char set_hw = 1;
>
> printk(bc_drvinfo);
> +
> + ret = parport_register_driver(&baycom_epp_par_driver);
> + if (ret)
> + return ret;
> +
> /*
> * register net devices
> */
> @@ -1241,7 +1277,12 @@ static int __init init_baycomepp(void)
> found++;
> }
>
> - return found ? 0 : -ENXIO;
> + if (found == 0) {
> + parport_unregister_driver(&baycom_epp_par_driver);
> + return -ENXIO;
> + }
> +
> + return 0;
> }
>
> static void __exit cleanup_baycomepp(void)
> @@ -1260,6 +1301,7 @@ static void __exit cleanup_baycomepp(void)
> printk(paranoia_str, "cleanup_module");
> }
> }
> + parport_unregister_driver(&baycom_epp_par_driver);
> }
>
> module_init(init_baycomepp);
>
next prev parent reply other threads:[~2017-09-17 18:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 11:46 Sudip Mukherjee
2017-09-17 18:20 ` Thomas Sailer [this message]
2017-09-18 23:40 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=413aa4e4-8b23-80e9-055d-576c9128f069@alumni.ethz.ch \
--to=t.sailer@alumni.ethz.ch \
--cc=davem@davemloft.net \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®