[Stgt-devel] PATCH 6 of 6 - Implement READ ELEMENT STATUS op code

Ming Zhang blackmagic02881
Fri May 11 16:35:16 CEST 2007


On Fri, 2007-05-11 at 13:23 +1000, Mark Harvey wrote:
> +/* Fill in Element Status Header - Always 8 bytes long */
> +static int
> +element_status_data_hdr(uint8_t * data, uint8_t dvcid, uint8_t
> volTag,
> +               int start, int count)
> +{
> +       int             element_sz;
> +       int             size;
> +       uint16_t        * sp;
> +       uint32_t        * lp;
> +
> +       element_sz = determine_element_sz(dvcid, volTag);
> +
> +       /* First Element address reported */
> +       sp = (uint16_t *)&data[0];
> +       *sp = __cpu_to_be16(start);

try to use data[0] = start >> 8, data[1] = start &0xff, instead. since
we can not be 100% sure that data memory address align to 2 bytes.

> +
> +       /* Number of elements available */
> +       sp = (uint16_t *)&data[2];
> +       *sp = __cpu_to_be16(count);
> +
> +       /* Byte count is the length required to return all valid data.
> +        * Allocated length is how much data the initiator will accept
> */
> +       lp = (uint32_t *)&data[4];
> +       size = ((8 + (count * element_sz)) & 0xffffff);
> +       *lp = __cpu_to_be32(size);
> +
> +return size;

code formatting issue? similarly in other place, pls go over and fix
some format issues.

like if(x) should be if (x),...

> +}
> + 




More information about the stgt mailing list