libbsp/powerpc/shared/motorola/vpd.c: Why is the _System_state_Is_up() path disabled?

Joel Sherrill joel.sherrill at OARcorp.com
Thu Jan 30 00:27:34 UTC 2014


On 1/29/2014 6:17 PM, Nick Withers wrote:
> On Wed, 2014-01-29 at 18:04 -0600, Joel Sherrill wrote:
>> On 1/29/2014 5:56 PM, Nick Withers wrote:
>>> Hi all,
>>>
>>> Anyone have any idea why the "_System_state_Is_up(_System_state_Get())"
>>> check in libbsp/powerpc/shared/motorola/vpd.c's BSP_vpdRetrieveFields()
>>> is disabled with an (0 && _System_state_Is_up(_System_state_Get())?
>> First, that is a violation of the public API. :(
> That's not OK for BSP code? It seems to be used in other, more generic
> places in libbsp too, e.g., c/src/lib/libbsp/shared/src/irq-generic.c .
Technically anything that starts with _[A-Z] is a private method. But
being open source,
folks find new ways to peek around the edge of the public API.

Historically, As we find these cases, we try to define an addition to
the public API that is
effectively the same but can provide a stable interface across releases.
>> But it is avoiding calling open() before the device drivers are
>> initialized and possibly before
>> RTEMS is even initialized.
> The _System_state_Is_up(_System_state_Get()) call you mean? Yeah, but
> it's disabled.
>
> Possibly because it's an API violation...?
Or this was never called before the system was up? :)

It is a good place for an assert if that was the intention.
>> I suppose it should be discussed what to do about this case and
>> if some system state information should be publicly available via
>> a defined API.
>>> I use the following and haven't observed any troubles (it mis-reads
>>> otherwise):
>>> ____
>>>
>>> diff --git a/c/src/lib/libbsp/powerpc/shared/motorola/vpd.c b/c/src/lib/libbsp/powerpc/shared/motorola/vpd.c
>>> index 4b0bbef..1cbfebc 100644
>>> --- a/c/src/lib/libbsp/powerpc/shared/motorola/vpd.c
>>> +++ b/c/src/lib/libbsp/powerpc/shared/motorola/vpd.c
>>> @@ -137,7 +137,7 @@ static int    (*stop)(int fd);
>>>  
>>>         memset(mot,0,sizeof(mot));
>>>  
>>> -       if ( 0 && _System_state_Is_up(_System_state_Get()) ) {
>>> +       if ( _System_state_Is_up(_System_state_Get()) ) {
>>>                 read_bytes = read;
>>>                 stop       = close;
>>>                 fd         = open(BSP_I2C_VPD_EEPROM_DEV_NAME, 0);
>>> ____

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list