nvmet: nvmet.h configfs helper cleanup
Subsystems (2)
Chaitanya Kulkarni
maintainerPATCH 1/1 nvmet: nvmet.h configfs helper cleanup
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.
--- drivers/nvme/target/configfs.c | 28 ++++++++++++++++++++++++++++ drivers/nvme/target/nvmet.h | 28 ---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-)
drivers/nvme/target/configfs.c +28 -0
@@ -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)
drivers/nvme/target/nvmet.h +0 -28
@@ -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);
Signature · 1 line
2.40.0
Christoph Hellwig
maintainerQuoted 3 lines · Chaitanya Kulkarni
Functions
to_nvmet_ns(),to_ana_group(),to_subsys(),to_host()andnamespaces_to_subsys()are only used intarget/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.
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Chaitanya Kulkarni
Functions
to_nvmet_ns(),to_ana_group(),to_subsys(),to_host()andnamespaces_to_subsys()are only used intarget/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_ofright 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