]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
libata: cleanup device sleep capability detection
authorDamien Le Moal <damien.lemoal@wdc.com>
Mon, 16 Aug 2021 01:44:49 +0000 (10:44 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 18 Aug 2021 13:19:39 +0000 (07:19 -0600)
Move the code to retrieve the device sleep capability and timings out of
ata_dev_configure() into the helper function ata_dev_config_devslp().
While at it, mark the device as supporting the device sleep capability
only if the sata settings page was retrieved successfully to ensure that
the timing information is correctly initialized.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20210816014456.2191776-5-damien.lemoal@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/ata/libata-core.c

index 44f434acfce08778b465d9f6fa1c6ba234906457..f96cd2f931bdf48681679bf3da4e2716d6d4a475 100644 (file)
@@ -2363,6 +2363,37 @@ static void ata_dev_config_trusted(struct ata_device *dev)
                dev->flags |= ATA_DFLAG_TRUSTED;
 }
 
+static void ata_dev_config_devslp(struct ata_device *dev)
+{
+       u8 *sata_setting = dev->link->ap->sector_buf;
+       unsigned int err_mask;
+       int i, j;
+
+       /*
+        * Check device sleep capability. Get DevSlp timing variables
+        * from SATA Settings page of Identify Device Data Log.
+        */
+       if (!ata_id_has_devslp(dev->id))
+               return;
+
+       err_mask = ata_read_log_page(dev,
+                                    ATA_LOG_IDENTIFY_DEVICE,
+                                    ATA_LOG_SATA_SETTINGS,
+                                    sata_setting, 1);
+       if (err_mask) {
+               ata_dev_dbg(dev,
+                           "failed to get SATA Settings Log, Emask 0x%x\n",
+                           err_mask);
+               return;
+       }
+
+       dev->flags |= ATA_DFLAG_DEVSLP;
+       for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) {
+               j = ATA_LOG_DEVSLP_OFFSET + i;
+               dev->devslp_timing[i] = sata_setting[j];
+       }
+}
+
 /**
  *     ata_dev_configure - Configure the specified ATA/ATAPI device
  *     @dev: Target device to configure
@@ -2565,29 +2596,7 @@ int ata_dev_configure(struct ata_device *dev)
                        }
                }
 
-               /* Check and mark DevSlp capability. Get DevSlp timing variables
-                * from SATA Settings page of Identify Device Data Log.
-                */
-               if (ata_id_has_devslp(dev->id)) {
-                       u8 *sata_setting = ap->sector_buf;
-                       int i, j;
-
-                       dev->flags |= ATA_DFLAG_DEVSLP;
-                       err_mask = ata_read_log_page(dev,
-                                                    ATA_LOG_IDENTIFY_DEVICE,
-                                                    ATA_LOG_SATA_SETTINGS,
-                                                    sata_setting,
-                                                    1);
-                       if (err_mask)
-                               ata_dev_dbg(dev,
-                                           "failed to get Identify Device Data, Emask 0x%x\n",
-                                           err_mask);
-                       else
-                               for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) {
-                                       j = ATA_LOG_DEVSLP_OFFSET + i;
-                                       dev->devslp_timing[i] = sata_setting[j];
-                               }
-               }
+               ata_dev_config_devslp(dev);
                ata_dev_config_sense_reporting(dev);
                ata_dev_config_zac(dev);
                ata_dev_config_trusted(dev);