@@ -541,8 +541,8 @@ static int lp55xx_request_firmware(struct lp55xx_chip *chip)
541541}
542542
543543static ssize_t select_engine_show (struct device * dev ,
544- struct device_attribute * attr ,
545- char * buf )
544+ struct device_attribute * attr ,
545+ char * buf )
546546{
547547 struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
548548 struct lp55xx_chip * chip = led -> chip ;
@@ -551,8 +551,8 @@ static ssize_t select_engine_show(struct device *dev,
551551}
552552
553553static ssize_t select_engine_store (struct device * dev ,
554- struct device_attribute * attr ,
555- const char * buf , size_t len )
554+ struct device_attribute * attr ,
555+ const char * buf , size_t len )
556556{
557557 struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
558558 struct lp55xx_chip * chip = led -> chip ;
@@ -593,8 +593,8 @@ static inline void lp55xx_run_engine(struct lp55xx_chip *chip, bool start)
593593}
594594
595595static ssize_t run_engine_store (struct device * dev ,
596- struct device_attribute * attr ,
597- const char * buf , size_t len )
596+ struct device_attribute * attr ,
597+ const char * buf , size_t len )
598598{
599599 struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
600600 struct lp55xx_chip * chip = led -> chip ;
@@ -620,6 +620,77 @@ static ssize_t run_engine_store(struct device *dev,
620620static DEVICE_ATTR_RW (select_engine );
621621static DEVICE_ATTR_WO (run_engine );
622622
623+ ssize_t lp55xx_show_engine_mode (struct device * dev ,
624+ struct device_attribute * attr ,
625+ char * buf , int nr )
626+ {
627+ struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
628+ struct lp55xx_chip * chip = led -> chip ;
629+ enum lp55xx_engine_mode mode = chip -> engines [nr - 1 ].mode ;
630+
631+ switch (mode ) {
632+ case LP55XX_ENGINE_RUN :
633+ return sysfs_emit (buf , "run\n" );
634+ case LP55XX_ENGINE_LOAD :
635+ return sysfs_emit (buf , "load\n" );
636+ case LP55XX_ENGINE_DISABLED :
637+ default :
638+ return sysfs_emit (buf , "disabled\n" );
639+ }
640+ }
641+ EXPORT_SYMBOL_GPL (lp55xx_show_engine_mode );
642+
643+ ssize_t lp55xx_store_engine_mode (struct device * dev ,
644+ struct device_attribute * attr ,
645+ const char * buf , size_t len , int nr )
646+ {
647+ struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
648+ struct lp55xx_chip * chip = led -> chip ;
649+ const struct lp55xx_device_config * cfg = chip -> cfg ;
650+ struct lp55xx_engine * engine = & chip -> engines [nr - 1 ];
651+
652+ mutex_lock (& chip -> lock );
653+
654+ chip -> engine_idx = nr ;
655+
656+ if (!strncmp (buf , "run" , 3 )) {
657+ cfg -> run_engine (chip , true);
658+ engine -> mode = LP55XX_ENGINE_RUN ;
659+ } else if (!strncmp (buf , "load" , 4 )) {
660+ lp55xx_stop_engine (chip );
661+ lp55xx_load_engine (chip );
662+ engine -> mode = LP55XX_ENGINE_LOAD ;
663+ } else if (!strncmp (buf , "disabled" , 8 )) {
664+ lp55xx_stop_engine (chip );
665+ engine -> mode = LP55XX_ENGINE_DISABLED ;
666+ }
667+
668+ mutex_unlock (& chip -> lock );
669+
670+ return len ;
671+ }
672+ EXPORT_SYMBOL_GPL (lp55xx_store_engine_mode );
673+
674+ ssize_t lp55xx_store_engine_load (struct device * dev ,
675+ struct device_attribute * attr ,
676+ const char * buf , size_t len , int nr )
677+ {
678+ struct lp55xx_led * led = i2c_get_clientdata (to_i2c_client (dev ));
679+ struct lp55xx_chip * chip = led -> chip ;
680+ int ret ;
681+
682+ mutex_lock (& chip -> lock );
683+
684+ chip -> engine_idx = nr ;
685+ lp55xx_load_engine (chip );
686+ ret = lp55xx_update_program_memory (chip , buf , len );
687+
688+ mutex_unlock (& chip -> lock );
689+
690+ return ret ;
691+ }
692+ EXPORT_SYMBOL_GPL (lp55xx_store_engine_load );
693+
623694static struct attribute * lp55xx_engine_attributes [] = {
624695 & dev_attr_select_engine .attr ,
625696 & dev_attr_run_engine .attr ,
0 commit comments