cdev to pdev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Im trying to update scx200_gpio to properly use the 2.6 api
    (and thus learn it)
attached patch does following:
- register chrdev-region for 32 devices, (or alloc-chrdev-region)
- allocate array of 32 cdevs,
- initialize each cdev in scx200_gpio_init()
   with gpio_fops, and major, minors

What follows, is a stream-of-conciousness, discover, a bit of fumbling ..
its a monologue in search of a dialogue ..

One thing missing wrt current best practice is
the lack of dev_dbg(), etc to control debug messages.
I cant figure out how to get a dev I can use.

1st printk()s Id like to lose are in fops write-handler

static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
                                size_t len, loff_t *ppos)
{
       unsigned m = iminor(file->f_dentry->d_inode);
      ...
               case 'O':
printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
                       scx200_gpio_configure(m, ~1, 1);
                       break;


Oooh, I think the light just went on...

If I set up file->private_data with the right info, then the dev is obtainable.
right now, (in patch 5) I do
(retrieval, and initialization, in write-handler, and open-handler respectively) chr-scx200-gpio-vtable-calls:+ struct gpio_access_methods *amp = file->private_data;
chr-scx200-gpio-vtable-calls:+  file->private_data = &scx200_access;

access-methods has .owner, with THIS_MODULE.
add a struct device *,
   or something that contains one, like:
    platform_device, miscdevice, probably many others.

so, wheres my device ?
dont I automatically get one, perhaps under the covers ?

why isnt/arent there THIS_DRIVER, THIS_PLATFORM, THIS_BUS constructs ?
THIS_MODULE storage is magically populated
   ( during what? compilation, module-loading, init ?)
couldnt the others be also (if later).

I also found this:
**Subject: Driver model ISA bus**
http://marc.theaimsgroup.com/?l=linux-kernel&m=114678055902797&w=2
It looks interesting - anything that simplifies stuff is -
but alas - theres no empty-isa-driver.c for me to start from.

.. any comments ?


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux