diff options
author | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-01-25 02:26:33 +0100 |
---|---|---|
committer | Damien Le Moal <damien.lemoal@opensource.wdc.com> | 2022-01-31 01:58:32 +0100 |
commit | 6e163f9b866a96ed6070f0653da477b3501d902a (patch) | |
tree | 258d0346d6225b6e6af253c126459b550585b734 | |
parent | ata: libata-scsi: Simplify ata_scsi_mode_select_xlat() (diff) | |
download | linux-6e163f9b866a96ed6070f0653da477b3501d902a.tar.xz linux-6e163f9b866a96ed6070f0653da477b3501d902a.zip |
ata: libata-scsi: Simplify scsi_XX_lba_len()
In scsi_10_lba_len() and scsi_16_lba_len() functions, use
get_unaligned_bexx() to access a cdb LBA and length fields instead of
hardcoding the byte retrieval. With these simplification, the functions
can also be declared inline.
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | drivers/ata/libata-scsi.c | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 515c5599cece..eb40c3796a3f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1314,21 +1314,10 @@ static void scsi_6_lba_len(const u8 *cdb, u64 *plba, u32 *plen) * @plba: the LBA * @plen: the transfer length */ -static void scsi_10_lba_len(const u8 *cdb, u64 *plba, u32 *plen) +static inline void scsi_10_lba_len(const u8 *cdb, u64 *plba, u32 *plen) { - u64 lba = 0; - u32 len = 0; - - lba |= ((u64)cdb[2]) << 24; - lba |= ((u64)cdb[3]) << 16; - lba |= ((u64)cdb[4]) << 8; - lba |= ((u64)cdb[5]); - - len |= ((u32)cdb[7]) << 8; - len |= ((u32)cdb[8]); - - *plba = lba; - *plen = len; + *plba = get_unaligned_be32(&cdb[2]); + *plen = get_unaligned_be16(&cdb[7]); } /** @@ -1341,27 +1330,10 @@ static void scsi_10_lba_len(const u8 *cdb, u64 *plba, u32 *plen) * @plba: the LBA * @plen: the transfer length */ -static void scsi_16_lba_len(const u8 *cdb, u64 *plba, u32 *plen) +static inline void scsi_16_lba_len(const u8 *cdb, u64 *plba, u32 *plen) { - u64 lba = 0; - u32 len = 0; - - lba |= ((u64)cdb[2]) << 56; - lba |= ((u64)cdb[3]) << 48; - lba |= ((u64)cdb[4]) << 40; - lba |= ((u64)cdb[5]) << 32; - lba |= ((u64)cdb[6]) << 24; - lba |= ((u64)cdb[7]) << 16; - lba |= ((u64)cdb[8]) << 8; - lba |= ((u64)cdb[9]); - - len |= ((u32)cdb[10]) << 24; - len |= ((u32)cdb[11]) << 16; - len |= ((u32)cdb[12]) << 8; - len |= ((u32)cdb[13]); - - *plba = lba; - *plen = len; + *plba = get_unaligned_be64(&cdb[2]); + *plen = get_unaligned_be32(&cdb[10]); } /** |