Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvmet: add generic type-name mapping

This patch adds a new type to name mapping generic structure. It
replaces nvmet_transport_name with new generic mapping structure
nvmet_transport.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Chaitanya Kulkarni and committed by
Jens Axboe
45e2f3c2 7890b970

+10 -9
+10 -9
drivers/nvme/target/configfs.c
··· 20 20 static LIST_HEAD(nvmet_ports_list); 21 21 struct list_head *nvmet_ports = &nvmet_ports_list; 22 22 23 - static const struct nvmet_transport_name { 23 + struct nvmet_type_name_map { 24 24 u8 type; 25 25 const char *name; 26 - } nvmet_transport_names[] = { 26 + }; 27 + 28 + static struct nvmet_type_name_map nvmet_transport[] = { 27 29 { NVMF_TRTYPE_RDMA, "rdma" }, 28 30 { NVMF_TRTYPE_FC, "fc" }, 29 31 { NVMF_TRTYPE_TCP, "tcp" }, ··· 256 254 struct nvmet_port *port = to_nvmet_port(item); 257 255 int i; 258 256 259 - for (i = 0; i < ARRAY_SIZE(nvmet_transport_names); i++) { 260 - if (port->disc_addr.trtype != nvmet_transport_names[i].type) 261 - continue; 262 - return sprintf(page, "%s\n", nvmet_transport_names[i].name); 257 + for (i = 0; i < ARRAY_SIZE(nvmet_transport); i++) { 258 + if (port->disc_addr.trtype == nvmet_transport[i].type) 259 + return sprintf(page, "%s\n", nvmet_transport[i].name); 263 260 } 264 261 265 262 return sprintf(page, "\n"); ··· 283 282 return -EACCES; 284 283 } 285 284 286 - for (i = 0; i < ARRAY_SIZE(nvmet_transport_names); i++) { 287 - if (sysfs_streq(page, nvmet_transport_names[i].name)) 285 + for (i = 0; i < ARRAY_SIZE(nvmet_transport); i++) { 286 + if (sysfs_streq(page, nvmet_transport[i].name)) 288 287 goto found; 289 288 } 290 289 ··· 292 291 return -EINVAL; 293 292 found: 294 293 memset(&port->disc_addr.tsas, 0, NVMF_TSAS_SIZE); 295 - port->disc_addr.trtype = nvmet_transport_names[i].type; 294 + port->disc_addr.trtype = nvmet_transport[i].type; 296 295 if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA) 297 296 nvmet_port_init_tsas_rdma(port); 298 297 return count;