Issue with ioctl commands - Linux version 2.6.35.7+

Chetan Nanda chetannanda at gmail.com
Wed Dec 28 22:12:55 EST 2011


On Wed, Dec 28, 2011 at 8:22 PM, autif khan <autif.mlist at gmail.com> wrote:

> Hi Chetan,
>
> I was wondering if switching to unlocked_ioctl() fixed the issue.
>
> I will be developing a hardware driver and would like to know how you
> made out. Please let me know if the 'cmd' is passed correctly.
>
> Thanks for sharing.
>
> Autif
>

Hi Autif,
Please go through the link:
http://lwn.net/Articles/119652/

Problem with my dummy driver was that i am using unlocked_ioctl, but
defined the ioctl function with wrong syntax (i.e. with syntax of normal
ioctl function.)

Thanks,
Chetan Nanda

>
> On Tue, Dec 27, 2011 at 10:34 PM, Chetan Nanda <chetannanda at gmail.com>
> wrote:
> >
> >
> > On Tue, Dec 27, 2011 at 11:25 PM, Dave Hylands <dhylands at gmail.com>
> wrote:
> >>
> >> Hi Chetan,
> >>
> >> On Tue, Dec 27, 2011 at 3:39 AM, Chetan Nanda <chetannanda at gmail.com>
> >> wrote:
> >> > Hi All,
> >> >
> >> > I am facing a strange issue with the ioctl commands, and not able to
> >> > find
> >> > what wrong I am doing.
> >> > I am trying with a dummy kernel driver and implemented ioctl command
> as
> >> > follow:
> >> >
> >> > in my_ioctl.h
> >> > #define READHWREG_MAGIC_NUMBER 0x15
> >> > #define READHWREG_CAM_READPE _IOR(READHWREG_MAGIC_NUMBER, 1, int*)
> >> >
> >> > But the value of 'READHWREG_CAM_READPE' is comes out to be different
> in
> >> > userspace (in the application) and kernel space (in the driver).
> >> >
> >> > In userspace I used ioctl as
> >> > ...
> >> >    printf("\ncommand %x \n",READHWREG_CAM_READPE); <-- command
> 80041501
> >> >    error = ioctl(g_DevFileId, READHWREG_CAM_READPE);
> >> > ..
> >> >
> >> > In kernel space
> >> >
> >> > int readHwReg_ioctl(struct inode *node, struct file *filp, unsigned
> int
> >> > cmd,  unsigned long arg)
> >> > {
> >> > ...
> >> >    printk("\n%d %s cmd = %x\n",__LINE__,__FUNCTION__,cmd); <--- cmd =
> >> > bee6a9d4
> >>
> >> Back in 2.6.36, the ioctl member of the struct file_operations
> >> structure  (which took 4 arguments) was finally deprecated, replaced
> >> with unlocked_ioctl (which only takes 3 arguments).
> >>
> >> If you just renamed and ignored the compiler warnings, then that
> >> explains your problem.
> >>
> > Thanks Dave for pointing out 'unlocked_ioctl'
> > I come across this link:
> > http://lwn.net/Articles/119652/
> >
> >> --
> >> Dave Hylands
> >> Shuswap, BC, Canada
> >> http://www.davehylands.com
> >
> >
> > Thanks,
> > Chetan Nanda
> >
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111229/30d7faa2/attachment.html 


More information about the Kernelnewbies mailing list