• Kevin Hilman's avatar
    OMAP: omap_device: add omap_device_is_valid() · 0007122a
    Kevin Hilman authored
    The omap_device struct contains a 'struct platform_device'.  Normally,
    converting a platform_device pointer to an omap_device pointer
    consists of simply doing a container_of(), as is done currently by the
    to_omap_device() macro.
    
    However, if this is attempted when using platform_device that has not
    been created as part of the omap_device creation, the container_of()
    will point to a memory location before the platform_device pointer
    which will contain random data.
    
    Therefore, we need a way to detect valid omap_device pointers.  This
    patch solves this by using the simple magic number approach.
    Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
    Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
    0007122a
omap_device.c 20.1 KB