Hi, apparently I didn't present the my problem clear enough. Fortunately we figured it out.
I wanted to be able to write u32 data to a character device from a C program, but couldn't figure out if i was doing something wrong in my device driver or my C code. Apparently to do this I just have to treat the device as a binary file when writing to. Thanks for the help though. Willis ________________________________________ From: Belisko Marek [marek.beli...@gmail.com] Sent: Wednesday, February 18, 2009 1:41 PM To: Troy, Willis Cc: kernelnewbies@nl.linux.org Subject: Re: writing integers to the char device driver Hi, On Wed, Feb 18, 2009 at 8:29 PM, Troy, Willis <willis_t...@baylor.edu> wrote: > Howdy, > > I am fairly new to device drivers and this list, but I'm sure someone in here > can help me. > > First, some background. I am working on device drivers for a FPGA that is > currently running kernel 2.6.28, because it is an FPGA I can add custom > hardware. The custom hardware I currently have is very simple- just a > multiplier- for a proof of concept. Currently I have a char device driver > written for it that will take in ascii and multiply its ascii value by > another ascii value. Eg. 0x0=char(0)*char(0)=48*48. This isn't really what > I want, I want a device driver that can read in two 32 bit numbers and return > a 32 bit number. > > So, can I write integers/longs to a character device driver? Is there a > better way to do this? Of course, you can write also buffers to character device. Maybee name is misleading but in kernel basically exist 3 types of drivers: 1. character 2. block 3. network If you would like to write to character device first you should copy data from userspace to kernel space. Function copy_from_user(void *to, const void __user *from, int n) *to - pointer lo kernel buffer *from pointer from write method (function) n - length of buffer > > Thanks in advance, > Willis > > > > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecar...@nl.linux.org > Please read the FAQ at http://kernelnewbies.org/FAQ > > good luck, Marek -- as simple as primitive as possible ---------------------------------------------- Marek Beliško - open-nandra Ruská Nová Ves 219 08005 Prešov Slovakia http://open-nandra.com -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecar...@nl.linux.org Please read the FAQ at http://kernelnewbies.org/FAQ