From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org, xxjack12xx@gmail.com,
Niklas Cassel <cassel@kernel.org>
Subject: [PATCH v2 3/8] ata: libata: Add ata_force_get_fe_for_dev() helper
Date: Fri, 28 Nov 2025 09:48:18 +0100 [thread overview]
Message-ID: <20251128084814.3798425-13-cassel@kernel.org> (raw)
In-Reply-To: <20251128084814.3798425-10-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>
---
drivers/ata/libata-core.c | 55 ++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 21 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 634d6b07a92dc..b1ef45c1a376a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -474,29 +474,20 @@ 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)
{
int devno = dev->link->pmp + dev->devno;
int alt_devno = devno;
int i;
+ const struct ata_force_ent *fe;
/* allow n.15/16 for devices attached to host port */
if (ata_is_host_link(dev->link))
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 +496,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-11-28 8:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 8:48 [PATCH v2 0/8] ata: libata: Quirk DELLBOSS VD max_sectors Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 1/8] ata: libata: Move quirk flags to their own enum Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 2/8] ata: libata: Add ATA_QUIRK_MAX_SEC and convert all device quirks Niklas Cassel
2025-11-28 8:48 ` Niklas Cassel [this message]
2025-11-28 8:48 ` [PATCH v2 4/8] ata: libata: Change libata.force to use the generic ATA_QUIRK_MAX_SEC quirk Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 5/8] ata: libata-core: Quirk DELLBOSS VD max_sectors Niklas Cassel
2025-11-28 9:00 ` Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 6/8] ata: libata: Add support to parse equal sign in libata.force Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 7/8] ata: libata: Add libata.force parameter max_sec Niklas Cassel
2025-11-28 8:48 ` [PATCH v2 8/8] ata: libata: Allow more quirks Niklas Cassel
2025-11-29 21:50 ` [PATCH v2 0/8] ata: libata: Quirk DELLBOSS VD max_sectors Martin K. Petersen
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=20251128084814.3798425-13-cassel@kernel.org \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=xxjack12xx@gmail.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