diff options
author | Dan Williams <dan.j.williams@intel.com> | 2016-05-21 22:33:04 +0300 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2016-05-21 22:33:04 +0300 |
commit | 36092ee8ba695fce023b2118ececa6c2a56b1331 (patch) | |
tree | b9579893cdd559e7b72fa569003b19792de58fad /drivers/nvdimm/claim.c | |
parent | 1b982baf75e7d9585967fcfccd05b77bf9054010 (diff) | |
parent | 03dca343afe080968d90c4d9196404b5bbbc8461 (diff) | |
download | linux-36092ee8ba695fce023b2118ececa6c2a56b1331.tar.xz |
Merge branch 'for-4.7/dax' into libnvdimm-for-next
Diffstat (limited to 'drivers/nvdimm/claim.c')
-rw-r--r-- | drivers/nvdimm/claim.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c index 5f53db59a058..8b2e3c4fb0ad 100644 --- a/drivers/nvdimm/claim.c +++ b/drivers/nvdimm/claim.c @@ -93,6 +93,25 @@ static bool is_idle(struct device *dev, struct nd_namespace_common *ndns) return true; } +struct nd_pfn *to_nd_pfn_safe(struct device *dev) +{ + /* + * pfn device attributes are re-used by dax device instances, so we + * need to be careful to correct device-to-nd_pfn conversion. + */ + if (is_nd_pfn(dev)) + return to_nd_pfn(dev); + + if (is_nd_dax(dev)) { + struct nd_dax *nd_dax = to_nd_dax(dev); + + return &nd_dax->nd_pfn; + } + + WARN_ON(1); + return NULL; +} + static void nd_detach_and_reset(struct device *dev, struct nd_namespace_common **_ndns) { @@ -106,8 +125,8 @@ static void nd_detach_and_reset(struct device *dev, nd_btt->lbasize = 0; kfree(nd_btt->uuid); nd_btt->uuid = NULL; - } else if (is_nd_pfn(dev)) { - struct nd_pfn *nd_pfn = to_nd_pfn(dev); + } else if (is_nd_pfn(dev) || is_nd_dax(dev)) { + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); kfree(nd_pfn->uuid); nd_pfn->uuid = NULL; |