fans: Link phosphor-fan-control service for JSON vs YAML

JSON configured phosphor-fan-control only uses the non-init service to
start phosphor-fan-control at multi-user.target and poweron in case its
stopped after multi-user.target is loaded.

YAML configured phosphor-fan-control continues to use both the init and
non-init service files without changing the targets each is linked to.

Change-Id: I51a6fd9cafb72cde3dc8a0b37423dd56d1184a21
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/meta-phosphor/recipes-phosphor/fans/phosphor-fan_git.bb b/meta-phosphor/recipes-phosphor/fans/phosphor-fan_git.bb
index e13434e..708fe4d 100644
--- a/meta-phosphor/recipes-phosphor/fans/phosphor-fan_git.bb
+++ b/meta-phosphor/recipes-phosphor/fans/phosphor-fan_git.bb
@@ -84,15 +84,25 @@
 TMPL_CONTROL = "phosphor-fan-control@.service"
 INSTFMT_CONTROL = "phosphor-fan-control@{0}.service"
 FMT_CONTROL = "../${TMPL_CONTROL}:${FAN_CONTROL_TGT}.requires/${INSTFMT_CONTROL}"
+FMT_CONTROL_MUSR = "../${TMPL_CONTROL}:${MULTI_USR_TGT}.wants/${INSTFMT_CONTROL}"
+FMT_CONTROL_PWRON = "../${TMPL_CONTROL}:${POWERON_TGT}.requires/${INSTFMT_CONTROL}"
 
 TMPL_CONTROL_INIT = "phosphor-fan-control-init@.service"
 INSTFMT_CONTROL_INIT = "phosphor-fan-control-init@{0}.service"
 FMT_CONTROL_INIT = "../${TMPL_CONTROL_INIT}:${POWERON_TGT}.wants/${INSTFMT_CONTROL_INIT}"
 
 FILES_${PN}-control = "${bindir}/phosphor-fan-control"
-SYSTEMD_SERVICE_${PN}-control += "${TMPL_CONTROL} ${TMPL_CONTROL_INIT}"
-SYSTEMD_LINK_${PN}-control += "${@compose_list(d, 'FMT_CONTROL', 'OBMC_CHASSIS_INSTANCES')}"
-SYSTEMD_LINK_${PN}-control += "${@compose_list(d, 'FMT_CONTROL_INIT', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_SERVICE_${PN}-control += "${TMPL_CONTROL}"
+SYSTEMD_SERVICE_${PN}-control += "${@bb.utils.contains('PACKAGECONFIG', 'json', '', '${TMPL_CONTROL_INIT}', d)}"
+
+# JSON: Linked to multi-user and poweron
+# YAML: Linked to fans-ready and fan control-init poweron
+SYSTEMD_LINK_${PN}-control += "${@bb.utils.contains('PACKAGECONFIG', 'json', \
+        compose_list(d, 'FMT_CONTROL_MUSR', 'OBMC_CHASSIS_INSTANCES'), \
+        compose_list(d, 'FMT_CONTROL', 'OBMC_CHASSIS_INSTANCES'), d)}"
+SYSTEMD_LINK_${PN}-control += "${@bb.utils.contains('PACKAGECONFIG', 'json', \
+        compose_list(d, 'FMT_CONTROL_PWRON', 'OBMC_CHASSIS_INSTANCES'), \
+        compose_list(d, 'FMT_CONTROL_INIT', 'OBMC_CHASSIS_INSTANCES'), d)}"
 
 # --------------------------------------
 # ${PN}-monitor specific configuration