From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Niklas Cassel <cassel@kernel.org>
Subject: [PATCH v4 2/6] ata: libata: Add ata_force_get_fe_for_dev() helper
Date: Tue, 2 Dec 2025 13:21:32 +0100 [thread overview]
Message-ID: <20251202122129.421783-10-cassel@kernel.org> (raw)
In-Reply-To: <20251202122129.421783-8-cassel@kernel.org>
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>
---
drivers/ata/libata-core.c | 56 ++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index e33008803e04e..4dad69b603713 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) { }
--
2.52.0
next prev parent reply other threads:[~2025-12-02 12:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 12:21 [PATCH v4 0/6] ata: libata: Improve max sectors quirk handling Niklas Cassel
2025-12-02 12:21 ` [PATCH v4 1/6] ata: libata: Add ATA_QUIRK_MAX_SEC and convert all device quirks Niklas Cassel
2025-12-02 13:10 ` Martin K. Petersen
2025-12-02 12:21 ` Niklas Cassel [this message]
2025-12-02 12:21 ` [PATCH v4 3/6] ata: libata: Change libata.force to use the generic ATA_QUIRK_MAX_SEC quirk Niklas Cassel
2025-12-02 12:21 ` [PATCH v4 4/6] ata: libata: Add support to parse equal sign in libata.force Niklas Cassel
2025-12-02 12:21 ` [PATCH v4 5/6] ata: libata: Add libata.force parameter max_sec Niklas Cassel
2025-12-02 12:21 ` [PATCH v4 6/6] ata: libata: Allow more quirks Niklas Cassel
2025-12-08 3:48 ` [PATCH v4 0/6] ata: libata: Improve max sectors quirk handling Damien Le Moal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251202122129.421783-10-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox