[PATCH 08/14] nvme-core: move util quirk at the top of the file
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Tue Feb 16 19:10:26 EST 2021
The quirk utility functions and structure are defined in the middle of
the file (line:2762) & they are not accessed immediately after their
declaration until we get to nvme_init_identify() (line:3114).
Move quirk related util functions at the top of the file that avoids
any global structure related definitions in the middle of the code
where they are not accessed immediately after definition.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/host/core.c | 126 +++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 63 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4a59a46193e8..5cb90bd8704d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -93,6 +93,69 @@ static void nvme_put_subsystem(struct nvme_subsystem *subsys);
static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
unsigned nsid);
+struct nvme_core_quirk_entry {
+ /*
+ * NVMe model and firmware strings are padded with spaces. For
+ * simplicity, strings in the quirk table are padded with NULLs
+ * instead.
+ */
+ u16 vid;
+ const char *mn;
+ const char *fr;
+ unsigned long quirks;
+};
+
+static const struct nvme_core_quirk_entry core_quirks[] = {
+ {
+ /*
+ * This Toshiba device seems to die using any APST states. See:
+ * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1678184/comments/11
+ */
+ .vid = 0x1179,
+ .mn = "THNSF5256GPUK TOSHIBA",
+ .quirks = NVME_QUIRK_NO_APST,
+ },
+ {
+ /*
+ * This LiteON CL1-3D*-Q11 firmware version has a race
+ * condition associated with actions related to suspend to idle
+ * LiteON has resolved the problem in future firmware
+ */
+ .vid = 0x14a4,
+ .fr = "22301111",
+ .quirks = NVME_QUIRK_SIMPLE_SUSPEND,
+ }
+};
+
+/* match is null-terminated but idstr is space-padded. */
+static bool string_matches(const char *idstr, const char *match, size_t len)
+{
+ size_t matchlen;
+
+ if (!match)
+ return true;
+
+ matchlen = strlen(match);
+ WARN_ON_ONCE(matchlen > len);
+
+ if (memcmp(idstr, match, matchlen))
+ return false;
+
+ for (; matchlen < len; matchlen++)
+ if (idstr[matchlen] != ' ')
+ return false;
+
+ return true;
+}
+
+static bool quirk_matches(const struct nvme_id_ctrl *id,
+ const struct nvme_core_quirk_entry *q)
+{
+ return q->vid == le16_to_cpu(id->vid) &&
+ string_matches(id->mn, q->mn, sizeof(id->mn)) &&
+ string_matches(id->fr, q->fr, sizeof(id->fr));
+}
+
/*
* Prepare a queue for teardown.
*
@@ -2704,69 +2767,6 @@ static void nvme_set_latency_tolerance(struct device *dev, s32 val)
}
}
-struct nvme_core_quirk_entry {
- /*
- * NVMe model and firmware strings are padded with spaces. For
- * simplicity, strings in the quirk table are padded with NULLs
- * instead.
- */
- u16 vid;
- const char *mn;
- const char *fr;
- unsigned long quirks;
-};
-
-static const struct nvme_core_quirk_entry core_quirks[] = {
- {
- /*
- * This Toshiba device seems to die using any APST states. See:
- * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1678184/comments/11
- */
- .vid = 0x1179,
- .mn = "THNSF5256GPUK TOSHIBA",
- .quirks = NVME_QUIRK_NO_APST,
- },
- {
- /*
- * This LiteON CL1-3D*-Q11 firmware version has a race
- * condition associated with actions related to suspend to idle
- * LiteON has resolved the problem in future firmware
- */
- .vid = 0x14a4,
- .fr = "22301111",
- .quirks = NVME_QUIRK_SIMPLE_SUSPEND,
- }
-};
-
-/* match is null-terminated but idstr is space-padded. */
-static bool string_matches(const char *idstr, const char *match, size_t len)
-{
- size_t matchlen;
-
- if (!match)
- return true;
-
- matchlen = strlen(match);
- WARN_ON_ONCE(matchlen > len);
-
- if (memcmp(idstr, match, matchlen))
- return false;
-
- for (; matchlen < len; matchlen++)
- if (idstr[matchlen] != ' ')
- return false;
-
- return true;
-}
-
-static bool quirk_matches(const struct nvme_id_ctrl *id,
- const struct nvme_core_quirk_entry *q)
-{
- return q->vid == le16_to_cpu(id->vid) &&
- string_matches(id->mn, q->mn, sizeof(id->mn)) &&
- string_matches(id->fr, q->fr, sizeof(id->fr));
-}
-
static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ctrl,
struct nvme_id_ctrl *id)
{
--
2.22.1
More information about the Linux-nvme
mailing list