2424#include <linux/slab.h>
2525#include <linux/spinlock.h>
2626#include <linux/string.h>
27+ #include <linux/string_choices.h>
2728#include <linux/types.h>
2829#include <linux/usb.h>
2930#include <linux/usb/typec.h>
@@ -733,7 +734,7 @@ static int tcpm_set_vconn(struct tcpc_dev *dev, bool on)
733734
734735 mutex_lock (& chip -> lock );
735736 if (chip -> vconn_on == on ) {
736- fusb302_log (chip , "vconn is already %s" , on ? "On" : "Off" );
737+ fusb302_log (chip , "vconn is already %s" , str_on_off ( on ) );
737738 goto done ;
738739 }
739740 if (on ) {
@@ -746,7 +747,7 @@ static int tcpm_set_vconn(struct tcpc_dev *dev, bool on)
746747 if (ret < 0 )
747748 goto done ;
748749 chip -> vconn_on = on ;
749- fusb302_log (chip , "vconn := %s" , on ? "On" : "Off" );
750+ fusb302_log (chip , "vconn := %s" , str_on_off ( on ) );
750751done :
751752 mutex_unlock (& chip -> lock );
752753
@@ -761,23 +762,22 @@ static int tcpm_set_vbus(struct tcpc_dev *dev, bool on, bool charge)
761762
762763 mutex_lock (& chip -> lock );
763764 if (chip -> vbus_on == on ) {
764- fusb302_log (chip , "vbus is already %s" , on ? "On" : "Off" );
765+ fusb302_log (chip , "vbus is already %s" , str_on_off ( on ) );
765766 } else {
766767 if (on )
767768 ret = regulator_enable (chip -> vbus );
768769 else
769770 ret = regulator_disable (chip -> vbus );
770771 if (ret < 0 ) {
771772 fusb302_log (chip , "cannot %s vbus regulator, ret=%d" ,
772- on ? "enable" : "disable" , ret );
773+ str_enable_disable ( on ) , ret );
773774 goto done ;
774775 }
775776 chip -> vbus_on = on ;
776- fusb302_log (chip , "vbus := %s" , on ? "On" : "Off" );
777+ fusb302_log (chip , "vbus := %s" , str_on_off ( on ) );
777778 }
778779 if (chip -> charge_on == charge )
779- fusb302_log (chip , "charge is already %s" ,
780- charge ? "On" : "Off" );
780+ fusb302_log (chip , "charge is already %s" , str_on_off (charge ));
781781 else
782782 chip -> charge_on = charge ;
783783
@@ -854,16 +854,16 @@ static int tcpm_set_pd_rx(struct tcpc_dev *dev, bool on)
854854 ret = fusb302_pd_set_auto_goodcrc (chip , on );
855855 if (ret < 0 ) {
856856 fusb302_log (chip , "cannot turn %s auto GCRC, ret=%d" ,
857- on ? "on" : "off" , ret );
857+ str_on_off ( on ) , ret );
858858 goto done ;
859859 }
860860 ret = fusb302_pd_set_interrupts (chip , on );
861861 if (ret < 0 ) {
862862 fusb302_log (chip , "cannot turn %s pd interrupts, ret=%d" ,
863- on ? "on" : "off" , ret );
863+ str_on_off ( on ) , ret );
864864 goto done ;
865865 }
866- fusb302_log (chip , "pd := %s" , on ? "on" : "off" );
866+ fusb302_log (chip , "pd := %s" , str_on_off ( on ) );
867867done :
868868 mutex_unlock (& chip -> lock );
869869
@@ -1531,7 +1531,7 @@ static void fusb302_irq_work(struct work_struct *work)
15311531 if (interrupt & FUSB_REG_INTERRUPT_VBUSOK ) {
15321532 vbus_present = !!(status0 & FUSB_REG_STATUS0_VBUSOK );
15331533 fusb302_log (chip , "IRQ: VBUS_OK, vbus=%s" ,
1534- vbus_present ? "On" : "Off" );
1534+ str_on_off ( vbus_present ) );
15351535 if (vbus_present != chip -> vbus_present ) {
15361536 chip -> vbus_present = vbus_present ;
15371537 tcpm_vbus_change (chip -> tcpm_port );
@@ -1562,7 +1562,7 @@ static void fusb302_irq_work(struct work_struct *work)
15621562 if ((interrupt & FUSB_REG_INTERRUPT_COMP_CHNG ) && intr_comp_chng ) {
15631563 comp_result = !!(status0 & FUSB_REG_STATUS0_COMP );
15641564 fusb302_log (chip , "IRQ: COMP_CHNG, comp=%s" ,
1565- comp_result ? "true" : "false" );
1565+ str_true_false ( comp_result ) );
15661566 if (comp_result ) {
15671567 /* cc level > Rd_threshold, detach */
15681568 chip -> cc1 = TYPEC_CC_OPEN ;
0 commit comments