Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752257AbdLJPUj (ORCPT ); Sun, 10 Dec 2017 10:20:39 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35287 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbdLJPUi (ORCPT ); Sun, 10 Dec 2017 10:20:38 -0500 X-Google-Smtp-Source: AGs4zMbTgxCLHXRa34Q3sVCM0Gjjkf/RT0OWsirpzowwftSQTufGl7DHPLbvhbihwzhL4UFs5lZpVw== From: Antonio Borneo To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , Andrew Lunn , Chris Packham , Rob Herring , linux-mtd@lists.infradead.org Cc: Antonio Borneo , linux-kernel@vger.kernel.org Subject: [PATCH] mtd: mchp23k256: propagate return value of spi_sync() Date: Sun, 10 Dec 2017 16:19:56 +0100 Message-Id: <20171210151956.2053-1-borneo.antonio@gmail.com> X-Mailer: git-send-email 2.15.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2251 Lines: 80 The call to spi_sync() can fail. Check the return value and propagate it. Signed-off-by: Antonio Borneo --- To: David Woodhouse To: Brian Norris To: Boris Brezillon To: Marek Vasut To: Richard Weinberger To: Cyrille Pitchen To: Andrew Lunn To: Chris Packham To: Rob Herring To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/mtd/devices/mchp23k256.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c index 787e9ec7..4c91c0e 100644 --- a/drivers/mtd/devices/mchp23k256.c +++ b/drivers/mtd/devices/mchp23k256.c @@ -68,6 +68,7 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len, struct spi_transfer transfer[2] = {}; struct spi_message message; unsigned char command[MAX_CMD_SIZE]; + int ret; spi_message_init(&message); @@ -84,12 +85,16 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len, mutex_lock(&flash->lock); - spi_sync(flash->spi, &message); + ret = spi_sync(flash->spi, &message); + + mutex_unlock(&flash->lock); + + if (ret) + return ret; if (retlen && message.actual_length > sizeof(command)) *retlen += message.actual_length - sizeof(command); - mutex_unlock(&flash->lock); return 0; } @@ -100,6 +105,7 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len, struct spi_transfer transfer[2] = {}; struct spi_message message; unsigned char command[MAX_CMD_SIZE]; + int ret; spi_message_init(&message); @@ -117,12 +123,16 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len, mutex_lock(&flash->lock); - spi_sync(flash->spi, &message); + ret = spi_sync(flash->spi, &message); + + mutex_unlock(&flash->lock); + + if (ret) + return ret; if (retlen && message.actual_length > sizeof(command)) *retlen += message.actual_length - sizeof(command); - mutex_unlock(&flash->lock); return 0; } -- 2.7.4