Re: [PARPORT] Re: PARPORT_DEV_EXCL


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


On Fri, 25 Sep 1998, Andrea Arcangeli wrote:

> Agreed. If you are going to produce code I' d like if you would start from
> my latest parport-arca diff. (No one problem so far).

This is against 2.1.122. I'll get your patch and redo against it...

Tim.
*/

--- linux/include/linux/parport.h~ Wed Sep 23 21:02:25 1998
+++ linux/include/linux/parport.h Fri Sep 25 20:08:39 1998
@@ -296,9 +296,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<<1) /* We lurk. */
+#define PARPORT_DEV_EXCL (1<<2) /* 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~ Thu Sep 10 18:20:03 1998
+++ linux/drivers/misc/parport_share.c Fri Sep 25 20:06:07 1998
@@ -197,6 +197,13 @@
         struct pardevice *tmp;
         unsigned long flgs;
 
+ if (port->flags & PARPORT_FLAG_EXCL) {
+ /* An exclusive device is registered. */
+ printk (KERN_DEBUG "%s: no more drivers 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);
@@ -243,6 +250,21 @@
         /* Chain this onto the list */
         tmp->prev = NULL;
         spin_lock_irqsave (&port->lock, flgs);
+
+ if (flags & PARPORT_DEV_EXCL) {
+ if (port->devices) {
+ spin_unlock_irqrestore (&port->lock, flgs);
+ 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;
@@ -286,6 +308,10 @@
                 dev->prev->next = dev->next;
         else
                 port->devices = dev->next;
+
+ if (dev->flags & PARPORT_DEV_EXCL)
+ port->flags &= ~PARPORT_FLAG_EXCL;
+
         spin_unlock_irqrestore (&port->lock, flags);
 
         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