master/module.c
changeset 325 7833cf70c4f2
parent 321 64e20e6e9d0b
child 330 b984763cecc2
equal deleted inserted replaced
324:9aa51cbdbfae 325:7833cf70c4f2
   235 
   235 
   236 /**
   236 /**
   237    Prints slave states in clear text.
   237    Prints slave states in clear text.
   238 */
   238 */
   239 
   239 
   240 void ec_print_states(const uint8_t states /**< slave states */)
   240 size_t ec_state_string(uint8_t states, /**< slave states */
   241 {
   241                        char *buffer /**< target buffer (min. 25 bytes) */
       
   242                        )
       
   243 {
       
   244     off_t off = 0;
   242     unsigned int first = 1;
   245     unsigned int first = 1;
   243 
   246 
   244     if (!states) {
   247     if (!states) {
   245         printk("(unknown)");
   248         off += sprintf(buffer + off, "(unknown)");
   246         return;
   249         return off;
   247     }
   250     }
   248 
   251 
   249     if (states & EC_SLAVE_STATE_INIT) {
   252     if (states & EC_SLAVE_STATE_INIT) {
   250         printk("INIT");
   253         off += sprintf(buffer + off, "INIT");
   251         first = 0;
   254         first = 0;
   252     }
   255     }
   253     if (states & EC_SLAVE_STATE_PREOP) {
   256     if (states & EC_SLAVE_STATE_PREOP) {
   254         if (!first) printk(", ");
   257         if (!first) off += sprintf(buffer + off, ", ");
   255         printk("PREOP");
   258         off += sprintf(buffer + off, "PREOP");
   256         first = 0;
   259         first = 0;
   257     }
   260     }
   258     if (states & EC_SLAVE_STATE_SAVEOP) {
   261     if (states & EC_SLAVE_STATE_SAVEOP) {
   259         if (!first) printk(", ");
   262         if (!first) off += sprintf(buffer + off, ", ");
   260         printk("SAVEOP");
   263         off += sprintf(buffer + off, "SAVEOP");
   261         first = 0;
   264         first = 0;
   262     }
   265     }
   263     if (states & EC_SLAVE_STATE_OP) {
   266     if (states & EC_SLAVE_STATE_OP) {
   264         if (!first) printk(", ");
   267         if (!first) off += sprintf(buffer + off, ", ");
   265         printk("OP");
   268         off += sprintf(buffer + off, "OP");
   266     }
   269     }
       
   270 
       
   271     return off;
   267 }
   272 }
   268 
   273 
   269 /******************************************************************************
   274 /******************************************************************************
   270  *  Device interface
   275  *  Device interface
   271  *****************************************************************************/
   276  *****************************************************************************/
   424         goto out_release;
   429         goto out_release;
   425     }
   430     }
   426 
   431 
   427     ec_master_idle_stop(master);
   432     ec_master_idle_stop(master);
   428     ec_master_reset(master);
   433     ec_master_reset(master);
   429     master->mode = EC_MASTER_MODE_RUNNING;
   434     master->mode = EC_MASTER_MODE_OPERATION;
   430 
   435 
   431     if (!master->device->link_state) EC_WARN("Link is DOWN.\n");
   436     if (!master->device->link_state) EC_WARN("Link is DOWN.\n");
   432 
   437 
   433     if (ec_master_bus_scan(master)) {
   438     if (ec_master_bus_scan(master)) {
   434         EC_ERR("Bus scan failed!\n");
   439         EC_ERR("Bus scan failed!\n");