summaryrefslogtreecommitdiff
path: root/drivers/ata
diff options
context:
space:
mode:
authorNiklas Cassel <cassel@kernel.org>2025-12-02 13:21:32 +0100
committerDamien Le Moal <dlemoal@kernel.org>2025-12-15 16:32:05 +0900
commit873abd72b8b54443ac7783d207be7333289f8287 (patch)
treef3797b1fa829925a5d9090df93578de514efd73a /drivers/ata
parent59b7bb3d48333889adb1dd2aac3ab0cf26714390 (diff)
ata: libata: Add ata_force_get_fe_for_dev() helper
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>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-core.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index b6127fa0b550..1779cd5a1cbb 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -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) { }