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

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>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
09249ecd 95ecde0f

+7 -9
+7 -9
drivers/staging/fbtft/fb_ssd1306.c
··· 84 84 /* Vertical addressing mode */ 85 85 write_reg(par, 0x01); 86 86 87 - /*Set Segment Re-map */ 87 + /* Set Segment Re-map */ 88 88 /* column address 127 is mapped to SEG0 */ 89 89 write_reg(par, 0xA0 | 0x1); 90 90 ··· 183 183 static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) 184 184 { 185 185 u16 *vmem16 = (u16 *)par->info->screen_buffer; 186 + u32 xres = par->info->var.xres; 187 + u32 yres = par->info->var.yres; 186 188 u8 *buf = par->txbuf.buf; 187 189 int x, y, i; 188 190 int ret = 0; 189 191 190 - for (x = 0; x < par->info->var.xres; x++) { 191 - for (y = 0; y < par->info->var.yres/8; y++) { 192 + for (x = 0; x < xres; x++) { 193 + for (y = 0; y < yres / 8; y++) { 192 194 *buf = 0x00; 193 195 for (i = 0; i < 8; i++) 194 - *buf |= (vmem16[(y * 8 + i) * 195 - par->info->var.xres + x] ? 196 - 1 : 0) << i; 196 + *buf |= (vmem16[(y * 8 + i) * xres + x] ? 1 : 0) << i; 197 197 buf++; 198 198 } 199 199 } 200 200 201 201 /* Write data */ 202 202 gpio_set_value(par->gpio.dc, 1); 203 - ret = par->fbtftops.write(par, par->txbuf.buf, 204 - par->info->var.xres * par->info->var.yres / 205 - 8); 203 + ret = par->fbtftops.write(par, par->txbuf.buf, xres * yres / 8); 206 204 if (ret < 0) 207 205 dev_err(par->info->device, "write failed and returned: %d\n", 208 206 ret);