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.

Dynamically register uart platform device ( for am335x & linux 3.2)

Hi all,

I'm stuck at something that at first looked like  something not to difficult. The main idea is  that we don't want to have all uarts initialized with default tty driver from TI. Therefore, we remove the entries for the uarts in the list in ../mach-omap2/omap_hwmod_33xx_data.c. Since the platform device/driver frame work is used here, it would be sufficient to register a omap_uart device to the platform and the binding would automatically load the omap_serial driver. So that's the theory. 

To have this ability, I want to have function omap_device_build from ../plat-omap/omap_device.c being exported so that I can use it from my own kernel module. I belief that this should be possible by the macro EXPORT_SYMBOL. However, after a couple of hours trying to do so without success I went a step back and tried to export just a dummy function (that basically just prints something on the screen) which I added in ../plat-omap/omap_device.c.  But even this didn't work. When I loaded my kernel module that would use this dummy function I just get the error that symbol could not be found

Unknown symbol dummy(err 0)
insmod: can't insert 'rs485_uart.ko': unknown symbol in module, or unknown parameter

However, if I grep /proc/kallsyms for my dummy function I find an entry. I'm now wondering why this does not work. I don't have any problem exporting a function from a kernel module and using it in another one. But some how it does not work the same way if I try to export the function  omap_device_build. 

What am I missing here. Any hint is highly appreciated.

Sam

  • Hi Sam.

    How are you building your module?  You want to build it using the kernel make files.  That is, your local makefile should invoke make in the kernel directory using "make -C <path_to_kernel_src> M=$PWD".  See "How to Build External Modules"  in Documentation/kbuild/modules.txt for details.  Without using the kernel make + scripts, you might be running into a modversion problem.

    Regards,

        Steve

  • Hi Steve,

    I know about Documentation/kbuild/modules.txt. Actually, I don't have any problem if I export a symbol from a kernel module. What I want to do, is use EXPORT_SYMBOL for a function that is located in the file omap_hwmon.c

    I also tried with kernel CONFIG_MODVERSIONS not set.  But this did not change anything. So I think it's not a problem about modversion. 

    Thanks anyway. I keep looking for a solution but right now I'm running out a bit of ideas.

    Ragards

    Sam

  • Hi Steve,

    I got it: If you want to use EXPORT_SYMBOL to export from kernel to kernel modules you need to include

    #include <linux/export.h>

    Well, kind of a stupid mistake. Somehow, I was misguided by the fact that I could see the function name in /proc/kallsyms.  If everything works well, Module.symvers gets an entry too with the exported function name.

    Regards

    Sam 

  • Hi Sam.

    Curious.  EXPORT_SYMBOL() is defined in linux/export.h.  So if that file wasn't included, where did the definition of that macro come from?

    Regards,

        Steve