<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using kernel driver functions in User space application in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458886#M71908</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is incorrect!&lt;/P&gt;&lt;P&gt;You should't use /dev/input/event5, you should find mag3110_position_show file in /sys and use it.&lt;/P&gt;&lt;P&gt;Read examples without check return:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14406805382135649 jive_text_macro" data-renderedposition="71_8_1154_64" jivemacro_uid="_14406805382135649"&gt;&lt;P&gt;char buf[10] = {0};&lt;/P&gt;&lt;P&gt;in fd = open("file",&amp;nbsp; O_RDONLY);&lt;/P&gt;&lt;P&gt;read(fd, buf, 9);&lt;/P&gt;&lt;P&gt;close(fd);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;Write example without check return:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14406805482192633 jive_macro_code jive_text_macro" data-renderedposition="156_8_1154_64" jivemacro_uid="_14406805482192633"&gt;&lt;P&gt;const char *buf = "5";&lt;/P&gt;&lt;P&gt;in fd = open("file",&amp;nbsp; O_WRONLY);&lt;/P&gt;&lt;P&gt;write(fd, buf, strlen(buf));&lt;/P&gt;&lt;P&gt;close(fd);&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Aug 2015 13:01:26 GMT</pubDate>
    <dc:creator>BrilliantovKiri</dc:creator>
    <dc:date>2015-08-27T13:01:26Z</dc:date>
    <item>
      <title>Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458877#M71899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i am using imx6qsabresd board. and using eclipse for user space application development.&lt;/P&gt;&lt;P&gt;I can able to access i2c and read or write address. But for that first i need to remove particular .ko module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i want to use functions of MMA8451Q or MAG3110 's driver in my application without removing the ko module.&lt;/P&gt;&lt;P&gt;So how can i do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 11:17:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458877#M71899</guid>
      <dc:creator>ritesh_panchal</dc:creator>
      <dc:date>2015-08-24T11:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458878#M71900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ritesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if I missunderstood, you are creating an application in user space, that it is going to need the usage of the i2c module, but&amp;nbsp; when you try to access you are read and write, functions are not working until removed of&amp;nbsp; MMA8451 Module (KO ). If this is the scenario,&amp;nbsp; I think you are using the same I2C bus that has the Accelerometer and the Magnetometer, so you have two options access a diferent I2C bus or then it is necesary to remove the Sensor KOs, since they are handling the same bus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jaime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 14:20:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458878#M71900</guid>
      <dc:creator>jamesbone</dc:creator>
      <dc:date>2015-08-24T14:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458879#M71901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;Thanks for the Reply.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d;"&gt;What ever u have written that's right. And i am telling the same in my question. That i can able to access &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;MMA8451 after i removed its module. Otherwise open command will give me error that "resource or device busy".&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Actually i am new to linux environment. And i am learning linux driver development.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I have one basic question that how can i use linux driver in user space? &lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;As i read somewhere i found using ioctl or sysfs interface. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;In &lt;SPAN&gt;MMA8451 or MAG3110 driver sysfs is created as user interface.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;So my question is how to use sysfs or ioctl in my user application so i can able to access my driver and thus the IC.?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 05:28:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458879#M71901</guid>
      <dc:creator>ritesh_panchal</dc:creator>
      <dc:date>2015-08-27T05:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458880#M71902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14406603867401549 jive_macro_code jive_text_macro" data-renderedposition="8_8_1232_128" jivemacro_uid="_14406603867401549"&gt;&lt;P&gt;int fd = open(NULL == device ? default_device : device, O_WRONLY);&lt;/P&gt;&lt;P&gt;if (fd != -1) {&lt;/P&gt;&lt;P&gt;drv8825_rotate cfg;&lt;/P&gt;&lt;P&gt;cfg.step = step;&lt;/P&gt;&lt;P&gt;cfg.delay = delay;&lt;/P&gt;&lt;P&gt;ioctl(fd, DRV8825_SET_ROTATE, &amp;amp;cfg);&lt;/P&gt;&lt;P&gt;close(fd);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14406668158834995 jive_text_macro" data-renderedposition="136_8_1232_400" jivemacro_uid="_14406668158834995"&gt;&lt;P&gt;#define GPIO_SYSFS "/sys/class/gpio"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static int gpio_enable(int gpio, unsigned char enable)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const char *export_file = GPIO_SYSFS "/export";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const char *unexport_file = GPIO_SYSFS "/unexport";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int status = -1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (gpio &amp;lt;= 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return -1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fd = open(enable ? export_file : unexport_file, O_WRONLY);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fd != -1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; char number[4] = {0};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; const size_t len = 3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; snprintf(number, len, "%u", gpio);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((ssize_t)len == write(fd, number, len))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; close(fd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return status;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 07:25:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458880#M71902</guid>
      <dc:creator>BrilliantovKiri</dc:creator>
      <dc:date>2015-08-27T07:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458881#M71903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tested with ov5640 driver. i can set exposer using ioctl.&lt;/P&gt;&lt;P&gt;but i unable to use sysfs of MAG3110.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This device is detected as "/dev/input/event5".&lt;/P&gt;&lt;P&gt;I can successfully open the device. But there's some functions like "mag3110_position_show", "mag3110_position_store" etc.&lt;/P&gt;&lt;P&gt;How can i access this function from user space program.?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 10:03:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458881#M71903</guid>
      <dc:creator>ritesh_panchal</dc:creator>
      <dc:date>2015-08-27T10:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458882#M71904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't execute kernel function from user-space.&lt;/P&gt;&lt;P&gt;If you should configure device throw kernel functions you can modify driver, e.g. add ioctl support. As result you can follow path: user_space -&amp;gt; ioctl -&amp;gt; kernel_space.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 11:00:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458882#M71904</guid>
      <dc:creator>BrilliantovKiri</dc:creator>
      <dc:date>2015-08-27T11:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458883#M71905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MAG3110 driver has sysfs for user interface.&lt;/P&gt;&lt;P&gt;Please find driver code.&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/0B5xLP5YaPU3_TkFITU1KNDlvRHc/view?usp=sharing"&gt;https://drive.google.com/file/d/0B5xLP5YaPU3_TkFITU1KNDlvRHc/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Can you tell me how can i use sysfs read/write for this driver?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 11:13:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458883#M71905</guid>
      <dc:creator>ritesh_panchal</dc:creator>
      <dc:date>2015-08-27T11:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458884#M71906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a very simple - you can use standart functions open, close, read and write.&lt;/P&gt;&lt;P&gt;As you can see driver create some files in /sys:&lt;/P&gt;&lt;P&gt;- mag3110_dr_mode_show return curren value, use read&lt;/P&gt;&lt;P&gt;- mag3110_dr_mode_store apply decimal value, should be &amp;lt;= 7, use write&lt;/P&gt;&lt;P&gt;- mag3110_enable_store apply decimal value, use write&lt;/P&gt;&lt;P&gt;- mag3110_enable_show return current value, use read&lt;/P&gt;&lt;P&gt;- mag3110_position_show return current value, use read&lt;/P&gt;&lt;P&gt;- mag3110_position_store apply decimal value, use write&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 11:50:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458884#M71906</guid>
      <dc:creator>BrilliantovKiri</dc:creator>
      <dc:date>2015-08-27T11:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458885#M71907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate your effort. But i'm sorry but as i am new to this field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you show one example how to use this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i can open by this function.&lt;/P&gt;&lt;P&gt;fd = open("/dev/input/event5", O_RDWR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am using read( fd, "mag3110_position_show", 10,&amp;nbsp; &amp;amp;buf);&lt;/P&gt;&lt;P&gt;but dont getting result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 12:42:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458885#M71907</guid>
      <dc:creator>ritesh_panchal</dc:creator>
      <dc:date>2015-08-27T12:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using kernel driver functions in User space application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458886#M71908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is incorrect!&lt;/P&gt;&lt;P&gt;You should't use /dev/input/event5, you should find mag3110_position_show file in /sys and use it.&lt;/P&gt;&lt;P&gt;Read examples without check return:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14406805382135649 jive_text_macro" data-renderedposition="71_8_1154_64" jivemacro_uid="_14406805382135649"&gt;&lt;P&gt;char buf[10] = {0};&lt;/P&gt;&lt;P&gt;in fd = open("file",&amp;nbsp; O_RDONLY);&lt;/P&gt;&lt;P&gt;read(fd, buf, 9);&lt;/P&gt;&lt;P&gt;close(fd);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;Write example without check return:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14406805482192633 jive_macro_code jive_text_macro" data-renderedposition="156_8_1154_64" jivemacro_uid="_14406805482192633"&gt;&lt;P&gt;const char *buf = "5";&lt;/P&gt;&lt;P&gt;in fd = open("file",&amp;nbsp; O_WRONLY);&lt;/P&gt;&lt;P&gt;write(fd, buf, strlen(buf));&lt;/P&gt;&lt;P&gt;close(fd);&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Aug 2015 13:01:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Using-kernel-driver-functions-in-User-space-application/m-p/458886#M71908</guid>
      <dc:creator>BrilliantovKiri</dc:creator>
      <dc:date>2015-08-27T13:01:26Z</dc:date>
    </item>
  </channel>
</rss>

