From patchwork Fri Jan 13 17:24:22 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: 9516085 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 7B5E36077E for ; Fri, 13 Jan 2017 17:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AA4528769 for ; Fri, 13 Jan 2017 17:26:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F6632876B; Fri, 13 Jan 2017 17:26:49 +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 5C4BE28763 for ; Fri, 13 Jan 2017 17:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751158AbdAMR03 (ORCPT ); Fri, 13 Jan 2017 12:26:29 -0500 Received: from mout.web.de ([212.227.17.12]:52909 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750900AbdAMRZH (ORCPT ); Fri, 13 Jan 2017 12:25:07 -0500 Received: from [192.168.1.2] ([78.49.203.248]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LbrQm-1ctkuJ3jbI-00jHk8; Fri, 13 Jan 2017 18:24:24 +0100 Subject: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers To: linux-spi@vger.kernel.org, Mark Brown References: <1413e173-dbac-7a6e-09cb-2287300a335e@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <676a6351-ec06-9744-9f6f-753feb65f8fb@users.sourceforge.net> Date: Fri, 13 Jan 2017 18:24:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <1413e173-dbac-7a6e-09cb-2287300a335e@users.sourceforge.net> X-Provags-ID: V03:K0:HTVmNH8gDOLinTcxLxqGANRW+/x9ON2sol4KU8Ji5BYHl9DOrnD 005uBzf0+78SMcza+WCn0z7fa8hoYWOiViETRld/esCbzQUq2oOyA89yCWhZ+CeU9RPi1Oe HuBMjQTAHHvjtjl0PiqgDgzmATLRxtYjI9R17N6A1OfxhUzCtojbA1CukrhG9L9QgT9vFrd Z+0nVlDN/PLSXx/KLJklQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:NLDi5uAEEC8=:4iG3b61HH3f9Oh/GuSZdZQ gP4E4GyeNbH42cPQhm12pbDG1GPpFIexrNX1crK5vIGlJ0NNKVzHb4dtN1sYYpwM6t447mKGw fRaYuF1wBn4whbsBJhmKAzVH3p3BbsHsxDuXbJwf3S2xGUqKz4xXydUu6u72AnphXWHvc7YYz +HXePK4yd0DRJAY5rcfg5f86A6Z+1V0CUay4ILkoSGyId5WbBOMeIFrf8fl7ckZIeKxV6zRmT /eTxp6kuEiHDajCpFKGAQ8y3DyP1B2GjWfA5hp75LNIFOisfapNU6Z+TifvO4iD2DLJjAGLrR Z7aI/3UZldM42lWbrvlF8haxaeFPMHquBLHD2gvUKwOl9fsG5OAo/tJKn/qCC+iz5IXYM+WVZ 7cBx8QF+RPupC0LcaateXxaEMfpS/v43dpJ2zqzBqIqj/9OUlOzKfRgEEBwCwhbRdv+jDfo6y mzQjpLgWPtdWw8M6Sevoffn9ikMhscnf+CCRE9PSnQgZUlaKi2g+F7Q7fDYopi5/yDbhgHxSc jdPifMi74nTyCOgxbRviLhAVL1AKDP/II9Ga1q2Aym4sbQSLQSXFjTjSpmwNhwL0p/0tm2N8Y tbBIkdtisM/qbC8zVdwvQPqB/wL2VclofF02XAAQjzgALZDBUvfRYVuollGGTxfpOHPdlOg6L 1Xhv0Jx8pN4FLM45SIQLGkALXwcOCLbVuZ+l2getK63Ga1I+pFGHuSCXsAkfBpRW0LC0TRZrl kUUIP4dIzeYpaL2Mc9N1LYkg9qOsq3s6wvSxl3gWI4a9la4IYEXSyBuJz9lAee9X0RvZiYXzg mwANpvo 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: Fri, 13 Jan 2017 16:16:05 +0100 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 the affected source code places. Signed-off-by: Markus Elfring --- drivers/spi/spi-topcliff-pch.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index 0a876311b67b..e4f1f66b751b 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -531,12 +531,11 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) static inline void pch_spi_select_chip(struct pch_spi_data *data, struct spi_device *pspi) { - if (data->current_chip != NULL) { + if (data->current_chip) if (pspi->chip_select != data->n_curnt_chip) { dev_dbg(&pspi->dev, "%s : different slave\n", __func__); data->current_chip = NULL; } - } data->current_chip = pspi; @@ -583,7 +582,7 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw) /* allocate memory for pkt_tx_buff & pkt_rx_buffer */ data->pkt_tx_buff = kzalloc(size, GFP_KERNEL); - if (data->pkt_tx_buff != NULL) { + if (data->pkt_tx_buff) { data->pkt_rx_buff = kzalloc(size, GFP_KERNEL); if (!data->pkt_rx_buff) kfree(data->pkt_tx_buff); @@ -605,7 +604,7 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw) } /* copy Tx Data */ - if (data->cur_trans->tx_buf != NULL) { + if (data->cur_trans->tx_buf) { if (*bpw == 8) { tx_buf = data->cur_trans->tx_buf; for (j = 0; j < data->bpw_len; j++) @@ -965,7 +964,7 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) } /* copy Tx Data */ - if (data->cur_trans->tx_buf != NULL) { + if (data->cur_trans->tx_buf) { if (*bpw == 8) { tx_buf = data->cur_trans->tx_buf; tx_dma_buf = dma->tx_buf_virt; @@ -1176,7 +1175,7 @@ static void pch_spi_process_messages(struct work_struct *pwork) transfer structure from the message otherwise retrieve the 1st transfer request from the message. */ spin_lock(&data->lock); - if (data->cur_trans == NULL) { + if (!data->cur_trans) { data->cur_trans = list_entry(data->current_msg->transfers.next, struct spi_transfer, transfer_list); @@ -1247,9 +1246,7 @@ static void pch_spi_process_messages(struct work_struct *pwork) } spin_unlock(&data->lock); - - } while (data->cur_trans != NULL); - + } while (data->cur_trans); out: pch_spi_writereg(data->master, PCH_SSNXCR, SSN_HIGH); if (data->use_dma)