On Wednesday 06 January 2010 06:18:21 Sudhakar Rajashekhara wrote:
> +     ds = malloc(sizeof(struct davinci_spi_slave));

personally i find sizeof(*ds) to be better

> +void spi_free_slave(struct spi_slave *slave)
> +{
> +     struct davinci_spi_slave *ds = to_davinci_spi(slave);
> +
> +     if (ds) {
> +             free(ds);
> +             ds = NULL;
> +     }
> +}

free() already does a NULL pointer check, and assigning NULL to a stack 
variable is pointless.  i.e. this function should simply be:
        free(slave);

> +static inline struct davinci_spi_slave *to_davinci_spi(struct spi_slave
>  *slave) +{
> +     if (!slave)
> +             return NULL;
> +     else
> +             return container_of(slave, struct davinci_spi_slave, slave);
> +}

this logic is pointless ... container_of() on a NULL pointer is a NULL 
pointer, and it isnt like container_of() will deref the pointer causing a 
crash.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to