[PATCH] libi2c allowed to probe on device init libi2c registration of a device fails if the device initialization fails Benefits: allows for device probing on multiple addreses
Gedare Bloom
gedare at rtems.org
Wed Apr 1 15:30:29 UTC 2015
Two line length/break issues, and I think we're set!
On Wed, Apr 1, 2015 at 11:18 AM, Alexandru-Sever Horin
<alex.sever.h at gmail.com> wrote:
> From: Alexandru-Sever Horin <alex.sever.h at gmail.com>
>
> ---
> cpukit/libi2c/libi2c.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/cpukit/libi2c/libi2c.c b/cpukit/libi2c/libi2c.c
> index 233cb68..43daa86 100644
> --- a/cpukit/libi2c/libi2c.c
> +++ b/cpukit/libi2c/libi2c.c
> @@ -736,6 +736,17 @@ 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);
This could be squeezed to fit in 80 characters on one line. like:
err = drvtbl->ops->initialization_entry(rtems_libi2c_major, minor, 0);
> + if (err) {
> + LIBUNLOCK ();
> + /* make sure the returned value is negative, not to mistake it for minor number */
Break up this comment or shorten it to < 80 characters on the line.
> + return err < 0 ? err : -err;
> + }
> + }
> +
> if (name) {
> size_t length = strlen (busses[busno].name) + strlen (name) + 2;
> str = malloc (length);
> @@ -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;
> }
> --
> 2.3.5
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list