public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parport: check exclusive access before register
@ 2015-06-12  9:50 Sudip Mukherjee
  2015-06-12 16:25 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2015-06-12  9:50 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Sudip Mukherjee

As of now we were starting the registration process and after the device
is registered we were checking if the device can be used by the
parport. Now lets check it first so that we do not need to go through
the registration process only to fail at the end.
The original exclusive access check at the end is still there so that we
do not get any surprises if two different process registers its device
with same parport and with exclusive access at the same time.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

Hi Greg,
One doubt - if anyone sends any patch regarding parport, it will be
addressed to me. so do i need to forward it to you?

 drivers/parport/share.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 697c6d7..8067f54 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -708,6 +708,20 @@ parport_register_device(struct parport *port, const char *name,
 		}
 	}
 
+	if (flags & PARPORT_DEV_EXCL) {
+		if (port->physport->devices) {
+			/*
+			 * If a device is already registered and this new
+			 * device wants exclusive access, then no need to
+			 * continue as we can not grant exclusive access to
+			 * this device.
+			 */
+			pr_err("%s: cannot grant exclusive access for device %s\n",
+			       port->name, name);
+			return NULL;
+		}
+	}
+
 	/* We up our own module reference count, and that of the port
            on which a device is to be registered, to ensure that
            neither of us gets unloaded while we sleep in (e.g.)
@@ -827,6 +841,20 @@ parport_register_dev_model(struct parport *port, const char *name,
 		}
 	}
 
+	if (par_dev_cb->flags & PARPORT_DEV_EXCL) {
+		if (port->physport->devices) {
+			/*
+			 * If a device is already registered and this new
+			 * device wants exclusive access, then no need to
+			 * continue as we can not grant exclusive access to
+			 * this device.
+			 */
+			pr_err("%s: cannot grant exclusive access for device %s\n",
+			       port->name, name);
+			return NULL;
+		}
+	}
+
 	if (!try_module_get(port->ops->owner))
 		return NULL;
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] parport: check exclusive access before register
  2015-06-12  9:50 [PATCH] parport: check exclusive access before register Sudip Mukherjee
@ 2015-06-12 16:25 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2015-06-12 16:25 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: linux-kernel

On Fri, Jun 12, 2015 at 03:20:20PM +0530, Sudip Mukherjee wrote:
> As of now we were starting the registration process and after the device
> is registered we were checking if the device can be used by the
> parport. Now lets check it first so that we do not need to go through
> the registration process only to fail at the end.
> The original exclusive access check at the end is still there so that we
> do not get any surprises if two different process registers its device
> with same parport and with exclusive access at the same time.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
> 
> Hi Greg,
> One doubt - if anyone sends any patch regarding parport, it will be
> addressed to me. so do i need to forward it to you?

Yes, please do so, I'll be glad to queue them up in my trees to go to
Linus.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-12 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-12  9:50 [PATCH] parport: check exclusive access before register Sudip Mukherjee
2015-06-12 16:25 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox