From patchwork Wed Jan 14 08:24:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 5628371 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EAC5E9F358 for ; Wed, 14 Jan 2015 08:25:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 039432038A for ; Wed, 14 Jan 2015 08:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04CCB2038E for ; Wed, 14 Jan 2015 08:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751475AbbANIY4 (ORCPT ); Wed, 14 Jan 2015 03:24:56 -0500 Received: from mail-we0-f171.google.com ([74.125.82.171]:43560 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbbANIYy (ORCPT ); Wed, 14 Jan 2015 03:24:54 -0500 Received: by mail-we0-f171.google.com with SMTP id u56so7326260wes.2; Wed, 14 Jan 2015 00:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ojbysOujiiYWZRs8LSy8BJDbMB8nRmkpe55wS+zcLFk=; b=xGDMiPcNGVLhBi0ozoqJm46ikEo+6YfGLyMwzBiySBTqMLXrzoKibJpMMBkVwRTjYG s454JFJFXMYQWgqTSn3GzKBGeEiB8muUYnhgkbOEyT5wGB+5PNsQGI/7/DGAtiPXTi4t u7LhIqVPughce7YH02SnqgvpbHuVf7WOkhrJ7kAI7h69GLKizi1bYucwA4JyhGaC8ct0 NlO2sUUoLL1dDkMvZ4yjwwCDKuM7QJ5x+3dA20/PXh6H7yfycREJMkXlXfhWUkE3cK20 MxWQV1X0zYWPDOsy6I1MqcUsJbb5CGHDQnJomSn7+vBAAqGyHy0mbBNtu3kyl7l9e6H5 aocA== X-Received: by 10.180.73.206 with SMTP id n14mr6341234wiv.60.1421223893275; Wed, 14 Jan 2015 00:24:53 -0800 (PST) Received: from tango-charlie.Home ([94.10.25.115]) by mx.google.com with ESMTPSA id fc6sm17598859wib.12.2015.01.14.00.24.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jan 2015 00:24:52 -0800 (PST) From: "Lad, Prabhakar" To: LFBDEV , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Maxime Ripard Cc: LKML , "Lad, Prabhakar" Subject: [PATCH] fbdev: ssd1307fb: return proper error code if write command fails Date: Wed, 14 Jan 2015 08:24:49 +0000 Message-Id: <1421223889-9448-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP this patch fixes ssd1307fb_ssd1306_init() function to return proper error codes in case of failures. Signed-off-by: Lad, Prabhakar --- drivers/video/fbdev/ssd1307fb.c | 54 ++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index f4daa59..528ea16 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -320,7 +320,9 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) /* Set initial 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) return ret; @@ -336,63 +338,87 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) /* Set multiplex ratio value */ 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) return ret; /* set display offset value */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); + if (ret < 0) + return ret; ret = ssd1307fb_write_cmd(par->client, 0x20); if (ret < 0) return ret; /* Set clock frequency */ 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) return ret; /* Set precharge period in number of ticks from the internal clock */ 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) return ret; /* Set COM pins configuration */ 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) return ret; /* 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) return ret; /* Turn on the DC-DC 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) return ret; /* Switch to horizontal addressing mode */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); - ret = ret & ssd1307fb_write_cmd(par->client, - SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); + if (ret < 0) + return ret; + ret = ssd1307fb_write_cmd(par->client, + SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL); if (ret < 0) return ret; ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); - ret = ret & ssd1307fb_write_cmd(par->client, 0x0); - ret = ret & ssd1307fb_write_cmd(par->client, par->width - 1); + if (ret < 0) + 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) return ret; ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); - ret = ret & ssd1307fb_write_cmd(par->client, 0x0); - ret = ret & ssd1307fb_write_cmd(par->client, - par->page_offset + (par->height / 8) - 1); + if (ret < 0) + 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); if (ret < 0) return ret;