From patchwork Wed May 17 11:55:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9730949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 31FFB602B4 for ; Wed, 17 May 2017 11:55:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21D522874E for ; Wed, 17 May 2017 11:55:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1646328754; Wed, 17 May 2017 11:55:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA0152874E for ; Wed, 17 May 2017 11:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752344AbdEQLzi (ORCPT ); Wed, 17 May 2017 07:55:38 -0400 Received: from mout.web.de ([212.227.15.4]:58114 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751637AbdEQLzh (ORCPT ); Wed, 17 May 2017 07:55:37 -0400 Received: from [192.168.1.3] ([78.48.117.83]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MQc7J-1dYMeH13ID-00U5QT; Wed, 17 May 2017 13:55:32 +0200 Subject: [PATCH 2/2] spi-bfin5xx: Adjust 14 checks for null pointers From: SF Markus Elfring To: linux-spi@vger.kernel.org, Mark Brown Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <07be1666-abb0-8abe-e66c-7b7dbc7c94bd@users.sourceforge.net> Date: Wed, 17 May 2017 13:55:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K0:iiDpKvaM+xIpy3UiR0yM33en25+kspBT7F6SYwotC/JxCshjpUc WtwiNUEPOKhiBAwL4TXmDK1XEuywdv6h7hbOULEmEKy3rWIhSs4oEr4E5MxKz4Iv+wv8J9f 4SqwbX62dWrC1SSX4tBQEkI3PtHQbrin0DElh9JChgKsowFzqtJwZf7/AmQV/vGXRqm5D2k yrnfX978gxHoomvasFC5g== X-UI-Out-Filterresults: notjunk:1; V01:K0:WFWYWOEQGiE=:glEQ5o+9qMkvlbjBNKXacx AjajbUT67mZDEfZo6mHRz22xPl3qx7DfaTVLf6lpor/JXcMtISmSfzG0VrOUVkQE1WxovsdTw 5vzmVxKBF5Qm3iT9JRvwKDuxnihia390xQlE5jWV1WsLGITRZmsTNnitxVUnL4+i/AZp4pixZ lvQAO8qI2fgTRI48dAnfRkpLnumYYsuIsIdgDugOCO2xWRsv3qRx2gTmlzwGMxe0pId7AgYuf EWEdH3BsKpeyhyJVFD1H/UnpVpBQbTLFTwS5cjZb3JtHIdevIcagMz4fBtK+7OuAC7GxjNlul BB34tLcIYQAVHItcGOab1x69MbOGs/mPIO7OITiEOyPBBIGw7ceTYO0ZvW6Gh0evEquAYQ8Jw QsQfNaooPn3SHgQxBBy63zyHzFhGFeMcfLge0f/FrukmXzZ+XEKSuLsC+S3YEbtq32U5L6aqB bGMAHACft2261g0XP8SlK4HApMk75TmYqfEIwHSq6ZmVibgcTye92u9smh8sYdPudgpph4ar4 rArgx+9fmh2mjyZeVxGUgJgeTGurfxHZ5xZw1iGKl5T70GFexPBgFg3rJ1Xci/I9vynseSUDl UKR2UEA8YTzkuYPfe2q8Y8axyLYrKB1mJFaHveUgtAb9Q5BSVBWZGuo68SUjt+7MhexDTPjWh /ggGygEkTsDtTrvupXGEnHFEiESUppVCypvkPkCx181aD0tMBWRtwAab5uNnJxCnFYgsa41J2 g5hhKjnxjwnUsA+4Q8Mo2OAUfgoq80DSWkQkZB4eFZhZkqFMZjnoLHaNFEoxukwDXVOnOogo+ 3XsJT9x Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 17 May 2017 13:13:26 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix affected source code places. Signed-off-by: Markus Elfring --- drivers/spi/spi-bfin5xx.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c index 3265f4967d2b..c1353ac49c9c 100644 --- a/drivers/spi/spi-bfin5xx.c +++ b/drivers/spi/spi-bfin5xx.c @@ -489,7 +489,7 @@ static irqreturn_t bfin_spi_dma_irq_handler(int irq, void *dev_id) "in dma_irq_handler dmastat:0x%x spistat:0x%x\n", dmastat, spistat); - if (drv_data->rx != NULL) { + if (drv_data->rx) { u16 cr = bfin_read(&drv_data->regs->ctl); /* discard old RX data and clear RXS */ bfin_spi_dummy_read(drv_data); @@ -506,7 +506,7 @@ static irqreturn_t bfin_spi_dma_irq_handler(int irq, void *dev_id) * to be transmitted ... software needs to poll TXS in the SPI_STAT * register until it goes low for 2 successive reads */ - if (drv_data->tx != NULL) { + if (drv_data->tx) { while ((bfin_read(&drv_data->regs->stat) & BIT_STAT_TXS) || (bfin_read(&drv_data->regs->stat) & BIT_STAT_TXS)) cpu_relax(); @@ -612,7 +612,7 @@ static void bfin_spi_pump_transfers(unsigned long data) return; } - if (transfer->tx_buf != NULL) { + if (transfer->tx_buf) { drv_data->tx = (void *)transfer->tx_buf; drv_data->tx_end = drv_data->tx + transfer->len; dev_dbg(&drv_data->pdev->dev, "tx_buf is %p, tx_end is %p\n", @@ -621,7 +621,7 @@ static void bfin_spi_pump_transfers(unsigned long data) drv_data->tx = NULL; } - if (transfer->rx_buf != NULL) { + if (transfer->rx_buf) { full_duplex = transfer->tx_buf != NULL; drv_data->rx = transfer->rx_buf; drv_data->rx_end = drv_data->rx + transfer->len; @@ -723,7 +723,7 @@ static void bfin_spi_pump_transfers(unsigned long data) /* In dma mode, rx or tx must be NULL in one transfer */ dma_config = (RESTART | dma_width | DI_EN); - if (drv_data->rx != NULL) { + if (drv_data->rx) { /* set transfer mode, and enable SPI */ dev_dbg(&drv_data->pdev->dev, "doing DMA in to %p (size %zx)\n", drv_data->rx, drv_data->len_in_bytes); @@ -738,7 +738,7 @@ static void bfin_spi_pump_transfers(unsigned long data) dma_start_addr = (unsigned long)drv_data->rx; cr |= BIT_CTL_TIMOD_DMA_RX | BIT_CTL_SENDOPT; - } else if (drv_data->tx != NULL) { + } else if (drv_data->tx) { dev_dbg(&drv_data->pdev->dev, "doing DMA out.\n"); /* flush caches, if needed */ @@ -789,7 +789,7 @@ static void bfin_spi_pump_transfers(unsigned long data) bfin_spi_dummy_read(drv_data); /* start transfer */ - if (drv_data->tx == NULL) + if (!drv_data->tx) bfin_write(&drv_data->regs->tdbr, chip->idle_tx_val); else { int loop; @@ -827,7 +827,7 @@ static void bfin_spi_pump_transfers(unsigned long data) if (drv_data->tx != drv_data->tx_end) tranf_success = 0; - } else if (drv_data->tx != NULL) { + } else if (drv_data->tx) { /* write only half duplex */ dev_dbg(&drv_data->pdev->dev, "IO write: cr is 0x%x\n", cr); @@ -836,7 +836,7 @@ static void bfin_spi_pump_transfers(unsigned long data) if (drv_data->tx != drv_data->tx_end) tranf_success = 0; - } else if (drv_data->rx != NULL) { + } else if (drv_data->rx) { /* read only half duplex */ dev_dbg(&drv_data->pdev->dev, "IO read: cr is 0x%x\n", cr); @@ -979,6 +979,6 @@ static int bfin_spi_setup(struct spi_device *spi) /* Only alloc (or use chip_info) on first setup */ chip_info = NULL; chip = spi_get_ctldata(spi); - if (chip == NULL) { + if (!chip) { chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (!chip) { @@ -1086,7 +1086,7 @@ static int bfin_spi_setup(struct spi_device *spi) if (chip->chip_select_num >= MAX_CTRL_CS) { /* Only request on first setup */ - if (spi_get_ctldata(spi) == NULL) { + if (!spi_get_ctldata(spi)) { ret = gpio_request(chip->cs_gpio, spi->modalias); if (ret) { dev_err(&spi->dev, "gpio_request() error\n"); @@ -1278,21 +1278,21 @@ static int bfin_spi_probe(struct platform_device *pdev) /* Find and map our resources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { + if (!res) { dev_err(dev, "Cannot get IORESOURCE_MEM\n"); status = -ENOENT; goto out_error_get_res; } drv_data->regs = ioremap(res->start, resource_size(res)); - if (drv_data->regs == NULL) { + if (!drv_data->regs) { dev_err(dev, "Cannot map IO\n"); status = -ENXIO; goto out_error_ioremap; } res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (res == NULL) { + if (!res) { dev_err(dev, "No DMA channel specified\n"); status = -ENOENT; goto out_error_free_io;