summaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/pmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nvdimm/pmem.c')
-rw-r--r--drivers/nvdimm/pmem.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index c544d466ea51..7bd383aeea14 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -49,19 +49,19 @@ static struct nd_region *to_region(struct pmem_device *pmem)
49 return to_nd_region(to_dev(pmem)->parent); 49 return to_nd_region(to_dev(pmem)->parent);
50} 50}
51 51
52static int pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset, 52static blk_status_t pmem_clear_poison(struct pmem_device *pmem,
53 unsigned int len) 53 phys_addr_t offset, unsigned int len)
54{ 54{
55 struct device *dev = to_dev(pmem); 55 struct device *dev = to_dev(pmem);
56 sector_t sector; 56 sector_t sector;
57 long cleared; 57 long cleared;
58 int rc = 0; 58 blk_status_t rc = BLK_STS_OK;
59 59
60 sector = (offset - pmem->data_offset) / 512; 60 sector = (offset - pmem->data_offset) / 512;
61 61
62 cleared = nvdimm_clear_poison(dev, pmem->phys_addr + offset, len); 62 cleared = nvdimm_clear_poison(dev, pmem->phys_addr + offset, len);
63 if (cleared < len) 63 if (cleared < len)
64 rc = -EIO; 64 rc = BLK_STS_IOERR;
65 if (cleared > 0 && cleared / 512) { 65 if (cleared > 0 && cleared / 512) {
66 cleared /= 512; 66 cleared /= 512;
67 dev_dbg(dev, "%s: %#llx clear %ld sector%s\n", __func__, 67 dev_dbg(dev, "%s: %#llx clear %ld sector%s\n", __func__,
@@ -84,7 +84,7 @@ static void write_pmem(void *pmem_addr, struct page *page,
84 kunmap_atomic(mem); 84 kunmap_atomic(mem);
85} 85}
86 86
87static int read_pmem(struct page *page, unsigned int off, 87static blk_status_t read_pmem(struct page *page, unsigned int off,
88 void *pmem_addr, unsigned int len) 88 void *pmem_addr, unsigned int len)
89{ 89{
90 int rc; 90 int rc;
@@ -93,15 +93,15 @@ static int read_pmem(struct page *page, unsigned int off,
93 rc = memcpy_mcsafe(mem + off, pmem_addr, len); 93 rc = memcpy_mcsafe(mem + off, pmem_addr, len);
94 kunmap_atomic(mem); 94 kunmap_atomic(mem);
95 if (rc) 95 if (rc)
96 return -EIO; 96 return BLK_STS_IOERR;
97 return 0; 97 return BLK_STS_OK;
98} 98}
99 99
100static int pmem_do_bvec(struct pmem_device *pmem, struct page *page, 100static blk_status_t pmem_do_bvec(struct pmem_device *pmem, struct page *page,
101 unsigned int len, unsigned int off, bool is_write, 101 unsigned int len, unsigned int off, bool is_write,
102 sector_t sector) 102 sector_t sector)
103{ 103{
104 int rc = 0; 104 blk_status_t rc = BLK_STS_OK;
105 bool bad_pmem = false; 105 bool bad_pmem = false;
106 phys_addr_t pmem_off = sector * 512 + pmem->data_offset; 106 phys_addr_t pmem_off = sector * 512 + pmem->data_offset;
107 void *pmem_addr = pmem->virt_addr + pmem_off; 107 void *pmem_addr = pmem->virt_addr + pmem_off;
@@ -111,7 +111,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
111 111
112 if (!is_write) { 112 if (!is_write) {
113 if (unlikely(bad_pmem)) 113 if (unlikely(bad_pmem))
114 rc = -EIO; 114 rc = BLK_STS_IOERR;
115 else { 115 else {
116 rc = read_pmem(page, off, pmem_addr, len); 116 rc = read_pmem(page, off, pmem_addr, len);
117 flush_dcache_page(page); 117 flush_dcache_page(page);
@@ -149,7 +149,7 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
149 149
150static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio) 150static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio)
151{ 151{
152 int rc = 0; 152 blk_status_t rc = 0;
153 bool do_acct; 153 bool do_acct;
154 unsigned long start; 154 unsigned long start;
155 struct bio_vec bvec; 155 struct bio_vec bvec;
@@ -166,7 +166,7 @@ static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio)
166 bvec.bv_offset, op_is_write(bio_op(bio)), 166 bvec.bv_offset, op_is_write(bio_op(bio)),
167 iter.bi_sector); 167 iter.bi_sector);
168 if (rc) { 168 if (rc) {
169 bio->bi_error = rc; 169 bio->bi_status = rc;
170 break; 170 break;
171 } 171 }
172 } 172 }
@@ -184,7 +184,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,
184 struct page *page, bool is_write) 184 struct page *page, bool is_write)
185{ 185{
186 struct pmem_device *pmem = bdev->bd_queue->queuedata; 186 struct pmem_device *pmem = bdev->bd_queue->queuedata;
187 int rc; 187 blk_status_t rc;
188 188
189 rc = pmem_do_bvec(pmem, page, PAGE_SIZE, 0, is_write, sector); 189 rc = pmem_do_bvec(pmem, page, PAGE_SIZE, 0, is_write, sector);
190 190
@@ -197,7 +197,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,
197 if (rc == 0) 197 if (rc == 0)
198 page_endio(page, is_write, 0); 198 page_endio(page, is_write, 0);
199 199
200 return rc; 200 return blk_status_to_errno(rc);
201} 201}
202 202
203/* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ 203/* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */