From patchwork Thu Jul 15 00:46:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshitaka Ikeda X-Patchwork-Id: 477822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04319C12002 for ; Thu, 15 Jul 2021 00:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBB28613CF for ; Thu, 15 Jul 2021 00:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbhGOAtZ (ORCPT ); Wed, 14 Jul 2021 20:49:25 -0400 Received: from mail-eopbgr1400075.outbound.protection.outlook.com ([40.107.140.75]:35596 "EHLO JPN01-TY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229666AbhGOAtZ (ORCPT ); Wed, 14 Jul 2021 20:49:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dm4W5xjYUTLgnpoZpCwCVJdYnnwoHZaMTSETeqUcP42WZfYlo5IM8uwb1AtFeYegQ0yiieOOhVDFf7pI7bGAioZW0xNADeoWd6T5y2K3ktQZAN8AbW3Ev34pYhnafOd9UWgfAwMdtUXqhkjvf64PjDFaYVjNOP9A6TxCyu16/R7c9+uxhZ7gA4KoKZZVtK2YCn18cwW5N5X5TL8AJYTZYRQqli9VmOZPNDjCQ0cbKoJIOpb4/r5F3A5+O+EqjdtHcK1JVrRQQ+Pr1BRoJPthaKuC0VutnEKwY16r4gzjpj5xIr7S/wd5UmgwURwpCDFEKQegOFVNhqE5kjEYI39DOA== 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-SenderADCheck; bh=YS3Abz0VDH1Oti6gop/Q/AOux+UxUi0zOi9Bn7VYz8k=; b=oeJSO+DifmOJHnIeeDS2sElqgaJyglQnhEMAZb6bYyP59olD/Dn2cbP9D9PNZGkYZuq4tI6E/mE8dGHelTIAKjvYf5evqCdj8hf7eABgsb8yMO6dD2NOxj4JLrt2J4AN5j6gTrlUWyXzUNzmIgnzRwzlktQ9ssgIGzp39Sjwl55FHiiEsHt/RwNW2ppYBfe7TqBfCUKBo1oNUryxFRIJG9PHY9wp0/TNPDLW48hX8waiXzAe/g3IS3CoFL7Gv1wXDsfBvA/z9C03RHA26x5UHdaRVmqkZZ7Zb/Ul8cSkJQoHRLp13Z3hLfaWoL3fqCCr8mKheTIK6l1IDWzXUClmZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nskint.co.jp; dmarc=pass action=none header.from=nskint.co.jp; dkim=pass header.d=nskint.co.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nskint.onmicrosoft.com; s=selector1-nskint-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YS3Abz0VDH1Oti6gop/Q/AOux+UxUi0zOi9Bn7VYz8k=; b=EDbTp76OXWP5QrKBKyH10mwl2+ylsdRpYH1B6AJVYpsuf/jEUtyT11lbok/th1Bxf0yxUT0VNDpCVqt/pNy/mtMXbZRjePtJIktG1MWBR9HV5gKgNeKrprYJu/2LdpbvYaYkKZjkGSZ/FhwRYjOi04WM0phwD17NSQ3lpNHY9YA= Received: from OSZPR01MB7004.jpnprd01.prod.outlook.com (2603:1096:604:13c::9) by OS3PR01MB5941.jpnprd01.prod.outlook.com (2603:1096:604:b4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22; Thu, 15 Jul 2021 00:46:31 +0000 Received: from OSZPR01MB7004.jpnprd01.prod.outlook.com ([fe80::94dd:c412:338:709e]) by OSZPR01MB7004.jpnprd01.prod.outlook.com ([fe80::94dd:c412:338:709e%5]) with mapi id 15.20.4308.027; Thu, 15 Jul 2021 00:46:31 +0000 From: Yoshitaka Ikeda To: Mark Brown CC: Philipp Zabel , "linux-spi@vger.kernel.org" , Masahiro Mizutani , Ken Kurematsu , Yoshitaka Ikeda Subject: [PATCH v2] spi: spi-cadence-quadspi: Fix division by zero warning Thread-Topic: [PATCH v2] spi: spi-cadence-quadspi: Fix division by zero warning Thread-Index: AQHXeRLRq9j2aM/2WUWyoM0xh6yPGw== Date: Thu, 15 Jul 2021 00:46:30 +0000 Message-ID: <362e0cbc-ed82-bf7d-025c-d586d11eaac2@nskint.co.jp> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 authentication-results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nskint.co.jp; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d6b1b313-a268-4561-96f8-08d94729fcd0 x-ms-traffictypediagnostic: OS3PR01MB5941: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:337; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lezb0Xdh6Su/efH5t+kfKzBDovkEUn8AY0xTQCMbInbH/bNjSCtrTX/o6/9T3Uzw8d5WXe3v4NzkWV7tQLg/jh/5fHf2B7B9hTy61FbFxvxekyHxxT5mVZJrG5frjAgbyo1WrwD7cNKxz2Fp2tMYbWzcoJMm2ah2pggodtemFSYD+MiyYsu9zcBUKgBny1MpY+NHTtvn9q89LbWJiEeWR23VY/H+suHbZsDLd3LTUieH4tDOVDGG3U6NGHxVNrrxhvRDGuhj1parDHW7PIWLxSyH5BuSGckYccsfiYB62C9DbKU1mu6FhSPQ0S532dCD0bYxUxzl6B32JE5hZfJLOX96we9g7yNz4dgb7mK7HW3aydS50C4gDWJVdqp9/2/lJpXxgVxmQ5E6sZQkX0671VlJUicxvmWX3rwE1z+XzbQM1Q5LMXGnrKZKQqVHWhRMYYgTdK0yxBCV0wOu9gdYEEuyrnnDHXrsNQ/l33av9VfJvEWe0cRM7GAItsoBBTJj8qOPLMr9XTmKK6d20o18nDaEZVV1Ny3XJemY4ESnM4R3Z5kisQRCWL/z8Wsc2kfFDXn9/X6fxO0mGZxjyhrse5P0cHcX2hu2ku44KYM4P6YPOROig+ZDinQlfKpkTCFwSpfTCHqhAs6UpO0QFjGZEx7dyIYfNsW/WJ7NIZloT6YSpCXmisV7tCei3BNS+hiQm+zPx7WRXro6QdQXRx/wQKDDvfcbpXZzLaWZRkubMEDRQTh0ohEP18Vcpi+ncGbVkZn/+fzt4pmuM3VlWkXLIA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:OSZPR01MB7004.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(2906002)(71200400001)(8936002)(86362001)(36756003)(66446008)(31696002)(316002)(64756008)(5660300002)(54906003)(66556008)(66476007)(122000001)(83380400001)(8676002)(6512007)(107886003)(2616005)(478600001)(6916009)(38100700002)(6506007)(76116006)(66946007)(4326008)(26005)(31686004)(186003)(6486002)(43740500002)(38070700004)(45980500001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-2022-jp?b?MktxZGk5bmU0Vnha?= =?iso-2022-jp?b?Y0xyNjlqTzFobnRMVks2R1g1M2g1QysvYjNtTkhDN0NSbmpx?= =?iso-2022-jp?b?SGZrMUVOZFFzLzc5U2F0bXVVamlqZWFwUG9KNEJLeHZNTkw2?= =?iso-2022-jp?b?REZ4ZXpmM044czIyczZlRm54VHpMS0tzNlZjbCsvQ3VPU1hF?= =?iso-2022-jp?b?Nk5jNmFJT0lxUmd3UVllTUg3V1FXNEVSSTJ3ZDUwaS9KZ1Y2?= =?iso-2022-jp?b?U2xCdmZKMVhla0JyUzdIQUczTkVIb0c4MWRqdVErOVB3emtM?= =?iso-2022-jp?b?ZWJwWXRRc2J6RFUvVEtNOER1K015bk9UUWlRY1c3MUtYRVVK?= =?iso-2022-jp?b?MThoejduTlc2eHJ4UmNrT2NUbVEvM3V1dWdSZlNLMmtUQjI5?= =?iso-2022-jp?b?ZllOVnh4N29jUGx4S0ZwQmdZYllqNXkwN000ZFQ0Y1RlRXc5?= =?iso-2022-jp?b?U3dIZU5nSHk3dTZvU0lzNWVTWlV2QnR6WTVMWURiR1ZDZGV5?= =?iso-2022-jp?b?MkJjSnRGZnFKS3FhT01BUHNTLzFYWFBVVnFuaTk0Q1JmQVhM?= =?iso-2022-jp?b?NHZKejBiMmw0RXlKcmZ2R3VPdnNGU2ZaaG1WMGF5c1Zjakpo?= =?iso-2022-jp?b?UFQ0bXJ4RUtaQUJTaXBZUkhXN1krbk5UWUpmMEY1dkZhSWlW?= =?iso-2022-jp?b?UGI4ZnQrM3Fkc2x4cWdaK0syVmg0WWdSaEQ4SWI4SU9JckpG?= =?iso-2022-jp?b?bWFrV0RYYitTa0JvNHUvYzFscHpvNkZFbmgweFJuUFYzQWpa?= =?iso-2022-jp?b?YktPbWRyWEFxUzRVdWR6azNMbWg1c1EwU2s1RHFGTTltVk9K?= =?iso-2022-jp?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OWlkNFhyMEdJc1o2?= =?iso-2022-jp?b?UkZnMng1RnA2bFdsb0h5NzZDNUdqR3RzU3A0bHJWM0p6QkRL?= =?iso-2022-jp?b?NGFKYzNIK3N2RDBwMERSMER3YllTb1pzOGd0SVJtTzJoWE1Y?= =?iso-2022-jp?b?aFJmd3k2QnBMVU1nckgveWcvWmZpWUtKajBWd1MvOFY3dkJT?= =?iso-2022-jp?b?UU1CallTWmhNSjVWaXI3Tmt0SWZNK0FkenptUzBqbmhDclBl?= =?iso-2022-jp?b?OG9paDlOMVZtOFdYZnZqSnJnVVVPMGJtSlNXd1Jvbmhqa0dl?= Content-ID: <429F4CF7D8542E45B5075D9A45B811B5@jpnprd01.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nskint.co.jp X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: OSZPR01MB7004.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6b1b313-a268-4561-96f8-08d94729fcd0 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2021 00:46:30.9390 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 727455a2-9822-4451-819f-f03e059d1a55 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yXQFVnG5ZDUr+3l61RZ4UJ/ltqIHSKNGbOjxEFUmHw1TlFFT8japSBLYeE20vIjCf6oLVZKGU3kfn5xx88HlKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB5941 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Fix below division by zero warning: - Added an if statement because buswidth can be zero, resulting in division by zero. - The modified code was based on another driver (atmel-quadspi). [ 0.795337] Division by zero in kernel. : [ 0.834051] [<807fd40c>] (__div0) from [<804e1acc>] (Ldiv0+0x8/0x10) [ 0.839097] [<805f0710>] (cqspi_exec_mem_op) from [<805edb4c>] (spi_mem_exec_op+0x3b0/0x3f8) Signed-off-by: Yoshitaka Ikeda --- v2: - Fix commit message. --- drivers/spi/spi-cadence-quadspi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 7a00346ff9b9..13d1f0ce618e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -307,11 +307,13 @@ static unsigned int cqspi_calc_rdreg(struct cqspi_flash_pdata *f_pdata) static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr) { - unsigned int dummy_clk; + unsigned int dummy_clk = 0; - dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth); - if (dtr) - dummy_clk /= 2; + if (op->dummy.buswidth && op->dummy.nbytes) { + dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth); + if (dtr) + dummy_clk /= 2; + } return dummy_clk; }