All of lore.kernel.org
 help / color / mirror / Atom feed
* ata_tf_read_block() question
@ 2009-08-15 13:48 Atsushi Nemoto
  2009-08-16  2:15 ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2009-08-15 13:48 UTC (permalink / raw)
  To: Jeff Garzik, Tejun Heo; +Cc: linux-ide, linux-kernel

I have a question on CHS calculation in ata_tf_read_block().

The calculation in ata_tf_read_block() is:
	block = (cyl * dev->heads + head) * dev->sectors + sect;

but ata_build_rw_tf() does:
	track = (u32)block / dev->sectors;
	cyl   = track / dev->heads;
	head  = track % dev->heads;
	sect  = (u32)block % dev->sectors + 1;

It seems inconsistent.  The correct calculation is:
	block = (cyl * dev->heads + head) * dev->sectors + sect - 1;
isn't it?

I don't have any real problem.  Just noticed by code reading.
---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-09  1:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-15 13:48 ata_tf_read_block() question Atsushi Nemoto
2009-08-16  2:15 ` Tejun Heo
2009-08-16  9:33   ` Atsushi Nemoto
2009-08-16 12:21     ` [PATCH #upstream-fixes] libata: fix off-by-one error in ata_tf_read_block() Tejun Heo
2009-09-09  1:19       ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.