Re: [PATCH 4/5] staging: ft1000: Fix coding style in write_blk_fifo() function.
From: Belisko Marek
Date: Wed Jan 26 2011 - 08:35:10 EST
On Wed, Jan 26, 2011 at 2:07 PM, Dan Carpenter <error27@xxxxxxxxx> wrote:
> You didn't introduce it but do you know what the code is trying to do
> here?
>
> Â Â Â Âbyte_length = word_length * 4;
>
> Â Â Â Âif (byte_length % 4)
> Â Â Â Â Â Â Â Âaligncnt = 4 - (byte_length % 4);
> Â Â Â Âelse
> Â Â Â Â Â Â Â Âaligncnt = 0;
> Â Â Â Âbyte_length += aligncnt;
>
> Â Â Â Âif (byte_length && ((byte_length % 64) == 0))
> Â Â Â Â Â Â Â Âbyte_length += 4;
>
> Â Â Â Âif (byte_length < 64)
> Â Â Â Â Â Â Â Âbyte_length = 68;
>
>
> Apparently the stuff has to be aligned to 4 bytes, but it can't be
> aligned at 64 bytes and it can't be less than 68 bytes long. ÂThe
> part that especially confuses me is why it can't be aligned at 64 bytes.
Yes this code seems little bit confusing but basically this routine send data
to device when firmware code is downloaded. Length which should be send is
asked by device itself (word_length) so maybe it should be somehow
aligned in some cases
(don't know details). Just to get some idea about length I add some
printk(before 4*word_length
and after byte_length is counted before sending to usb):
Jan 26 14:22:24 linux kernel: [29632.843980] write_blk_fifo: word_length:4
Jan 26 14:22:24 linux kernel: [29632.843984] write_blk_fifo: byte_length:68
Jan 26 14:22:24 linux kernel: [29632.859982] write_blk_fifo: word_length:506
Jan 26 14:22:24 linux kernel: [29632.859986] write_blk_fifo: byte_length:2024
Jan 26 14:22:24 linux kernel: [29632.874984] write_blk_fifo: word_length:505
Jan 26 14:22:24 linux kernel: [29632.874988] write_blk_fifo: byte_length:2020
Jan 26 14:22:24 linux kernel: [29632.890046] write_blk_fifo: word_length:4
Jan 26 14:22:24 linux kernel: [29632.890051] write_blk_fifo: byte_length:68
>
> regards,
> dan carpenter
>
thanks,
marek
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer
Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/