LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 10-26-2010, 03:23 AM   #1
mysurface
LQ Newbie
 
Registered: Oct 2004
Posts: 3

Rep: Reputation: 0
Access SPI within kernel space


I have spidev driver compiled, which i do have /dev/spidevx.x exist at my filesystem. Accessing through spi within userspace is working, but now I need to access spi from kernel space.

Upon machine_halt(), I need to access spi to write and read something. Within kernel space i found the function 'spi_write_then_read' which it ask for spi_device.

Where can I obtain the spi_device pointer from? Initially I try to get it from my platform_device, under platform_device i have .dev which is struct device.

Obtaining the device, i can convert it to spi_device by using to_spi_device(). Then I try to set the chipselect etc at spi_device.

After that, I try to spi_write_then_read() but i caught a kernel dump mention "Unable to handle kernel NULL pointer dereference"

My question is, is that a proper way to obtain spi_device? What should i do to access spi within kernel space?
 
Old 10-29-2010, 02:30 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,008

Rep: Reputation: 67
In your SPI device driver, how to convert from device structure to spi_device structure? This is key.
 
Old 03-28-2012, 03:04 AM   #3
yixiaoyang
LQ Newbie
 
Registered: Mar 2012
Location: China
Posts: 4

Rep: Reputation: Disabled
you can compile spidev.h,spidev.c to be a .ko module.

may be you can compile spidev.h,spidev.c to be a .ko module.
modify spidev.c with your own message transfer protocol.
 
  


Reply

Tags
kernelmodule


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I access SPI Drivers from a User Space App? Aglets Programming 0 09-29-2010 01:31 PM
LXer: User space memory access from the Linux kernel LXer Syndicated Linux News 0 08-13-2010 06:40 AM
Division of Logical Memory Space in to User Space and Kernel Space shreshtha Linux - Newbie 2 01-14-2010 09:59 AM
How to Access the User Space Variable in Kernel rheosiva Linux - Kernel 3 04-17-2009 07:55 PM


All times are GMT -5. The time now is 03:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration