From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] parport: check exclusive access before register
Date: Fri, 12 Jun 2015 15:20:20 +0530 [thread overview]
Message-ID: <1434102620-2564-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)
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
next reply other threads:[~2015-06-12 9:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 9:50 Sudip Mukherjee [this message]
2015-06-12 16:25 ` Greg KH
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=1434102620-2564-1-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®