ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a project I am working on, where we use a serial port (/dev/ttyS0) to communicate with our real device. Hence the serial port is simply a "bus driver" for the module. I have it working in user mode using standard open/read/write system calls. Now I am in the process of moving the upper driver into the kernel via a module, but I still need to use the serial driver as a bus driver to access my device.
The question is: How do I "open/read/write" the serial from the module. One of my leads is using filp_open(..), get the file * and use the read/write, etc structure methods from there. Is this the best way? or is there another operation I can use to get to the serial device?
I need to configure it to RAW mode, use hardware handshake if available. Pointers greatly appreciated.
but my module will not be a user program where I can open a serial device with the char device name ("/dev/ttyS1"). Rather as a module, I will already in the kernel and cannot use the glibc system call mechanism. It does the user mode to kernel mode transition. My code is already in the kernel, I just don't know the mechansim under linux to "hook" into the "open" path of another device also in the kernel.
Hence, my investigation indicates using the aforemention filp_open call. I need to play with this shortly. I was just wondering if others have tried something like this prior to myself doing it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.