[PATCH v2] bsps/beagle: register i2c device at initialization

Vijay Kumar Banerjee vijaykumar9597 at gmail.com
Thu Sep 19 18:56:49 UTC 2019


On Fri, Sep 20, 2019 at 12:08 AM Christian Mauderer <list at c-mauderer.de>
wrote:

> On 19/09/2019 19:48, Vijay Kumar Banerjee wrote:
> >
> >
> >
> > On Thu, Sep 19, 2019 at 10:05 PM Christian Mauderer <list at c-mauderer.de
> > <mailto:list at c-mauderer.de>> wrote:
> >
> >     Hello Vijay,
> >
> >     sorry for being picky: What happens if something goes wrong during
> that
> >     initialization? For example: If the system has a configuration where
> >     /dev/i2c0 can't be created. In that case it will just silently fail
> to
> >     create the i2c-0 which maybe leads to odd errors later.
> >
> > This is a very good point.
> >
> >     There's already one precedent case how that could be handled: The
> >     powerpc/mvme3100 BSP. That BSP also initializes an I2C driver with a
> >     RTEMS_SYSINIT_ITEM. The return value is ignored too. But the
> >     BSP_i2c_initialize does print error messages.
> >
> >     I would suggest that here too: Check the return value of
> >     am335x_i2c_bus_register in your new bbb_i2c_0_initialize and at least
> >     print an error message that i2c0 couldn't be initialized. Most likely
> >     you should use printk here because it's not sure whether printf would
> >     work already.
> >
> > Will it be sufficient to do this:
> > ```
> > static void bbb_i2c_0_initialize(void)
> > {
> >   int err;
> >
> >   err = am335x_i2c_bus_register(BBB_I2C_0_BUS_PATH,
> >                                 AM335X_I2C0_BASE,
> >                                 I2C_BUS_CLOCK_DEFAULT,
> >                                 BBB_I2C0_IRQ);
> >   if (err != 0){
> >     printk("i2c-0 device could not be registered");
> >   }
> > }
> > ```
>
> You might could add the value of `err` to the output (just at the end in
> brackets or similar). Sometimes it is helpful to find the reason.
> Otherwise I'm OK with it.
>
> Fixed it in the attached v3 of the patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20190920/f3390828/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-bsps-beagle-register-i2c-device-at-initialization.patch
Type: text/x-patch
Size: 2706 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20190920/f3390828/attachment-0002.bin>


More information about the devel mailing list