diff mbox

[v2,3/3,ALSA] portman2x4 - use new parport device model

Message ID 1454146417-11567-3-git-send-email-sudipm.mukherjee@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sudip Mukherjee Jan. 30, 2016, 9:33 a.m. UTC
Modify portman driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

v2: 
 1. pardev_cb is initialized while declaring, thus removing the use of
memset.
 2. used pdev->id.
 3. v1 did not have the parport probe callback, but
we will need the probe callback for binding as the name of the driver
and the name of the device is different.
 4. in v1 I missed modifying snd_portman_probe_port().

 sound/drivers/portman2x4.c | 53 ++++++++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 14 deletions(-)

Comments

Takashi Iwai Feb. 1, 2016, 2:26 p.m. UTC | #1
On Sat, 30 Jan 2016 10:33:37 +0100,
Sudip Mukherjee wrote:
> 
> Modify portman driver to use the new parallel port device model.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>

Please be more verbose about your changes.  You didn't test it with
real hardware but just compile-tested, right?  Explain the reason --
why you need/want this conversion, and whether this wouldn't give any
regression or user-visible change.


thanks,

Takashi

> ---
> 
> v2: 
>  1. pardev_cb is initialized while declaring, thus removing the use of
> memset.
>  2. used pdev->id.
>  3. v1 did not have the parport probe callback, but
> we will need the probe callback for binding as the name of the driver
> and the name of the device is different.
>  4. in v1 I missed modifying snd_portman_probe_port().
> 
>  sound/drivers/portman2x4.c | 53 ++++++++++++++++++++++++++++++++++------------
>  1 file changed, 39 insertions(+), 14 deletions(-)
> 
> diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
> index 172685d..a22f56c 100644
> --- a/sound/drivers/portman2x4.c
> +++ b/sound/drivers/portman2x4.c
> @@ -650,10 +650,21 @@ static int snd_portman_probe_port(struct parport *p)
>  {
>  	struct pardevice *pardev;
>  	int res;
> -
> -	pardev = parport_register_device(p, DRIVER_NAME,
> -					 NULL, NULL, NULL,
> -					 0, NULL);
> +	struct pardev_cb pdev_cb = {
> +		.preempt = NULL,
> +		.wakeup = NULL,
> +		.private = NULL,
> +		.irq_func = NULL,
> +		.flags = 0,
> +	};
> +
> +	/*
> +	 * Specify the device number as SNDRV_CARDS + 1 so that the
> +	 * device id alloted to this temporary device will never clash
> +	 * with an actual device already registered.
> +	 */
> +	pardev = parport_register_dev_model(p, DRIVER_NAME, &pdev_cb,
> +					    SNDRV_CARDS + 1);
>  	if (!pardev)
>  		return -EIO;
>  
> @@ -703,10 +714,20 @@ static void snd_portman_detach(struct parport *p)
>  	/* nothing to do here */
>  }
>  
> +static int snd_portman_dev_probe(struct pardevice *pardev)
> +{
> +	if (strcmp(pardev->name, DRIVER_NAME))
> +		return -ENODEV;
> +
> +	return 0;
> +}
> +
>  static struct parport_driver portman_parport_driver = {
> -	.name   = "portman2x4",
> -	.attach = snd_portman_attach,
> -	.detach = snd_portman_detach
> +	.name		= "portman2x4",
> +	.probe		= snd_portman_dev_probe,
> +	.match_port	= snd_portman_attach,
> +	.detach		= snd_portman_detach,
> +	.devmodel	= true,
>  };
>  
>  /*********************************************************************
> @@ -734,6 +755,12 @@ static int snd_portman_probe(struct platform_device *pdev)
>  	struct snd_card *card = NULL;
>  	struct portman *pm = NULL;
>  	int err;
> +	struct pardev_cb portman_cb = {
> +		.preempt = NULL,
> +		.wakeup = NULL,
> +		.irq_func = snd_portman_interrupt,	/* ISR */
> +		.flags = PARPORT_DEV_EXCL,		/* flags */
> +	};
>  
>  	p = platform_get_drvdata(pdev);
>  	platform_set_drvdata(pdev, NULL);
> @@ -758,13 +785,11 @@ static int snd_portman_probe(struct platform_device *pdev)
>  	sprintf(card->longname,  "%s at 0x%lx, irq %i",
>  		card->shortname, p->base, p->irq);
>  
> -	pardev = parport_register_device(p,                     /* port */
> -					 DRIVER_NAME,           /* name */
> -					 NULL,                  /* preempt */
> -					 NULL,                  /* wakeup */
> -					 snd_portman_interrupt, /* ISR */
> -					 PARPORT_DEV_EXCL,      /* flags */
> -					 (void *)card);         /* private */
> +	portman_cb.private = card;			   /* private */
> +	pardev = parport_register_dev_model(p,		   /* port */
> +					    DRIVER_NAME,   /* name */
> +					    &portman_cb,   /* callbacks */
> +					    pdev->id);	   /* device number */
>  	if (pardev == NULL) {
>  		snd_printd("Cannot register pardevice\n");
>  		err = -EIO;
> -- 
> 1.9.1
> 
>
diff mbox

Patch

diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
index 172685d..a22f56c 100644
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -650,10 +650,21 @@  static int snd_portman_probe_port(struct parport *p)
 {
 	struct pardevice *pardev;
 	int res;
-
-	pardev = parport_register_device(p, DRIVER_NAME,
-					 NULL, NULL, NULL,
-					 0, NULL);
+	struct pardev_cb pdev_cb = {
+		.preempt = NULL,
+		.wakeup = NULL,
+		.private = NULL,
+		.irq_func = NULL,
+		.flags = 0,
+	};
+
+	/*
+	 * Specify the device number as SNDRV_CARDS + 1 so that the
+	 * device id alloted to this temporary device will never clash
+	 * with an actual device already registered.
+	 */
+	pardev = parport_register_dev_model(p, DRIVER_NAME, &pdev_cb,
+					    SNDRV_CARDS + 1);
 	if (!pardev)
 		return -EIO;
 
@@ -703,10 +714,20 @@  static void snd_portman_detach(struct parport *p)
 	/* nothing to do here */
 }
 
+static int snd_portman_dev_probe(struct pardevice *pardev)
+{
+	if (strcmp(pardev->name, DRIVER_NAME))
+		return -ENODEV;
+
+	return 0;
+}
+
 static struct parport_driver portman_parport_driver = {
-	.name   = "portman2x4",
-	.attach = snd_portman_attach,
-	.detach = snd_portman_detach
+	.name		= "portman2x4",
+	.probe		= snd_portman_dev_probe,
+	.match_port	= snd_portman_attach,
+	.detach		= snd_portman_detach,
+	.devmodel	= true,
 };
 
 /*********************************************************************
@@ -734,6 +755,12 @@  static int snd_portman_probe(struct platform_device *pdev)
 	struct snd_card *card = NULL;
 	struct portman *pm = NULL;
 	int err;
+	struct pardev_cb portman_cb = {
+		.preempt = NULL,
+		.wakeup = NULL,
+		.irq_func = snd_portman_interrupt,	/* ISR */
+		.flags = PARPORT_DEV_EXCL,		/* flags */
+	};
 
 	p = platform_get_drvdata(pdev);
 	platform_set_drvdata(pdev, NULL);
@@ -758,13 +785,11 @@  static int snd_portman_probe(struct platform_device *pdev)
 	sprintf(card->longname,  "%s at 0x%lx, irq %i",
 		card->shortname, p->base, p->irq);
 
-	pardev = parport_register_device(p,                     /* port */
-					 DRIVER_NAME,           /* name */
-					 NULL,                  /* preempt */
-					 NULL,                  /* wakeup */
-					 snd_portman_interrupt, /* ISR */
-					 PARPORT_DEV_EXCL,      /* flags */
-					 (void *)card);         /* private */
+	portman_cb.private = card;			   /* private */
+	pardev = parport_register_dev_model(p,		   /* port */
+					    DRIVER_NAME,   /* name */
+					    &portman_cb,   /* callbacks */
+					    pdev->id);	   /* device number */
 	if (pardev == NULL) {
 		snd_printd("Cannot register pardevice\n");
 		err = -EIO;