wspoon: Fix max31785 hwmon startup

The max31785 hwmon instance fails to start after a systemd patch was
removed to handle special characters in the device paths. This uses
`systemd-escape` to escape and unescape the device path when the udev
rule triggers the max31785 hwmon startup script.

Resolves openbmc/openbmc#3443

Change-Id: I4a504aaae0b0692e8838f66f8d7c37415e9566d0
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/70-max31785-hwmon.rules b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/70-max31785-hwmon.rules
index e1c3172..fd63e05 100755
--- a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/70-max31785-hwmon.rules
+++ b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/70-max31785-hwmon.rules
@@ -1 +1 @@
-SUBSYSTEM=="hwmon", ACTION=="add", ENV{OF_NAME}=="max31785", RUN="/bin/systemctl start max31785-hwmon-helper@%E{OF_FULLNAME}.service"
+SUBSYSTEM=="hwmon", ACTION=="add", ENV{OF_NAME}=="max31785", PROGRAM="/bin/systemd-escape -p '%E{OF_FULLNAME}'", RUN="/bin/systemctl start max31785-hwmon-helper@%c.service"
diff --git a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/max31785-hwmon-helper@.service b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/max31785-hwmon-helper@.service
index 98b5541..c7ed6f1 100644
--- a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/max31785-hwmon-helper@.service
+++ b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/max31785-hwmon-helper@.service
@@ -5,5 +5,5 @@
 
 [Service]
 Type=oneshot
-ExecStart=/usr/bin/env start_max31785_hwmon.sh %I
+ExecStart=/usr/bin/env start_max31785_hwmon.sh %i
 SyslogIdentifier=max31785-hwmon-helper
diff --git a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/start_max31785_hwmon.sh b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/start_max31785_hwmon.sh
index 6d4e6ba..5eff174 100755
--- a/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/start_max31785_hwmon.sh
+++ b/meta-witherspoon/recipes-phosphor/sensors/phosphor-hwmon/start_max31785_hwmon.sh
@@ -3,9 +3,9 @@
 # Copy in the correct MAX31785 phosphor-hwmon config file to use based on the
 # WaterCooled property, and then start the hwmon service.
 
-# $1: The OF_FULLNAME udev attribute for the MAX31785
+# $1: The escaped OF_FULLNAME udev attribute for the MAX31785
 
-base="/etc/default/obmc/hwmon/"$1
+base="/etc/default/obmc/hwmon/"$(systemd-escape -u "$1")
 target=$base".conf"
 
 service=$(mapper get-service /xyz/openbmc_project/inventory/system/chassis)
@@ -22,5 +22,5 @@
 
 cp $source $target
 
-instance=$(systemd-escape $1)
+instance='-'$1
 systemctl start xyz.openbmc_project.Hwmon@$instance.service