All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jean Delvare <jdelvare@suse.de>, Wolfram Sang <wsa@the-dreams.de>,
	Rodolfo Giometti <giometti@enneenne.com>,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	Mark Brown <broonie@kernel.org>, Willy Tarreau <willy@meta-x.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	netdev@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-spi@vger.kernel.org, devel@driverdev.osuosl.org,
	alsa-devel@alsa-project.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH 01/14] parport: return value of attach and parport_register_driver
Date: Wed,  8 Apr 2015 16:50:27 +0530	[thread overview]
Message-ID: <1428492040-5581-2-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1428492040-5581-1-git-send-email-sudipm.mukherjee@gmail.com>

as of now, we are not checking if attach or parport_register_driver
has succeeded or failed. But attach can fail in the places where they
have been used. Lets check the return of attach, and if attach fails
then parport_register_driver should also fail. We can have multiple
parallel port so we only mark attach as failed only if it has never
returned a 0.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/parport/share.c | 20 +++++++++++++++-----
 include/linux/parport.h |  2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 3fa6624..640ce41 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -148,23 +148,33 @@ static void get_lowlevel_driver (void)
  *	callback, but if the driver wants to take a copy of the
  *	pointer it must call parport_get_port() to do so.
  *
- *	Returns 0 on success.  Currently it always succeeds.
+ *	Returns 0 on success.
  **/
 
 int parport_register_driver (struct parport_driver *drv)
 {
 	struct parport *port;
+	int ret, err;
+	bool attached = false;
 
 	if (list_empty(&portlist))
 		get_lowlevel_driver ();
 
 	mutex_lock(&registration_lock);
-	list_for_each_entry(port, &portlist, list)
-		drv->attach(port);
-	list_add(&drv->list, &drivers);
+	list_for_each_entry(port, &portlist, list) {
+		err = drv->attach(port);
+		if (err == 0)
+			attached = true;
+		else
+			ret = err;
+	}
+	if (attached) {
+		list_add(&drv->list, &drivers);
+		ret = 0;
+	}
 	mutex_unlock(&registration_lock);
 
-	return 0;
+	return ret;
 }
 
 /**
diff --git a/include/linux/parport.h b/include/linux/parport.h
index c22f125..9411065 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -249,7 +249,7 @@ struct parport {
 
 struct parport_driver {
 	const char *name;
-	void (*attach) (struct parport *);
+	int (*attach)(struct parport *);
 	void (*detach) (struct parport *);
 	struct list_head list;
 };
-- 
1.8.1.2


  reply	other threads:[~2015-04-08 11:21 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 11:20 [PATCH 00/14] parport: check success of attach call Sudip Mukherjee
2015-04-08 11:20 ` Sudip Mukherjee
2015-04-08 11:20 ` Sudip Mukherjee [this message]
2015-04-08 11:38   ` [PATCH 01/14] parport: return value of attach and parport_register_driver Dan Carpenter
2015-04-08 11:38     ` Dan Carpenter
2015-04-08 11:44     ` Dan Carpenter
2015-04-08 11:44       ` Dan Carpenter
2015-04-08 12:14       ` Sudip Mukherjee
2015-04-08 12:14         ` Sudip Mukherjee
2015-04-08 11:50     ` Sudip Mukherjee
2015-04-08 11:50       ` Sudip Mukherjee
2015-04-08 12:27       ` Dan Carpenter
2015-04-08 12:27         ` Dan Carpenter
2015-04-08 17:56         ` Willy Tarreau
2015-04-08 17:56           ` Willy Tarreau
2015-04-08 11:20 ` [PATCH 02/14] ALSA: portman2x4: return proper error values from attach Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 13:32   ` Sergei Shtylyov
2015-04-08 13:32     ` Sergei Shtylyov
2015-04-08 13:40     ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 03/14] ALSA: mts64: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 04/14] staging: panel: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 05/14] spi: lm70llp: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 06/14] spi: butterfly: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 07/14] [SCSI] ppa: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 08/14] [SCSI] imm: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 09/14] pps: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 10/14] " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 11/14] net: plip: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 12/14] i2c-parport: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee
2015-04-09  7:13   ` Wolfram Sang
2015-04-09  7:13     ` Wolfram Sang
2015-04-09  9:33     ` Jean Delvare
2015-04-09 10:25       ` Wolfram Sang
2015-04-09 10:25         ` Wolfram Sang
2015-04-10  5:05         ` Sudip Mukherjee
2015-04-10  5:05           ` Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 13/14] ppdev: " Sudip Mukherjee
2015-04-08 11:20 ` [PATCH 14/14] char: lp: " Sudip Mukherjee
2015-04-08 11:20   ` Sudip Mukherjee

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=1428492040-5581-2-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=giometti@enneenne.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    --cc=willy@meta-x.org \
    --cc=wsa@the-dreams.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.