[composite_sample] Add README instructions.

Clean up sample imports, add comment and README instructions.

Change-Id: I5d8d4f558a6a939eb56bf877bc1f50cadeb9e423
Reviewed-on: https://fuchsia-review.googlesource.com/c/sdk-samples/drivers/+/712383
Reviewed-by: Sarah Chan <spqchan@google.com>
Reviewed-by: Suraj Malhotra <surajmalhotra@google.com>
Commit-Queue: Dave Smith <smithdave@google.com>
diff --git a/src/composite_sample/BUILD.bazel b/src/composite_sample/BUILD.bazel
index a285da3..c05f67d 100644
--- a/src/composite_sample/BUILD.bazel
+++ b/src/composite_sample/BUILD.bazel
@@ -40,6 +40,9 @@
 fuchsia_component_manifest(
     name = "manifest",
     src = "meta/composite_sample.cml",
+    includes = [
+        "@fuchsia_sdk//pkg/syslog:client",
+    ],
 )
 
 fuchsia_driver_component(
diff --git a/src/composite_sample/README.md b/src/composite_sample/README.md
new file mode 100644
index 0000000..6d25f68
--- /dev/null
+++ b/src/composite_sample/README.md
@@ -0,0 +1,36 @@
+# Composite Device Sample
+
+This sample project contains a Fuchsia driver for a composite device node. The driver binds with
+multiple parent device nodes described using ACPI.
+
+## Building
+
+To build the `composite_sample` driver and related components, run the following command:
+
+```
+tools/bazel build --config=fuchsia_x64 //src/composite_device:pkg
+```
+
+## Running
+
+Use the following commands to load the driver component on a target device:
+
+1.  Load the `composite_sample` driver component:
+
+    ```
+    tools/bazel run --config=fuchsia_x64 //src/composite_sample:pkg.component
+    ```
+
+1.  Open the device log viewer:
+
+    ```
+    tools/ffx log --filter composite_sample
+    ```
+
+You should see the driver component print the topological path of each parent device node
+after the driver has successfully bound:
+
+```
+[composite-sample,driver][I]: [composite_sample.cc:69] Topological path  path=sys/platform/platform-passthrough/acpi/acpi-_SB_/acpi-GFBY/acpi-GFBY-passthrough
+[composite-sample,driver][I]: [composite_sample.cc:69] Topological path  path=sys/platform/platform-passthrough/acpi/acpi-_SB_/acpi-GFRT/acpi-GFRT-passthrough
+```
diff --git a/src/composite_sample/composite_sample.bind b/src/composite_sample/composite_sample.bind
index 241a2ad..1ae1d05 100644
--- a/src/composite_sample/composite_sample.bind
+++ b/src/composite_sample/composite_sample.bind
@@ -6,6 +6,8 @@
 
 using fuchsia.acpi;
 
+// Bind to an unused ACPI node in Qemu or Atlas.
+// TODO(fxb/100716): Bind to a test node once it's available.
 primary node "acpi-GFBY" {
     if fuchsia.acpi.hid == "GFSH0001" {
         true;
diff --git a/src/composite_sample/composite_sample.cc b/src/composite_sample/composite_sample.cc
index b2c74b1..26a0dff 100644
--- a/src/composite_sample/composite_sample.cc
+++ b/src/composite_sample/composite_sample.cc
@@ -2,13 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "src/composite_sample/composite_sample.h"
+#include "composite_sample.h"
 
 #include <fidl/fuchsia.driver.compat/cpp/wire.h>
 #include <lib/driver2/record_cpp.h>
 
-namespace fio = fuchsia_io;
-
 namespace composite_sample {
 
 // static
@@ -27,7 +25,7 @@
 }
 
 zx::status<> CompositeSampleDriver::Run(async_dispatcher *dispatcher,
-                                        fidl::ServerEnd<fio::Directory> outgoing_dir) {
+                                        fidl::ServerEnd<fuchsia_io::Directory> outgoing_dir) {
   auto result = PrintTopologicalPath("acpi-GFBY");
   if (result.is_error()) {
     FDF_SLOG(ERROR, "Failed to print topological path for \"acpi-GFBY\"",
@@ -45,8 +43,9 @@
   return outgoing_.Serve(std::move(outgoing_dir));
 }
 
+// Print the topological path for a given parent device node.
 zx::status<> CompositeSampleDriver::PrintTopologicalPath(std::string_view name) {
-  // Connect to parent.
+  // Connect to the parent device node.
   auto result = ns_.OpenService<fuchsia_driver_compat::Service>(name);
   if (result.is_error()) {
     FDF_SLOG(ERROR, "Failed to open service", KV("status", result.status_string()));
@@ -59,7 +58,8 @@
     return parent.take_error();
   }
 
-  auto path_result = fidl::WireCall(*parent)->GetTopologicalPath();
+  // Retrieve the path of the device node from the `fuchsia.driver.compat` service
+  auto path_result = fidl::WireCall<fuchsia_driver_compat::Device>(*parent)->GetTopologicalPath();
   if (!path_result.ok()) {
     FDF_SLOG(ERROR, "Failed to get topological path", KV("status", result.status_string()));
     return zx::error(path_result.status());
diff --git a/src/composite_sample/meta/composite_sample.cml b/src/composite_sample/meta/composite_sample.cml
index 9d34ab4..3127b3f 100644
--- a/src/composite_sample/meta/composite_sample.cml
+++ b/src/composite_sample/meta/composite_sample.cml
@@ -1,15 +1,16 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
 {
+    include: [
+        'syslog/client.shard.cml',
+    ],
     program: {
         runner: 'driver',
         binary: 'lib/libcomposite_sample.so',
         bind: 'meta/bind/composite_sample.bindbc'
     },
     use: [
-        {
-            protocol: [
-              'fuchsia.logger.LogSink',
-            ],
-        },
-        { service: "fuchsia.driver.compat.Service" },
+        { service: 'fuchsia.driver.compat.Service' },
     ],
 }