]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ata: libata: Add ata_force_get_fe_for_dev() helper
authorNiklas Cassel <cassel@kernel.org>
Tue, 2 Dec 2025 12:21:32 +0000 (13:21 +0100)
committerDamien Le Moal <dlemoal@kernel.org>
Mon, 15 Dec 2025 07:32:05 +0000 (16:32 +0900)
Add ata_force_get_fe_for_dev() helper to get the struct ata_force_ent for
a struct ata_device.

Use the helper in ata_force_quirks().
The helper will also be used in follow up commits.

No functional change intended.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
drivers/ata/libata-core.c

index b6127fa0b55048b538a075bb4276c2bffffb67c2..1779cd5a1cbb084664b425760de52078cf8dfb16 100644 (file)
@@ -474,19 +474,10 @@ static void ata_force_xfermask(struct ata_device *dev)
        }
 }
 
-/**
- *     ata_force_quirks - force quirks according to libata.force
- *     @dev: ATA device of interest
- *
- *     Force quirks according to libata.force and whine about it.
- *     For consistency with link selection, device number 15 selects
- *     the first device connected to the host link.
- *
- *     LOCKING:
- *     EH context.
- */
-static void ata_force_quirks(struct ata_device *dev)
+static const struct ata_force_ent *
+ata_force_get_fe_for_dev(struct ata_device *dev)
 {
+       const struct ata_force_ent *fe;
        int devno = dev->link->pmp + dev->devno;
        int alt_devno = devno;
        int i;
@@ -496,8 +487,7 @@ static void ata_force_quirks(struct ata_device *dev)
                alt_devno += 15;
 
        for (i = 0; i < ata_force_tbl_size; i++) {
-               const struct ata_force_ent *fe = &ata_force_tbl[i];
-
+               fe = &ata_force_tbl[i];
                if (fe->port != -1 && fe->port != dev->link->ap->print_id)
                        continue;
 
@@ -505,16 +495,38 @@ static void ata_force_quirks(struct ata_device *dev)
                    fe->device != alt_devno)
                        continue;
 
-               if (!(~dev->quirks & fe->param.quirk_on) &&
-                   !(dev->quirks & fe->param.quirk_off))
-                       continue;
+               return fe;
+       }
 
-               dev->quirks |= fe->param.quirk_on;
-               dev->quirks &= ~fe->param.quirk_off;
+       return NULL;
+}
 
-               ata_dev_notice(dev, "FORCE: modified (%s)\n",
-                              fe->param.name);
-       }
+/**
+ *     ata_force_quirks - force quirks according to libata.force
+ *     @dev: ATA device of interest
+ *
+ *     Force quirks according to libata.force and whine about it.
+ *     For consistency with link selection, device number 15 selects
+ *     the first device connected to the host link.
+ *
+ *     LOCKING:
+ *     EH context.
+ */
+static void ata_force_quirks(struct ata_device *dev)
+{
+       const struct ata_force_ent *fe = ata_force_get_fe_for_dev(dev);
+
+       if (!fe)
+               return;
+
+       if (!(~dev->quirks & fe->param.quirk_on) &&
+           !(dev->quirks & fe->param.quirk_off))
+               return;
+
+       dev->quirks |= fe->param.quirk_on;
+       dev->quirks &= ~fe->param.quirk_off;
+
+       ata_dev_notice(dev, "FORCE: modified (%s)\n", fe->param.name);
 }
 #else
 static inline void ata_force_pflags(struct ata_port *ap) { }