From patchwork Thu Mar 19 07:18:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 451762 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6239714010F for ; Thu, 19 Mar 2015 18:20:18 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 2849F1A09E1 for ; Thu, 19 Mar 2015 18:20:18 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 00B8F1A02D1 for ; Thu, 19 Mar 2015 18:20:04 +1100 (AEDT) Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Mar 2015 17:20:03 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Mar 2015 17:20:02 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 32E08357804C for ; Thu, 19 Mar 2015 18:20:02 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2J7JscD27656350 for ; Thu, 19 Mar 2015 18:20:02 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2J7JSAE019903 for ; Thu, 19 Mar 2015 18:19:29 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t2J7JS7f019109 for ; Thu, 19 Mar 2015 18:19:28 +1100 Received: from cyril.au.ibm.com (cyril.au.ibm.com [9.190.107.150]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 96E61A025E for ; Thu, 19 Mar 2015 18:19:05 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Thu, 19 Mar 2015 18:18:20 +1100 Message-Id: <1426749501-6251-2-git-send-email-cyril.bur@au1.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426749501-6251-1-git-send-email-cyril.bur@au1.ibm.com> References: <1426749501-6251-1-git-send-email-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15031907-0033-0000-0000-000001319C5B Subject: [Skiboot] [RFC PATCH 1/2] libflash: don't use the low level interface if it doesn't exist X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" During init libflash calls low level functions without checking. libflash states to backends that if they implement all the higher level functions the lower level functions are optional (from libflash-priv.h): If all functions of the high level interface are implemented then the low level one is optional. A controller can implement some of the high level one in which case the missing ones will be handled by libflash using the low level interface. Signed-off-by: Cyril Bur --- libflash/libflash.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libflash/libflash.c b/libflash/libflash.c index a229668..ce6a899 100644 --- a/libflash/libflash.c +++ b/libflash/libflash.c @@ -91,6 +91,10 @@ int fl_wren(struct spi_flash_ctrl *ct) int i, rc; uint8_t stat; + /* If lower level interface not implmented, just return */ + if (!ct->cmd_wr) + return 0; + /* Some flashes need it to be hammered */ for (i = 0; i < 1000; i++) { rc = ct->cmd_wr(ct, CMD_WREN, false, 0, NULL, 0); @@ -674,6 +678,11 @@ static int flash_set_4b(struct flash_chip *c, bool enable) /* Ignore the error & move on (could be wrprotect chip) */ } + /* Don't have low level interface, assume all is well */ + if (!ct->cmd_wr) + return 0; + + /* Ignore error in case chip is write protected */ return ct->cmd_wr(ct, enable ? CMD_EN4B : CMD_EX4B, false, 0, NULL, 0); @@ -757,7 +766,6 @@ static int flash_configure(struct flash_chip *c) return rc; } } - /* Set controller to 3b mode if mode switch is supported */ if (ct->set_4b) { FL_DBG("LIBFLASH: Disabling controller 4B mode...\n");