[PATCH] libata CHS: LBA28/LBA48 optimization (revise #6)

     - add lba_28_ok() and lba_48_ok() to ata.h.
     - check ending block number instead of staring block number.
     - use lba_28_ok() for CHS range check
     - LBA28/LBA48 optimization

Suggested by Mark Lord and Alan Cox.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>

=====
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 630908c..b7e7e1c 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -291,4 +291,16 @@
 			== ATA_DRDY);
 }
 
+static inline int lba_28_ok(u64 block, u32 n_block)
+{
+	/* check the ending block number */
+	return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256);
+}
+
+static inline int lba_48_ok(u64 block, u32 n_block)
+{
+	/* check the ending block number */
+	return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
+}
+
 #endif /* __LINUX_ATA_H__ */