mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Problem with minor devices numbers in 2.4.4/68k
@ 2001-05-29 15:25 Michael Baumann
  2001-05-29 16:56 ` Alan Cox
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Baumann @ 2001-05-29 15:25 UTC (permalink / raw)
  To: linux-kernel

Hopefully, I don't offend anyone by asking this here, but
I assume (perhaps incorrectly) that this is the place to
go when trying to decipher writing device drivers.
My problem: A device driver for a custom board worked fine
under 2.2.10 - I used the minor number to identify various
channels on the board. In the open() call, I used
MINOR(inode->i_rdev) to decode that information. Now under
2.4.4, this *appears* to be broken - though I am certain it
is my misunderstanding. In checking, every minor device
returns exactly the same i_rdev code.
Anyway, attached are some snippets of code, if someone can point
out where I goofed, I would really appreciate it. I'm in the
process of trying to prove to the PHB that linux is a viable
embedded platform.
Note that at this time, I am not using the devfs, though I did
try and incorporate support. If someone can point me to a good
"how do deal with the changes in 2.4" I'd appreciate that as well.
Anyway in my init_module() routine I register the region, and major/minor
devices:
 if((devfs_register_chrdev(42,"timer", &timer_fops)) < 0)
  {
    printk("Timer: bad doobie, device 42 missing?\n");
    return -EIO;
  }
  else
  {
    int tmrs;

    printk("Timer: Cool,chrdev is regsitered!\n");
    for(tmrs=0;tmrs<8;tmrs++)
    {
      timer_handles[tmrs]=devfs_register(NULL,"timer",DEVFS_FL_DEFAULT,
                                42, tmrs, S_IFCHR |
                                       S_IRUGO | S_IWUSR,&timer_fops,tmrs);
    }

  }


And in my open, I try to decode the minor number:

static
int timer_open(struct inode *inode, struct file *file)
{

  printk("sysclk: open() f_mode=%d, minor = %1d, minor2 %0x\n",
       file->f_mode, MINOR(inode->i_rdev),(inode->i_rdev));

  // we're going to be sneaky here - the minor number
  // stored in the file private data will be used to
  // index the 'interrupt occurred' flag for the poll
  // routine.
  file->private_data = (void *)MINOR(inode->i_rdev);
  usequeue[MINOR(inode->i_rdev)]++;
  MOD_INC_USE_COUNT;
  return 0;
}

But MINOR(inode->i_rdev) always returns 0, no matter which
minor devices I open.
If this doesn't belong here, please direct mail me, as this
has my stymied.

Thank you.

--
Michael Baumann  Optivus Technology Inc.|Loma Linda University Medical
Center
San Bernardino, California. (909)799-8308 |Internet: baumann@llumc.edu



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

* Re: Problem with minor devices numbers in 2.4.4/68k
  2001-05-29 15:25 Problem with minor devices numbers in 2.4.4/68k Michael Baumann
@ 2001-05-29 16:56 ` Alan Cox
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2001-05-29 16:56 UTC (permalink / raw)
  To: baumann; +Cc: linux-kernel

> MINOR(inode->i_rdev) to decode that information. Now under
> 2.4.4, this *appears* to be broken - though I am certain it

Nope . Its right

> But MINOR(inode->i_rdev) always returns 0, no matter which
> minor devices I open.
> If this doesn't belong here, please direct mail me, as this
> has my stymied.

The code looks right, check your config matches between the kernel and your
modules, _especially_ if you are not using modversions

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

end of thread, other threads:[~2001-05-29 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-29 15:25 Problem with minor devices numbers in 2.4.4/68k Michael Baumann
2001-05-29 16:56 ` Alan Cox

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®