Add option to override of_node to use devpath
Allow us to force phosphor-hwmon to use the devpath to detect even if
the of_name exists. Some system may not be setup properly to have the
hwmon setup matching what we needed. This allow us to have the
flexibility to override some config if we are not able to fix it on the
driver side.
The linux change in
https://github.com/torvalds/linux/commit/2315332efcbe7124252f080e03b57d3d2f1f4771
create the of_node to the device's ancestor instead of having it
missing. This forces multiple devices to be linked to the same node.
This required a single config to support multiple different type of
devices.
This change allow us to avoid that if it is not feasible to fix the
issue on the driver side.
Tested:
Override the devices with devpath only and didn't break other devices.
```
meson build -Doverride-with-devpath=nodeA,nodeB
```
with this if the `of_fullname` has a filename ended with nodeA or
nodeB, then it will not use the `of_fullname` and use the devpath
instead.
Change-Id: I76d05f0cf2aa8de3b7efadea8eb513f4708f049b
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/meson.build b/meson.build
index c9c4970..7a1b810 100644
--- a/meson.build
+++ b/meson.build
@@ -116,10 +116,13 @@
install_dir: udev_dir / 'rules.d'
)
-install_data(
- 'start_hwmon.sh',
+configure_file(
+ input : 'start_hwmon.sh.in',
+ output : 'start_hwmon.sh',
+ configuration: {'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath'))},
install_dir: get_option('bindir'),
- install_mode: 'rwxr-xr-x'
+ install_mode: 'rwxr-xr-x',
+ install: true,
)
subdir('msl')
diff --git a/meson_options.txt b/meson_options.txt
index ccf3f90..5aa5729 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -25,3 +25,10 @@
value: false,
description: 'Include building and installing the MAX31785 chip\'s minimum ship level checking application.'
)
+
+
+option(
+ 'override-with-devpath',
+ type: 'array',
+ description: 'Only use the devpath of the device even if OFPath exists'
+)
diff --git a/start_hwmon.sh b/start_hwmon.sh
deleted file mode 100755
index 2e346d0..0000000
--- a/start_hwmon.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-action=$1
-devpath=$2
-of_fullname=$3
-
-#Use of_fullname if it's there, otherwise use devpath.
-
-path=$of_fullname
-if [ -z "$path" ]
-then
- path=$devpath
-
- if [[ "$path" =~ (.*)/hwmon/hwmon[0-9]+$ ]];
- then
- path=${BASH_REMATCH[1]}
- fi
-fi
-
-# Needed to re-do escaping used to avoid bitbake separator conflicts
-path="${path//:/--}"
-# Needed to escape prior to being used as a unit argument
-path="$(systemd-escape "$path")"
-systemctl --no-block "$action" "xyz.openbmc_project.Hwmon@$path.service"
diff --git a/start_hwmon.sh.in b/start_hwmon.sh.in
new file mode 100755
index 0000000..c14a7da
--- /dev/null
+++ b/start_hwmon.sh.in
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+action=$1
+devpath=$2
+of_fullname=$3
+
+#Use of_fullname if it's there, otherwise use devpath.
+function use_devpath(){
+ path=$devpath
+
+ if [[ "$path" =~ (.*)/hwmon/hwmon[0-9]+$ ]];
+ then
+ path=${BASH_REMATCH[1]}
+ fi
+ echo "${path}"
+}
+
+path=$of_fullname
+if [ -z "${path}" ]
+then
+ path="$(use_devpath)"
+else
+ override_with_devpath=(@OVERRIDE_WITH_DEVPATH@)
+ if [[ "$path" =~ .*/(.*)$ ]];
+ then
+ of_name="${BASH_REMATCH[1]}"
+ for i in ${!override_with_devpath[@]}; do
+ if [[ "${override_with_devpath[$i]}" == "${of_name}" ]];
+ then
+ path="$(use_devpath)"
+ break
+ fi
+ done
+ fi
+fi
+
+# Needed to re-do escaping used to avoid bitbake separator conflicts
+path="${path//:/--}"
+# Needed to escape prior to being used as a unit argument
+path="$(systemd-escape "$path")"
+systemctl --no-block "$action" "xyz.openbmc_project.Hwmon@$path.service"