scripts/dev-needs: Add script to list device dependencies
authorSaravana Kannan <saravanak@google.com>
Tue, 1 Sep 2020 22:48:42 +0000 (15:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Sep 2020 16:19:37 +0000 (18:19 +0200)
commit51fae39bd5018e4f6d3e65a1a1a8ad40b5ee3662
tree3c1ab93e50871b5cad6d54c538ac3a04fb8f7cd8
parentd012a7190fc1fd72ed48911e77ca97ba4521bccd
scripts/dev-needs: Add script to list device dependencies

This script can be useful for:
- Figuring out the list of modules you need to pack in initrd
- Figuring out the list of drivers you need to modularize for a device
  to be fully functional without building in any dependencies.
- Figuring out which drivers to enable first, when porting drivers
  between kernels (say, to upstream).
- Plotting graphs of system dependencies, etc.

Usage: dev-needs.sh [-c|-d|-m|-f] [filter options] <list of devices>

This script needs to be run on the target device once it has booted to a
shell.

The script takes as input a list of one or more device directories under
/sys/devices and then lists the probe dependency chain (suppliers and
parents) of these devices. It does a breadth first search of the dependency
chain, so the last entry in the output is close to the root of the
dependency chain.

By default it lists the full path to the devices under /sys/devices.

It also takes an optional modifier flag as the first parameter to change
what information is listed in the output. If the requested information is
not available, the device name is printed.

  -c lists the compatible string of the dependencies
  -d lists the driver name of the dependencies that have probed
  -m lists the module name of the dependencies that have a module
  -f list the firmware node path of the dependencies
  -g list the dependencies as edges and nodes for graphviz
  -t list the dependencies as edges for tsort

The filter options provide a way to filter out some dependencies:
  --allow-no-driver By default dependencies that don't have a driver
attached are ignored. This is to avoid following
device links to "class" devices that are created
when the consumer probes (as in, not a probe
dependency). If you want to follow these links
anyway, use this flag.

  --exclude-devlinks Don't follow device links when tracking probe
dependencies.

  --exclude-parents Don't follow parent devices when tracking probe
dependencies.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20200901224842.1787825-1-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
MAINTAINERS
scripts/dev-needs.sh [new file with mode: 0755]