[fdf][ramnand] Use new topological path

ram-nand now binds to a platform-device. All clients were updated to use
the new location, and test packages had platform-bus added.

Bug: 77388
Tested: fx paver-test.cmx
Tested: fx minfs-fs-tests
Change-Id: Icf9886e8e54180253f8c3c7a0c26fdb228d37585
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/555045
Fuchsia-Auto-Submit: Suraj Malhotra <surajmalhotra@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Abdulla Kamar <abdulla@google.com>
Reviewed-by: David Gilhooley <dgilhooley@google.com>
diff --git a/docs/development/testing/nand_testing.md b/docs/development/testing/nand_testing.md
index 828c983..b4e4ae9 100644
--- a/docs/development/testing/nand_testing.md
+++ b/docs/development/testing/nand_testing.md
@@ -38,7 +38,7 @@
 test does not modify anything outside blocks [100, 109]:
 
 ```shell
-$ /boot/test/sys/nand-test --device /dev/misc/nand-ctl/ram-nand-0 --first-block 100 --num-blocks 10
+$ /boot/test/sys/nand-test --device /dev/sys/platform/00:00:2e/nand-ctl/ram-nand-0 --first-block 100 --num-blocks 10
 ```
 
 ## Correctness testing
@@ -47,7 +47,7 @@
 test.
 
 ```shell
-$ nand-util --device /dev/misc/nand-ctl/ram-nand-0 --check
+$ nand-util --device /dev/sys/platform/00:00:2e/nand-ctl/ram-nand-0 --check
 ```
 
 ## Inspection / manipulation
