From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH v3 3/3] ALSA: mts64: use new parport device model
Date: Thu, 4 Feb 2016 22:16:34 +0530 [thread overview]
Message-ID: <1454604394-16055-3-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1454604394-16055-1-git-send-email-sudipm.mukherjee@gmail.com>
Modify mts64 driver to use the new parallel port device model.
The advantage of using the device model is that the device gets binded
to the hardware, we get the feature of hotplug, we can bind/unbind
the driver at runtime.
The only change is in the way the driver gets registered with the
parallel port subsystem and so as a result there is no user visible
change or any chance of regression.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
v3: changed commit message
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_mts64_dev_probe().
sound/drivers/mts64.c | 52 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index ee6a87f..74698ea 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -851,10 +851,21 @@ static int snd_mts64_probe_port(struct parport *p)
{
struct pardevice *pardev;
int res;
+ struct pardev_cb pdev_cb = {
+ .preempt = NULL,
+ .wakeup = NULL,
+ .private = NULL,
+ .irq_func = NULL,
+ .flags = 0,
+ };
- pardev = parport_register_device(p, DRIVER_NAME,
- NULL, NULL, NULL,
- 0, NULL);
+ /*
+ * 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;
@@ -904,10 +915,20 @@ static void snd_mts64_detach(struct parport *p)
/* nothing to do here */
}
+static int snd_mts64_dev_probe(struct pardevice *pardev)
+{
+ if (strcmp(pardev->name, DRIVER_NAME))
+ return -ENODEV;
+
+ return 0;
+}
+
static struct parport_driver mts64_parport_driver = {
- .name = "mts64",
- .attach = snd_mts64_attach,
- .detach = snd_mts64_detach
+ .name = "mts64",
+ .probe = snd_mts64_dev_probe,
+ .match_port = snd_mts64_attach,
+ .detach = snd_mts64_detach,
+ .devmodel = true,
};
/*********************************************************************
@@ -935,6 +956,12 @@ static int snd_mts64_probe(struct platform_device *pdev)
struct snd_card *card = NULL;
struct mts64 *mts = NULL;
int err;
+ struct pardev_cb mts64_cb = {
+ .preempt = NULL,
+ .wakeup = NULL,
+ .irq_func = snd_mts64_interrupt, /* ISR */
+ .flags = PARPORT_DEV_EXCL, /* flags */
+ };
p = platform_get_drvdata(pdev);
platform_set_drvdata(pdev, NULL);
@@ -959,13 +986,12 @@ static int snd_mts64_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_mts64_interrupt, /* ISR */
- PARPORT_DEV_EXCL, /* flags */
- (void *)card); /* private */
+ mts64_cb.private = card; /* private */
+
+ pardev = parport_register_dev_model(p, /* port */
+ DRIVER_NAME, /* name */
+ &mts64_cb, /* callbacks */
+ pdev->id); /* device number */
if (pardev == NULL) {
snd_printd("Cannot register pardevice\n");
err = -EIO;
--
1.9.1
prev parent reply other threads:[~2016-02-04 16:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 16:46 [PATCH v3 1/3] ALSA: mts64: whitespace fixes Sudip Mukherjee
2016-02-04 16:46 ` [PATCH v3 2/3] ALSA: mts64: assignment in if Sudip Mukherjee
2016-02-04 16:46 ` Sudip Mukherjee [this message]
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=1454604394-16055-3-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).