This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

build dsplink with kernel 2.6.36

Other Parts Discussed in Thread: OMAP3530

Hi all,

I'm trying to build the dsplink package 1.65.01 with kbuid against the kernel 2.6.36 (arago git repository). Until kernel 2.6.35, everything has been working properly.

Now I'm having troubles because starting from 2.6.36 in file include/linux/fs.h the ioctl field has been removed from struct file_operations.

When I try to build the package, I get the following error:

dsplink_linux_1_65_00_01/dsplink/kbuild/../gpp/src/pmgr/Linux/2.6.18/drv_pmgr.c:496: error: unknown field 'ioctl' specified in initializer

Do you have any idea about how to solve this issue? 
Thanks a lot!

  • In general, you can just use the 'unlocked_ioctl' member of the file_operations struct.  To do so, change
    STATIC struct file_operations driverOps = {
        open:    DRV_Open,
        flush:   DRV_Flush,
        release: DRV_Release,
        ioctl:   DRV_Ioctl,
        mmap:    DRV_Mmap,
        read:    DRV_Read
    } ;

    to
    STATIC struct file_operations driverOps = {
        open:    DRV_Open,
        flush:   DRV_Flush,
        release: DRV_Release,
        unlocked_ioctl:   DRV_Ioctl,
        mmap:    DRV_Mmap,
        read:    DRV_Read
    } ;

    I don't know if other things in DSPLink would need to change to accomodate this new kernel.

    Regards,

    - Rob

  • Robert,

    the hint is right,  but it's not enough.

    The two members (ioctl and unlocked_ioctl) have different parameters so I've changed also the function prototype removing the first argument (which isn't used) and it seems to be working properly.

    The driver compiles, the system is able to lead it and the driver components PROC and MESG seems to work properly

     

    Thanks for your support.

     

     

  • Miriano,

    That's right, sorry for neglecting to include that info.

    For the Forum record...

    The unlocked_ioctl interface removes the first parameter "inode" (which can be obtained anyways through the filp), and changes the return value:

    unlocked_ioctl: long ioctl(struct file *filp, unsigned int cmd, unsigned long args);

    old ioctl: int ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long args);

    Regards,

    - Rob

  • Hi,

    i came across these same errors while trying to build the kernel modules for C6RUN. This problem is not unique to DSPLink and CMem, i'm having the same trouble with LPM as well, however i can't apply the same suggestion. This is because inode  is referenced elsewhere multiple times. could you please suggest what i can do to fix this?

    in lpm_driver.c line 114:  .ioctl =    lpm_ioctl,

    when i compile this i get

    Building LPM kernel module.../home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:114: error: unknown field 'ioctl' specified in initializer
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:114: warning: initialization from incompatible pointer type
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c: In function 'lpm_open':
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:474: error: implicit declaration of function 'kmalloc'
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:474: warning: assignment makes pointer from integer without a cast
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:500: error: implicit declaration of function 'kfree'
    make[5]: *** [/home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.o] Error 1
    make[4]: *** [_module_/home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm] Error 2
    make[3]: *** [release] Error 2
    make[2]: *** [kernel_mod] Error 2

    i changed it according suggestions here to

        .unlocked_ioctl =    lpm_ioctl,

    for this i got the following error code:

    Building LPM kernel module.../home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:114: warning: initialization from incompatible pointer type

    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c: In function 'lpm_open':
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:474: error: implicit declaration of function 'kmalloc'
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:474: warning: assignment makes pointer from integer without a cast
    /home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.c:500: error: implicit declaration of function 'kfree'
    make[5]: *** [/home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm/lpm_driver.o] Error 1
    make[4]: *** [_module_/home/administrator/C6Run_0_94_04_05/local_power_manager_linux_1_24_02_09/packages/ti/bios/power/modules/omap3530/lpm] Error 2

    Does that mean the ioctl issue is addressed and the problem is else where? Could you please advise on the course of action?

    Thank you,

     

    Tejapratap B

     

  • After a little digging around,

    i added 

    #include <linux/slab.h>

    to the lpm_driver.c file.

     

    That seems to have taken care of the kmalloc and kfree definitions.

     

    But the problem of ioctl still remains in lpm_driver.c file.

    inode from the lpm_ioctl is used multiple times in the code, i can not remove the argument from the structure as i did for DSPLink and Cmem

     

    thanks,

     

    Tejapratap Bollu

  • Teja,

    The 'inode' value that was passed to 'ioctl' function is available for use with the 'unlocked_ioctl' function by way of filp->d_entry->d_inode:
        long (*unlocked_ioctl) (struct file *filp, unsigned int cmd, unsigned long arg);
        ...
        struct inode *inode = filp->d_entry->d_inode;

    There is a nice explanation of this at http://lwn.net/Articles/119652/

    Regards,

    - Rob

  • Is there a newer version of DSPLINK that fixes this problem? I am using 1.65.00.03 from what looks to be from August 2010.

     

  • I have made the changes in the  lpm_driver.c

        struct inode *inode = filp->d_entry->d_inode;

     

    But i am getting the following error

    error: 'struct file' has no member named 'd_entry'

     

    Can anyone send a copy of lpm_driver.c with the changes.

    Thanks,

    Anand.

     

     

     

  • Hi,

    There is an archive talk about The new way of ioctl() :http://lwn.net/Articles/119652/ 

    after linux-2.6.36 filesystem did not provide an ioctl() method, which is instead of unlocked_ioctl().

    int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
    long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);

    The differences are that the inode argument is not provided (it's available as filp->f_dentry->d_inode).

    The dsplink  drv_pmgr.c add like this:

    #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
              ioctl: DRV_Ioctl,
    #else
              unlocked_ioctl: DRV_Ioctl,
    #endif

    This method also using in local-power-manager_1_24_02_09/

     

    Here is my patch of  drv_pmgr.c in dsplink_linux_1_65_00_03/dsplink/gpp/src/pmgr/Linux/2.6.18,

    created by  git diff drv_pmgr.c drv_pmgr.c-orig > drv_pmgr.patch

    diff --git a/drv_pmgr.c b/drv_pmgr.c-orig
    index 53ebd63..a9b831c 100644
    --- a/drv_pmgr.c
    +++ b/drv_pmgr.c-orig
    @@ -379,11 +379,7 @@ DRV_Release (struct inode * inode, struct file * filp) ;
    * @desc ioctl function for of Linux LINK driver.
    *
    * @arg inode
    - * inode pointer(kernel version < 2.6.36).
    - * long (*unlocked_ioctl) (struct file *filp, unsigned int cmd,
    - * unsigned long arg);
    - * The differences are that the inode argument is not provided (it's available as filp->f_dentry->d_inode)
    - * and the BKL is not taken prior to the call.
    + * inode pointer.
    * @arg filp
    * file pointer.
    * @arg cmd
    @@ -403,16 +399,11 @@ DRV_Release (struct inode * inode, struct file * filp) ;
    * @see None
    * ----------------------------------------------------------------------------
    */
    -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
    STATIC
    int
    DRV_Ioctl (struct inode * inode, struct file * filp,
    unsigned int cmd, unsigned long args) ;
    -#else
    -STATIC
    -int
    -DRV_Ioctl (struct file *filp, unsigned int cmd, unsigned long args) ;
    -#endif
    +

    /** ----------------------------------------------------------------------------
    * @func DRV_Mmap
    @@ -504,11 +495,7 @@ STATIC struct file_operations driverOps = {
    open: DRV_Open,
    flush: DRV_Flush,
    release: DRV_Release,
    -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
    ioctl: DRV_Ioctl,
    -#else
    - unlocked_ioctl: DRV_Ioctl,
    -#endif
    mmap: DRV_Mmap,
    read: DRV_Read,
    .owner = THIS_MODULE
    @@ -830,17 +817,10 @@ DRV_Release (struct inode * inode, struct file * filp)
    * @desc Function to invoke the APIs through ioctl.
    * ----------------------------------------------------------------------------
    */
    -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
    STATIC
    NORMAL_API
    int DRV_Ioctl (struct inode * inode, struct file * filp,
    unsigned int cmd, unsigned long args)
    -#else
    -STATIC
    -NORMAL_API
    -int DRV_Ioctl (struct file *filp,
    - unsigned int cmd, unsigned long args)
    -#endif
    {
    DSP_STATUS status = DSP_SOK ;
    int osStatus = 0 ;
    @@ -848,11 +828,8 @@ int DRV_Ioctl (struct file *filp,
    CMD_Args * srcAddr = (CMD_Args *) args ;
    CMD_Args apiArgs ;

    -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
    +
    TRC_4ENTER ("DRV_Ioctl", inode, filp, cmd, args) ;
    -#else
    - TRC_3ENTER ("DRV_Ioctl", filp, cmd, args) ;
    -#endif

    retVal = copy_from_user ((Pvoid) &apiArgs,
    (const Pvoid) srcAddr,

     Good luck,

    lihh

     

  • Anand, did you find a solution to your problem? Did someone give you the file lpm_driver.c with the changes?

  • I believe the latest release of DSPLink addresses this problem.