Commit 5b72ae9a authored by Prabhakar Lad's avatar Prabhakar Lad Committed by Tomi Valkeinen

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: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent 4d073292
...@@ -303,7 +303,10 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) ...@@ -303,7 +303,10 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
/* Set initial contrast */ /* Set initial contrast */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST);
ret = ret & ssd1307fb_write_cmd(par->client, 0x7f); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x7f);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -319,62 +322,98 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) ...@@ -319,62 +322,98 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par)
/* Set multiplex ratio value */ /* Set multiplex ratio value */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO);
ret = ret & ssd1307fb_write_cmd(par->client, par->height - 1); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, par->height - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* set display offset value */ /* set display offset value */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET);
if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x20); ret = ssd1307fb_write_cmd(par->client, 0x20);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Set clock frequency */ /* Set clock frequency */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ);
ret = ret & ssd1307fb_write_cmd(par->client, 0xf0); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0xf0);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Set precharge period in number of ticks from the internal clock */ /* Set precharge period in number of ticks from the internal clock */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD);
ret = ret & ssd1307fb_write_cmd(par->client, 0x22); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x22);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Set COM pins configuration */ /* Set COM pins configuration */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG);
ret = ret & ssd1307fb_write_cmd(par->client, 0x22); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x22);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Set VCOMH */ /* Set VCOMH */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH);
ret = ret & ssd1307fb_write_cmd(par->client, 0x49); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x49);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Turn on the DC-DC Charge Pump */ /* Turn on the DC-DC Charge Pump */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
ret = ret & ssd1307fb_write_cmd(par->client, 0x14); if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, 0x14);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Switch to horizontal addressing mode */ /* Switch to horizontal addressing mode */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE);
ret = ret & ssd1307fb_write_cmd(par->client, if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client,
SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
ret = ret & ssd1307fb_write_cmd(par->client, 0x0); if (ret < 0)
ret = ret & ssd1307fb_write_cmd(par->client, par->width - 1); return ret;
ret = ssd1307fb_write_cmd(par->client, 0x0);
if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client, par->width - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
ret = ret & ssd1307fb_write_cmd(par->client, 0x0); if (ret < 0)
ret = ret & ssd1307fb_write_cmd(par->client, return ret;
ret = ssd1307fb_write_cmd(par->client, 0x0);
if (ret < 0)
return ret;
ret = ssd1307fb_write_cmd(par->client,
par->page_offset + (par->height / 8) - 1); par->page_offset + (par->height / 8) - 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment