aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/core.c
diff options
context:
space:
mode:
authorMatias Bjørling <m@bjorling.me>2016-07-07 03:54:22 -0400
committerJens Axboe <axboe@fb.com>2016-07-07 10:51:52 -0400
commit8680f165eaa56cc9812d7d9b4903f449df0f6a45 (patch)
tree78a0e8a717942fb26dacae7ba44275ff58e289fa /drivers/lightnvm/core.c
parent24d4a7d721484498462bc3117d6d5c88ca623574 (diff)
lightnvm: make ppa_list const in nvm_set_rqd_list
The passed by reference ppa list in nvm_set_rqd_list() is updated when multiple planes are available. In that case, each PPA plane is incremented when the device side PPA list is created. This prevents the caller to rely on the PPA list to be unmodified after a call. Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r--drivers/lightnvm/core.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index ddc809803084..00b64f78887d 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -237,9 +237,10 @@ void nvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd)
237EXPORT_SYMBOL(nvm_generic_to_addr_mode); 237EXPORT_SYMBOL(nvm_generic_to_addr_mode);
238 238
239int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, 239int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd,
240 struct ppa_addr *ppas, int nr_ppas, int vblk) 240 const struct ppa_addr *ppas, int nr_ppas, int vblk)
241{ 241{
242 int i, plane_cnt, pl_idx; 242 int i, plane_cnt, pl_idx;
243 struct ppa_addr ppa;
243 244
244 if ((!vblk || dev->plane_mode == NVM_PLANE_SINGLE) && nr_ppas == 1) { 245 if ((!vblk || dev->plane_mode == NVM_PLANE_SINGLE) && nr_ppas == 1) {
245 rqd->nr_ppas = nr_ppas; 246 rqd->nr_ppas = nr_ppas;
@@ -264,8 +265,9 @@ int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd,
264 265
265 for (i = 0; i < nr_ppas; i++) { 266 for (i = 0; i < nr_ppas; i++) {
266 for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) { 267 for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) {
267 ppas[i].g.pl = pl_idx; 268 ppa = ppas[i];
268 rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppas[i]; 269 ppa.g.pl = pl_idx;
270 rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppa;
269 } 271 }
270 } 272 }
271 } 273 }