Revision e69f0602

b/hw/lm832x.c
25 25

  
26 26
typedef struct {
27 27
    i2c_slave i2c;
28
    int i2c_dir;
29
    int i2c_cycle;
30
    int reg;
28
    uint8_t i2c_dir;
29
    uint8_t i2c_cycle;
30
    uint8_t reg;
31 31

  
32 32
    qemu_irq nirq;
33 33
    uint16_t model;
......
54 54
    struct {
55 55
        uint8_t dbnctime;
56 56
        uint8_t size;
57
        int start;
58
        int len;
57
        uint8_t start;
58
        uint8_t len;
59 59
        uint8_t fifo[16];
60 60
    } kbd;
61 61

  
......
152 152
    LM832x_CMD_PWM_WRITE	= 0x95, /* Write PWM script. */
153 153
    LM832x_CMD_PWM_START	= 0x96, /* Start PWM engine. */
154 154
    LM832x_CMD_PWM_STOP		= 0x97, /* Stop PWM engine. */
155
    LM832x_GENERAL_ERROR	= 0xff, /* There was one error.
156
                                           Previously was represented by -1
157
                                           This is not a command */
155 158
};
156 159

  
157 160
#define LM832x_MAX_KPX		8
......
257 260
        lm_kbd_irq_update(s);
258 261
        s->kbd.len = 0;
259 262
        s->kbd.start = 0;
260
        s->reg = -1;
263
        s->reg = LM832x_GENERAL_ERROR;
261 264
        break;
262 265

  
263 266
    case LM832x_CMD_RESET:
......
265 268
            lm_kbd_reset(s);
266 269
        else
267 270
            lm_kbd_error(s, ERR_BADPAR);
268
        s->reg = -1;
271
        s->reg = LM832x_GENERAL_ERROR;
269 272
        break;
270 273

  
271 274
    case LM823x_CMD_WRITE_PULL_DOWN:
......
274 277
        else {
275 278
            s->gpio.pull |= value << 8;
276 279
            lm_kbd_gpio_update(s);
277
            s->reg = -1;
280
            s->reg = LM832x_GENERAL_ERROR;
278 281
        }
279 282
        break;
280 283
    case LM832x_CMD_WRITE_PORT_SEL:
......
283 286
        else {
284 287
            s->gpio.dir |= value << 8;
285 288
            lm_kbd_gpio_update(s);
286
            s->reg = -1;
289
            s->reg = LM832x_GENERAL_ERROR;
287 290
        }
288 291
        break;
289 292
    case LM832x_CMD_WRITE_PORT_STATE:
......
292 295
        else {
293 296
            s->gpio.mask |= value << 8;
294 297
            lm_kbd_gpio_update(s);
295
            s->reg = -1;
298
            s->reg = LM832x_GENERAL_ERROR;
296 299
        }
297 300
        break;
298 301

  
299 302
    case LM832x_CMD_SET_ACTIVE:
300 303
        s->acttime = value;
301
        s->reg = -1;
304
        s->reg = LM832x_GENERAL_ERROR;
302 305
        break;
303 306

  
304 307
    case LM832x_CMD_SET_DEBOUNCE:
305 308
        s->kbd.dbnctime = value;
306
        s->reg = -1;
309
        s->reg = LM832x_GENERAL_ERROR;
307 310
        if (!value)
308 311
            lm_kbd_error(s, ERR_BADPAR);
309 312
        break;
310 313

  
311 314
    case LM832x_CMD_SET_KEY_SIZE:
312 315
        s->kbd.size = value;
313
        s->reg = -1;
316
        s->reg = LM832x_GENERAL_ERROR;
314 317
        if (
315 318
                        (value & 0xf) < 3 || (value & 0xf) > LM832x_MAX_KPY ||
316 319
                        (value >> 4) < 3 || (value >> 4) > LM832x_MAX_KPX)
......
319 322

  
320 323
    case LM832x_CMD_WRITE_CLOCK:
321 324
        s->clock = value;
322
        s->reg = -1;
325
        s->reg = LM832x_GENERAL_ERROR;
323 326
        if ((value & 3) && (value & 3) != 3) {
324 327
            lm_kbd_error(s, ERR_BADPAR);
325 328
            fprintf(stderr, "%s: invalid clock setting in RCPWM\n",
......
332 335
        if (byte == 0) {
333 336
            if (!(value & 3) || (value >> 2) > 59) {
334 337
                lm_kbd_error(s, ERR_BADPAR);
335
                s->reg = -1;
338
                s->reg = LM832x_GENERAL_ERROR;
336 339
                break;
337 340
            }
338 341

  
......
342 345
            s->pwm.file[s->pwm.faddr] |= value << 8;
343 346
        } else if (byte == 2) {
344 347
            s->pwm.file[s->pwm.faddr] |= value << 0;
345
            s->reg = -1;
348
            s->reg = LM832x_GENERAL_ERROR;
346 349
        }
347 350
        break;
348 351
    case LM832x_CMD_PWM_START:
349
        s->reg = -1;
352
        s->reg = LM832x_GENERAL_ERROR;
350 353
        if (!(value & 3) || (value >> 2) > 59) {
351 354
            lm_kbd_error(s, ERR_BADPAR);
352 355
            break;
......
356 359
        lm_kbd_pwm_start(s, (value & 3) - 1);
357 360
        break;
358 361
    case LM832x_CMD_PWM_STOP:
359
        s->reg = -1;
362
        s->reg = LM832x_GENERAL_ERROR;
360 363
        if (!(value & 3)) {
361 364
            lm_kbd_error(s, ERR_BADPAR);
362 365
            break;
......
365 368
        qemu_del_timer(s->pwm.tm[(value & 3) - 1]);
366 369
        break;
367 370

  
368
    case -1:
371
    case LM832x_GENERAL_ERROR:
369 372
        lm_kbd_error(s, ERR_BADPAR);
370 373
        break;
371 374
    default:

Also available in: Unified diff