Revert "tty: hvc: Fix data abort due to race in hvc_open"
[linux/fpc-iii.git] / tools / testing / nvdimm / dax-dev.c
blob7e5d979e73cbeb3bcc3f1f400e5b3efc59dfbafb
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2016, Intel Corporation.
4 */
5 #include "test/nfit_test.h"
6 #include <linux/mm.h>
7 #include "../../../drivers/dax/dax-private.h"
9 phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
10 unsigned long size)
12 struct resource *res = &dev_dax->region->res;
13 phys_addr_t addr;
15 addr = pgoff * PAGE_SIZE + res->start;
16 if (addr >= res->start && addr <= res->end) {
17 if (addr + size - 1 <= res->end) {
18 if (get_nfit_res(addr)) {
19 struct page *page;
21 if (dev_dax->region->align > PAGE_SIZE)
22 return -1;
24 page = vmalloc_to_page((void *)addr);
25 return PFN_PHYS(page_to_pfn(page));
26 } else
27 return addr;
30 return -1;