diff options
author | Prabhakar Lad <prabhakar.csengg@gmail.com> | 2015-01-15 14:05:37 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-01-30 02:40:00 -0500 |
commit | 5b72ae9a901cbfbe632570f278486142b037fe51 (patch) | |
tree | 34724583354de89a4e44e7cbd3fcda47ec7301b8 /drivers/video | |
parent | 4d073292a74b31ea00443d7778a95c209140aa42 (diff) |
fbdev: ssd1307fb: return proper error code if write command fails
this patch fixes ssd1307fb_ssd1306_init() function to return
proper error codes in case of failures.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/ssd1307fb.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 3d6611f1958f..f7ed6d9016f7 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c | |||
@@ -303,7 +303,10 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) | |||
303 | 303 | ||
304 | /* Set initial contrast */ | 304 | /* Set initial contrast */ |
305 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); | 305 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); |
306 | ret = ret & ssd1307fb_write_cmd(par->client, 0x7f); | 306 | if (ret < 0) |
307 | return ret; | ||
308 | |||
309 | ret = ssd1307fb_write_cmd(par->client, 0x7f); | ||
307 | if (ret < 0) | 310 | if (ret < 0) |
308 | return ret; | 311 | return ret; |
309 | 312 | ||
@@ -319,63 +322,99 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) | |||
319 | 322 | ||
320 | /* Set multiplex ratio value */ | 323 | /* Set multiplex ratio value */ |
321 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); | 324 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); |
322 | ret = ret & ssd1307fb_write_cmd(par->client, par->height - 1); | 325 | if (ret < 0) |
326 | return ret; | ||
327 | |||
328 | ret = ssd1307fb_write_cmd(par->client, par->height - 1); | ||
323 | if (ret < 0) | 329 | if (ret < 0) |
324 | return ret; | 330 | return ret; |
325 | 331 | ||
326 | /* set display offset value */ | 332 | /* set display offset value */ |
327 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); | 333 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); |
334 | if (ret < 0) | ||
335 | return ret; | ||
336 | |||
328 | ret = ssd1307fb_write_cmd(par->client, 0x20); | 337 | ret = ssd1307fb_write_cmd(par->client, 0x20); |
329 | if (ret < 0) | 338 | if (ret < 0) |
330 | return ret; | 339 | return ret; |
331 | 340 | ||
332 | /* Set clock frequency */ | 341 | /* Set clock frequency */ |
333 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); | 342 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); |
334 | ret = ret & ssd1307fb_write_cmd(par->client, 0xf0); | 343 | if (ret < 0) |
344 | return ret; | ||
345 | |||
346 | ret = ssd1307fb_write_cmd(par->client, 0xf0); | ||
335 | if (ret < 0) | 347 | if (ret < 0) |
336 | return ret; | 348 | return ret; |
337 | 349 | ||
338 | /* Set precharge period in number of ticks from the internal clock */ | 350 | /* Set precharge period in number of ticks from the internal clock */ |
339 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); | 351 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); |
340 | ret = ret & ssd1307fb_write_cmd(par->client, 0x22); | 352 | if (ret < 0) |
353 | return ret; | ||
354 | |||
355 | ret = ssd1307fb_write_cmd(par->client, 0x22); | ||
341 | if (ret < 0) | 356 | if (ret < 0) |
342 | return ret; | 357 | return ret; |
343 | 358 | ||
344 | /* Set COM pins configuration */ | 359 | /* Set COM pins configuration */ |
345 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); | 360 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); |
346 | ret = ret & ssd1307fb_write_cmd(par->client, 0x22); | 361 | if (ret < 0) |
362 | return ret; | ||
363 | |||
364 | ret = ssd1307fb_write_cmd(par->client, 0x22); | ||
347 | if (ret < 0) | 365 | if (ret < 0) |
348 | return ret; | 366 | return ret; |
349 | 367 | ||
350 | /* Set VCOMH */ | 368 | /* Set VCOMH */ |
351 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); | 369 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); |
352 | ret = ret & ssd1307fb_write_cmd(par->client, 0x49); | 370 | if (ret < 0) |
371 | return ret; | ||
372 | |||
373 | ret = ssd1307fb_write_cmd(par->client, 0x49); | ||
353 | if (ret < 0) | 374 | if (ret < 0) |
354 | return ret; | 375 | return ret; |
355 | 376 | ||
356 | /* Turn on the DC-DC Charge Pump */ | 377 | /* Turn on the DC-DC Charge Pump */ |
357 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); | 378 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); |
358 | ret = ret & ssd1307fb_write_cmd(par->client, 0x14); | 379 | if (ret < 0) |
380 | return ret; | ||
381 | |||
382 | ret = ssd1307fb_write_cmd(par->client, 0x14); | ||
359 | if (ret < 0) | 383 | if (ret < 0) |
360 | return ret; | 384 | return ret; |
361 | 385 | ||
362 | /* Switch to horizontal addressing mode */ | 386 | /* Switch to horizontal addressing mode */ |
363 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); | 387 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); |
364 | ret = ret & ssd1307fb_write_cmd(par->client, | 388 | if (ret < 0) |
365 | SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); | 389 | return ret; |
390 | |||
391 | ret = ssd1307fb_write_cmd(par->client, | ||
392 | SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); | ||
366 | if (ret < 0) | 393 | if (ret < 0) |
367 | return ret; | 394 | return ret; |
368 | 395 | ||
369 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); | 396 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); |
370 | ret = ret & ssd1307fb_write_cmd(par->client, 0x0); | 397 | if (ret < 0) |
371 | ret = ret & ssd1307fb_write_cmd(par->client, par->width - 1); | 398 | return ret; |
399 | |||
400 | ret = ssd1307fb_write_cmd(par->client, 0x0); | ||
401 | if (ret < 0) | ||
402 | return ret; | ||
403 | |||
404 | ret = ssd1307fb_write_cmd(par->client, par->width - 1); | ||
372 | if (ret < 0) | 405 | if (ret < 0) |
373 | return ret; | 406 | return ret; |
374 | 407 | ||
375 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); | 408 | ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); |
376 | ret = ret & ssd1307fb_write_cmd(par->client, 0x0); | 409 | if (ret < 0) |
377 | ret = ret & ssd1307fb_write_cmd(par->client, | 410 | return ret; |
378 | par->page_offset + (par->height / 8) - 1); | 411 | |
412 | ret = ssd1307fb_write_cmd(par->client, 0x0); | ||
413 | if (ret < 0) | ||
414 | return ret; | ||
415 | |||
416 | ret = ssd1307fb_write_cmd(par->client, | ||
417 | par->page_offset + (par->height / 8) - 1); | ||
379 | if (ret < 0) | 418 | if (ret < 0) |
380 | return ret; | 419 | return ret; |
381 | 420 | ||