diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-01-19 12:45:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-19 12:50:28 +0100 |
commit | 09249ecdfd9bafd14bfcf71f6801290c2fafda5a (patch) | |
tree | 48f038579b23961b738b4ac5c88b5a7c9497bb9d /drivers/staging/fbtft | |
parent | 95ecde0f65661d7fd34bb3e846e1cc7bcbfe7b6d (diff) |
staging: fbtft: fb_ssd1306: Refactor write_vmem()
Refactor write_vmem() for sake of readability.
While here, fix indentation in one comment.
Acked-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/fbtft')
-rw-r--r-- | drivers/staging/fbtft/fb_ssd1306.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/staging/fbtft/fb_ssd1306.c b/drivers/staging/fbtft/fb_ssd1306.c index bede2d5a5571..76f7da3c7703 100644 --- a/drivers/staging/fbtft/fb_ssd1306.c +++ b/drivers/staging/fbtft/fb_ssd1306.c @@ -84,7 +84,7 @@ static int init_display(struct fbtft_par *par) /* Vertical addressing mode */ write_reg(par, 0x01); - /*Set Segment Re-map */ + /* Set Segment Re-map */ /* column address 127 is mapped to SEG0 */ write_reg(par, 0xA0 | 0x1); @@ -183,26 +183,24 @@ static int set_gamma(struct fbtft_par *par, unsigned long *curves) static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) { u16 *vmem16 = (u16 *)par->info->screen_buffer; + u32 xres = par->info->var.xres; + u32 yres = par->info->var.yres; u8 *buf = par->txbuf.buf; int x, y, i; int ret = 0; - for (x = 0; x < par->info->var.xres; x++) { - for (y = 0; y < par->info->var.yres/8; y++) { + for (x = 0; x < xres; x++) { + for (y = 0; y < yres / 8; y++) { *buf = 0x00; for (i = 0; i < 8; i++) - *buf |= (vmem16[(y * 8 + i) * - par->info->var.xres + x] ? - 1 : 0) << i; + *buf |= (vmem16[(y * 8 + i) * xres + x] ? 1 : 0) << i; buf++; } } /* Write data */ gpio_set_value(par->gpio.dc, 1); - ret = par->fbtftops.write(par, par->txbuf.buf, - par->info->var.xres * par->info->var.yres / - 8); + ret = par->fbtftops.write(par, par->txbuf.buf, xres * yres / 8); if (ret < 0) dev_err(par->info->device, "write failed and returned: %d\n", ret); |