Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1558618
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers |
| Date | 2017-01-13 18:30 +0100 |
| Message-ID | <sZdPQ-3DF-19@gated-at.bofh.it> (permalink) |
| References | <sZdwt-3x7-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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)
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/17] SPI: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 01/17] spi: Use kcalloc() in spi_register_board_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:10 +0100
[PATCH 04/17] spi: fsl: Use kmalloc_array() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 07/17] spi/mpc52xx: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 06/17] spi/mpc52xx: Use kmalloc_array() in mpc52xx_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 02/17] spi: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 03/17] spi: fsl: Use kcalloc() in of_fsl_spi_get_chipselects() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 10/17] spi/ppc4xx: Adjust checks for null pointers in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 08/17] spi/ppc4xx: Use kcalloc() in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 09/17] spi/ppc4xx: Combine substrings for a message in spi_ppc4xx_of_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:20 +0100
[PATCH 05/17] spi: fsl: Combine substrings for two messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 17/17] spi/topcliff-pch: One check less in pch_spi_set_tx() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-13 19:20 +0100
[PATCH 12/17] spi/topcliff-pch: Improve size determinations in pch_spi_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
Re: [PATCH 14/17] spi/topcliff-pch: Adjust six checks for null pointers Dan Carpenter <dan.carpenter@oracle.com> - 2017-01-14 07:40 +0100
[PATCH 16/17] spi/topcliff-pch: Delete an error message for a failed memory allocation in pch_spi_set_tx() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 13/17] spi/topcliff-pch: Delete an unnecessary return statement in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 15/17] spi/topcliff-pch: Combine substrings for four messages SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
[PATCH 11/17] spi/topcliff-pch: Use kcalloc() in pch_spi_handle_dma() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-13 18:30 +0100
csiph-web