int ret;
        u8 buf;
 
-       ret = lp5523_write(client, LP5523_REG_ENABLE, 0x40);
+       ret = lp5523_write(client, LP5523_REG_ENABLE, LP5523_ENABLE);
        if (ret)
                return ret;
        ret = lp5523_read(client, LP5523_REG_ENABLE, &buf);
 {
        int i;
        u16 tmp_mux = 0;
-       len = len < LP5523_LEDS ? len : LP5523_LEDS;
+
+       len = min_t(int, len, LP5523_LEDS);
        for (i = 0; i < len; i++) {
                switch (buf[i]) {
                case '1':
        unsigned cmd;
        u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
 
+       if (engine->mode != LP5523_CMD_LOAD)
+               return -EINVAL;
+
        while ((offset < len - 1) && (i < LP5523_PROGRAM_LENGTH)) {
                /* separate sscanfs because length is working only for %s */
                ret = sscanf(buf + offset, "%2s%n ", c, &nrchars);
                goto fail;
 
        mutex_lock(&chip->lock);
-
-       if (engine->mode == LP5523_CMD_LOAD)
-               ret = lp5523_load_program(engine, pattern);
-       else
-               ret = -EINVAL;
-
+       ret = lp5523_load_program(engine, pattern);
        mutex_unlock(&chip->lock);
 
        if (ret) {