From patchwork Fri Apr 29 17:41:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12832573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A33EFC433EF for ; Fri, 29 Apr 2022 17:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=JFckWBod1EdOWQ94GnfnYziKyetxYhz3px+DyeYQofQ=; b=QfhtbrLqWrJJL+ nE+MXhFR7KCdChgZDIhgmZMZe6nV2LA3UV1jHpvouaOZio7QwYpRJ8PYs0cMmfNBEOqh2zqHGP9Zo bpnX0uu0Z/T/RNUy+eRlWYM6UxjEypdOAjrO0D+E1m/Vlh9HGYTpUUnL5e+wesIqOhWBk+NP/nRzQ btrAMcFH7L3Fn34l0UU4VF5RvDjUgSDBt9F76GRT0UfmGOf+Q806lTjDWYAZdIVU40bDmrzu/rwH+ A4ErLjuGURe6ryFsNcIoFbwgSKajW30vYsskjvGQ1UXTNoTehNkbbQcDYenASDTN7z+Dpm2JuNU0+ zfADDa2gmut1N0VSDfgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkUdJ-00C75p-6a; Fri, 29 Apr 2022 17:42:21 +0000 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkUdF-00C75C-Q7 for linux-mediatek@lists.infradead.org; Fri, 29 Apr 2022 17:42:19 +0000 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23THPWqp018608; Fri, 29 Apr 2022 17:42:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : content-type : mime-version; s=corp-2021-07-09; bh=8x338saWQSdA1UydheMJ00f+qNZ6OWiVBPt8zZlM2yY=; b=t+z3m2j7dKEUeyNe6YfjKBGegqc7Mgwc3XTL+gReIrgpcNckPwBahlf8amLMlRaF7a30 tIbSXKjuz5sFeE9RauzU8AXqMFIRXMLY0kBc5Jsyyucmbi9H4WU5tdd7P5Sd8kT+ud38 eCtBcQlun3NMWWxmevoxGvIV0cJTZT5sBtJmBcCwvNCol6ep1uuNAli2bAErRRVzeJCr e9Nc595MHdMmQegP/PsXg4rXf2T47um/iYMK9vKSpTCs6ULDKbWDWK1LxPW9FhxOLH5F Wyd+nCdvVBdgIb1Mt+X+RlPLH5v+TGqW7nx8f8m5vO7QnRiZUUMo6dR+G7n7ylhf7cgz oA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3fmb5k7g2b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Apr 2022 17:42:11 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23THafIu011824; Fri, 29 Apr 2022 17:42:10 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fp5yqeg4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Apr 2022 17:42:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f/zF7ZBuaTNGwDf5d36q5LvWTKHQnzjhLBZN9krSpRHrbJRdpcDPN4VAHe1042pw0qJ2n8J4zpk/mUu8StBpJhD4cnWb5uIUxlc9TWfwd7Gn0XayR0y4MEN8ssFRnhGAa4m/HmKkl/eLrvKz4JWogqiuDyNeEyc52sUps/dXLM8t/hJTvQ7JAPO7Km2lq5r5Dg+c472noHtNdGR3eCXGZMT1TmSc9QXWnOopi12///t0ZDYQXWyUtItygYWwIsogGXvVcBlJk7pkzqu6O9+OK4pWGNhGCvD+AOMBXbaNjyO2l+/4OXg67D/gjXo7cmk6wslCyne0WrMc73WR8RSKvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8x338saWQSdA1UydheMJ00f+qNZ6OWiVBPt8zZlM2yY=; b=dMTzI20LdmpJ4L4Xucrz9teydBOwWRfCcnfZR1sknRJYNUYDPhVMeEx6bNXG+sBzOi7piJVS7O70SAc0pjmSGhrvVsQG0GTXX4nMIXR1pDMrqFCcWFF5sa0Tp2VaUs0Of8DtSuJJfNJQFSDQukl8Hedh7mPPu2nsi33gmEcsVWwXh4llfDKz8NIhnznLVYPWk70U6+zXkG+wkE+DHRTrA2ELHehjM/J2ug2NMOb8wNxWAPYKNYOpcvU2wMrpla4hUOMenmmT0vdgHG1vzKjttBSnAUowBDeVHIslSM8y13BML/TcnF7HftWlp+LLIsEYa8SpWWYAIZ/hQcQ/ecxObQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8x338saWQSdA1UydheMJ00f+qNZ6OWiVBPt8zZlM2yY=; b=zvoIhHqmj3yki7xL319QsNif86VQEn1BVQSwZFeDP3dfozGfRnm398K1j6nribji/imWpr3RKLj6dYvxmv6D+jlxjURh1owdRocV9gNdTtqtnosoIfHjVgptOPU2oT7ZnJbkJz8SW7PgrLGb1F5fRMH7upVtQEifHGAG11tJ0z0= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by SA2PR10MB4537.namprd10.prod.outlook.com (2603:10b6:806:116::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13; Fri, 29 Apr 2022 17:42:08 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::b5d5:7b39:ca2d:1b87]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::b5d5:7b39:ca2d:1b87%5]) with mapi id 15.20.5164.025; Fri, 29 Apr 2022 17:42:08 +0000 Date: Fri, 29 Apr 2022 20:41:37 +0300 From: Dan Carpenter To: Mark Brown , Chuanhong Guo Cc: Matthias Brugger , Chuanhong Guo , linux-spi@vger.kernel.org, linux-mediatek@lists.infradead.org, kernel-janitors@vger.kernel.org Subject: [PATCH] spi: mtk-snfi: preserve dma_mapping_error() error codes Message-ID: Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-ClientProxiedBy: ZR0P278CA0143.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:40::22) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 32708fe6-39a6-4dee-ca70-08da2a0794dc X-MS-TrafficTypeDiagnostic: SA2PR10MB4537:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kuhCLFo3nJGxPw57QAhbUksKKR9JhrjyuzGqwK+0tNSBkjT3Lp9srl/eGtCyeAVuZ/KQINv/U1qiGGmXK6w+dATmk8CTxs6GzJQmK92+9oyyYXwC1y2mrVPZJbyP80OsB5IeDGhRr04r4JscJNl6w+n9IVL6JEN6zh6A1oGZ9un22qS5Wf7N/zEy3o9PUeCaCFF91JIRo3TkI8hAy0Ll8qDFb5IHEwrCY/8STaGueFObkw2j5c/2IzEVyJqQ3ZdiNRTr5LqaQOaKwiLclxIMZAzs2J02pY56QneSa1opVPOaUyNUqabiwZgGK9K8pEkO0c0nwrU3C2BXHreGZl3HKRYLUwMZ+Lg3NUh9iV1rQGHTG0ALx0V0HIi5yrtadHSoFZknmM3f/Ylw1RAPKD/uwIJTKJqaHNxQHw8aJDK+YnsDRWjUZjy2Rnuo9RypYxwZH7Q774ZwaHUu7WNdrP3JAOEHLcQAkySko6P3rBMKT2hORz3yb8ucMKySv0Bc1OrlEjmbOi4n9988QU3LXrt3r/hovLEVwjo/9B1XJIzCg2Z5StP2tqSNr/HGPJG9yfbVCHcmMCVEc3jgkt+qRPHxwdgCYgwz84o2VZ5/k4Th9AOecV63HaAdusjEUrfCek72s8e0lhPc/vd1j8d57+h1iuk7cqL9jowNOWHkhu464zCYnpX0j8snT9c/MWV5e/xrSXC5deHawxoH9VaKcfYpkA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2365.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(7916004)(366004)(186003)(5660300002)(52116002)(66946007)(66556008)(33716001)(316002)(66476007)(44832011)(2906002)(83380400001)(8676002)(4326008)(8936002)(110136005)(54906003)(6486002)(86362001)(508600001)(38350700002)(38100700002)(6666004)(9686003)(6512007)(26005)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PdEKLIusnP3T5sAH4g48ZlrkMSyjICkC3O/CRtvybQrmJe/uHogKTx2AoJ2AmYh1RBxukqXZ9YIF36ehvQqcqN42Lj9q9DD2LkCJSyTneSiAekVh+tpZxvKyaOzO3B9m8sx5QOotnwSNW/Yo6VUJref4aUHDLWIcO8JoAVZtwXWlhK9gZiEhueS+sZPN6pUEvcalrd55rxPiphiFm6gethhFMOhb+aHImDsa8gaskWzMTcAJkgv1lgdkhEhMP3itp2815YR4tWBgVQ8rL5388vNr/8iZj8IZfX0tMJUxSdAmIZXrmuQIavBg0ctCrrrlXGDC1UPYVa4ij1qJX4XizL0Msu+XbfRJROU9wxkRqP9XIPe57xCditnvZXw7FrPIMLZrmlwS0ug1Q1bJPRD1Tw3KYQs01GI0tHf+HtW6wvVAOafH3k7LPEqwi/7QRu4rS3yzutEbgYa2/hH8WDPG/DN+QgoRirqkvpL41BsFxg8nJoL0GVlD9ajE42kUTqB25fA7yvCupCws9F/T5MQ2FMO67V1qWXtVNv7mX7mJf474vY6tikd9g9gOkOdTtKnittqhnVykFicmglyzUyxLMUeBhYqhGxVu5/tdfu2nue50H/J510NfgqMaGbq15Dus0rJie94wuvBusMea6IIEx6bV0IYdEE03+uip6kbKtGBtD5rpENASAyYcthnGZDqSzKBHo+7hCQGDB4yw+9LxIfC9gu4L86kVirJHFxupvZsVaK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a6-4dee-ca70-08da2a0794dc X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2022 17:42:08.2762 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GFdPIZte4d521ted9jE7x0qktzokNLZ2Pf6fu1QbNG+oTeCBNgjnnlA0MBUvIy5QOhUDqHd+9rF9v++7y607199Rg3/c1wwmVOx6NtTnrSo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4537 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-29_06:2022-04-28, 2022-04-29 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204290088 X-Proofpoint-GUID: DtzalwjGD2wQjqjluj1rxwUnY-uObKzZ X-Proofpoint-ORIG-GUID: DtzalwjGD2wQjqjluj1rxwUnY-uObKzZ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220429_104218_212654_2B6FA2F7 X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Return -ENOMEM of there is a dma mapping error. Do not return success. Fixes: 764f1b748164 ("spi: add driver for MTK SPI NAND Flash Interface") Signed-off-by: Dan Carpenter Reviewed-by: Chuanhong Guo --- drivers/spi/spi-mtk-snfi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c index 2c556e304673..d66bf9762557 100644 --- a/drivers/spi/spi-mtk-snfi.c +++ b/drivers/spi/spi-mtk-snfi.c @@ -903,7 +903,8 @@ static int mtk_snand_read_page_cache(struct mtk_snand *snf, nfi_write32(snf, NFI_CON, (snf->nfi_cfg.nsectors << CON_SEC_NUM_S)); buf_dma = dma_map_single(snf->dev, buf, dma_len, DMA_FROM_DEVICE); - if (dma_mapping_error(snf->dev, buf_dma)) { + ret = dma_mapping_error(snf->dev, buf_dma); + if (ret) { dev_err(snf->dev, "DMA mapping failed.\n"); goto cleanup; } @@ -1092,7 +1093,8 @@ static int mtk_snand_write_page_cache(struct mtk_snand *snf, nfi_write32(snf, NFI_CON, (snf->nfi_cfg.nsectors << CON_SEC_NUM_S)); buf_dma = dma_map_single(snf->dev, snf->buf, dma_len, DMA_TO_DEVICE); - if (dma_mapping_error(snf->dev, buf_dma)) { + ret = dma_mapping_error(snf->dev, buf_dma); + if (ret) { dev_err(snf->dev, "DMA mapping failed.\n"); goto cleanup; }