[PATCH] cpukit/libi2c allowed to probe on device init

Alexandru-Sever Horin alex.sever.h at gmail.com
Thu Apr 2 07:45:46 UTC 2015


Hello Sebastian,

Thank you for the suggestion. The API compatible with Linux devices sounds
great.
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.

I have one question, though, is there a plan to port other Linux driver
APIs like SPI ?

Thank you,
Alex H

On Thu, Apr 2, 2015 at 9:53 AM, Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> Hello Alexandru-Sever,
>
> in case you use the latest RTEMS version, then I would consider to use the
> new I2C support:
>
> https://docs.rtems.org/doxygen/cpukit/html/group__I2C.html
>
> For example see:
>
> https://git.rtems.org/rtems/tree/cpukit/dev/i2c
>
> https://git.rtems.org/rtems/tree/testsuites/libtests/i2c01
>
>
> On 02/04/15 08:48, Alexandru-Sever Horin wrote:
>
>> From: Alexandru-Sever Horin <alex.sever.h at gmail.com>
>>
>> libi2c registration of a device fails if the device initialization fails
>> Benefits: allows for device probing on multiple addresses
>> ---
>>   cpukit/libi2c/libi2c.c | 27 ++++++++++++++++-----------
>>   1 file changed, 16 insertions(+), 11 deletions(-)
>>
>> diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c
>> index 233cb68..315a761 100644
>> --- a/cpukit/libi2c/libi2c.c
>> +++ b/cpukit/libi2c/libi2c.c
>> @@ -736,6 +736,16 @@ rtems_libi2c_register_drv (const char *name,
>> rtems_libi2c_drv_t * drvtbl,
>>         /* found a free slot; encode slot + 1 ! */
>>         minor = ((i + 1) << 13) | RTEMS_LIBI2C_MAKE_MINOR (busno,
>> i2caddr);
>>   +      /* before registering, try to initialize the device to check
>> it's there */
>> +      if (drvtbl->ops->initialization_entry) {
>> +        err = drvtbl->ops->initialization_entry (rtems_libi2c_major,
>> minor, 0);
>> +        if (err) {
>> +          LIBUNLOCK ();
>> +          /* returned value must be negative on failure */
>> +          return err < 0 ? err : -err;
>> +        }
>> +      }
>> +
>>         if (name) {
>>           size_t length = strlen (busses[busno].name) + strlen (name) + 2;
>>           str = malloc (length);
>> @@ -751,9 +761,10 @@ rtems_libi2c_register_drv (const char *name,
>> rtems_libi2c_drv_t * drvtbl,
>>             /* note that 'umask' is applied to 'mode' */
>>           if (mknod (str, mode, dev)) {
>> -          safe_printf( DRVNM
>> -                   "Creating device node failed: %s; you can try to do
>> it manually...\n",
>> -                   strerror (errno));
>> +          safe_printf ( DRVNM
>> +                        "Creating device node failed: %s;\n"
>> +                        "you can try to do it manually...\n",
>> +                        strerror (errno));
>>           }
>>             free (str);
>> @@ -761,17 +772,11 @@ rtems_libi2c_register_drv (const char *name,
>> rtems_libi2c_drv_t * drvtbl,
>>           drvs[i].drv = drvtbl;
>>   -      if (drvtbl->ops->initialization_entry)
>> -        err =
>> -          drvs[i].drv->ops->initialization_entry (rtems_libi2c_major,
>> minor,
>> -                                                  0);
>> -      else
>> -        err = RTEMS_SUCCESSFUL;
>> -
>>         LIBUNLOCK ();
>> -      return err ? -err : minor;
>> +      return minor;
>>       }
>>     }
>> +
>>     LIBUNLOCK ();
>>     return -RTEMS_TOO_MANY;
>>   }
>>
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax     : +49 89 189 47 41-09
> E-Mail  : sebastian.huber at embedded-brains.de
> PGP     : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20150402/06063857/attachment-0002.html>


More information about the devel mailing list