ata: libata: use min() to make code cleaner
authorChangcheng Deng <deng.changcheng@zte.com.cn>
Mon, 20 Dec 2021 11:33:58 +0000 (11:33 +0000)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 4 Jan 2022 11:00:12 +0000 (20:00 +0900)
Use min() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
drivers/ata/libata-scsi.c

index 5f27f5c..b0b7ab4 100644 (file)
@@ -3591,10 +3591,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
         */
 
        if (len != CACHE_MPAGE_LEN - 2) {
-               if (len < CACHE_MPAGE_LEN - 2)
-                       *fp = len;
-               else
-                       *fp = CACHE_MPAGE_LEN - 2;
+               *fp = min(len, CACHE_MPAGE_LEN - 2);
                return -EINVAL;
        }
 
@@ -3647,10 +3644,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
         */
 
        if (len != CONTROL_MPAGE_LEN - 2) {
-               if (len < CONTROL_MPAGE_LEN - 2)
-                       *fp = len;
-               else
-                       *fp = CONTROL_MPAGE_LEN - 2;
+               *fp = min(len, CONTROL_MPAGE_LEN - 2);
                return -EINVAL;
        }