diff options
author | Dan Williams <dan.j.williams@intel.com> | 2016-07-09 09:12:52 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2016-07-13 00:13:48 +0200 |
commit | 476f848aaee466fd5d74f123fa652e757f2baeba (patch) | |
tree | d84cdd4fdb50252dfc5d1e2916b665d4f5570b76 /drivers/nvdimm/bus.c | |
parent | libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush() (diff) | |
download | linux-476f848aaee466fd5d74f123fa652e757f2baeba.tar.xz linux-476f848aaee466fd5d74f123fa652e757f2baeba.zip |
libnvdimm, pmem: flush posted-write queues on shutdown
Commit writes to media on system shutdown or pmem driver unload.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/bus.c')
-rw-r--r-- | drivers/nvdimm/bus.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index e4882e63bece..1cc7880320fe 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -136,6 +136,21 @@ static int nvdimm_bus_remove(struct device *dev) return rc; } +static void nvdimm_bus_shutdown(struct device *dev) +{ + struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); + struct nd_device_driver *nd_drv = NULL; + + if (dev->driver) + nd_drv = to_nd_device_driver(dev->driver); + + if (nd_drv && nd_drv->shutdown) { + nd_drv->shutdown(dev); + dev_dbg(&nvdimm_bus->dev, "%s.shutdown(%s)\n", + dev->driver->name, dev_name(dev)); + } +} + void nd_device_notify(struct device *dev, enum nvdimm_event event) { device_lock(dev); @@ -214,6 +229,7 @@ static struct bus_type nvdimm_bus_type = { .match = nvdimm_bus_match, .probe = nvdimm_bus_probe, .remove = nvdimm_bus_remove, + .shutdown = nvdimm_bus_shutdown, }; static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain); |