[PATCH v3 3/7] libnvdimm: simplify walk_to_nvdimm_bus()
From: Zhen Lei
Date: Wed Aug 19 2020 - 22:17:31 EST
Return as soon as nvdimm_bus device has been found, make us no need to
check "dev" or "!dev" in subsequent code.
No functional change.
Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
---
drivers/nvdimm/bus.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 955265656b96c73..1d89114cb6ab93e 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -316,10 +316,9 @@ struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev)
for (dev = nd_dev; dev; dev = dev->parent)
if (is_nvdimm_bus(dev))
- break;
- dev_WARN_ONCE(nd_dev, !dev, "invalid dev, not on nd bus\n");
- if (dev)
- return to_nvdimm_bus(dev);
+ return to_nvdimm_bus(dev);
+
+ dev_WARN_ONCE(nd_dev, 1, "invalid dev, not on nd bus\n");
return NULL;
}
--
1.8.3