* [PATCH] nvmet: nvmet.h configfs helper cleanup
@ 2024-02-11 23:39 Chaitanya Kulkarni
2024-02-12 6:59 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-02-11 23:39 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, hch, sagi, Chaitanya Kulkarni
Functions to_nvmet_ns(), to_ana_group(), to_subsys(), to_host() and
namespaces_to_subsys() are only used in target/configfs.c, move it
to the appropriate file instead of bloating common header.
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
drivers/nvme/target/configfs.c | 28 ++++++++++++++++++++++++++++
drivers/nvme/target/nvmet.h | 28 ----------------------------
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 2482a0db2504..a4307cbf9cf7 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -49,6 +49,34 @@ static const struct nvmet_type_name_map nvmet_addr_family[] = {
{ NVMF_ADDR_FAMILY_LOOP, "loop" },
};
+static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item)
+{
+ return container_of(to_config_group(item), struct nvmet_ns, group);
+}
+
+static inline struct nvmet_ana_group *to_ana_group(struct config_item *item)
+{
+ return container_of(to_config_group(item), struct nvmet_ana_group,
+ group);
+}
+
+static inline struct nvmet_subsys *to_subsys(struct config_item *item)
+{
+ return container_of(to_config_group(item), struct nvmet_subsys, group);
+}
+
+static inline struct nvmet_subsys *namespaces_to_subsys(
+ struct config_item *item)
+{
+ return container_of(to_config_group(item), struct nvmet_subsys,
+ namespaces_group);
+}
+
+static inline struct nvmet_host *to_host(struct config_item *item)
+{
+ return container_of(to_config_group(item), struct nvmet_host, group);
+}
+
static bool nvmet_is_port_enabled(struct nvmet_port *p, const char *caller)
{
if (p->enabled)
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 6c8acebe1a1a..ad8d1f096349 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -87,11 +87,6 @@ struct nvmet_ns {
u8 csi;
};
-static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item)
-{
- return container_of(to_config_group(item), struct nvmet_ns, group);
-}
-
static inline struct device *nvmet_ns_dev(struct nvmet_ns *ns)
{
return ns->bdev ? disk_to_dev(ns->bdev->bd_disk) : NULL;
@@ -132,12 +127,6 @@ struct nvmet_ana_group {
u32 grpid;
};
-static inline struct nvmet_ana_group *to_ana_group(struct config_item *item)
-{
- return container_of(to_config_group(item), struct nvmet_ana_group,
- group);
-}
-
/**
* struct nvmet_port - Common structure to keep port
* information for the target.
@@ -293,18 +282,6 @@ struct nvmet_subsys {
#endif /* CONFIG_BLK_DEV_ZONED */
};
-static inline struct nvmet_subsys *to_subsys(struct config_item *item)
-{
- return container_of(to_config_group(item), struct nvmet_subsys, group);
-}
-
-static inline struct nvmet_subsys *namespaces_to_subsys(
- struct config_item *item)
-{
- return container_of(to_config_group(item), struct nvmet_subsys,
- namespaces_group);
-}
-
struct nvmet_host {
struct config_group group;
u8 *dhchap_secret;
@@ -315,11 +292,6 @@ struct nvmet_host {
u8 dhchap_dhgroup_id;
};
-static inline struct nvmet_host *to_host(struct config_item *item)
-{
- return container_of(to_config_group(item), struct nvmet_host, group);
-}
-
static inline char *nvmet_host_name(struct nvmet_host *host)
{
return config_item_name(&host->group.cg_item);
--
2.40.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] nvmet: nvmet.h configfs helper cleanup
2024-02-11 23:39 [PATCH] nvmet: nvmet.h configfs helper cleanup Chaitanya Kulkarni
@ 2024-02-12 6:59 ` Christoph Hellwig
2024-02-13 7:43 ` Chaitanya Kulkarni
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2024-02-12 6:59 UTC (permalink / raw)
To: Chaitanya Kulkarni; +Cc: linux-nvme, kbusch, hch, sagi
On Sun, Feb 11, 2024 at 03:39:49PM -0800, Chaitanya Kulkarni wrote:
> Functions to_nvmet_ns(), to_ana_group(), to_subsys(), to_host() and
> namespaces_to_subsys() are only used in target/configfs.c, move it
> to the appropriate file instead of bloating common header.
Does it matter? I find having the helpers to do a container_of right
next to the structures they are used on pretty helpful.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvmet: nvmet.h configfs helper cleanup
2024-02-12 6:59 ` Christoph Hellwig
@ 2024-02-13 7:43 ` Chaitanya Kulkarni
0 siblings, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-02-13 7:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-nvme@lists.infradead.org, kbusch@kernel.org,
sagi@grimberg.me, Chaitanya Kulkarni
On 2/11/24 22:59, Christoph Hellwig wrote:
> On Sun, Feb 11, 2024 at 03:39:49PM -0800, Chaitanya Kulkarni wrote:
>> Functions to_nvmet_ns(), to_ana_group(), to_subsys(), to_host() and
>> namespaces_to_subsys() are only used in target/configfs.c, move it
>> to the appropriate file instead of bloating common header.
> Does it matter? I find having the helpers to do a container_of right
> next to the structures they are used on pretty helpful.
>
hmmm, from what I know it is a bad practice to carry private interface
in header file vs prioritizing the readability, please disregard this
patch if it is going to create any inconvenience.
-ck
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-13 7:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-11 23:39 [PATCH] nvmet: nvmet.h configfs helper cleanup Chaitanya Kulkarni
2024-02-12 6:59 ` Christoph Hellwig
2024-02-13 7:43 ` Chaitanya Kulkarni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox