Re: [PARPORT] Re: PARPORT_DEV_EXCL


Tim Waugh (tim@cyberelk.demon.co.uk)
Fri, 25 Sep 1998 20:30:52 +0100 (BST)


Hi guys,

This is the same thing (mostly; some typos fixed) against
parport-arca-2.1.122-8:

It's still untested, but it compiles. What do you think?

Tim.
*/

--- linux/include/linux/parport.h~ Fri Sep 25 20:17:07 1998
+++ linux/include/linux/parport.h Fri Sep 25 20:25:34 1998
@@ -316,9 +316,11 @@
 
 /* Flags used to identify what a device does. */
 #define PARPORT_DEV_TRAN 0x0000 /* We're transient. */
-#define PARPORT_DEV_LURK 0x0001 /* We lurk. */
+#define PARPORT_DEV_LURK (1<<0) /* We lurk. */
+#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */
 
-#define PARPORT_FLAG_COMA 1
+#define PARPORT_FLAG_COMA (1<<0)
+#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */
 
 extern void parport_parse_irqs(int, const char *[], int irqval[]);
 extern int parport_ieee1284_nibble_mode_ok(struct parport *, unsigned char);
--- linux/drivers/misc/parport_share.c~ Fri Sep 25 20:17:07 1998
+++ linux/drivers/misc/parport_share.c Fri Sep 25 20:25:32 1998
@@ -197,6 +197,13 @@
 {
         struct pardevice *tmp;
 
+ if (port->flags & PARPORT_FLAG_EXCL) {
+ /* An exclusive device is registered. */
+ printk (KERN_DEBUG "%s: no more devices allowed\n",
+ port->name);
+ return NULL;
+ }
+
         if (flags & PARPORT_DEV_LURK) {
                 if (!pf || !kf) {
                         printk(KERN_INFO "%s: refused to register lurking device (%s) without callbacks\n", port->name, name);
@@ -247,6 +254,20 @@
          * to clear irq on the local CPU. -arca
          */
         spin_lock(&port->pardevice_lock);
+
+ if (flags & PARPORT_DEV_EXCL) {
+ if (port->devices) {
+ spin_unlock (&port->pardevice_lock);
+ kfree (tmp->state);
+ kfree (tmp);
+ printk (KERN_DEBUG
+ "%s: cannot grant exclusive access\n",
+ port->name);
+ return NULL;
+ }
+ port->flags |= PARPORT_FLAG_EXCL;
+ }
+
         tmp->next = port->devices;
         if (port->devices)
                 port->devices->prev = tmp;
@@ -289,6 +310,10 @@
                 dev->prev->next = dev->next;
         else
                 port->devices = dev->next;
+
+ if (dev->flags & PARPORT_DEV_EXCL)
+ port->flags &= ~PARPORT_FLAG_EXCL;
+
         spin_unlock(&port->pardevice_lock);
 
         kfree(dev->state);

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:18:24 EST