From patchwork Thu Feb 4 16:38:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8225281 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 C031C9F1C0 for ; Thu, 4 Feb 2016 16:41:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CAB92203B1 for ; Thu, 4 Feb 2016 16:41:01 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6DCD9203AC for ; Thu, 4 Feb 2016 16:40:40 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3F0A0266579; Thu, 4 Feb 2016 17:40:39 +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 C74EE266406; Thu, 4 Feb 2016 17:39:13 +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 D3DEF266406; Thu, 4 Feb 2016 17:39:12 +0100 (CET) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by alsa0.perex.cz (Postfix) with ESMTP id 41E3B266168 for ; Thu, 4 Feb 2016 17:38:39 +0100 (CET) Received: by mail-pf0-f179.google.com with SMTP id 65so50142244pfd.2 for ; Thu, 04 Feb 2016 08:38:39 -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=atf0Znws6DkLHDvRO2FGMQVBBeV5Iy5TnbPnXRFpYVM=; b=eMEphyqXm3hJm8bp8Giz219i186wqQZLsd/0NiXVvxdjGSVSdkjT+S4e7w5pmgKZzE DCm1+bCh7hARC+HIP5FWD8t2A24T3BGi0WEckK3ehJ0gkdXpGNxDfsyVRzSHnIVnGeEj 7DLiG63B9xqb3AqHcFDP/ULIAy0DUEL1GCDFEMIRdNPSaChpxRnO+l5MIVpx2C6HrqWQ GFzpfPKa0yJSUIgGZM3f32b5+lq7rkti0DJahDVIcHR3ip5AjJoBp1o8n66Om4vzEwIU TZyBojlKef8MusVUNhKDpmBqJDZobat1XiQSOjnXNZdvjS0KJkyc/Oy6PhEBSy+ywvR+ aZtA== 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=atf0Znws6DkLHDvRO2FGMQVBBeV5Iy5TnbPnXRFpYVM=; b=ffzLbolko4gQTSsm72w7DSybGwtcecj5XHQ4MHSiEHy3GHxizGcm+ch94OsT0pSUEx xEbf0rivm8M/0GkQoDxrBwObz58xlFjRpDbmK8dzUYUhKse5zoe83eEpiE5i/6Ti2DSJ gm2qblt5ya57EDTuBQ9nQv8IXlT7VsUAkZY8+duzo8Rc1HuOOi57w2+RmtqcFrLFmqx2 Z7NnhgPVw8ITgHIDZjp2p8huS4rg0H7sLy7Wr7xGfwesfZL0a5mLOQi5rP6U5FoAvEC6 PxL2PX0fxakskJCfSb/up8lYeb95ottZEI9M8Qse7QvRyx19nZmMg7LpYfPiOYcfZ34H 2Pow== X-Gm-Message-State: AG10YOQyt7YsNOJIMgkOjXH8jEjF5ptNscILkHkWaLHReN9wKRoC7l/PXOzplrAou0Awzg== X-Received: by 10.66.163.196 with SMTP id yk4mr12324941pab.115.1454603918509; Thu, 04 Feb 2016 08:38:38 -0800 (PST) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id g81sm18386561pfj.1.2016.02.04.08.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 08:38:37 -0800 (PST) From: Sudip Mukherjee To: Jaroslav Kysela , Takashi Iwai Date: Thu, 4 Feb 2016 22:08:23 +0530 Message-Id: <1454603903-15967-3-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454603903-15967-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1454603903-15967-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] portman2x4 - 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 portman 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_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;