<div dir="ltr"><div><div><div><div><div><div>Hello Sebastian,<br><br>Thank you for the suggestion. The API compatible with Linux devices sounds great. <br></div></div></div>However, the RTEMS version we are using is a few days before your patches, and probably I will port a bt firther along the road.<br><br></div>I have one question, though, is there a plan to port other Linux driver APIs like SPI ? <br><br></div>Thank you,<br></div>Alex H<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 9:53 AM, Sebastian Huber <span dir="ltr"><<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Alexandru-Sever,<br>
<br>
in case you use the latest RTEMS version, then I would consider to use the new I2C support:<br>
<br>
<a href="https://docs.rtems.org/doxygen/cpukit/html/group__I2C.html" target="_blank">https://docs.rtems.org/<u></u>doxygen/cpukit/html/group__<u></u>I2C.html</a><br>
<br>
For example see:<br>
<br>
<a href="https://git.rtems.org/rtems/tree/cpukit/dev/i2c" target="_blank">https://git.rtems.org/rtems/<u></u>tree/cpukit/dev/i2c</a><br>
<br>
<a href="https://git.rtems.org/rtems/tree/testsuites/libtests/i2c01" target="_blank">https://git.rtems.org/rtems/<u></u>tree/testsuites/libtests/i2c01</a><div><div class="h5"><br>
<br>
On 02/04/15 08:48, Alexandru-Sever Horin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Alexandru-Sever Horin <<a href="mailto:alex.sever.h@gmail.com" target="_blank">alex.sever.h@gmail.com</a>><br>
<br>
libi2c registration of a device fails if the device initialization fails<br>
Benefits: allows for device probing on multiple addresses<br>
---<br>
cpukit/libi2c/libi2c.c | 27 ++++++++++++++++-----------<br>
1 file changed, 16 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c<br>
index 233cb68..315a761 100644<br>
--- a/cpukit/libi2c/libi2c.c<br>
+++ b/cpukit/libi2c/libi2c.c<br>
@@ -736,6 +736,16 @@ rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,<br>
/* found a free slot; encode slot + 1 ! */<br>
minor = ((i + 1) << 13) | RTEMS_LIBI2C_MAKE_MINOR (busno, i2caddr);<br>
+ /* before registering, try to initialize the device to check it's there */<br>
+ if (drvtbl->ops->initialization_<u></u>entry) {<br>
+ err = drvtbl->ops->initialization_<u></u>entry (rtems_libi2c_major, minor, 0);<br>
+ if (err) {<br>
+ LIBUNLOCK ();<br>
+ /* returned value must be negative on failure */<br>
+ return err < 0 ? err : -err;<br>
+ }<br>
+ }<br>
+<br>
if (name) {<br>
size_t length = strlen (busses[busno].name) + strlen (name) + 2;<br>
str = malloc (length);<br>
@@ -751,9 +761,10 @@ rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,<br>
/* note that 'umask' is applied to 'mode' */<br>
if (mknod (str, mode, dev)) {<br>
- safe_printf( DRVNM<br>
- "Creating device node failed: %s; you can try to do it manually...\n",<br>
- strerror (errno));<br>
+ safe_printf ( DRVNM<br>
+ "Creating device node failed: %s;\n"<br>
+ "you can try to do it manually...\n",<br>
+ strerror (errno));<br>
}<br>
free (str);<br>
@@ -761,17 +772,11 @@ rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl,<br>
drvs[i].drv = drvtbl;<br>
- if (drvtbl->ops->initialization_<u></u>entry)<br>
- err =<br>
- drvs[i].drv->ops-><u></u>initialization_entry (rtems_libi2c_major, minor,<br>
- 0);<br>
- else<br>
- err = RTEMS_SUCCESSFUL;<br>
-<br>
LIBUNLOCK ();<br>
- return err ? -err : minor;<br>
+ return minor;<br>
}<br>
}<br>
+<br>
LIBUNLOCK ();<br>
return -RTEMS_TOO_MANY;<br>
}<br>
</blockquote>
<br>
-- <br></div></div>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
Phone : <a href="tel:%2B49%2089%20189%2047%2041-16" value="+4989189474116" target="_blank">+49 89 189 47 41-16</a><br>
Fax : <a href="tel:%2B49%2089%20189%2047%2041-09" value="+4989189474109" target="_blank">+49 89 189 47 41-09</a><br>
E-Mail : <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-<u></u>brains.de</a><br>
PGP : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
<br>
______________________________<u></u>_________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" target="_blank">http://lists.rtems.org/<u></u>mailman/listinfo/devel</a><br>
</blockquote></div><br></div>