lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 22 Apr 2008 14:34:33 -0400
From:	"Kathy Frazier" <kfrazier@...twyler-rd.com>
To:	"'Alan Cox'" <alan@...rguk.ukuu.org.uk>,
	"'Kathy Frazier'" <kfrazier@...twyler-rd.com>
Cc:	<linux-kernel@...r.kernel.org>
Subject: RE: Talking to parallel port in 2.6 kernel without using parport

Alan,

Thanks for your response.  I had some shifting priorities, but I finally had
a chance to try your suggestion.  Unfortunately I am still having trouble.
In my init routine, I do:


    dev = MKDEV(MY_MAJOR, 0);
    status = register_chrdev_region(dev, 1, MY_DEVNAME);
    if (status < 0)
    {
       printk(KERN_ERR "pp:  unable to get major %d\n", MY_MAJOR);
       return - EIO;
    }
    else
       printk(KERN_INFO "pp:  major number= %d\n", MY_MAJOR);

   printk(KERN_INFO "pp: Adding character device\n");
   cdev_init(&chrdev, &pp_fops);
   chrdev.owner = THIS_MODULE;
   chrdev.ops = &pp_fops;
   status = cdev_add (&chrdev, dev, 1);
   if (status < 0)
   {
      printk(KERN_ERR "pp:  unable to add device %d to system.  status =
%d\n", MY_MAJOR, status);
      return -ENODEV;
   }
    printk(KERN_INFO "pp:  registering with parport\n");
    if (parport_register_driver(&ppdrv))
    {
       printk(KERN_ERR "pp:  unable to register driver with parport\n");
       unregister_chrdev(mymajor, MY_DEVNAME);
       return -EIO;
    }

   my_parport = parport_find_base(DATA);
   if (!my_parport)
   {
      printk(KERN_WARNING "pp:  no associated port!");
      return -ENXIO;
   }
   else
   {
      printk(KERN_INFO "pp:  Found base 0x%x for parport device %s number %d
module state = %d ref count=%d flags = 0x%x\n",
           DATA, my_parport->name, my_parport->number, 
           my_parport->ops->owner->state, 
           my_parport->ops->owner->ref[0].count, 
           my_parport->physport->flags);
   }
   table[0].dev = parport_register_device(my_parport, MY_DEVNAME, NULL,
NULL, NULL, PARPORT_FLAG_EXCL, (void *) &table[0]);
   if (table[0].dev == NULL)
   {
      printk(KERN_ERR "pp:  Error registering device\n");
      return;
   }
   else
      printk(KERN_INFO "pp:  Registered device with parport\n");


Everthing happens as expected, except that the parport_register_device fails
returning NULL.  

One of our engineers downloaded source code a while back from
linux-2.6.18-rc7, but I am not sure how close that is to what is installed
on my system (uname -r returns 2.6.18-1.2798.fc6.  When I set my printk to 8
(echo 8 > /proc/sys/kernel/printk), there are no messages shown on the
failure.  According to the source code I have, the only silent failure in
parport_register_device is:

If (!try_module_get(port->ops->owner)) {
   return NULL;
}

The printk debug I have following the parport_find_base gives the following
result:

pp:  Found base 0x378 for parport device parport0 number 0, module state = 0
ref count=1 flags=0x0
pp:  Error registering device

When I change the flags from PARPORT_FLAG_EXCL to 0 in the call to
parport_register_device, the call returns a non-zero to indicate success.

Can you tell me what I am missing?  Where can I get the actual source code
that goes with this version to further unravel this?

Thanks in advance for your help!  Please CC me.

Kathy Frazier

-----Original Message-----
From: linux-kernel-owner@...r.kernel.org
[mailto:linux-kernel-owner@...r.kernel.org] On Behalf Of Alan Cox
Sent: Monday, April 14, 2008 8:40 AM
To: Kathy Frazier
Cc: linux-kernel@...r.kernel.org
Subject: Re: Talking to parallel port in 2.6 kernel without using parport

> ***** However, I am still unable to open my device.  Can someone tell 
> me what I am missing?
> What do I need to do to talk to the parallel port myself and NOT go 
> through parport?

You should go through parport. The parport layer is there for a reason.
You drive on the road not through fields (even if shorter distances) please
show the same respect for the kernel and your users (plus it'll make your
job easier).

If you need to hog the device because it doesn't follow 1284 or other
sharing standards the parport_register_device can be called with
PARPORT_DEV_EXCL in flags, which means you want to sit on it.

So for something like a standard PC built in port (for the little time they
have left before they go away in hardware..)

	struct parport *p = parport_find_base(0x378 /* etc */);
	
	parport_register_device(p, "mywidget", NULL,
		my_irq_handler, PARPORT_DEV_EXCL, &mystruct)
	parport_enable_irq(p);

where mystruct is a private object that will be passed back to you in the
callbacks. If you don't use the IRQ then don't call parport_enable_irq and
my_irq_handler can also be NULL.

Alan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