RE: writing integers to the char device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.belisko@xxxxxxxxx]
Sent: Wednesday, February 18, 2009 1:41 PM
To: Troy, Willis
Cc: kernelnewbies@xxxxxxxxxxxx
Subject: Re: writing integers to the char device driver

Hi,

On Wed, Feb 18, 2009 at 8:29 PM, Troy, Willis <Willis_Troy@xxxxxxxxxx> 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 ecartis@xxxxxxxxxxxx
> 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 ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux