From patchwork Tue Feb 16 17:33:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8330061 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 946499F38B for ; Tue, 16 Feb 2016 17:38:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B2B0202AE for ; Tue, 16 Feb 2016 17:38:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 40F7C20272 for ; Tue, 16 Feb 2016 17:38:52 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5CE7B26672C; Tue, 16 Feb 2016 18:38:51 +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 1678926667B; Tue, 16 Feb 2016 18:35:14 +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 8CE0B266672; Tue, 16 Feb 2016 18:35:11 +0100 (CET) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by alsa0.perex.cz (Postfix) with ESMTP id 614372665DF for ; Tue, 16 Feb 2016 18:33:43 +0100 (CET) Received: by mail-pa0-f43.google.com with SMTP id fl4so94858041pad.0 for ; Tue, 16 Feb 2016 09:33:43 -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; bh=ZyxMMJ/lch/7sNGo7dz4SrZOujcin2b2P9pVC9VtEU8=; b=f17v6WtKTy1CHsFYPAiWIriUDlwjbbxE/fXtDHMCuyyCpX5Ey9IywZizy19XiXnw3K AIgbkL2DMfj0QhNzqFRq1pKUIQwPMj7ote7M/Ioi/WyvA3SS+8SWyiVMFCRL8bvePdUU BgdeLYk/pymSrtq8d8afdBO57LUhghfc1AG8XnRma+4F6ObjrLGTilIa4L8A6jGtf4+k 27Gy+xILvITmYRt1zSz86C/CkYa4sE+yMlfx7t464TVtD5fuXooFLmX/bfunBzIgCcyC s/QBDtpnedHtmVY0AhFFH6656KmmiuBuDWWh1bA8anKDTOwL/nSleDrPbO0ASrPqXIlI KyKA== 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; bh=ZyxMMJ/lch/7sNGo7dz4SrZOujcin2b2P9pVC9VtEU8=; b=QapGutyJlNxIcW7uVQ/r9qDx5OG+RsvRt5Q6O/hbSzxlzIMREMjj2mM910IAgrNjyf XhLWWo3UIS7kTGJektuEl3+mmZN0o9DR6MNn6JpQJjYCEoiZhe7XqEeoOnTtExaq1P4Z xFus/V6opOUkzc5ehkmUr2B6JMYuBb2zfPDP/W2yrnxnCmkhWOdykisGHknbSznKKKJq /V+AZLAxAypHnPtQIpx65TJx2HJ70Ox4wc53SR8MECHe7cDyV8tpHyxf98q5JwZv4pCY Q0AY4bIshMF0KE3qzlm6JSricUX4mbNISt+afOjzrXKXzGCjSxIdHY0FVPtpc+wPI3KV rzGA== X-Gm-Message-State: AG10YOTz7RB/Z6L1A7VbPI7EADRpVQIwSBdz4r1uZUxiRKtC4JrRm14qEpuCHah82j1TEA== X-Received: by 10.66.124.131 with SMTP id mi3mr32263193pab.7.1455644022075; Tue, 16 Feb 2016 09:33:42 -0800 (PST) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id 67sm45526868pfi.2.2016.02.16.09.33.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 09:33:41 -0800 (PST) From: Sudip Mukherjee To: Jaroslav Kysela , Takashi Iwai Date: Tue, 16 Feb 2016 23:03:31 +0530 Message-Id: <1455644011-1148-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [alsa-devel] [PATCH v4] 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 changes are in the way the driver gets registered with the parallel port subsystem and the temporary device to probe portman card is removed and portman_probe() is used in the probe callback. Signed-off-by: Sudip Mukherjee --- v4: temporary device to probe is removed. 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 | 79 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 464385a..0741a3b 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -648,30 +648,6 @@ static void snd_portman_interrupt(void *userdata) spin_unlock(&pm->reg_lock); } -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); - if (!pardev) - return -EIO; - - if (parport_claim(pardev)) { - parport_unregister_device(pardev); - return -EIO; - } - - res = portman_probe(p); - - parport_release(pardev); - parport_unregister_device(pardev); - - return res ? -EIO : 0; -} - static void snd_portman_attach(struct parport *p) { struct platform_device *device; @@ -705,10 +681,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, }; /********************************************************************* @@ -736,6 +722,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); @@ -745,9 +737,6 @@ static int snd_portman_probe(struct platform_device *pdev) if (!enable[dev]) return -ENOENT; - if ((err = snd_portman_probe_port(p)) < 0) - return err; - err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE, 0, &card); if (err < 0) { @@ -759,23 +748,33 @@ 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; goto __err; } + if (parport_claim(pardev)) { + err = -EIO; + goto free_pardev; + } + + err = portman_probe(p); + parport_release(pardev); + + if (err) { + err = -EIO; + goto free_pardev; + } + if ((err = portman_create(card, pardev, &pm)) < 0) { snd_printd("Cannot create main component\n"); - parport_unregister_device(pardev); - goto __err; + goto free_pardev; } card->private_data = pm; card->private_free = snd_portman_card_private_free; @@ -808,6 +807,8 @@ static int snd_portman_probe(struct platform_device *pdev) snd_printk(KERN_INFO "Portman 2x4 on 0x%lx\n", p->base); return 0; +free_pardev: + parport_unregister_device(pardev); __err: snd_card_free(card); return err;