From patchwork Thu Feb 4 16:46:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8225351 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EE7B39F1C0 for ; Thu, 4 Feb 2016 16:47:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EC69203A9 for ; Thu, 4 Feb 2016 16:47:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C50F520397 for ; Thu, 4 Feb 2016 16:47:39 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8849226652E; Thu, 4 Feb 2016 17:47:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E9757261B03; Thu, 4 Feb 2016 17:47:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8ED1F26602C; Thu, 4 Feb 2016 17:47:00 +0100 (CET) Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) by alsa0.perex.cz (Postfix) with ESMTP id 06985261B03 for ; Thu, 4 Feb 2016 17:46:55 +0100 (CET) Received: by mail-pf0-f169.google.com with SMTP id 65so50354028pfd.2 for ; Thu, 04 Feb 2016 08:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FYlYUoWjxYVfoMbW8mPQl8nfscG4k6YAW79LemPTnWk=; b=JByFeG526eGxqYS6NxCANeaVzoHphQTmZy/yzAEHgqZ1wG8Bqyt6m6k0BEnCda5i9r nEe0fet6iJvL96KAv+dFa2BIJl1wo2SUgxNtvvAXEXcv8tCFemTfIGk83PyWP/kwwiiJ oFYfLMLO3N24zKZysBbQH7QxKEVK8ZBDocC4Yn+fry/Q0o1PYhseqEippItfKZyEnovC plSwoSG6sVsxByjYwXcJJN5yqaSWKyWhAHLuDTrBVXl/aqLa9mrPI7xNhMLqFLezBCaa 1knTiK0Y9qCKbRo5aeNxQIGyPv9ejsztfZsHN7z2Lh1OIc92CU9XeC8GN3nrJwTURFh+ zPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FYlYUoWjxYVfoMbW8mPQl8nfscG4k6YAW79LemPTnWk=; b=C+NjWleTjLEcd68wg7VbJOUG1GgcY9lZmxTc4Nb6sEz4u+p9K4KrlwPV/eGM4qgGjJ 0QrwcNKbN2F1bWzoLNfJP51SZ9mq6mBUCAGO6AhjlhMxpMNFG5GBmyIjPlTD2290B5qt EdI+lR9Y1BFPY6PST6aCF+ZQyBSEdwLlS7nN67dz5ccKnUIi0n3nzeH8gZkYASalwl+g Cqm21Ftxq7z3/AnDeI7aFsrWJMs/ae4RMMQ34qiLrq2WaorjXdglYIbND/ExyFonsx7E NQnlWpQQscA3D6zVlqlVvXsjJ9Hxf3lmYHlPqy9cq6mQp3WurzFDbzwkKY4I0OEd+8t6 zOpg== X-Gm-Message-State: AG10YOTfio38a6yRf3M6Pd9RwMnSxrmSHoWjbcGteh+uKkRK+5tmIom7LTNvRjDTFyZxtA== X-Received: by 10.98.19.12 with SMTP id b12mr12265273pfj.29.1454604414313; Thu, 04 Feb 2016 08:46:54 -0800 (PST) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id dg1sm18367498pad.18.2016.02.04.08.46.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 08:46:53 -0800 (PST) From: Sudip Mukherjee To: Jaroslav Kysela , Takashi Iwai Date: Thu, 4 Feb 2016 22:16:34 +0530 Message-Id: <1454604394-16055-3-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454604394-16055-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1454604394-16055-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [alsa-devel] [PATCH v3 3/3] ALSA: mts64: use new parport device model X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;