From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932536AbdABLfn (ORCPT ); Mon, 2 Jan 2017 06:35:43 -0500 Received: from mga07.intel.com ([134.134.136.100]:56550 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755230AbdABLfl (ORCPT ); Mon, 2 Jan 2017 06:35:41 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="1078352642" From: Andy Shevchenko To: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Greg Kroah-Hartman , devel@driverdev.osuosl.org, Thomas Petazzoni , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v2 6/6] staging: fbtft: fb_ssd1306: Refactor write_vmem() Date: Mon, 2 Jan 2017 13:35:34 +0200 Message-Id: <20170102113534.127692-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170102113534.127692-1-andriy.shevchenko@linux.intel.com> References: <20170102113534.127692-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor write_vmem() for sake of readability. While here, fix indentation in one comment. Signed-off-by: Andy Shevchenko --- drivers/staging/fbtft/fb_ssd1306.c | 16 +++++++--------- 1 file 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); -- 2.11.0