Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Prabhakar Lad and committed by
Tomi Valkeinen
5b72ae9a 4d073292

+53 -14
+53 -14
drivers/video/fbdev/ssd1307fb.c
··· 303 303 304 304 /* Set initial contrast */ 305 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 310 if (ret < 0) 308 311 return ret; 309 312 ··· 322 319 323 320 /* Set multiplex ratio value */ 324 321 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); 325 - ret = ret & ssd1307fb_write_cmd(par->client, par->height - 1); 322 + if (ret < 0) 323 + return ret; 324 + 325 + ret = ssd1307fb_write_cmd(par->client, par->height - 1); 326 326 if (ret < 0) 327 327 return ret; 328 328 329 329 /* set display offset value */ 330 330 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); 331 + if (ret < 0) 332 + return ret; 333 + 331 334 ret = ssd1307fb_write_cmd(par->client, 0x20); 332 335 if (ret < 0) 333 336 return ret; 334 337 335 338 /* Set clock frequency */ 336 339 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); 337 - ret = ret & ssd1307fb_write_cmd(par->client, 0xf0); 340 + if (ret < 0) 341 + return ret; 342 + 343 + ret = ssd1307fb_write_cmd(par->client, 0xf0); 338 344 if (ret < 0) 339 345 return ret; 340 346 341 347 /* Set precharge period in number of ticks from the internal clock */ 342 348 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); 343 - ret = ret & ssd1307fb_write_cmd(par->client, 0x22); 349 + if (ret < 0) 350 + return ret; 351 + 352 + ret = ssd1307fb_write_cmd(par->client, 0x22); 344 353 if (ret < 0) 345 354 return ret; 346 355 347 356 /* Set COM pins configuration */ 348 357 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); 349 - ret = ret & ssd1307fb_write_cmd(par->client, 0x22); 358 + if (ret < 0) 359 + return ret; 360 + 361 + ret = ssd1307fb_write_cmd(par->client, 0x22); 350 362 if (ret < 0) 351 363 return ret; 352 364 353 365 /* Set VCOMH */ 354 366 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); 355 - ret = ret & ssd1307fb_write_cmd(par->client, 0x49); 367 + if (ret < 0) 368 + return ret; 369 + 370 + ret = ssd1307fb_write_cmd(par->client, 0x49); 356 371 if (ret < 0) 357 372 return ret; 358 373 359 374 /* Turn on the DC-DC Charge Pump */ 360 375 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); 361 - ret = ret & ssd1307fb_write_cmd(par->client, 0x14); 376 + if (ret < 0) 377 + return ret; 378 + 379 + ret = ssd1307fb_write_cmd(par->client, 0x14); 362 380 if (ret < 0) 363 381 return ret; 364 382 365 383 /* Switch to horizontal addressing mode */ 366 384 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); 367 - ret = ret & ssd1307fb_write_cmd(par->client, 368 - SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); 385 + if (ret < 0) 386 + return ret; 387 + 388 + ret = ssd1307fb_write_cmd(par->client, 389 + SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); 369 390 if (ret < 0) 370 391 return ret; 371 392 372 393 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); 373 - ret = ret & ssd1307fb_write_cmd(par->client, 0x0); 374 - ret = ret & ssd1307fb_write_cmd(par->client, par->width - 1); 394 + if (ret < 0) 395 + return ret; 396 + 397 + ret = ssd1307fb_write_cmd(par->client, 0x0); 398 + if (ret < 0) 399 + return ret; 400 + 401 + ret = ssd1307fb_write_cmd(par->client, par->width - 1); 375 402 if (ret < 0) 376 403 return ret; 377 404 378 405 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); 379 - ret = ret & ssd1307fb_write_cmd(par->client, 0x0); 380 - ret = ret & ssd1307fb_write_cmd(par->client, 381 - par->page_offset + (par->height / 8) - 1); 406 + if (ret < 0) 407 + return ret; 408 + 409 + ret = ssd1307fb_write_cmd(par->client, 0x0); 410 + if (ret < 0) 411 + return ret; 412 + 413 + ret = ssd1307fb_write_cmd(par->client, 414 + par->page_offset + (par->height / 8) - 1); 382 415 if (ret < 0) 383 416 return ret; 384 417