diff --git a/src/devices/block/drivers/ftl/tests/ftl_test_observer.cc b/src/devices/block/drivers/ftl/tests/ftl_test_observer.cc
index 1c39bd3..c37816d 100644
--- a/src/devices/block/drivers/ftl/tests/ftl_test_observer.cc
+++ b/src/devices/block/drivers/ftl/tests/ftl_test_observer.cc
@@ -59,7 +59,7 @@
 
   fbl::unique_fd block_device;
   zx_status_t status = devmgr_integration_test::RecursiveWaitForFile(
-      devfs_root(), "misc/nand-ctl/ram-nand-0/ftl/block", &block_device);
+      devfs_root(), "sys/platform/00:00:2e/nand-ctl/ram-nand-0/ftl/block", &block_device);
   if (status != ZX_OK) {
     printf("Unable to open device, %d\n", status);
     return status;
diff --git a/src/devices/block/drivers/ftl/tests/ftl_test_observer.h b/src/devices/block/drivers/ftl/tests/ftl_test_observer.h
index b67b3cb..c8d2249 100644
--- a/src/devices/block/drivers/ftl/tests/ftl_test_observer.h
+++ b/src/devices/block/drivers/ftl/tests/ftl_test_observer.h
@@ -7,7 +7,7 @@
 #include <zxtest/zxtest.h>
 
 // The path for the block device under test.
-constexpr char kTestDevice[] = "/fake/dev/misc/nand-ctl/ram-nand-0/ftl/block";
+constexpr char kTestDevice[] = "/fake/dev/sys/platform/00:00:2e/nand-ctl/ram-nand-0/ftl/block";
 
 // Performs process-wide setup for the integration test.
 class FtlTestObserver {
diff --git a/src/devices/nand/drivers/broker/test/nandpart-main.cc b/src/devices/nand/drivers/broker/test/nandpart-main.cc
index d5ccef5..6e31bc8 100644
--- a/src/devices/nand/drivers/broker/test/nandpart-main.cc
+++ b/src/devices/nand/drivers/broker/test/nandpart-main.cc
@@ -72,9 +72,10 @@
   }
 
   fbl::unique_fd ctl;
-  st = devmgr_integration_test::RecursiveWaitForFile(devmgr.devfs_root(), "misc/nand-ctl", &ctl);
+  st = devmgr_integration_test::RecursiveWaitForFile(devmgr.devfs_root(),
+                                                     "sys/platform/00:00:2e/nand-ctl", &ctl);
   if (st != ZX_OK) {
-    fprintf(stderr, "misc/nand-ctl failed to enumerate: %d\n", st);
+    fprintf(stderr, "sys/platform/00:00:2e/nand-ctl failed to enumerate: %d\n", st);
     return st;
   }
 
diff --git a/src/devices/nand/drivers/ram-nand/BUILD.gn b/src/devices/nand/drivers/ram-nand/BUILD.gn
index 7144b73..c7d15f7 100644
--- a/src/devices/nand/drivers/ram-nand/BUILD.gn
+++ b/src/devices/nand/drivers/ram-nand/BUILD.gn
@@ -12,10 +12,7 @@
   rules = "ram-nand.bind"
   header_output = "ram-nand-bind.h"
   tests = "bind-tests.json"
-  deps = [
-    "//src/devices/bind/fuchsia.misc",
-    "//src/devices/bind/fuchsia.platform",
-  ]
+  deps = [ "//src/devices/bind/fuchsia.platform" ]
 }
 
 driver_module("ram-nand-driver") {
diff --git a/src/devices/nand/drivers/ram-nand/bind-tests.json b/src/devices/nand/drivers/ram-nand/bind-tests.json
index abe666f..403af08 100644
--- a/src/devices/nand/drivers/ram-nand/bind-tests.json
+++ b/src/devices/nand/drivers/ram-nand/bind-tests.json
@@ -1,18 +1,11 @@
 [
-  {
-    "name": "Success",
-    "expected": "match",
-    "device": {
-      "fuchsia.BIND_PROTOCOL": "fuchsia.misc.BIND_PROTOCOL.PARENT"
-    }
-  },
-  {
-    "name": "WrongProtocol",
-    "expected": "abort",
-    "device": {
-      "fuchsia.BIND_PROTOCOL": "fuchsia.misc.BIND_PROTOCOL.DEVICE"
-    }
-  },
+    {
+        "device": {
+            "fuchsia.BIND_PROTOCOL": "fuchsia.misc.BIND_PROTOCOL.DEVICE"
+        },
+        "expected": "abort",
+        "name": "WrongProtocol"
+    },
     {
         "device": {
             "fuchsia.BIND_PLATFORM_DEV_DID": "fuchsia.platform.BIND_PLATFORM_DEV_DID.RAM_NAND",
diff --git a/src/devices/nand/drivers/ram-nand/ram-nand.bind b/src/devices/nand/drivers/ram-nand/ram-nand.bind
index a1b1e15..b8af867 100644
--- a/src/devices/nand/drivers/ram-nand/ram-nand.bind
+++ b/src/devices/nand/drivers/ram-nand/ram-nand.bind
@@ -3,12 +3,8 @@
 // found in the LICENSE file.
 
 using fuchsia.platform;
-using fuchsia.misc;
 
-if fuchsia.BIND_PROTOCOL == fuchsia.platform.BIND_PROTOCOL.DEVICE {
-  fuchsia.BIND_PLATFORM_DEV_VID == fuchsia.platform.BIND_PLATFORM_DEV_VID.GENERIC;
-  fuchsia.BIND_PLATFORM_DEV_PID == fuchsia.platform.BIND_PLATFORM_DEV_PID.GENERIC;
-  fuchsia.BIND_PLATFORM_DEV_DID == fuchsia.platform.BIND_PLATFORM_DEV_DID.RAM_NAND;
-} else {
-  fuchsia.BIND_PROTOCOL == fuchsia.misc.BIND_PROTOCOL.PARENT;
-}
+fuchsia.BIND_PROTOCOL == fuchsia.platform.BIND_PROTOCOL.DEVICE;
+fuchsia.BIND_PLATFORM_DEV_VID == fuchsia.platform.BIND_PLATFORM_DEV_VID.GENERIC;
+fuchsia.BIND_PLATFORM_DEV_PID == fuchsia.platform.BIND_PLATFORM_DEV_PID.GENERIC;
+fuchsia.BIND_PLATFORM_DEV_DID == fuchsia.platform.BIND_PLATFORM_DEV_DID.RAM_NAND;
diff --git a/src/storage/fs_test/fs_test.cc b/src/storage/fs_test/fs_test.cc
index d5daa82..3ca540f 100644
--- a/src/storage/fs_test/fs_test.cc
+++ b/src/storage/fs_test/fs_test.cc
@@ -147,10 +147,11 @@
         options.device_block_size * options.device_block_count / kPageSize / kPagesPerBlock;
   }
 
-  status = zx::make_status(wait_for_device("/dev/misc/nand-ctl", zx::sec(10).get()));
+  status =
+      zx::make_status(wait_for_device("/dev/sys/platform/00:00:2e/nand-ctl", zx::sec(10).get()));
   if (status.is_error()) {
-    std::cout << "Failed waiting for /dev/misc/nand-ctl to appear: " << status.status_string()
-              << std::endl;
+    std::cout << "Failed waiting for /dev/sys/platform/00:00:2e/nand-ctl to appear: "
+              << status.status_string() << std::endl;
     return status.take_error();
   }
 
diff --git a/src/storage/lib/paver/test/paversvc-test.cc b/src/storage/lib/paver/test/paversvc-test.cc
index 01648d6..086792d 100644
--- a/src/storage/lib/paver/test/paversvc-test.cc
+++ b/src/storage/lib/paver/test/paversvc-test.cc
@@ -299,9 +299,10 @@
   void WaitForDevices() {
     fbl::unique_fd fd;
     ASSERT_OK(RecursiveWaitForFile(device_->devfs_root(),
-                                   "misc/nand-ctl/ram-nand-0/sysconfig/skip-block", &fd));
-    ASSERT_OK(RecursiveWaitForFile(device_->devfs_root(), "misc/nand-ctl/ram-nand-0/fvm/ftl/block",
-                                   &fvm_));
+                                   "sys/platform/00:00:2e/nand-ctl/ram-nand-0/sysconfig/skip-block",
+                                   &fd));
+    ASSERT_OK(RecursiveWaitForFile(
+        device_->devfs_root(), "sys/platform/00:00:2e/nand-ctl/ram-nand-0/fvm/ftl/block", &fvm_));
   }
 
   void FindBootManager() {
diff --git a/src/storage/testing/BUILD.gn b/src/storage/testing/BUILD.gn
index df58f1a..cb39e06 100644
--- a/src/storage/testing/BUILD.gn
+++ b/src/storage/testing/BUILD.gn
@@ -26,6 +26,7 @@
   deps = [
     ":isolated-devmgr-component",
     ":storage_drivers",
+    "//src/devices/bus/drivers/platform",
   ]
 }
 
diff --git a/zircon/system/ulib/ramdevice-client/include/ramdevice-client/ramnand.h b/zircon/system/ulib/ramdevice-client/include/ramdevice-client/ramnand.h
index 52102a9..7db8d2e 100644
--- a/zircon/system/ulib/ramdevice-client/include/ramdevice-client/ramnand.h
+++ b/zircon/system/ulib/ramdevice-client/include/ramdevice-client/ramnand.h
@@ -2,19 +2,20 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#pragma once
+#ifndef RAMDEVICE_CLIENT_RAMNAND_H_
+#define RAMDEVICE_CLIENT_RAMNAND_H_
+
+#include <fuchsia/hardware/nand/c/fidl.h>
+#include <inttypes.h>
+#include <lib/driver-integration-test/fixture.h>
+#include <zircon/compiler.h>
 
 #include <memory>
 #include <optional>
 
-#include <inttypes.h>
-
 #include <fbl/ref_counted.h>
 #include <fbl/ref_ptr.h>
 #include <fbl/string.h>
-#include <fuchsia/hardware/nand/c/fidl.h>
-#include <lib/driver-integration-test/fixture.h>
-#include <zircon/compiler.h>
 
 namespace ramdevice_client {
 
@@ -40,7 +41,7 @@
 
 class RamNand {
  public:
-  static constexpr char kBasePath[] = "/dev/misc/nand-ctl";
+  static constexpr char kBasePath[] = "/dev/sys/platform/00:00:2e/nand-ctl";
 
   // Creates a ram_nand under ram_nand_ctl running under the main devmgr.
   static zx_status_t Create(const fuchsia_hardware_nand_RamNandInfo* config,
@@ -106,3 +107,5 @@
 };
 
 }  // namespace ramdevice_client
+
+#endif  // RAMDEVICE_CLIENT_RAMNAND_H_
diff --git a/zircon/system/ulib/ramdevice-client/ramnand.cc b/zircon/system/ulib/ramdevice-client/ramnand.cc
index 7d738ca..28768cb 100644
--- a/zircon/system/ulib/ramdevice-client/ramnand.cc
+++ b/zircon/system/ulib/ramdevice-client/ramnand.cc
@@ -72,7 +72,8 @@
   }
 
   fbl::unique_fd ctl;
-  st = devmgr_integration_test::RecursiveWaitForFile(devmgr.devfs_root(), "misc/nand-ctl", &ctl);
+  st = devmgr_integration_test::RecursiveWaitForFile(devmgr.devfs_root(),
+                                                     "sys/platform/00:00:2e/nand-ctl", &ctl);
   if (st != ZX_OK) {
     fprintf(stderr, "ram_nand_ctl device failed enumerated, %d\n", st);
     return st;
@@ -153,7 +154,7 @@
   // TODO(fxbug.dev/33003): We should be able to open relative to ctl->fd(), but
   // due to a bug, we have to be relative to devfs_root instead.
   fbl::StringBuffer<PATH_MAX> path;
-  path.Append("misc/nand-ctl/");
+  path.Append("sys/platform/00:00:2e/nand-ctl/");
   path.Append(name);
   fprintf(stderr, "Trying to open (%s)\n", path.c_str());