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: use type-name map for ana states

Now that we have a generic type to name map for configfs, get rid of
the nvmet_ana_state_names structure and replace it with newly added
nvmet_type_name_map.

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
84b8d0d7 7e764179

+8 -12
+8 -12
drivers/nvme/target/configfs.c
··· 1153 1153 .ct_group_ops = &nvmet_referral_group_ops, 1154 1154 }; 1155 1155 1156 - static struct { 1157 - enum nvme_ana_state state; 1158 - const char *name; 1159 - } nvmet_ana_state_names[] = { 1156 + struct nvmet_type_name_map nvmet_ana_state[] = { 1160 1157 { NVME_ANA_OPTIMIZED, "optimized" }, 1161 1158 { NVME_ANA_NONOPTIMIZED, "non-optimized" }, 1162 1159 { NVME_ANA_INACCESSIBLE, "inaccessible" }, ··· 1168 1171 enum nvme_ana_state state = grp->port->ana_state[grp->grpid]; 1169 1172 int i; 1170 1173 1171 - for (i = 0; i < ARRAY_SIZE(nvmet_ana_state_names); i++) { 1172 - if (state != nvmet_ana_state_names[i].state) 1173 - continue; 1174 - return sprintf(page, "%s\n", nvmet_ana_state_names[i].name); 1174 + for (i = 0; i < ARRAY_SIZE(nvmet_ana_state); i++) { 1175 + if (state == nvmet_ana_state[i].type) 1176 + return sprintf(page, "%s\n", nvmet_ana_state[i].name); 1175 1177 } 1176 1178 1177 1179 return sprintf(page, "\n"); ··· 1180 1184 const char *page, size_t count) 1181 1185 { 1182 1186 struct nvmet_ana_group *grp = to_ana_group(item); 1187 + enum nvme_ana_state *ana_state = grp->port->ana_state; 1183 1188 int i; 1184 1189 1185 - for (i = 0; i < ARRAY_SIZE(nvmet_ana_state_names); i++) { 1186 - if (sysfs_streq(page, nvmet_ana_state_names[i].name)) 1190 + for (i = 0; i < ARRAY_SIZE(nvmet_ana_state); i++) { 1191 + if (sysfs_streq(page, nvmet_ana_state[i].name)) 1187 1192 goto found; 1188 1193 } 1189 1194 ··· 1193 1196 1194 1197 found: 1195 1198 down_write(&nvmet_ana_sem); 1196 - grp->port->ana_state[grp->grpid] = nvmet_ana_state_names[i].state; 1199 + ana_state[grp->grpid] = (enum nvme_ana_state) nvmet_ana_state[i].type; 1197 1200 nvmet_ana_chgcnt++; 1198 1201 up_write(&nvmet_ana_sem); 1199 - 1200 1202 nvmet_port_send_ana_event(grp->port); 1201 1203 return count; 1202 1204 }