From patchwork Sat Aug 8 10:35:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6974371 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C21D0C05AC for ; Sat, 8 Aug 2015 10:35:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7D1A20628 for ; Sat, 8 Aug 2015 10:35:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B11920620 for ; Sat, 8 Aug 2015 10:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932692AbbHHKfZ (ORCPT ); Sat, 8 Aug 2015 06:35:25 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33348 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932633AbbHHKfY (ORCPT ); Sat, 8 Aug 2015 06:35:24 -0400 Received: by pabyb7 with SMTP id yb7so72690142pab.0; Sat, 08 Aug 2015 03:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=2TMQ4F7wf34W5TEHB9fFz5uj9KZEXi8SsBKwuJlEJ0M=; b=voVbClc3q8BJOfeeoBIPZDKpbTo0IB3+EsVP/eHyZEc6XCfoaQpr7QH3yEh5NdAH/5 nWSO52khueYgfu27Mh2FCPV9ZJ4dE2H5GuKVsjlPlVSprIOd7FwDJ/qib4GJUI+ytsYu qcezSbDcIjw/NB47KoyDid4TBc8WjS3c4r5ZzCQHiRSycC4g01ne20dMXkhJ6mUK+Ppw 2Z0je0vOxX7Xea5QsnZmCTV7iRIp6fP6/vbVjbfWZKPxya6yDp1xDUhEkfVugj7yiF3T z1Ec4Xy248hJ+0lEOa1Bs9HBYDqUELWSdUazSkVm+HbV7yX+1YIFQwoBDH454bSyDqHg QIaQ== X-Received: by 10.68.219.73 with SMTP id pm9mr25264182pbc.84.1439030123901; Sat, 08 Aug 2015 03:35:23 -0700 (PDT) Received: from sudip-pc ([122.169.130.215]) by smtp.gmail.com with ESMTPSA id sa2sm13019740pbb.86.2015.08.08.03.35.20 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 08 Aug 2015 03:35:23 -0700 (PDT) Date: Sat, 8 Aug 2015 16:05:15 +0530 From: Sudip Mukherjee To: Dmitry Torokhov Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, gregkh@linuxfoundation.org Subject: Re: [PATCH v2] Input: drivers/joystick: use parallel port device model Message-ID: <20150808103515.GC1301@sudip-pc> References: <1438698351-24604-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1438698351-24604-1-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Aug 04, 2015 at 07:55:51PM +0530, Sudip Mukherjee wrote: > Modify db9 driver to use the new Parallel Port device model. > > Signed-off-by: Sudip Mukherjee > --- > > v2: an extra check was removed. db9_base could not be removed. Already > mailed you the reasons, reference is at: > https://lkml.org/lkml/2015/8/3/403 Hi Dmitry, I was telling you on the other thread that to remove db9_base we will need to modify the parport code and then it has to be tested by everyone again and that will also change the old behaviour of parport. The v2 to which I am replying now is still having that db9_base. Please see the following patch, this is the minimum change required to update db9 driver. Personally I donot like this approach as in this method if a parallel port is hotplugged after this driver is loaded then it will not work. Please let me know your views on the posted v2 and also on the following proposal. regards sudip Tested-By: Pali Rohár --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index 8e7de5c..348e7d2 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c @@ -553,7 +553,7 @@ static void db9_close(struct input_dev *dev) mutex_unlock(&db9->mutex); } -static struct db9 __init *db9_probe(int parport, int mode) +static struct db9 __init *db9_probe(int parport, int mode, int cnt) { struct db9 *db9; const struct db9_mode_data *db9_mode; @@ -562,6 +562,7 @@ static struct db9 __init *db9_probe(int parport, int mode) struct input_dev *input_dev; int i, j; int err; + struct pardev_cb db9_parport_cb; if (mode < 1 || mode >= DB9_MAX_PAD || !db9_modes[mode].n_buttons) { printk(KERN_ERR "db9.c: Bad device type %d\n", mode); @@ -584,7 +585,9 @@ static struct db9 __init *db9_probe(int parport, int mode) goto err_put_pp; } - pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); + db9_parport_cb.flags = PARPORT_FLAG_EXCL; + + pd = parport_register_dev_model(pp, "db9", &db9_parport_cb, cnt); if (!pd) { printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n"); err = -EBUSY; @@ -671,11 +674,19 @@ static void db9_remove(struct db9 *db9) kfree(db9); } +static struct parport_driver db9_parport_driver = { + .name = "db9", + .devmodel = true, +}; + static int __init db9_init(void) { int i; int have_dev = 0; - int err = 0; + int err = parport_register_driver(&db9_parport_driver); + + if (err) + return err; for (i = 0; i < DB9_MAX_PORTS; i++) { if (db9_cfg[i].nargs == 0 || db9_cfg[i].args[DB9_ARG_PARPORT] < 0) @@ -688,7 +699,7 @@ static int __init db9_init(void) } db9_base[i] = db9_probe(db9_cfg[i].args[DB9_ARG_PARPORT], - db9_cfg[i].args[DB9_ARG_MODE]); + db9_cfg[i].args[DB9_ARG_MODE], i); if (IS_ERR(db9_base[i])) { err = PTR_ERR(db9_base[i]); break; @@ -701,10 +712,15 @@ static int __init db9_init(void) while (--i >= 0) if (db9_base[i]) db9_remove(db9_base[i]); + parport_unregister_driver(&db9_parport_driver); return err; } - return have_dev ? 0 : -ENODEV; + if (have_dev) + return 0; + + parport_unregister_driver(&db9_parport_driver); + return -ENODEV; } static void __exit db9_exit(void) @@ -714,6 +730,7 @@ static void __exit db9_exit(void) for (i = 0; i < DB9_MAX_PORTS; i++) if (db9_base[i]) db9_remove(db9_base[i]); + parport_unregister_driver(&db9_parport_driver); } module_init(db9_init);