[PATCH 1/3] staging: kpc2000: simplify comparison to NULL in kpc2000_spi.c

2019-07-04 Thread Simon Sandström
Fixes checkpatch warning "Comparison to NULL could be written [...]".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 009dec2f4641..35ac1d7070b3 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -436,7 +436,7 @@ kp_spi_probe(struct platform_device *pldev)
}
 
master = spi_alloc_master(>dev, sizeof(struct kp_spi));
-   if (master == NULL) {
+   if (!master) {
dev_err(>dev, "%s: master allocation failed\n",
__func__);
return -ENOMEM;
@@ -460,7 +460,7 @@ kp_spi_probe(struct platform_device *pldev)
master->bus_num = pldev->id;
 
r = platform_get_resource(pldev, IORESOURCE_MEM, 0);
-   if (r == NULL) {
+   if (!r) {
dev_err(>dev, "%s: Unable to get platform resources\n",
__func__);
status = -ENODEV;
-- 
2.20.1



[PATCH 3/3] staging: kpc2000: simplify comparison to NULL in fileops.c

2019-07-04 Thread Simon Sandström
Fixes checkpatch warning "Comparison to NULL could be written [...]".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c 
b/drivers/staging/kpc2000/kpc_dma/fileops.c
index 7feb2fde0db2..48ca88bc6b0b 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -247,7 +247,7 @@ int  kpc_dma_open(struct inode *inode, struct file *filp)
struct dev_private_data *priv;
struct kpc_dma_device *ldev = kpc_dma_lookup_device(iminor(inode));
 
-   if (ldev == NULL)
+   if (!ldev)
return -ENODEV;
 
if (!atomic_dec_and_test(>open_count)) {
-- 
2.20.1



[PATCH 2/3] staging: kpc2000: simplify comparison to NULL in dma.c

2019-07-04 Thread Simon Sandström
Fixes checkpatch warning "Comparison to NULL could be written [...]".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc_dma/dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c 
b/drivers/staging/kpc2000/kpc_dma/dma.c
index 8092d0cf4a4a..51a4dd534a0d 100644
--- a/drivers/staging/kpc2000/kpc_dma/dma.c
+++ b/drivers/staging/kpc2000/kpc_dma/dma.c
@@ -119,7 +119,7 @@ int  setup_dma_engine(struct kpc_dma_device *eng, u32 
desc_cnt)
cur = eng->desc_pool_first;
for (i = 1 ; i < eng->desc_pool_cnt ; i++) {
next = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, 
_handle);
-   if (next == NULL)
+   if (!next)
goto done_alloc;
 
clear_desc(next);
@@ -245,7 +245,7 @@ int  count_descriptors_available(struct kpc_dma_device *eng)
 
 void  clear_desc(struct kpc_dma_descriptor *desc)
 {
-   if (desc == NULL)
+   if (!desc)
return;
desc->DescByteCount = 0;
desc->DescStatusErrorFlags  = 0;
-- 
2.20.1



[PATCH 0/3] Simplify NULL comparisons in staging/kpc2000

2019-07-04 Thread Simon Sandström
Hi,

These patches simplifies a few comparisons to NULL ("foo == NULL" =>
"!foo") in staging/kpc2000, as reported by checkpatch.pl.

- Simon

Simon Sandström (3):
  staging: kpc2000: simplify comparison to NULL in kpc2000_spi.c
  staging: kpc2000: simplify comparison to NULL in dma.c
  staging: kpc2000: simplify comparison to NULL in fileops.c

 drivers/staging/kpc2000/kpc2000_spi.c | 4 ++--
 drivers/staging/kpc2000/kpc_dma/dma.c | 4 ++--
 drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.20.1



[PATCH v2] staging: kpc2000: fix brace issues in kpc2000_spi.c

2019-07-01 Thread Simon Sandström
Fixes issues found by checkpatch:

- "WARNING: braces {} are not necessary for single statement blocks"
- "WARNING: braces {} are not necessary for any arm of this statement"

Signed-off-by: Simon Sandström 
---

Changed in v2: rebased.

 drivers/staging/kpc2000/kpc2000_spi.c | 33 ++-
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 021cc859feed..009dec2f4641 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -165,9 +165,9 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
u64 val;
 
addr += idx;
-   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) {
+   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0))
return cs->conf_cache;
-   }
+
val = readq(addr);
return val;
 }
@@ -192,11 +192,10 @@ kp_spi_wait_for_reg_bit(struct kp_spi_controller_state 
*cs, int idx,
timeout = jiffies + msecs_to_jiffies(1000);
while (!(kp_spi_read_reg(cs, idx) & bit)) {
if (time_after(jiffies, timeout)) {
-   if (!(kp_spi_read_reg(cs, idx) & bit)) {
+   if (!(kp_spi_read_reg(cs, idx) & bit))
return -ETIMEDOUT;
-   } else {
+   else
return 0;
-   }
}
cpu_relax();
}
@@ -269,9 +268,8 @@ kp_spi_setup(struct spi_device *spidev)
cs = spidev->controller_state;
if (!cs) {
cs = kzalloc(sizeof(*cs), GFP_KERNEL);
-   if (!cs) {
+   if (!cs)
return -ENOMEM;
-   }
cs->base = kpspi->base;
cs->conf_cache = -1;
spidev->controller_state = cs;
@@ -305,9 +303,8 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
cs = spidev->controller_state;
 
/* reject invalid messages and transfers */
-   if (list_empty(>transfers)) {
+   if (list_empty(>transfers))
return -EINVAL;
-   }
 
/* validate input */
list_for_each_entry(transfer, >transfers, transfer_list) {
@@ -365,17 +362,14 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG);
 
/* ...direction */
-   if (transfer->tx_buf) {
+   if (transfer->tx_buf)
sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_TX;
-   }
-   else if (transfer->rx_buf) {
+   else if (transfer->rx_buf)
sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_RX;
-   }
 
/* ...word length */
-   if (transfer->bits_per_word) {
+   if (transfer->bits_per_word)
word_len = transfer->bits_per_word;
-   }
sc.bitfield.wl = word_len - 1;
 
/* ...chip select */
@@ -394,9 +388,8 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
}
}
 
-   if (transfer->delay_usecs) {
+   if (transfer->delay_usecs)
udelay(transfer->delay_usecs);
-   }
}
 
/* de-assert chip select to end the sequence */
@@ -419,9 +412,8 @@ kp_spi_cleanup(struct spi_device *spidev)
 {
struct kp_spi_controller_state *cs = spidev->controller_state;
 
-   if (cs) {
+   if (cs)
kfree(cs);
-   }
 }
 
 /**
@@ -464,9 +456,8 @@ kp_spi_probe(struct platform_device *pldev)
kpspi->dev = >dev;
 
master->num_chipselect = 4;
-   if (pldev->id != -1) {
+   if (pldev->id != -1)
master->bus_num = pldev->id;
-   }
 
r = platform_get_resource(pldev, IORESOURCE_MEM, 0);
if (r == NULL) {
-- 
2.20.1



[PATCH] staging: kpc2000: fix brace issues in kpc2000_spi.c

2019-06-27 Thread Simon Sandström
Fixes issues found by checkpatch:

- "WARNING: braces {} are not necessary for single statement blocks"
- "WARNING: braces {} are not necessary for any arm of this statement"

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 98484fbb9d2e..76db8e8510df 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -164,9 +164,9 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
u64 val;
 
addr += idx;
-   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) {
+   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0))
return cs->conf_cache;
-   }
+
val = readq(addr);
return val;
 }
@@ -188,11 +188,10 @@ kp_spi_wait_for_reg_bit(struct kp_spi_controller_state 
*cs, int idx, unsigned lo
timeout = jiffies + msecs_to_jiffies(1000);
while (!(kp_spi_read_reg(cs, idx) & bit)) {
if (time_after(jiffies, timeout)) {
-   if (!(kp_spi_read_reg(cs, idx) & bit)) {
+   if (!(kp_spi_read_reg(cs, idx) & bit))
return -ETIMEDOUT;
-   } else {
+   else
return 0;
-   }
}
cpu_relax();
}
@@ -215,9 +214,8 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
for (i = 0 ; i < c ; i++) {
char val = *tx++;
 
-   if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, 
KP_SPI_REG_STATUS_TXS) < 0) {
+   if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, 
KP_SPI_REG_STATUS_TXS) < 0)
goto out;
-   }
 
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val);
processed++;
@@ -229,9 +227,8 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
 
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00);
 
-   if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, 
KP_SPI_REG_STATUS_RXS) < 0) {
+   if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, 
KP_SPI_REG_STATUS_RXS) < 0)
goto out;
-   }
 
test = kp_spi_read_reg(cs, KP_SPI_REG_RXDATA);
*rx++ = test;
@@ -261,9 +258,8 @@ kp_spi_setup(struct spi_device *spidev)
cs = spidev->controller_state;
if (!cs) {
cs = kzalloc(sizeof(*cs), GFP_KERNEL);
-   if (!cs) {
+   if (!cs)
return -ENOMEM;
-   }
cs->base = kpspi->base;
cs->conf_cache = -1;
spidev->controller_state = cs;
@@ -297,9 +293,8 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
cs = spidev->controller_state;
 
/* reject invalid messages and transfers */
-   if (list_empty(>transfers)) {
+   if (list_empty(>transfers))
return -EINVAL;
-   }
 
/* validate input */
list_for_each_entry(transfer, >transfers, transfer_list) {
@@ -353,17 +348,14 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG);
 
/* ...direction */
-   if (transfer->tx_buf) {
+   if (transfer->tx_buf)
sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_TX;
-   }
-   else if (transfer->rx_buf) {
+   else if (transfer->rx_buf)
sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_RX;
-   }
 
/* ...word length */
-   if (transfer->bits_per_word) {
+   if (transfer->bits_per_word)
word_len = transfer->bits_per_word;
-   }
sc.bitfield.wl = word_len - 1;
 
/* ...chip select */
@@ -382,9 +374,8 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
}
}
 
-   if (transfer->delay_usecs) {
+   if (transfer->delay_usecs)
udelay(transfer->delay_usecs);
-   }
}
 
/* de-assert chip select to end the sequence */
@@ -406,9 +397,8 @@ kp_s

[PATCH 4/4] staging: kpc2000: fix brace issues in kpc2000_spi.c

2019-06-25 Thread Simon Sandström
Fixes checkpatch errors: "else should follow close brace '}'" and
"braces {} are not necessary for single statement blocks".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 68b049f9ad69..4b1468137703 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -164,9 +164,9 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
u64 val;
 
addr += idx;
-   if (idx == KP_SPI_REG_CONFIG && cs->conf_cache >= 0) {
+   if (idx == KP_SPI_REG_CONFIG && cs->conf_cache >= 0)
return cs->conf_cache;
-   }
+
val = readq(addr);
return val;
 }
@@ -222,8 +222,7 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val);
processed++;
}
-   }
-   else if (rx) {
+   } else if (rx) {
for (i = 0 ; i < c ; i++) {
char test = 0;
 
@@ -261,9 +260,8 @@ kp_spi_setup(struct spi_device *spidev)
cs = spidev->controller_state;
if (!cs) {
cs = kzalloc(sizeof(*cs), GFP_KERNEL);
-   if (!cs) {
+   if (!cs)
return -ENOMEM;
-   }
cs->base = kpspi->base;
cs->conf_cache = -1;
spidev->controller_state = cs;
-- 
2.20.1



[PATCH 0/4] Minor style issue fixes for staging/kpc2000

2019-06-25 Thread Simon Sandström
Hi,

Here are some fixes for minor space, parenthese and brace issues in
kpc2000 reported by checkpatch.pl.

- Simon

Simon Sandström (4):
  staging: kpc2000: add missing spaces in kpc2000_i2c.c
  staging: kpc2000: add missing spaces in kpc2000_spi.c
  staging: kpc2000: remove unnecessary parentheses in kpc2000_spi.c
  staging: kpc2000: fix brace issues in kpc2000_spi.c

 drivers/staging/kpc2000/kpc2000_i2c.c |  6 +++---
 drivers/staging/kpc2000/kpc2000_spi.c | 18 --
 2 files changed, 11 insertions(+), 13 deletions(-)

-- 
2.20.1



[PATCH 2/4] staging: kpc2000: add missing spaces in kpc2000_spi.c

2019-06-25 Thread Simon Sandström
Fixes checkpatch errors:
- spaces required around that '=' (ctx:VxV)
- space required before the open parenthesis '('
- spaces preferred around that '-' (ctx:VxV)
- space required before the open brace '{'

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index c3e5c1848f53..98484fbb9d2e 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -164,7 +164,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
u64 val;
 
addr += idx;
-   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){
+   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) {
return cs->conf_cache;
}
val = readq(addr);
@@ -223,9 +223,9 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct 
spi_transfer *transfer)
processed++;
}
}
-   else if(rx) {
+   else if (rx) {
for (i = 0 ; i < c ; i++) {
-   char test=0;
+   char test = 0;
 
kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00);
 
@@ -261,7 +261,7 @@ kp_spi_setup(struct spi_device *spidev)
cs = spidev->controller_state;
if (!cs) {
cs = kzalloc(sizeof(*cs), GFP_KERNEL);
-   if(!cs) {
+   if (!cs) {
return -ENOMEM;
}
cs->base = kpspi->base;
@@ -364,7 +364,7 @@ kp_spi_transfer_one_message(struct spi_master *master, 
struct spi_message *m)
if (transfer->bits_per_word) {
word_len = transfer->bits_per_word;
}
-   sc.bitfield.wl = word_len-1;
+   sc.bitfield.wl = word_len - 1;
 
/* ...chip select */
sc.bitfield.cs = spidev->chip_select;
@@ -425,7 +425,7 @@ kp_spi_probe(struct platform_device *pldev)
int i;
 
drvdata = pldev->dev.platform_data;
-   if (!drvdata){
+   if (!drvdata) {
dev_err(>dev, "kp_spi_probe: platform_data is NULL!\n");
return -ENODEV;
}
@@ -476,7 +476,7 @@ kp_spi_probe(struct platform_device *pldev)
spi_new_device(master, &(table[i])); \
}
 
-   switch ((drvdata->card_id & 0x) >> 16){
+   switch ((drvdata->card_id & 0x) >> 16) {
case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0:
NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info);
break;
-- 
2.20.1



[PATCH 1/4] staging: kpc2000: add missing spaces in kpc2000_i2c.c

2019-06-25 Thread Simon Sandström
Fixes checkpatch "CHECK: spaces preferred around that '+' (ctx:VxV)".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_i2c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c 
b/drivers/staging/kpc2000/kpc2000_i2c.c
index 69e8773c1ef8..3e08df9f205d 100644
--- a/drivers/staging/kpc2000/kpc2000_i2c.c
+++ b/drivers/staging/kpc2000/kpc2000_i2c.c
@@ -257,7 +257,7 @@ static int i801_block_transaction_by_block(struct 
i2c_device *priv, union i2c_sm
len = data->block[0];
outb_p(len, SMBHSTDAT0(priv));
for (i = 0; i < len; i++)
-   outb_p(data->block[i+1], SMBBLKDAT(priv));
+   outb_p(data->block[i + 1], SMBBLKDAT(priv));
}
 
status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | 
I801_PEC_EN * hwpec);
@@ -337,8 +337,8 @@ static int i801_block_transaction_byte_by_byte(struct 
i2c_device *priv, union i2
/* Retrieve/store value in SMBBLKDAT */
if (read_write == I2C_SMBUS_READ)
data->block[i] = inb_p(SMBBLKDAT(priv));
-   if (read_write == I2C_SMBUS_WRITE && i+1 <= len)
-   outb_p(data->block[i+1], SMBBLKDAT(priv));
+   if (read_write == I2C_SMBUS_WRITE && i + 1 <= len)
+   outb_p(data->block[i + 1], SMBBLKDAT(priv));
/* signals SMBBLKDAT ready */
outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv));
}
-- 
2.20.1



[PATCH 3/4] staging: kpc2000: remove unnecessary parentheses in kpc2000_spi.c

2019-06-25 Thread Simon Sandström
Fixes checkpatch "CHECK: Unnecessary parentheses around '...'".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c 
b/drivers/staging/kpc2000/kpc2000_spi.c
index 98484fbb9d2e..68b049f9ad69 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -164,7 +164,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
u64 val;
 
addr += idx;
-   if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) {
+   if (idx == KP_SPI_REG_CONFIG && cs->conf_cache >= 0) {
return cs->conf_cache;
}
val = readq(addr);
-- 
2.20.1



[PATCH] staging: kpc2000: simplify error handling in kp2000_pcie_probe

2019-06-19 Thread Simon Sandström
We can get rid of a few iounmaps in the middle of the function by
re-ordering the error handling labels and adding two new labels.

Signed-off-by: Simon Sandström 
---

This change has not been tested besides by compiling. It might be good
took take an extra look to make sure that I got everything right.

Also, this change was proposed by Dan Carpenter. Should I add anything
in the commit message to show this?

- Simon

 drivers/staging/kpc2000/kpc2000/core.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 610ea549d240..cb05cca687e1 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -351,12 +351,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 
err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000);
if (err) {
-   iounmap(pcard->regs_bar_base);
dev_err(>pdev->dev,
"probe: failed to acquire PCI region (%d)\n",
err);
err = -ENODEV;
-   goto err_disable_device;
+   goto err_unmap_regs;
}
 
pcard->regs_base_resource.start = reg_bar_phys_addr;
@@ -374,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: DMA_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
-   goto err_unmap_regs;
+   goto err_release_regs;
}
dev_dbg(>pdev->dev,
"probe: DMA_BAR virt hardware address start [%p]\n",
@@ -384,11 +383,10 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 
err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie");
if (err) {
-   iounmap(pcard->dma_bar_base);
dev_err(>pdev->dev,
"probe: failed to acquire PCI region (%d)\n", err);
err = -ENODEV;
-   goto err_unmap_regs;
+   goto err_unmap_dma;
}
 
pcard->dma_base_resource.start = dma_bar_phys_addr;
@@ -400,7 +398,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pcard->sysinfo_regs_base = pcard->regs_bar_base;
err = read_system_regs(pcard);
if (err)
-   goto err_unmap_dma;
+   goto err_release_dma;
 
// Disable all "user" interrupts because they're not used yet.
writeq(0x,
@@ -438,14 +436,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
if (err) {
dev_err(>pdev->dev,
"CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64));
-   goto err_unmap_dma;
+   goto err_release_dma;
}
dev_dbg(>pdev->dev,
"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));
 
err = pci_enable_msi(pcard->pdev);
if (err < 0)
-   goto err_unmap_dma;
+   goto err_release_dma;
 
rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED,
 pcard->name, pcard);
@@ -478,14 +476,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
free_irq(pcard->pdev->irq, pcard);
 err_disable_msi:
pci_disable_msi(pcard->pdev);
+err_release_dma:
+   pci_release_region(pdev, DMA_BAR);
 err_unmap_dma:
iounmap(pcard->dma_bar_base);
-   pci_release_region(pdev, DMA_BAR);
-   pcard->dma_bar_base = NULL;
+err_release_regs:
+   pci_release_region(pdev, REG_BAR);
 err_unmap_regs:
iounmap(pcard->regs_bar_base);
-   pci_release_region(pdev, REG_BAR);
-   pcard->regs_bar_base = NULL;
 err_disable_device:
pci_disable_device(pcard->pdev);
 err_remove_ida:
-- 
2.20.1



[PATCH] staging: kpc2000: remove dead code in core.c

2019-06-13 Thread Simon Sandström
Fixes checkpatch warning: "Consider removing the code enclosed by
this #if 0 and its #endif".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 6a5999e8ff4e..610ea549d240 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -223,15 +223,9 @@ static void wait_and_read_ssid(struct kp2000_device *pcard)
 
dev_notice(>pdev->dev, "SSID didn't show up!\n");
 
-#if 0
-   // Timed out waiting for the SSID to show up, just use the DDNA instead?
-   read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA);
-   pcard->ssid = read_val;
-#else
// Timed out waiting for the SSID to show up, stick all zeros in the
// value
pcard->ssid = 0;
-#endif
 }
 
 static int  read_system_regs(struct kp2000_device *pcard)
-- 
2.20.1



[PATCH v2 0/2] staging: kpc2000: minor fixes in kp2000_pcie_probe

2019-06-12 Thread Simon Sandström
These two patches fixes issues pointed out by Dan in a previous
staging/kpc2000 patch thread: many comments in kp2000_pcie_probe just
repeats the code and the current label names doesn't add any information
and makes it hard to follow the code.

Rename all labels and remove the comments that just repeats the code.

Version 2:
 - Don't convert C style comments to C++ style

Simon Sandström (2):
  staging: kpc2000: improve label names in kp2000_pcie_probe
  staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe

 drivers/staging/kpc2000/kpc2000/core.c | 80 --
 1 file changed, 25 insertions(+), 55 deletions(-)

-- 
2.20.1



[PATCH v2 1/2] staging: kpc2000: improve label names in kp2000_pcie_probe

2019-06-12 Thread Simon Sandström
Use self-explanatory label names instead of the generic numbered ones,
to make it easier to follow and understand the code.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 9b9b29ac90c5..ee6b9be7127d 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -327,7 +327,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
if (err < 0) {
dev_err(>dev, "probe: failed to get card number (%d)\n",
err);
-   goto out2;
+   goto err_free_pcard;
}
pcard->card_num = err;
scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num);
@@ -346,7 +346,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: failed to enable PCIE2000 PCIe device (%d)\n",
err);
-   goto out3;
+   goto err_remove_ida;
}
 
/*
@@ -360,7 +360,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: REG_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
-   goto out4;
+   goto err_disable_device;
}
dev_dbg(>pdev->dev,
"probe: REG_BAR virt hardware address start [%p]\n",
@@ -373,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
"probe: failed to acquire PCI region (%d)\n",
err);
err = -ENODEV;
-   goto out4;
+   goto err_disable_device;
}
 
pcard->regs_base_resource.start = reg_bar_phys_addr;
@@ -393,7 +393,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: DMA_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
-   goto out5;
+   goto err_unmap_regs;
}
dev_dbg(>pdev->dev,
"probe: DMA_BAR virt hardware address start [%p]\n",
@@ -407,7 +407,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: failed to acquire PCI region (%d)\n", err);
err = -ENODEV;
-   goto out5;
+   goto err_unmap_regs;
}
 
pcard->dma_base_resource.start = dma_bar_phys_addr;
@@ -421,7 +421,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pcard->sysinfo_regs_base = pcard->regs_bar_base;
err = read_system_regs(pcard);
if (err)
-   goto out6;
+   goto err_unmap_dma;
 
// Disable all "user" interrupts because they're not used yet.
writeq(0x,
@@ -461,7 +461,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
if (err) {
dev_err(>pdev->dev,
"CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64));
-   goto out7;
+   goto err_unmap_dma;
}
dev_dbg(>pdev->dev,
"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));
@@ -471,14 +471,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 */
err = pci_enable_msi(pcard->pdev);
if (err < 0)
-   goto out8a;
+   goto err_unmap_dma;
 
rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED,
 pcard->name, pcard);
if (rv) {
dev_err(>pdev->dev,
"%s: failed to request_irq: %d\n", __func__, rv);
-   goto out8b;
+   goto err_disable_msi;
}
 
/*
@@ -487,7 +487,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
err = sysfs_create_files(>dev.kobj, kp_attr_list);
if (err) {
dev_err(>dev, "Failed to add sysfs files: %d\n", err);
-   goto out9;
+   goto err_free_irq;
}
 
/*
@@ -495,7 +495,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 */
err = kp2000_probe_cores(pcard);
if (err)
-   goto out10;
+   goto err_remove_sysfs;
 
/*
 * Step 11: Enable IRQs in HW
@@ -506,28 +506,26 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
mutex_unlock(>sem);
return 0;
 
-out10:
+err_remove_sysfs:
sysfs_remove_files(>dev.kobj, kp_attr_list);
-out9:
+err_free_irq:
 

[PATCH v2 2/2] staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe

2019-06-12 Thread Simon Sandström
Much of the code comments in kp2000_pcie_probe just repeats the code and
does not add any additional information. Delete them and make sure that
comments still left in the function all use the same style.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 38 --
 1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index ee6b9be7127d..6a5999e8ff4e 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -311,18 +311,12 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
unsigned long dma_bar_phys_len;
u16 regval;
 
-   /*
-* Step 1: Allocate a struct for the pcard
-*/
pcard = kzalloc(sizeof(*pcard), GFP_KERNEL);
if (!pcard)
return -ENOMEM;
dev_dbg(>dev, "probe: allocated struct kp2000_device @ %p\n",
pcard);
 
-   /*
-* Step 2: Initialize trivial pcard elements
-*/
err = ida_simple_get(_num_ida, 1, INT_MAX, GFP_KERNEL);
if (err < 0) {
dev_err(>dev, "probe: failed to get card number (%d)\n",
@@ -338,9 +332,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pcard->pdev = pdev;
pci_set_drvdata(pdev, pcard);
 
-   /*
-* Step 3: Enable PCI device
-*/
err = pci_enable_device(pcard->pdev);
if (err) {
dev_err(>pdev->dev,
@@ -349,9 +340,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
goto err_remove_ida;
}
 
-   /*
-* Step 4: Setup the Register BAR
-*/
+   /* Setup the Register BAR */
reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR);
reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR);
 
@@ -381,9 +370,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
  reg_bar_phys_len - 1;
pcard->regs_base_resource.flags = IORESOURCE_MEM;
 
-   /*
-* Step 5: Setup the DMA BAR
-*/
+   /* Setup the DMA BAR */
dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR);
dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR);
 
@@ -415,9 +402,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 dma_bar_phys_len - 1;
pcard->dma_base_resource.flags = IORESOURCE_MEM;
 
-   /*
-* Step 6: System Regs
-*/
+   /* Read System Regs */
pcard->sysinfo_regs_base = pcard->regs_bar_base;
err = read_system_regs(pcard);
if (err)
@@ -427,11 +412,9 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
writeq(0x,
   pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 
-   /*
-* Step 7: Configure PCI thingies
-*/
// let the card master PCIe
pci_set_master(pcard->pdev);
+
// enable IO and mem if not already done
pci_read_config_word(pcard->pdev, PCI_COMMAND, );
regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
@@ -466,9 +449,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_dbg(>pdev->dev,
"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));
 
-   /*
-* Step 8: Configure IRQs
-*/
err = pci_enable_msi(pcard->pdev);
if (err < 0)
goto err_unmap_dma;
@@ -481,25 +461,17 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
goto err_disable_msi;
}
 
-   /*
-* Step 9: Setup sysfs attributes
-*/
err = sysfs_create_files(>dev.kobj, kp_attr_list);
if (err) {
dev_err(>dev, "Failed to add sysfs files: %d\n", err);
goto err_free_irq;
}
 
-   /*
-* Step 10: Probe cores
-*/
err = kp2000_probe_cores(pcard);
if (err)
goto err_remove_sysfs;
 
-   /*
-* Step 11: Enable IRQs in HW
-*/
+   /* Enable IRQs in HW */
writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
   pcard->dma_common_regs);
 
-- 
2.20.1



Re: [PATCH 2/2] staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe

2019-06-12 Thread Simon Sandström
On 12/06, Greg KH wrote:
> On Wed, Jun 12, 2019 at 10:39:36AM +0300, Dan Carpenter wrote:
> > On Mon, Jun 10, 2019 at 10:05:35PM +0200, Simon Sandström wrote:
> > > @@ -349,9 +340,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
> > >   goto err_remove_ida;
> > >   }
> > >  
> > > - /*
> > > -  * Step 4: Setup the Register BAR
> > > -  */
> > > + // Setup the Register BAR
> > 
> > Greg, are we moving the C++ style comments?  Linus is fine with them.  I
> > don't like them but whatever...
> 
> I don't like them either.  I'm only "ok" with them on the very first
> line of the file.  Linus chose // to make it "stand out" from the normal
> flow of the file, which is fine for an SPDX line.  So putting these in
> here like this is not ok to me.
> 
> thanks,
> 
> greg k-h

I changed them to C++ style so that they would match the other comments
in the file, which are C++ style, but I guess that it should have been
done the other way around with the C++ style changed to C style.

Good to know. I'll change them back and send a v2.

- Simon


[PATCH 2/2] staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe

2019-06-10 Thread Simon Sandström
Much of the code comments in kp2000_pcie_probe just repeats the code and
does not add any additional information. Delete them and make sure that
comments still left in the function all use the same style.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 38 --
 1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index ee6b9be7127d..7ec54b672c20 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -311,18 +311,12 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
unsigned long dma_bar_phys_len;
u16 regval;
 
-   /*
-* Step 1: Allocate a struct for the pcard
-*/
pcard = kzalloc(sizeof(*pcard), GFP_KERNEL);
if (!pcard)
return -ENOMEM;
dev_dbg(>dev, "probe: allocated struct kp2000_device @ %p\n",
pcard);
 
-   /*
-* Step 2: Initialize trivial pcard elements
-*/
err = ida_simple_get(_num_ida, 1, INT_MAX, GFP_KERNEL);
if (err < 0) {
dev_err(>dev, "probe: failed to get card number (%d)\n",
@@ -338,9 +332,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pcard->pdev = pdev;
pci_set_drvdata(pdev, pcard);
 
-   /*
-* Step 3: Enable PCI device
-*/
err = pci_enable_device(pcard->pdev);
if (err) {
dev_err(>pdev->dev,
@@ -349,9 +340,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
goto err_remove_ida;
}
 
-   /*
-* Step 4: Setup the Register BAR
-*/
+   // Setup the Register BAR
reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR);
reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR);
 
@@ -381,9 +370,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
  reg_bar_phys_len - 1;
pcard->regs_base_resource.flags = IORESOURCE_MEM;
 
-   /*
-* Step 5: Setup the DMA BAR
-*/
+   // Setup the DMA BAR
dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR);
dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR);
 
@@ -415,9 +402,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 dma_bar_phys_len - 1;
pcard->dma_base_resource.flags = IORESOURCE_MEM;
 
-   /*
-* Step 6: System Regs
-*/
+   // Read System Regs
pcard->sysinfo_regs_base = pcard->regs_bar_base;
err = read_system_regs(pcard);
if (err)
@@ -427,11 +412,9 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
writeq(0x,
   pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
 
-   /*
-* Step 7: Configure PCI thingies
-*/
// let the card master PCIe
pci_set_master(pcard->pdev);
+
// enable IO and mem if not already done
pci_read_config_word(pcard->pdev, PCI_COMMAND, );
regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
@@ -466,9 +449,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_dbg(>pdev->dev,
"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));
 
-   /*
-* Step 8: Configure IRQs
-*/
err = pci_enable_msi(pcard->pdev);
if (err < 0)
goto err_unmap_dma;
@@ -481,25 +461,17 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
goto err_disable_msi;
}
 
-   /*
-* Step 9: Setup sysfs attributes
-*/
err = sysfs_create_files(>dev.kobj, kp_attr_list);
if (err) {
dev_err(>dev, "Failed to add sysfs files: %d\n", err);
goto err_free_irq;
}
 
-   /*
-* Step 10: Probe cores
-*/
err = kp2000_probe_cores(pcard);
if (err)
goto err_remove_sysfs;
 
-   /*
-* Step 11: Enable IRQs in HW
-*/
+   // Enable IRQs in HW
writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
   pcard->dma_common_regs);
 
-- 
2.20.1



[PATCH 1/2] staging: kpc2000: improve label names in kp2000_pcie_probe

2019-06-10 Thread Simon Sandström
Use self-explanatory label names instead of the generic numbered ones,
to make it easier to follow and understand the code.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 9b9b29ac90c5..ee6b9be7127d 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -327,7 +327,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
if (err < 0) {
dev_err(>dev, "probe: failed to get card number (%d)\n",
err);
-   goto out2;
+   goto err_free_pcard;
}
pcard->card_num = err;
scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num);
@@ -346,7 +346,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: failed to enable PCIE2000 PCIe device (%d)\n",
err);
-   goto out3;
+   goto err_remove_ida;
}
 
/*
@@ -360,7 +360,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: REG_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
-   goto out4;
+   goto err_disable_device;
}
dev_dbg(>pdev->dev,
"probe: REG_BAR virt hardware address start [%p]\n",
@@ -373,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
"probe: failed to acquire PCI region (%d)\n",
err);
err = -ENODEV;
-   goto out4;
+   goto err_disable_device;
}
 
pcard->regs_base_resource.start = reg_bar_phys_addr;
@@ -393,7 +393,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: DMA_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
-   goto out5;
+   goto err_unmap_regs;
}
dev_dbg(>pdev->dev,
"probe: DMA_BAR virt hardware address start [%p]\n",
@@ -407,7 +407,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
dev_err(>pdev->dev,
"probe: failed to acquire PCI region (%d)\n", err);
err = -ENODEV;
-   goto out5;
+   goto err_unmap_regs;
}
 
pcard->dma_base_resource.start = dma_bar_phys_addr;
@@ -421,7 +421,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
pcard->sysinfo_regs_base = pcard->regs_bar_base;
err = read_system_regs(pcard);
if (err)
-   goto out6;
+   goto err_unmap_dma;
 
// Disable all "user" interrupts because they're not used yet.
writeq(0x,
@@ -461,7 +461,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
if (err) {
dev_err(>pdev->dev,
"CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64));
-   goto out7;
+   goto err_unmap_dma;
}
dev_dbg(>pdev->dev,
"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));
@@ -471,14 +471,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 */
err = pci_enable_msi(pcard->pdev);
if (err < 0)
-   goto out8a;
+   goto err_unmap_dma;
 
rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED,
 pcard->name, pcard);
if (rv) {
dev_err(>pdev->dev,
"%s: failed to request_irq: %d\n", __func__, rv);
-   goto out8b;
+   goto err_disable_msi;
}
 
/*
@@ -487,7 +487,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
err = sysfs_create_files(>dev.kobj, kp_attr_list);
if (err) {
dev_err(>dev, "Failed to add sysfs files: %d\n", err);
-   goto out9;
+   goto err_free_irq;
}
 
/*
@@ -495,7 +495,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 */
err = kp2000_probe_cores(pcard);
if (err)
-   goto out10;
+   goto err_remove_sysfs;
 
/*
 * Step 11: Enable IRQs in HW
@@ -506,28 +506,26 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
mutex_unlock(>sem);
return 0;
 
-out10:
+err_remove_sysfs:
sysfs_remove_files(>dev.kobj, kp_attr_list);
-out9:
+err_free_irq:
 

[PATCH 0/2] staging: kpc2000: minor fixes in kp2000_pcie_probe

2019-06-10 Thread Simon Sandström
These two patches fixes issues pointed out by Dan in a previous
staging/kpc2000 patch thread: many comments in kp2000_pcie_probe just
repeats the code and the current label names doesn't add any information
and makes it hard to follow the code.

Rename all labels and remove the comments that just repeats the code.

Simon Sandström (2):
  staging: kpc2000: improve label names in kp2000_pcie_probe
  staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe

 drivers/staging/kpc2000/kpc2000/core.c | 80 --
 1 file changed, 25 insertions(+), 55 deletions(-)

-- 
2.20.1



[PATCH 2/5] staging: kpc2000: remove unnecessary debug prints in core.c

2019-06-10 Thread Simon Sandström
Debug prints that are used only to inform about function entry or exit
can be removed as ftrace can be used to get this information.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 93e381198b45..9b9b29ac90c5 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -311,9 +311,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
unsigned long dma_bar_phys_len;
u16 regval;
 
-   dev_dbg(>dev, "%s(pdev = [%p], id = [%p])\n",
-   __func__, pdev, id);
-
/*
 * Step 1: Allocate a struct for the pcard
 */
@@ -506,7 +503,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
   pcard->dma_common_regs);
 
-   dev_dbg(>pdev->dev, "%s() complete!\n", __func__);
mutex_unlock(>sem);
return 0;
 
@@ -540,8 +536,6 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
 {
struct kp2000_device *pcard = pci_get_drvdata(pdev);
 
-   dev_dbg(>dev, "%s(pdev=%p)\n", __func__, pdev);
-
if (!pcard)
return;
 
-- 
2.20.1



[PATCH 3/5] staging: kpc2000: remove unnecessary debug prints in dma.c

2019-06-10 Thread Simon Sandström
Debug prints that are used only to inform about function entry or exit
can be removed as ftrace can be used to get this information.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc_dma/dma.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c 
b/drivers/staging/kpc2000/kpc_dma/dma.c
index 059932ab5907..8092d0cf4a4a 100644
--- a/drivers/staging/kpc2000/kpc_dma/dma.c
+++ b/drivers/staging/kpc2000/kpc_dma/dma.c
@@ -92,8 +92,6 @@ int  setup_dma_engine(struct kpc_dma_device *eng, u32 
desc_cnt)
unsigned int i;
int rv;
 
-   dev_dbg(>pldev->dev, "Setting up DMA engine [%p]\n", eng);
-
caps = GetEngineCapabilities(eng);
 
if (WARN(!(caps & ENG_CAP_PRESENT), "%s() called for DMA Engine at %p 
which isn't present in hardware!\n", __func__, eng))
@@ -161,8 +159,6 @@ void  stop_dma_engine(struct kpc_dma_device *eng)
 {
unsigned long timeout;
 
-   dev_dbg(>pldev->dev, "Destroying DMA engine [%p]\n", eng);
-
// Disable the descriptor engine
WriteEngineControl(eng, 0);
 
-- 
2.20.1



[PATCH 1/5] staging: kpc2000: remove unnecessary debug prints in cell_probe.c

2019-06-10 Thread Simon Sandström
Debug prints that are used only to inform about function entry or exit
can be removed as ftrace can be used to get this information.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index f731a97c6cac..138d16bcf6e1 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -344,8 +344,6 @@ static int  create_dma_engine_core(struct kp2000_device 
*pcard, size_t engine_re
struct mfd_cell  cell = { .id = engine_num };
struct resource  resources[2];
 
-   dev_dbg(>pdev->dev, "create_dma_core(pcard = [%p], 
engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, 
engine_num);
-
cell.platform_data = NULL;
cell.pdata_size = 0;
cell.name = KP_DRIVER_NAME_DMA_CONTROLLER;
@@ -414,9 +412,6 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
unsigned int highest_core_id = 0;
struct core_table_entry cte;
 
-   dev_dbg(>pdev->dev, "%s(pcard = %p / %d)\n", __func__, pcard,
-   pcard->card_num);
-
err = kp2000_setup_dma_controller(pcard);
if (err)
return err;
-- 
2.20.1



[PATCH 4/5] staging: kpc2000: remove unnecessary debug prints in fileops.c

2019-06-10 Thread Simon Sandström
Debug prints that are used only to inform about function entry or exit
can be removed as ftrace can be used to get this information.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc_dma/fileops.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c 
b/drivers/staging/kpc2000/kpc_dma/fileops.c
index fdec1ab25dfd..f80b01715d93 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -54,8 +54,6 @@ int  kpc_dma_transfer(struct dev_private_data *priv, struct 
kiocb *kcb, unsigned
ldev = priv->ldev;
BUG_ON(ldev == NULL);
 
-   dev_dbg(>ldev->pldev->dev, "%s(priv = [%p], kcb = [%p], iov_base 
= [%p], iov_len = %zu) ldev = [%p]\n", __func__, priv, kcb, (void *)iov_base, 
iov_len, ldev);
-
acd = kzalloc(sizeof(*acd), GFP_KERNEL);
if (!acd) {
dev_err(>ldev->pldev->dev, "Couldn't kmalloc space for 
for the aio data\n");
@@ -218,8 +216,6 @@ void  transfer_complete_cb(struct aio_cb_data *acd, size_t 
xfr_count, u32 flags)
BUG_ON(acd->ldev == NULL);
BUG_ON(acd->ldev->pldev == NULL);
 
-   dev_dbg(>ldev->pldev->dev, "%s(acd = [%p])\n", __func__, acd);
-
for (i = 0 ; i < acd->page_count ; i++) {
if (!PageReserved(acd->user_pages[i])) {
set_page_dirty(acd->user_pages[i]);
@@ -275,7 +271,6 @@ int  kpc_dma_open(struct inode *inode, struct file *filp)
priv->ldev = ldev;
filp->private_data = priv;
 
-   dev_dbg(>ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = 
[%p] ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev);
return 0;
 }
 
@@ -286,8 +281,6 @@ int  kpc_dma_close(struct inode *inode, struct file *filp)
struct dev_private_data *priv = (struct dev_private_data 
*)filp->private_data;
struct kpc_dma_device *eng = priv->ldev;
 
-   dev_dbg(>ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = 
[%p], ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev);
-
lock_engine(eng);
 
stop_dma_engine(eng);
@@ -330,8 +323,6 @@ ssize_t   kpc_dma_aio_read(struct kiocb *kcb, const struct 
iovec *iov, unsigned
 {
struct dev_private_data *priv = (struct dev_private_data 
*)kcb->ki_filp->private_data;
 
-   dev_dbg(>ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count 
= %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, 
pos, priv, priv->ldev);
-
if (priv->ldev->dir != DMA_FROM_DEVICE)
return -EMEDIUMTYPE;
 
@@ -350,8 +341,6 @@ ssize_t  kpc_dma_aio_write(struct kiocb *kcb, const struct 
iovec *iov, unsigned
 {
struct dev_private_data *priv = (struct dev_private_data 
*)kcb->ki_filp->private_data;
 
-   dev_dbg(>ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count 
= %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, 
pos, priv, priv->ldev);
-
if (priv->ldev->dir != DMA_TO_DEVICE)
return -EMEDIUMTYPE;
 
@@ -371,8 +360,6 @@ ssize_t  kpc_dma_read(struct file *filp,   char __user 
*user_buf, size_t cou
 {
struct dev_private_data *priv = (struct dev_private_data 
*)filp->private_data;
 
-   dev_dbg(>ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], 
count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, 
user_buf, count, ppos, priv, priv->ldev);
-
if (priv->ldev->dir != DMA_FROM_DEVICE)
return -EMEDIUMTYPE;
 
@@ -384,8 +371,6 @@ ssize_t  kpc_dma_write(struct file *filp, const char __user 
*user_buf, size_t co
 {
struct dev_private_data *priv = (struct dev_private_data 
*)filp->private_data;
 
-   dev_dbg(>ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], 
count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, 
user_buf, count, ppos, priv, priv->ldev);
-
if (priv->ldev->dir != DMA_TO_DEVICE)
return -EMEDIUMTYPE;
 
@@ -397,8 +382,6 @@ long  kpc_dma_ioctl(struct file *filp, unsigned int 
ioctl_num, unsigned long ioc
 {
struct dev_private_data *priv = (struct dev_private_data 
*)filp->private_data;
 
-   dev_dbg(>ldev->pldev->dev, "%s(filp = [%p], ioctl_num = 0x%x, 
ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", __func__, filp, ioctl_num, 
ioctl_param, priv, priv->ldev);
-
switch (ioctl_num) {
case KND_IOCTL_SET_CARD_ADDR:
priv->card_addr  = ioctl_param; return priv->card_addr;
-- 
2.20.1



[PATCH 5/5] staging: kpc2000: remove unnecessary debug prints in kpc_dma_driver.c

2019-06-10 Thread Simon Sandström
Debug prints that are used only to inform about function entry or exit
can be removed as ftrace can be used to get this information.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c 
b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c
index 9acf1eafa024..4b854027e60a 100644
--- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c
+++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c
@@ -106,8 +106,6 @@ int  kpc_dma_probe(struct platform_device *pldev)
goto err_rv;
}
 
-   dev_dbg(>dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, pldev, 
ldev);
-
INIT_LIST_HEAD(>list);
 
ldev->pldev = pldev;
@@ -183,8 +181,6 @@ int  kpc_dma_remove(struct platform_device *pldev)
if (!ldev)
return -ENXIO;
 
-   dev_dbg(>pldev->dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, 
pldev, ldev);
-
lock_engine(ldev);
sysfs_remove_files(&(ldev->pldev->dev.kobj), ndd_attr_list);
destroy_dma_engine(ldev);
-- 
2.20.1



[PATCH 0/5] staging: kpc2000: remove unnecessary debug prints

2019-06-10 Thread Simon Sandström
These patches removes unnecessary debug prints in staging/kpc2000.
Debug prints that just informs about function entry or exit can be
removed as ftrace can be used to get this information.

Simon Sandström (5):
  staging: kpc2000: remove unnecessary debug prints in cell_probe.c
  staging: kpc2000: remove unnecessary debug prints in core.c
  staging: kpc2000: remove unnecessary debug prints in dma.c
  staging: kpc2000: remove unnecessary debug prints in fileops.c
  staging: kpc2000: remove unnecessary debug prints in kpc_dma_driver.c

 drivers/staging/kpc2000/kpc2000/cell_probe.c|  5 -
 drivers/staging/kpc2000/kpc2000/core.c  |  6 --
 drivers/staging/kpc2000/kpc_dma/dma.c   |  4 
 drivers/staging/kpc2000/kpc_dma/fileops.c   | 17 -
 .../staging/kpc2000/kpc_dma/kpc_dma_driver.c|  4 
 5 files changed, 36 deletions(-)

-- 
2.20.1



Re: [PATCH 4/7] staging: kpc2000: use __func__ in debug messages in core.c

2019-06-10 Thread Simon Sandström
On 06/06, Greg KH wrote:
> On Tue, Jun 04, 2019 at 12:29:13AM +0200, Simon Sandström wrote:
> >  
> > -   dev_dbg(>dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n",
> > -   pdev, id);
> > +   dev_dbg(>dev, "%s(pdev = [%p], id = [%p])\n",
> > +   __func__, pdev, id);
> 
> debugging lines that say "called this function!" can all be removed, as
> we have ftrace in the kernel tree, we can use that instead.  I'll take
> this, but feel free to clean them up as follow-on patches.
> 
> thanks,
> 
> greg k-h

Can they be removed even if they print function arguments or other
variables?

- Simon


[PATCH 4/7] staging: kpc2000: use __func__ in debug messages in core.c

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using
'', this function's name, in a string".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index a70665a202c3..6d4fc1f37c9f 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -312,8 +312,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
unsigned long dma_bar_phys_len;
u16 regval;
 
-   dev_dbg(>dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n",
-   pdev, id);
+   dev_dbg(>dev, "%s(pdev = [%p], id = [%p])\n",
+   __func__, pdev, id);
 
/*
 * Step 1: Allocate a struct for the pcard
@@ -481,7 +481,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 pcard->name, pcard);
if (rv) {
dev_err(>pdev->dev,
-   "kp2000_pcie_probe: failed to request_irq: %d\n", rv);
+   "%s: failed to request_irq: %d\n", __func__, rv);
goto out8b;
}
 
@@ -507,7 +507,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
   pcard->dma_common_regs);
 
-   dev_dbg(>pdev->dev, "kp2000_pcie_probe() complete!\n");
+   dev_dbg(>pdev->dev, "%s() complete!\n", __func__);
mutex_unlock(>sem);
return 0;
 
@@ -541,7 +541,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
 {
struct kp2000_device *pcard = pci_get_drvdata(pdev);
 
-   dev_dbg(>dev, "kp2000_pcie_remove(pdev=%p)\n", pdev);
+   dev_dbg(>dev, "%s(pdev=%p)\n", __func__, pdev);
 
if (!pcard)
return;
-- 
2.20.1



[PATCH 6/7] staging: kpc2000: use sizeof(var) in kzalloc call

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer kzalloc(sizeof(*pcard)...) over
kzalloc(sizeof(struct kp2000_device)...)".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 3f17566a9d03..2d8d188624f7 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -317,7 +317,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
/*
 * Step 1: Allocate a struct for the pcard
 */
-   pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);
+   pcard = kzalloc(sizeof(*pcard), GFP_KERNEL);
if (!pcard)
return -ENOMEM;
dev_dbg(>dev, "probe: allocated struct kp2000_device @ %p\n",
-- 
2.20.1



[PATCH 3/7] staging: kpc2000: remove unnecessary oom message in core.c

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl warning "Possible unnecessary 'out of memory'
message".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index dc6940e6c320..a70665a202c3 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -319,11 +319,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 * Step 1: Allocate a struct for the pcard
 */
pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);
-   if (!pcard) {
-   dev_err(>dev,
-   "probe: failed to allocate private card data\n");
+   if (!pcard)
return -ENOMEM;
-   }
dev_dbg(>dev, "probe: allocated struct kp2000_device @ %p\n",
pcard);
 
-- 
2.20.1



[PATCH 7/7] staging: kpc2000: fix incorrect code comment in core.c

2019-06-03 Thread Simon Sandström
Step 11 was removed from kp2000_pcie_probe in a previous commit but the
comment was not changed to reflect this, so do it now.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 2d8d188624f7..cd3876f1ce17 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -501,7 +501,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
goto out10;
 
/*
-* Step 12: Enable IRQs in HW
+* Step 11: Enable IRQs in HW
 */
writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
   pcard->dma_common_regs);
-- 
2.20.1



[PATCH 0/7] staging: kpc2000: various minor checkpatch fixes

2019-06-03 Thread Simon Sandström
Here is a bunch of checkpatch fixes for core.c in staging/kpc2000.

Some of these were sent earlier but not applied. Now rebased on top of
staging-testing (incl. Jeremy's kpc2000 misc device removal commits).


- Simon

Simon Sandström (7):
  staging: kpc2000: simplify comparisons to NULL in core.c
  staging: kpc2000: remove unnecessary parentheses in core.c
  staging: kpc2000: remove unnecessary oom message in core.c
  staging: kpc2000: use __func__ in debug messages in core.c
  staging: kpc2000: remove unnecessary include in core.c
  staging: kpc2000: use sizeof(var) in kzalloc call
  staging: kpc2000: fix incorrect code comment in core.c

 drivers/staging/kpc2000/kpc2000/core.c | 36 --
 1 file changed, 16 insertions(+), 20 deletions(-)

-- 
2.20.1



[PATCH 1/7] staging: kpc2000: simplify comparisons to NULL in core.c

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl warnings "Comparison to NULL could be written [...]"
and "Comparisons should place the constant on the right side of the
test".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 7f257c21e0cc..356a272c0b9c 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -319,7 +319,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 * Step 1: Allocate a struct for the pcard
 */
pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);
-   if (NULL == pcard) {
+   if (!pcard) {
dev_err(>dev,
"probe: failed to allocate private card data\n");
return -ENOMEM;
@@ -363,7 +363,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR);
 
pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE);
-   if (NULL == pcard->regs_bar_base) {
+   if (!pcard->regs_bar_base) {
dev_err(>pdev->dev,
"probe: REG_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
@@ -396,7 +396,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
 
pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr,
  dma_bar_phys_len);
-   if (NULL == pcard->dma_bar_base) {
+   if (!pcard->dma_bar_base) {
dev_err(>pdev->dev,
"probe: DMA_BAR could not remap memory to virtual 
space\n");
err = -ENODEV;
@@ -546,7 +546,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
 
dev_dbg(>dev, "kp2000_pcie_remove(pdev=%p)\n", pdev);
 
-   if (pcard == NULL)
+   if (!pcard)
return;
 
mutex_lock(>sem);
@@ -555,12 +555,12 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
free_irq(pcard->pdev->irq, pcard);
pci_disable_msi(pcard->pdev);
-   if (pcard->dma_bar_base != NULL) {
+   if (pcard->dma_bar_base) {
iounmap(pcard->dma_bar_base);
pci_release_region(pdev, DMA_BAR);
pcard->dma_bar_base = NULL;
}
-   if (pcard->regs_bar_base != NULL) {
+   if (pcard->regs_bar_base) {
iounmap(pcard->regs_bar_base);
pci_release_region(pdev, REG_BAR);
pcard->regs_bar_base = NULL;
-- 
2.20.1



[PATCH 5/7] staging: kpc2000: remove unnecessary include in core.c

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl warning "Use #include  instead of
".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 6d4fc1f37c9f..3f17566a9d03 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.20.1



[PATCH 2/7] staging: kpc2000: remove unnecessary parentheses in core.c

2019-06-03 Thread Simon Sandström
Fixes checkpatch.pl check "Unnecessary parentheses around
pdev->dev.kobj".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 356a272c0b9c..dc6940e6c320 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -491,7 +491,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
/*
 * Step 9: Setup sysfs attributes
 */
-   err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list);
+   err = sysfs_create_files(>dev.kobj, kp_attr_list);
if (err) {
dev_err(>dev, "Failed to add sysfs files: %d\n", err);
goto out9;
@@ -515,7 +515,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev,
return 0;
 
 out10:
-   sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
+   sysfs_remove_files(>dev.kobj, kp_attr_list);
 out9:
free_irq(pcard->pdev->irq, pcard);
 out8b:
@@ -552,7 +552,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev)
mutex_lock(>sem);
kp2000_remove_cores(pcard);
mfd_remove_devices(PCARD_TO_DEV(pcard));
-   sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
+   sysfs_remove_files(>dev.kobj, kp_attr_list);
free_irq(pcard->pdev->irq, pcard);
pci_disable_msi(pcard->pdev);
if (pcard->dma_bar_base) {
-- 
2.20.1



[PATCH] staging: kpc2000: replace bogus variable name in core.c

2019-05-29 Thread Simon Sandström
"struct kp2000_regs temp" has nothing to do with temperatures, so
replace it with the more proper name "regs".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 4110032d0cbb..11ac57e31d45 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -314,24 +314,24 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned 
int ioctl_num,
case KP2000_IOCTL_GET_PCIE_ERROR_REG:   return 
readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT);
 
case KP2000_IOCTL_GET_EVERYTHING: {
-   struct kp2000_regs temp;
+   struct kp2000_regs regs;
int ret;
 
-   memset(, 0, sizeof(temp));
-   temp.card_id = pcard->card_id;
-   temp.build_version = pcard->build_version;
-   temp.build_datestamp = pcard->build_datestamp;
-   temp.build_timestamp = pcard->build_timestamp;
-   temp.hw_rev = pcard->hardware_revision;
-   temp.ssid = pcard->ssid;
-   temp.ddna = pcard->ddna;
-   temp.cpld_reg = readq(pcard->sysinfo_regs_base + 
REG_CPLD_CONFIG);
-
-   ret = copy_to_user((void*)ioctl_param, (void*), 
sizeof(temp));
+   memset(, 0, sizeof(regs));
+   regs.card_id = pcard->card_id;
+   regs.build_version = pcard->build_version;
+   regs.build_datestamp = pcard->build_datestamp;
+   regs.build_timestamp = pcard->build_timestamp;
+   regs.hw_rev = pcard->hardware_revision;
+   regs.ssid = pcard->ssid;
+   regs.ddna = pcard->ddna;
+   regs.cpld_reg = readq(pcard->sysinfo_regs_base + 
REG_CPLD_CONFIG);
+
+   ret = copy_to_user((void*)ioctl_param, (void*), 
sizeof(regs));
if (ret)
return -EFAULT;
 
-   return sizeof(temp);
+   return sizeof(regs);
}
 
default:
-- 
2.20.1



Re: [PATCH 3/4] staging: kpc2000: add missing spaces in core.c

2019-05-29 Thread Simon Sandström
On Mon, May 27, 2019 at 10:31:59AM +0300, Dan Carpenter wrote:
> On Fri, May 24, 2019 at 01:08:01PM +0200, Simon Sandström wrote:
> > [..]
> > -   ret = copy_to_user((void*)ioctl_param, (void*), 
> > sizeof(temp));
> > +   ret = copy_to_user((void *)ioctl_param, (void *), 
> > sizeof(temp));
> > if (ret)
> > return -EFAULT;
> 
> This should really be written like so:
> 
>   if (copy_to_user((void __user *)ioctl_param, ,
>sizeof(temp)))
>   return -EFAULT;
> 
> temp is really the wrong name.  "temp" is for temperatures.  "tmp" means
> temporary.  But also "tmp" is wrong here because it's not a temporary
> variable.  It's better to call it "regs" here.
> 
> regards,
> dan carpenter
> 

I agree, but I don't think it fits within this patch. I can send a
separate patch with this change.

Thanks

- Simon


Re: [PATCH 2/2] staging: kpc2000: add missing dependencies for kpc2000

2019-05-25 Thread Simon Sandström
On Sat, May 25, 2019 at 10:39:18AM +0200, Simon Sandström wrote:
> On Sat, May 25, 2019 at 07:00:17AM +0200, Greg KH wrote:
> > 
> > This is already in linux-next (in a different form), are you sure you
> > are working against the latest kernel tree?
> > 
> > thanks,
> > 
> > greg k-h
> 
> It's based on your staging tree. I think that I have to go back and read
> about next trees again, because I thought it took longer time for things
> to get from staging-next to linux-next.
> 
> Anyway, neither the MFD_CORE nor the typo fix is in linux-next so I
> guess that I could just rebase this on linux-next and re-send as v2.
> I'm not sure if MFD_CORE should be "depends on" or "select" though...
> 
> 
> - Simon

Oh, it must be "select MFD_CORE" because there is no prompt for
MFD_CORE? Should I just rebase it on linux-next and re-send as v2 then?


- Simon


Re: [PATCH 2/2] staging: kpc2000: add missing dependencies for kpc2000

2019-05-25 Thread Simon Sandström
On Sat, May 25, 2019 at 07:00:17AM +0200, Greg KH wrote:
> On Fri, May 24, 2019 at 10:30:58PM +0200, Simon Sandström wrote:
> > Fixes build errors:
> > 
> > ERROR: "mfd_remove_devices" [kpc2000.ko] undefined!
> > ERROR: "uio_unregister_device" [kpc2000.ko] undefined!
> > ERROR: "mfd_add_devices" [kpc2000.ko] undefined!
> > ERROR: "__uio_register_device" [kpc2000.ko] undefined!
> > 
> > Signed-off-by: Simon Sandström 
> > ---
> >  drivers/staging/kpc2000/Kconfig | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/drivers/staging/kpc2000/Kconfig 
> > b/drivers/staging/kpc2000/Kconfig
> > index c463d232f2b4..5188b56123ab 100644
> > --- a/drivers/staging/kpc2000/Kconfig
> > +++ b/drivers/staging/kpc2000/Kconfig
> > @@ -3,6 +3,8 @@
> >  config KPC2000
> > bool "Daktronics KPC Device support"
> > depends on PCI
> > +   select MFD_CORE
> > +   select UIO
> > help
> >   Select this if you wish to use the Daktronics KPC PCI devices
> >  
> 
> This is already in linux-next (in a different form), are you sure you
> are working against the latest kernel tree?
> 
> thanks,
> 
> greg k-h

It's based on your staging tree. I think that I have to go back and read
about next trees again, because I thought it took longer time for things
to get from staging-next to linux-next.

Anyway, neither the MFD_CORE nor the typo fix is in linux-next so I
guess that I could just rebase this on linux-next and re-send as v2.
I'm not sure if MFD_CORE should be "depends on" or "select" though...


- Simon


[PATCH 0/2] Fixes for staging/kpc2000's Kconfig

2019-05-24 Thread Simon Sandström
Hi,

Here are two patches that fixes issues in kpc2000's Kconfig.

The first one is a typo fix (I'm guessing Kaktronics is a typo...).

The second one is a fix for a dependency issues I met when trying to
build kpc2000 on a default x86_64 config. I'm not familiar with neither
MFD nor UIO, so I'm not sure that I solved it correctly. Maybe there are
some other things to consider as this is in staging?


- Simon

Simon Sandström (2):
  staging: kpc2000: fix typo in Kconfig
  staging: kpc2000: add missing dependencies for kpc2000

 drivers/staging/kpc2000/Kconfig | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.20.1



[PATCH 1/2] staging: kpc2000: fix typo in Kconfig

2019-05-24 Thread Simon Sandström
Fixes two minor typos in kpc2000's Kconfig: s/Kaktronics/Daktronics

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/Kconfig b/drivers/staging/kpc2000/Kconfig
index fb5922928f47..c463d232f2b4 100644
--- a/drivers/staging/kpc2000/Kconfig
+++ b/drivers/staging/kpc2000/Kconfig
@@ -21,7 +21,7 @@ config KPC2000_CORE
  If unsure, say N.
 
 config KPC2000_SPI
-   tristate "Kaktronics KPC SPI device"
+   tristate "Daktronics KPC SPI device"
depends on KPC2000 && SPI
help
  Say Y here if you wish to support the Daktronics KPC PCI
@@ -33,7 +33,7 @@ config KPC2000_SPI
  If unsure, say N.
 
 config KPC2000_I2C
-   tristate "Kaktronics KPC I2C device"
+   tristate "Daktronics KPC I2C device"
depends on KPC2000 && I2C
help
  Say Y here if you wish to support the Daktronics KPC PCI
-- 
2.20.1



[PATCH 2/2] staging: kpc2000: add missing dependencies for kpc2000

2019-05-24 Thread Simon Sandström
Fixes build errors:

ERROR: "mfd_remove_devices" [kpc2000.ko] undefined!
ERROR: "uio_unregister_device" [kpc2000.ko] undefined!
ERROR: "mfd_add_devices" [kpc2000.ko] undefined!
ERROR: "__uio_register_device" [kpc2000.ko] undefined!

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/kpc2000/Kconfig b/drivers/staging/kpc2000/Kconfig
index c463d232f2b4..5188b56123ab 100644
--- a/drivers/staging/kpc2000/Kconfig
+++ b/drivers/staging/kpc2000/Kconfig
@@ -3,6 +3,8 @@
 config KPC2000
bool "Daktronics KPC Device support"
depends on PCI
+   select MFD_CORE
+   select UIO
help
  Select this if you wish to use the Daktronics KPC PCI devices
 
-- 
2.20.1



[PATCH 4/4] staging: kpc2000: remove extra spaces in core.c

2019-05-24 Thread Simon Sandström
Fixes checkpatch.pl error "foo __init  bar" should be "foo __init bar"
and "foo __exit  bar" should be "foo __exit bar".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index bb3b427a72b1..3b240eff62b7 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -655,7 +655,7 @@ static struct pci_driver kp2000_driver_inst = {
.remove =   kp2000_pcie_remove,
 };
 
-static int __init  kp2000_pcie_init(void)
+static int __init kp2000_pcie_init(void)
 {
kpc_uio_class = class_create(THIS_MODULE, "kpc_uio");
if (IS_ERR(kpc_uio_class))
@@ -666,7 +666,7 @@ static int __init  kp2000_pcie_init(void)
 }
 module_init(kp2000_pcie_init);
 
-static void __exit  kp2000_pcie_exit(void)
+static void __exit kp2000_pcie_exit(void)
 {
pci_unregister_driver(_driver_inst);
class_destroy(kpc_uio_class);
-- 
2.20.1



[PATCH 0/4] Fix whitespace issues in staging/kpc2000

2019-05-24 Thread Simon Sandström
Hi,

These patches fixes minor whitespace issues in staging/kpc2000/core.c as
reported by checkpatch.pl.

- Simon

Simon Sandström (4):
  staging: kpc2000: add spaces around operators in core.c
  staging: kpc2000: remove extra blank line in core.c
  staging: kpc2000: add missing spaces in core.c
  staging: kpc2000: remove extra spaces in core.c

 drivers/staging/kpc2000/kpc2000/core.c | 33 +-
 1 file changed, 16 insertions(+), 17 deletions(-)

-- 
2.20.1



[PATCH 3/4] staging: kpc2000: add missing spaces in core.c

2019-05-24 Thread Simon Sandström
Fixes checkpatch.pl errors "space required before the open brace '{'"
and "(foo*)" should be "(foo *)".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 40f65f96986b..bb3b427a72b1 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -308,7 +308,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned 
int ioctl_num,
 
dev_dbg(>pdev->dev, "kp2000_cdev_ioctl(filp = [%p], ioctl_num = 
0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n", filp, ioctl_num, ioctl_param, 
pcard);
 
-   switch (ioctl_num){
+   switch (ioctl_num) {
case KP2000_IOCTL_GET_CPLD_REG: return 
readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG);
case KP2000_IOCTL_GET_PCIE_ERROR_REG:   return 
readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT);
 
@@ -326,7 +326,7 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned 
int ioctl_num,
temp.ddna = pcard->ddna;
temp.cpld_reg = readq(pcard->sysinfo_regs_base + 
REG_CPLD_CONFIG);
 
-   ret = copy_to_user((void*)ioctl_param, (void*), 
sizeof(temp));
+   ret = copy_to_user((void *)ioctl_param, (void *), 
sizeof(temp));
if (ret)
return -EFAULT;
 
-- 
2.20.1



[PATCH 1/4] staging: kpc2000: add spaces around operators in core.c

2019-05-24 Thread Simon Sandström
Fixes checkpatch.pl check "spaces preferred around that ".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index 4110032d0cbb..b464973d12ad 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -276,18 +276,18 @@ static ssize_t kp2000_cdev_read(struct file *filp, char 
__user *buf,
if (WARN(NULL == buf, "kp2000_cdev_read: buf is a NULL pointer!\n"))
return -EINVAL;
 
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Card ID : 
0x%08x\n", pcard->card_id);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Version   : 
0x%08x\n", pcard->build_version);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Date  : 
0x%08x\n", pcard->build_datestamp);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Time  : 
0x%08x\n", pcard->build_timestamp);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Offset   : 
0x%08x\n", pcard->core_table_offset);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Length   : 
0x%08x\n", pcard->core_table_length);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Hardware Revision   : 
0x%08x\n", pcard->hardware_revision);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "SSID: 
0x%016llx\n", pcard->ssid);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "DDNA: 
0x%016llx\n", pcard->ddna);
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Mask: 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK));
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Active  : 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE));
-   cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "CPLD: 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG));
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Card ID : 
0x%08x\n", pcard->card_id);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Build Version   : 
0x%08x\n", pcard->build_version);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Build Date  : 
0x%08x\n", pcard->build_datestamp);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Build Time  : 
0x%08x\n", pcard->build_timestamp);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Core Table Offset   : 
0x%08x\n", pcard->core_table_offset);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Core Table Length   : 
0x%08x\n", pcard->core_table_length);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "Hardware Revision   : 
0x%08x\n", pcard->hardware_revision);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "SSID: 
0x%016llx\n", pcard->ssid);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "DDNA: 
0x%016llx\n", pcard->ddna);
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "IRQ Mask: 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK));
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "IRQ Active  : 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE));
+   cnt += scnprintf(buff + cnt, BUFF_CNT - cnt, "CPLD: 
0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG));
 
if (*f_pos >= cnt)
return 0;
-- 
2.20.1



[PATCH 2/4] staging: kpc2000: remove extra blank line in core.c

2019-05-24 Thread Simon Sandström
Fixes checkpatch.pl check "Please don't use multiple blank lines".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/core.c 
b/drivers/staging/kpc2000/kpc2000/core.c
index b464973d12ad..40f65f96986b 100644
--- a/drivers/staging/kpc2000/kpc2000/core.c
+++ b/drivers/staging/kpc2000/kpc2000/core.c
@@ -262,7 +262,6 @@ static int kp2000_cdev_close(struct inode *inode, struct 
file *filp)
return 0;
 }
 
-
 static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf,
size_t count, loff_t *f_pos)
 {
-- 
2.20.1



[PATCH v2 0/9] Fix more coding style issues in staging/kpc2000

2019-05-23 Thread Simon Sandström
Hi,

These patches fixes a few more minor coding style issues found in
staging/kpc2000/cell_probe.c. There are only two more types of
checkpatch.pl warnings left in this file with these patches applied:
"line over 80 characters" and "Macro argument reuse".

Changed in v2: don't bother fixing the __func__ usage in the out of
   memory debug message, instead add a patch that removes
   it completely.

- Simon

Simon Sandström (9):
  staging: kpc2000: add blank line after declarations
  staging: kpc2000: use __func__ in debug messages
  staging: kpc2000: add missing asterisk in comment
  staging: kpc2000: fix alignment issues in cell_probe.c
  staging: kpc2000: remove extra blank lines in cell_probe.c
  staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c
  staging: kpc2000: remove unnecessary braces in cell_probe.c
  staging: kpc2000: remove unnecessary include in cell_probe.c
  staging: kpc2000: remove unnecessary oom message

 drivers/staging/kpc2000/kpc2000/cell_probe.c | 81 +---
 1 file changed, 38 insertions(+), 43 deletions(-)

-- 
2.20.1



[PATCH v2 2/9] staging: kpc2000: use __func__ in debug messages

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using
'', this function's name, in a string".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 95bfbe4aae4d..b559ade04aca 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -327,7 +327,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
kudev->dev = device_create(kpc_uio_class, >pdev->dev, MKDEV(0, 
0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, 
kudev->core_num);
if (IS_ERR(kudev->dev)) {
-   dev_err(>pdev->dev, "probe_core_uio device_create 
failed!\n");
+   dev_err(>pdev->dev, "%s: device_create failed!\n",
+   __func__);
kfree(kudev);
return -ENODEV;
}
@@ -335,7 +336,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
rv = uio_register_device(kudev->dev, >uioinfo);
if (rv) {
-   dev_err(>pdev->dev, "probe_core_uio failed 
uio_register_device: %d\n", rv);
+   dev_err(>pdev->dev, "%s: failed uio_register_device: 
%d\n",
+   __func__, rv);
put_device(kudev->dev);
kfree(kudev);
return rv;
@@ -410,7 +412,8 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
return 0;
 
 err_out:
-   dev_err(>pdev->dev, "kp2000_setup_dma_controller: failed to add 
a DMA Engine: %d\n", err);
+   dev_err(>pdev->dev, "%s: failed to add a DMA Engine: %d\n",
+   __func__, err);
return err;
 }
 
@@ -423,7 +426,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
unsigned int highest_core_id = 0;
struct core_table_entry cte;
 
-   dev_dbg(>pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", 
pcard, pcard->card_num);
+   dev_dbg(>pdev->dev, "%s(pcard = %p / %d)\n", __func__, pcard,
+   pcard->card_num);
 
err = kp2000_setup_dma_controller(pcard);
if (err)
@@ -472,8 +476,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
}
if (err) {
dev_err(>pdev->dev,
-   "kp2000_probe_cores: failed to add core 
%d: %d\n",
-   i, err);
+   "%s: failed to add core %d: %d\n",
+   __func__, i, err);
goto error;
}
core_num++;
@@ -492,7 +496,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
cte.irq_base_num= 0;
err = probe_core_uio(0, pcard, "kpc_uio", cte);
if (err) {
-   dev_err(>pdev->dev, "kp2000_probe_cores: failed to add 
board_info core: %d\n", err);
+   dev_err(>pdev->dev, "%s: failed to add board_info core: 
%d\n",
+   __func__, err);
goto error;
}
 
-- 
2.20.1



[PATCH v2 1/9] staging: kpc2000: add blank line after declarations

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Missing a blank line after declarations".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index e5cddf0eeed3..95bfbe4aae4d 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -245,6 +245,7 @@ int  kp2000_check_uio_irq(struct kp2000_device *pcard, u32 
irq_num)
u64 interrupt_active   =  readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_ACTIVE);
u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_MASK);
u64 irq_check_mask = (1 << irq_num);
+
if (interrupt_active & irq_check_mask) { // if it's active (interrupt 
pending)
if (interrupt_mask_inv & irq_check_mask) {// and if it's 
not masked off
return 1;
@@ -257,6 +258,7 @@ static
 irqreturn_t  kuio_handler(int irq, struct uio_info *uioinfo)
 {
struct kpc_uio_device *kudev = uioinfo->priv;
+
if (irq != kudev->pcard->pdev->irq)
return IRQ_NONE;
 
@@ -506,8 +508,10 @@ void  kp2000_remove_cores(struct kp2000_device *pcard)
 {
struct list_head *ptr;
struct list_head *next;
+
list_for_each_safe(ptr, next, >uio_devices_list) {
struct kpc_uio_device *kudev = list_entry(ptr, struct 
kpc_uio_device, list);
+
uio_unregister_device(>uioinfo);
device_unregister(kudev->dev);
list_del(>list);
-- 
2.20.1



[PATCH v2 3/9] staging: kpc2000: add missing asterisk in comment

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl error "code indent should use tabs where possible".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index b559ade04aca..945d8e4e7ba5 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -25,7 +25,7 @@
  *  D  
 C2S DMA Present
  *   DDD   
 C2S DMA Channel Number[up to 8 channels]
  *  II 
 IRQ Count [0 to 3 IRQs per core]
-  
111000
+ *
111000
  *III  
 IRQ Base Number [up to 128 IRQs per card]
  *   
___Spare
  *
-- 
2.20.1



[PATCH v2 8/9] staging: kpc2000: remove unnecessary include in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Use #include  instead of
".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 682d61da5369..5e65bd56d66e 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -4,7 +4,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.20.1



[PATCH v2 9/9] staging: kpc2000: remove unnecessary oom message

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Possible unnecessary 'out of memory'
message".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 5e65bd56d66e..f731a97c6cac 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -291,10 +291,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
kudev = kzalloc(sizeof(*kudev), GFP_KERNEL);
-   if (!kudev) {
-   dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
+   if (!kudev)
return -ENOMEM;
-   }
 
INIT_LIST_HEAD(>list);
kudev->pcard = pcard;
-- 
2.20.1



[PATCH v2 5/9] staging: kpc2000: remove extra blank lines in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "Please don't use multiple blank lines".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 5b88504b00ec..f8d19e693f21 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -94,7 +94,6 @@ void parse_core_table_entry(struct core_table_entry *cte, 
const u64 read_val, co
}
 }
 
-
 static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard,
char *name, const struct core_table_entry cte)
 {
@@ -111,7 +110,6 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 
dev_dbg(>pdev->dev, "Found Basic core: type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
-
cell.platform_data = _pdata;
cell.pdata_size = sizeof(struct kpc_core_device_platdata);
cell.num_resources = 2;
@@ -137,7 +135,6 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
   NULL);  // struct irq_domain *
 }
 
-
 struct kpc_uio_device {
struct list_head list;
struct kp2000_device *pcard;
@@ -346,7 +343,6 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
return 0;
 }
 
-
 static int  create_dma_engine_core(struct kp2000_device *pcard, size_t 
engine_regs_offset, int engine_num, int irq_num)
 {
struct mfd_cell  cell = { .id = engine_num };
-- 
2.20.1



[PATCH v2 7/9] staging: kpc2000: remove unnecessary braces in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "braces {} are not necessary for single
statement blocks".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index caf48256aa2e..682d61da5369 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -273,11 +273,10 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 
mutex_lock(>sem);
mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
-   if (irq_on) {
+   if (irq_on)
mask &= ~(1 << (kudev->cte.irq_base_num));
-   } else {
+   else
mask |= (1 << (kudev->cte.irq_base_num));
-   }
writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
mutex_unlock(>sem);
 
@@ -432,12 +431,10 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
read_val = readq(pcard->sysinfo_regs_base + 
((pcard->core_table_offset + i) * 8));
parse_core_table_entry(, read_val, pcard->core_table_rev);
dbg_cte(pcard, );
-   if (cte.type > highest_core_id) {
+   if (cte.type > highest_core_id)
highest_core_id = cte.type;
-   }
-   if (cte.type == KP_CORE_ID_INVALID) {
+   if (cte.type == KP_CORE_ID_INVALID)
dev_info(>pdev->dev, "Found Invalid core: 
%016llx\n", read_val);
-   }
}
// Then, iterate over the possible core types.
for (current_type_id = 1 ; current_type_id <= highest_core_id ; 
current_type_id++) {
-- 
2.20.1



[PATCH v2 4/9] staging: kpc2000: fix alignment issues in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "Alignment should match open parenthesis"
and "Lines should not end with a '('".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 34 +---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 945d8e4e7ba5..5b88504b00ec 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -128,15 +128,13 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 
cell.resources = resources;
 
-   return mfd_add_devices(
-   PCARD_TO_DEV(pcard),// parent
-   pcard->card_num * 100,  // id
-   ,  // struct mfd_cell *
-   1,  // ndevs
-   >regs_base_resource,
-   0,  // irq_base
-   NULL// struct irq_domain *
-   );
+   return mfd_add_devices(PCARD_TO_DEV(pcard),// parent
+  pcard->card_num * 100,  // id
+  ,  // struct mfd_cell *
+  1,  // ndevs
+  >regs_base_resource,
+  0,  // irq_base
+  NULL);  // struct irq_domain *
 }
 
 
@@ -373,15 +371,13 @@ static int  create_dma_engine_core(struct kp2000_device 
*pcard, size_t engine_re
 
cell.resources = resources;
 
-   return mfd_add_devices(
-   PCARD_TO_DEV(pcard),// parent
-   pcard->card_num * 100,  // id
-   ,  // struct mfd_cell *
-   1,  // ndevs
-   >dma_base_resource,
-   0,  // irq_base
-   NULL// struct irq_domain *
-   );
+   return mfd_add_devices(PCARD_TO_DEV(pcard),// parent
+  pcard->card_num * 100,  // id
+  ,  // struct mfd_cell *
+  1,  // ndevs
+  >dma_base_resource,
+  0,  // irq_base
+  NULL);  // struct irq_domain *
 }
 
 static int  kp2000_setup_dma_controller(struct kp2000_device *pcard)
@@ -462,7 +458,7 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
switch (cte.type) {
case KP_CORE_ID_I2C:
err = probe_core_basic(core_num, pcard,
-   KP_DRIVER_NAME_I2C, cte);
+  KP_DRIVER_NAME_I2C, cte);
break;
 
case KP_CORE_ID_SPI:
-- 
2.20.1



[PATCH v2 6/9] staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer kzalloc(sizeof(*kudev)...) over
kzalloc(sizeof(struct kpc_uio_device)...)"

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index f8d19e693f21..caf48256aa2e 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
-   kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
+   kudev = kzalloc(sizeof(*kudev), GFP_KERNEL);
if (!kudev) {
dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
return -ENOMEM;
-- 
2.20.1



Re: [PATCH 2/8] staging: kpc2000: use __func__ in debug messages

2019-05-23 Thread Simon Sandström
On Thu, May 23, 2019 at 01:55:53PM +0200, Greg KH wrote:
> On Thu, May 23, 2019 at 01:36:07PM +0200, Simon Sandström wrote:
> > Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using
> > '', this function's name, in a string".
> > 
> > Signed-off-by: Simon Sandström 
> > ---
> >  drivers/staging/kpc2000/kpc2000/cell_probe.c | 22 +---
> >  1 file changed, 14 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
> > b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > index 95bfbe4aae4d..7b850f3e808b 100644
> > --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
> > @@ -299,7 +299,8 @@ static int probe_core_uio(unsigned int core_num, struct 
> > kp2000_device *pcard,
> >  
> > kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
> > if (!kudev) {
> > -   dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
> > kpc_uio_device\n");
> > +   dev_err(>pdev->dev, "%s: failed to kzalloc 
> > kpc_uio_device\n",
> > +   __func__);
> 
> kmalloc and friend error messages should just be deleted.  Didn't
> checkpatch say something about that?
> 
> thanks,
> 
> greg k-h

Yes sorry, it did. Should I delete this chunk from this patch and add
another patch to this series that just deletes the message, in v2?

- Simon


[PATCH 3/8] staging: kpc2000: add missing asterisk in comment

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl error "code indent should use tabs where possible".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 7b850f3e808b..c4015c62686f 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -25,7 +25,7 @@
  *  D  
 C2S DMA Present
  *   DDD   
 C2S DMA Channel Number[up to 8 channels]
  *  II 
 IRQ Count [0 to 3 IRQs per core]
-  
111000
+ *
111000
  *III  
 IRQ Base Number [up to 128 IRQs per card]
  *   
___Spare
  *
-- 
2.20.1



[PATCH 5/8] staging: kpc2000: remove extra blank lines in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "Please don't use multiple blank lines".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index b621adb712ff..0da41ca17eb7 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -94,7 +94,6 @@ void parse_core_table_entry(struct core_table_entry *cte, 
const u64 read_val, co
}
 }
 
-
 static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard,
char *name, const struct core_table_entry cte)
 {
@@ -111,7 +110,6 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 
dev_dbg(>pdev->dev, "Found Basic core: type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
-
cell.platform_data = _pdata;
cell.pdata_size = sizeof(struct kpc_core_device_platdata);
cell.num_resources = 2;
@@ -137,7 +135,6 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
   NULL);  // struct irq_domain *
 }
 
-
 struct kpc_uio_device {
struct list_head list;
struct kp2000_device *pcard;
@@ -347,7 +344,6 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
return 0;
 }
 
-
 static int  create_dma_engine_core(struct kp2000_device *pcard, size_t 
engine_regs_offset, int engine_num, int irq_num)
 {
struct mfd_cell  cell = { .id = engine_num };
-- 
2.20.1



[PATCH 0/8] Fix more coding style issues in staging/kpc2000

2019-05-23 Thread Simon Sandström
Hi,

These patches fixes a few more minor coding style issues found in
staging/kpc2000/cell_probe.c. There are only two more types of
checkpatch.pl warnings left in this file with these patches applied:
"line over 80 characters" and "Macro argument reuse".

- Simon

Simon Sandström (8):
  staging: kpc2000: add blank line after declarations
  staging: kpc2000: use __func__ in debug messages
  staging: kpc2000: add missing asterisk in comment
  staging: kpc2000: fix alignment issues in cell_probe.c
  staging: kpc2000: remove extra blank lines in cell_probe.c
  staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c
  staging: kpc2000: remove unnecessary braces in cell_probe.c
  staging: kpc2000: remove unnecessary include in cell_probe.c

 drivers/staging/kpc2000/kpc2000/cell_probe.c | 80 ++--
 1 file changed, 39 insertions(+), 41 deletions(-)

-- 
2.20.1



[PATCH 2/8] staging: kpc2000: use __func__ in debug messages

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using
'', this function's name, in a string".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 22 +---
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 95bfbe4aae4d..7b850f3e808b 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -299,7 +299,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
if (!kudev) {
-   dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
+   dev_err(>pdev->dev, "%s: failed to kzalloc 
kpc_uio_device\n",
+   __func__);
return -ENOMEM;
}
 
@@ -327,7 +328,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
kudev->dev = device_create(kpc_uio_class, >pdev->dev, MKDEV(0, 
0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, 
kudev->core_num);
if (IS_ERR(kudev->dev)) {
-   dev_err(>pdev->dev, "probe_core_uio device_create 
failed!\n");
+   dev_err(>pdev->dev, "%s: device_create failed!\n",
+   __func__);
kfree(kudev);
return -ENODEV;
}
@@ -335,7 +337,8 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
rv = uio_register_device(kudev->dev, >uioinfo);
if (rv) {
-   dev_err(>pdev->dev, "probe_core_uio failed 
uio_register_device: %d\n", rv);
+   dev_err(>pdev->dev, "%s: failed uio_register_device: 
%d\n",
+   __func__, rv);
put_device(kudev->dev);
kfree(kudev);
return rv;
@@ -410,7 +413,8 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
return 0;
 
 err_out:
-   dev_err(>pdev->dev, "kp2000_setup_dma_controller: failed to add 
a DMA Engine: %d\n", err);
+   dev_err(>pdev->dev, "%s: failed to add a DMA Engine: %d\n",
+   __func__, err);
return err;
 }
 
@@ -423,7 +427,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
unsigned int highest_core_id = 0;
struct core_table_entry cte;
 
-   dev_dbg(>pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", 
pcard, pcard->card_num);
+   dev_dbg(>pdev->dev, "%s(pcard = %p / %d)\n", __func__, pcard,
+   pcard->card_num);
 
err = kp2000_setup_dma_controller(pcard);
if (err)
@@ -472,8 +477,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
}
if (err) {
dev_err(>pdev->dev,
-   "kp2000_probe_cores: failed to add core 
%d: %d\n",
-   i, err);
+   "%s: failed to add core %d: %d\n",
+   __func__, i, err);
goto error;
}
core_num++;
@@ -492,7 +497,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
cte.irq_base_num= 0;
err = probe_core_uio(0, pcard, "kpc_uio", cte);
if (err) {
-   dev_err(>pdev->dev, "kp2000_probe_cores: failed to add 
board_info core: %d\n", err);
+   dev_err(>pdev->dev, "%s: failed to add board_info core: 
%d\n",
+   __func__, err);
goto error;
}
 
-- 
2.20.1



[PATCH 1/8] staging: kpc2000: add blank line after declarations

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Missing a blank line after declarations".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index e5cddf0eeed3..95bfbe4aae4d 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -245,6 +245,7 @@ int  kp2000_check_uio_irq(struct kp2000_device *pcard, u32 
irq_num)
u64 interrupt_active   =  readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_ACTIVE);
u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_MASK);
u64 irq_check_mask = (1 << irq_num);
+
if (interrupt_active & irq_check_mask) { // if it's active (interrupt 
pending)
if (interrupt_mask_inv & irq_check_mask) {// and if it's 
not masked off
return 1;
@@ -257,6 +258,7 @@ static
 irqreturn_t  kuio_handler(int irq, struct uio_info *uioinfo)
 {
struct kpc_uio_device *kudev = uioinfo->priv;
+
if (irq != kudev->pcard->pdev->irq)
return IRQ_NONE;
 
@@ -506,8 +508,10 @@ void  kp2000_remove_cores(struct kp2000_device *pcard)
 {
struct list_head *ptr;
struct list_head *next;
+
list_for_each_safe(ptr, next, >uio_devices_list) {
struct kpc_uio_device *kudev = list_entry(ptr, struct 
kpc_uio_device, list);
+
uio_unregister_device(>uioinfo);
device_unregister(kudev->dev);
list_del(>list);
-- 
2.20.1



[PATCH 4/8] staging: kpc2000: fix alignment issues in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "Alignment should match open parenthesis"
and "Lines should not end with a '('".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 34 +---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index c4015c62686f..b621adb712ff 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -128,15 +128,13 @@ static int probe_core_basic(unsigned int core_num, struct 
kp2000_device *pcard,
 
cell.resources = resources;
 
-   return mfd_add_devices(
-   PCARD_TO_DEV(pcard),// parent
-   pcard->card_num * 100,  // id
-   ,  // struct mfd_cell *
-   1,  // ndevs
-   >regs_base_resource,
-   0,  // irq_base
-   NULL// struct irq_domain *
-   );
+   return mfd_add_devices(PCARD_TO_DEV(pcard),// parent
+  pcard->card_num * 100,  // id
+  ,  // struct mfd_cell *
+  1,  // ndevs
+  >regs_base_resource,
+  0,  // irq_base
+  NULL);  // struct irq_domain *
 }
 
 
@@ -374,15 +372,13 @@ static int  create_dma_engine_core(struct kp2000_device 
*pcard, size_t engine_re
 
cell.resources = resources;
 
-   return mfd_add_devices(
-   PCARD_TO_DEV(pcard),// parent
-   pcard->card_num * 100,  // id
-   ,  // struct mfd_cell *
-   1,  // ndevs
-   >dma_base_resource,
-   0,  // irq_base
-   NULL// struct irq_domain *
-   );
+   return mfd_add_devices(PCARD_TO_DEV(pcard),// parent
+  pcard->card_num * 100,  // id
+  ,  // struct mfd_cell *
+  1,  // ndevs
+  >dma_base_resource,
+  0,  // irq_base
+  NULL);  // struct irq_domain *
 }
 
 static int  kp2000_setup_dma_controller(struct kp2000_device *pcard)
@@ -463,7 +459,7 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
switch (cte.type) {
case KP_CORE_ID_I2C:
err = probe_core_basic(core_num, pcard,
-   KP_DRIVER_NAME_I2C, cte);
+  KP_DRIVER_NAME_I2C, cte);
break;
 
case KP_CORE_ID_SPI:
-- 
2.20.1



[PATCH 7/8] staging: kpc2000: remove unnecessary braces in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warnings "braces {} are not necessary for single
statement blocks".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 8d9254db9498..b1ce1e715d9a 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -273,11 +273,10 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 
mutex_lock(>sem);
mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
-   if (irq_on) {
+   if (irq_on)
mask &= ~(1 << (kudev->cte.irq_base_num));
-   } else {
+   else
mask |= (1 << (kudev->cte.irq_base_num));
-   }
writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
mutex_unlock(>sem);
 
@@ -433,12 +432,10 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
read_val = readq(pcard->sysinfo_regs_base + 
((pcard->core_table_offset + i) * 8));
parse_core_table_entry(, read_val, pcard->core_table_rev);
dbg_cte(pcard, );
-   if (cte.type > highest_core_id) {
+   if (cte.type > highest_core_id)
highest_core_id = cte.type;
-   }
-   if (cte.type == KP_CORE_ID_INVALID) {
+   if (cte.type == KP_CORE_ID_INVALID)
dev_info(>pdev->dev, "Found Invalid core: 
%016llx\n", read_val);
-   }
}
// Then, iterate over the possible core types.
for (current_type_id = 1 ; current_type_id <= highest_core_id ; 
current_type_id++) {
-- 
2.20.1



[PATCH 8/8] staging: kpc2000: remove unnecessary include in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Use #include  instead of
".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index b1ce1e715d9a..5017c850 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -4,7 +4,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.20.1



[PATCH 6/8] staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c

2019-05-23 Thread Simon Sandström
Fixes checkpatch.pl warning "Prefer kzalloc(sizeof(*kudev)...) over
kzalloc(sizeof(struct kpc_uio_device)...)"

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 0da41ca17eb7..8d9254db9498 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
-   kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
+   kudev = kzalloc(sizeof(*kudev), GFP_KERNEL);
if (!kudev) {
dev_err(>pdev->dev, "%s: failed to kzalloc 
kpc_uio_device\n",
__func__);
-- 
2.20.1



Re: [PATCH 1/6] staging: kpc2000: fix indent in cell_probe.c

2019-05-23 Thread Simon Sandström
On Thu, May 23, 2019 at 09:27:59AM +0200, Greg KH wrote:
> On Thu, May 23, 2019 at 09:26:25AM +0200, Greg KH wrote:
> > 
> > This chunk does not match what you said this commit did :(
> > 
> > Please fix up and resend.
> 
> Actually, wait, rebase and resend after I apply your other patches.
> I'll hand-edit this patch to remove this chunk as your other fixes are
> good...
> 
> thanks,
> 
> greg k-h

Wops. OK, will do.

Thanks

- Simon


[PATCH 1/6] staging: kpc2000: fix indent in cell_probe.c

2019-05-22 Thread Simon Sandström
Use tabs instead of spaces for indentation.

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 574 +--
 1 file changed, 287 insertions(+), 287 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 0181b0a8ff82..6e034d115b47 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -25,7 +25,7 @@
  *  D  
 C2S DMA Present
  *   DDD   
 C2S DMA Channel Number[up to 8 channels]
  *  II 
 IRQ Count [0 to 3 IRQs per core]
-  
111000
+ *
111000
  *III  
 IRQ Base Number [up to 128 IRQs per card]
  *   
___Spare
  *
@@ -40,45 +40,45 @@
 #define KP_CORE_ID_SPI  5
 
 struct core_table_entry {
-u16 type;
-u32 offset;
-u32 length;
-bools2c_dma_present;
-u8  s2c_dma_channel_num;
-boolc2s_dma_present;
-u8  c2s_dma_channel_num;
-u8  irq_count;
-u8  irq_base_num;
+   u16  type;
+   u32  offset;
+   u32  length;
+   bool s2c_dma_present;
+   u8   s2c_dma_channel_num;
+   bool c2s_dma_present;
+   u8   c2s_dma_channel_num;
+   u8   irq_count;
+   u8   irq_base_num;
 };
 
 static
 void  parse_core_table_entry_v0(struct core_table_entry *cte, const u64 
read_val)
 {
-cte->type= ((read_val & 0xFFF0) >> 52);
-cte->offset  = ((read_val & 0x) >> 16) * 4096;
-cte->length  = ((read_val & 0x) >> 32) * 8;
-cte->s2c_dma_present = ((read_val & 0x0008) >> 51);
-cte->s2c_dma_channel_num = ((read_val & 0x0007) >> 48);
-cte->c2s_dma_present = ((read_val & 0x8000) >> 15);
-cte->c2s_dma_channel_num = ((read_val & 0x7000) >> 12);
-cte->irq_count   = ((read_val & 0x0C00) >> 10);
-cte->irq_base_num= ((read_val & 0x03F8) >>  3);
+   cte->type= ((read_val & 0xFFF0) >> 52);
+   cte->offset  = ((read_val & 0x) >> 16) * 
4096;
+   cte->length  = ((read_val & 0x) >> 32) * 8;
+   cte->s2c_dma_present = ((read_val & 0x0008) >> 51);
+   cte->s2c_dma_channel_num = ((read_val & 0x0007) >> 48);
+   cte->c2s_dma_present = ((read_val & 0x8000) >> 15);
+   cte->c2s_dma_channel_num = ((read_val & 0x7000) >> 12);
+   cte->irq_count   = ((read_val & 0x0C00) >> 10);
+   cte->irq_base_num= ((read_val & 0x03F8) >>  3);
 }
 
 static
 void dbg_cte(struct kp2000_device *pcard, struct core_table_entry *cte)
 {
-dev_dbg(>pdev->dev, "CTE: type:%3d  offset:%3d (%3d)  length:%3d 
(%3d)  s2c:%d  c2s:%d  irq_count:%d  base_irq:%d\n",
-cte->type,
-cte->offset,
-cte->offset / 4096,
-cte->length,
-cte->length / 8,
-(cte->s2c_dma_present ? cte->s2c_dma_channel_num : -1),
-(cte->c2s_dma_present ? cte->c2s_dma_channel_num : -1),
-cte->irq_count,
-cte->irq_base_num
-);
+   dev_dbg(>pdev->dev, "CTE: type:%3d  offset:%3d (%3d)  length:%3d 
(%3d)  s2c:%d  c2s:%d  irq_count:%d  base_irq:%d\n",
+   cte->type,
+   cte->offset,
+   cte->offset / 4096,
+   cte->length,
+   cte->length / 8,
+   (cte->s2c_dma_present ? cte->s2c_dma_channel_num : -1),
+   (cte->c2s_dma_present ? cte->c2s_dma_channel_num : -1),
+   cte->irq_count,
+   cte->irq_base_num
+   );
 }
 
 static
@@ -94,55 +94,55 @@ void parse_core_table_entry(struct core_table_entry *cte, 
const u64 read_val, co
 static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard,
char *name, const struct core_table_entry cte)
 {
-struct mfd_cell  cell = { .id = core_num, .name = name };
-struct resource  resources[2];
+   struct mfd_cel

[PATCH 5/6] staging: kpc2000: add space after comma in cell_probe.c

2019-05-22 Thread Simon Sandström
Fixes checkpatch.pl error "space required after that ','".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 9a32660a56e2..7d4986502013 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -323,7 +323,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE - 1) & ~(PAGE_SIZE 
- 1); // Round up to nearest PAGE_SIZE boundary
kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS;
 
-   kudev->dev = device_create(kpc_uio_class, >pdev->dev, 
MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, 
cte.type, kudev->core_num);
+   kudev->dev = device_create(kpc_uio_class, >pdev->dev, MKDEV(0, 
0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, 
kudev->core_num);
if (IS_ERR(kudev->dev)) {
dev_err(>pdev->dev, "probe_core_uio device_create 
failed!\n");
kfree(kudev);
-- 
2.20.1



[PATCH 2/6] staging: kpc2000: add space between ) and { in cell_probe.c

2019-05-22 Thread Simon Sandström
Fixes checkpatch.pl error "space required before the open brace '{'".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 6e034d115b47..51d32970f025 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -241,8 +241,8 @@ int  kp2000_check_uio_irq(struct kp2000_device *pcard, u32 
irq_num)
u64 interrupt_active   =  readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_ACTIVE);
u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + 
REG_INTERRUPT_MASK);
u64 irq_check_mask = (1 << irq_num);
-   if (interrupt_active & irq_check_mask){ // if it's active (interrupt 
pending)
-   if (interrupt_mask_inv & irq_check_mask){// and if it's not 
masked off
+   if (interrupt_active & irq_check_mask) { // if it's active (interrupt 
pending)
+   if (interrupt_mask_inv & irq_check_mask) {// and if it's 
not masked off
return 1;
}
}
@@ -256,7 +256,7 @@ irqreturn_t  kuio_handler(int irq, struct uio_info *uioinfo)
if (irq != kudev->pcard->pdev->irq)
return IRQ_NONE;
 
-   if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){
+   if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) {
writeq((1 << kudev->cte.irq_base_num), 
kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active 
flag
return IRQ_HANDLED;
}
@@ -272,7 +272,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on)
 
mutex_lock(>sem);
mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);
-   if (irq_on){
+   if (irq_on) {
mask &= ~(1 << (kudev->cte.irq_base_num));
} else {
mask |= (1 << (kudev->cte.irq_base_num));
@@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
dev_dbg(>pdev->dev, "Found UIO core:   type = %02d  dma = %02x / 
%02x  offset = 0x%x  length = 0x%x (%d regs)\n", cte.type, 
KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, 
cte.length, cte.length / 8);
 
kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL);
-   if (!kudev){
+   if (!kudev) {
dev_err(>pdev->dev, "probe_core_uio: failed to kzalloc 
kpc_uio_device\n");
return -ENOMEM;
}
@@ -305,7 +305,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
kudev->uioinfo.priv = kudev;
kudev->uioinfo.name = name;
kudev->uioinfo.version = "0.0";
-   if (cte.irq_count > 0){
+   if (cte.irq_count > 0) {
kudev->uioinfo.irq_flags = IRQF_SHARED;
kudev->uioinfo.irq = pcard->pdev->irq;
kudev->uioinfo.handler = kuio_handler;
@@ -328,7 +328,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
dev_set_drvdata(kudev->dev, kudev);
 
rv = uio_register_device(kudev->dev, >uioinfo);
-   if (rv){
+   if (rv) {
dev_err(>pdev->dev, "probe_core_uio failed 
uio_register_device: %d\n", rv);
put_device(kudev->dev);
kfree(kudev);
@@ -383,17 +383,17 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
u64 capabilities_reg;
 
// S2C Engines
-   for (i = 0 ; i < 32 ; i++){
+   for (i = 0 ; i < 32 ; i++) {
capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
-   if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){
+   if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i,  pcard->pdev->irq);
if (err) goto err_out;
}
}
// C2S Engines
-   for (i = 0 ; i < 32 ; i++){
+   for (i = 0 ; i < 32 ; i++) {
capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
-   if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){
+   if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i,  pcard->pdev->irq);
if (err) goto err_out;
}
@@ -423,23 +423,23 @@ int

[PATCH 4/6] staging: kpc2000: add spaces around operators in cell_probe.c

2019-05-22 Thread Simon Sandström
Fixes checkpatch.pl warning "spaces preferred around that ".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 4742f909db79..9a32660a56e2 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -320,7 +320,7 @@ static int probe_core_uio(unsigned int core_num, struct 
kp2000_device *pcard,
 
kudev->uioinfo.mem[0].name = "uiomap";
kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + 
cte.offset;
-   kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & 
~(PAGE_SIZE-1); // Round up to nearest PAGE_SIZE boundary
+   kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE - 1) & ~(PAGE_SIZE 
- 1); // Round up to nearest PAGE_SIZE boundary
kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS;
 
kudev->dev = device_create(kpc_uio_class, >pdev->dev, 
MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, 
cte.type, kudev->core_num);
@@ -399,7 +399,7 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
for (i = 0 ; i < 32 ; i++) {
capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
-   err = create_dma_engine_core(pcard, 
(KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i,  pcard->pdev->irq);
+   err = create_dma_engine_core(pcard, 
(KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32 + i,  
pcard->pdev->irq);
if (err)
goto err_out;
}
@@ -481,7 +481,7 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
// Finally, instantiate a UIO device for the core_table.
cte.type= 0; // CORE_ID_BOARD_INFO
cte.offset  = 0; // board info is always at the beginning
-   cte.length  = 512*8;
+   cte.length  = 512 * 8;
cte.s2c_dma_present = false;
cte.s2c_dma_channel_num = 0;
cte.c2s_dma_present = false;
-- 
2.20.1



[PATCH 6/6] staging: kpc2000: remove invalid spaces in cell_probe.c

2019-05-22 Thread Simon Sandström
Fixes checkpatch.pl error "space prohibited before/after that
parenthesis".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 7d4986502013..98a7a3194519 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -388,7 +388,7 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
 
// S2C Engines
for (i = 0 ; i < 32 ; i++) {
-   capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
+   capabilities_reg = readq(pcard->dma_bar_base + 
KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i));
if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i,  pcard->pdev->irq);
if (err)
@@ -397,7 +397,7 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
}
// C2S Engines
for (i = 0 ; i < 32 ; i++) {
-   capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
+   capabilities_reg = readq(pcard->dma_bar_base + 
KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i));
if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32 + i,  
pcard->pdev->irq);
if (err)
-- 
2.20.1



[PATCH 3/6] staging: kpc2000: fix invalid linebreaks in cell_probe.c

2019-05-22 Thread Simon Sandström
Fixes checkpatch.pl error "else should follow close brace '}'" and
"trailing statements should be on next line".

Signed-off-by: Simon Sandström 
---
 drivers/staging/kpc2000/kpc2000/cell_probe.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c 
b/drivers/staging/kpc2000/kpc2000/cell_probe.c
index 51d32970f025..4742f909db79 100644
--- a/drivers/staging/kpc2000/kpc2000/cell_probe.c
+++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c
@@ -85,8 +85,12 @@ static
 void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, 
const u8 entry_rev)
 {
switch (entry_rev) {
-   case 0: parse_core_table_entry_v0(cte, read_val); break;
-   default: cte->type = 0; break;
+   case 0:
+   parse_core_table_entry_v0(cte, read_val);
+   break;
+   default:
+   cte->type = 0;
+   break;
}
 }
 
@@ -387,7 +391,8 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i,  pcard->pdev->irq);
-   if (err) goto err_out;
+   if (err)
+   goto err_out;
}
}
// C2S Engines
@@ -395,7 +400,8 @@ static int  kp2000_setup_dma_controller(struct 
kp2000_device *pcard)
capabilities_reg = readq( pcard->dma_bar_base + 
KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) );
if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) {
err = create_dma_engine_core(pcard, 
(KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i,  pcard->pdev->irq);
-   if (err) goto err_out;
+   if (err)
+   goto err_out;
}
}
 
@@ -418,7 +424,8 @@ int  kp2000_probe_cores(struct kp2000_device *pcard)
dev_dbg(>pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", 
pcard, pcard->card_num);
 
err = kp2000_setup_dma_controller(pcard);
-   if (err) return err;
+   if (err)
+   return err;
 
INIT_LIST_HEAD(>uio_devices_list);
 
-- 
2.20.1



[PATCH 0/6] Fix coding style issues in drivers/staging/kpc2000

2019-05-22 Thread Simon Sandström
These patches fixes a bunch of minor coding style issues in
kpc2000/cell_probe.c.

- Simon

Simon Sandström (6):
  staging: kpc2000: fix indent in cell_probe.c
  staging: kpc2000: add space between ) and { in cell_probe.c
  staging: kpc2000: fix invalid linebreaks in cell_probe.c
  staging: kpc2000: add spaces around operators in cell_probe.c
  staging: kpc2000: add space after comma in cell_probe.c
  staging: kpc2000: remove invalid spaces in cell_probe.c

 drivers/staging/kpc2000/kpc2000/cell_probe.c | 585 ++-
 1 file changed, 296 insertions(+), 289 deletions(-)

-- 
2.20.1



[PATCH RESEND] staging: pi433: break long lines in pi433_if.c

2018-04-23 Thread Simon Sandström
Breaks long lines in pi433_if.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/pi433_if.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 2a05eff88469..b061f77dda41 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -591,13 +591,17 @@ pi433_tx_thread(void *data)
 */
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
-   dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
+   dev_dbg(device->dev,
+   "reading tx_cfg from fifo failed: got %d 
byte(s), expected %d",
+   retval, (unsigned int)sizeof(tx_cfg));
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
-   dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
+   dev_dbg(device->dev,
+   "reading msg size from fifo failed: got %d, 
expected %d",
+   retval, (unsigned int)sizeof(size_t));
continue;
}
 
@@ -619,7 +623,11 @@ pi433_tx_thread(void *data)
 
/* add length byte, if requested */
if (tx_cfg.enable_length_byte  == OPTION_ON)
-   device->buffer[position++] = size - 1; /* according to 
spec length byte itself must be excluded from the length calculation */
+   /*
+* according to spec, length byte itself must be
+* excluded from the length calculation
+*/
+   device->buffer[position++] = size - 1;
 
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
@@ -1047,7 +1055,7 @@ static int setup_gpio(struct pi433_device *device)
/* configure irq */
device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
if (device->irq_num[i] < 0) {
-   device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc 
*)device->irq_num[i];
+   device->gpiod[i] = ERR_PTR(-EINVAL);
return device->irq_num[i];
}
retval = request_irq(device->irq_num[i],
-- 
2.11.0



[PATCH RESEND] staging: pi433: break long lines in pi433_if.c

2018-04-23 Thread Simon Sandström
Breaks long lines in pi433_if.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/pi433_if.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 2a05eff88469..b061f77dda41 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -591,13 +591,17 @@ pi433_tx_thread(void *data)
 */
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
-   dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
+   dev_dbg(device->dev,
+   "reading tx_cfg from fifo failed: got %d 
byte(s), expected %d",
+   retval, (unsigned int)sizeof(tx_cfg));
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
-   dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
+   dev_dbg(device->dev,
+   "reading msg size from fifo failed: got %d, 
expected %d",
+   retval, (unsigned int)sizeof(size_t));
continue;
}
 
@@ -619,7 +623,11 @@ pi433_tx_thread(void *data)
 
/* add length byte, if requested */
if (tx_cfg.enable_length_byte  == OPTION_ON)
-   device->buffer[position++] = size - 1; /* according to 
spec length byte itself must be excluded from the length calculation */
+   /*
+* according to spec, length byte itself must be
+* excluded from the length calculation
+*/
+   device->buffer[position++] = size - 1;
 
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
@@ -1047,7 +1055,7 @@ static int setup_gpio(struct pi433_device *device)
/* configure irq */
device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
if (device->irq_num[i] < 0) {
-   device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc 
*)device->irq_num[i];
+   device->gpiod[i] = ERR_PTR(-EINVAL);
return device->irq_num[i];
}
retval = request_irq(device->irq_num[i],
-- 
2.11.0



[PATCH] staging: pi433: break long lines in rf69.c

2018-04-06 Thread Simon Sandström
Breaks long lines in rf69.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 182 ++-
 1 file changed, 129 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 5b0554823263..90280e9b006d 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -97,7 +97,8 @@ static int rf69_clear_bit(struct spi_device *spi, u8 reg, u8 
mask)
return rf69_write_reg(spi, reg, tmp);
 }
 
-static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, u8 mask, 
u8 value)
+static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg,
+ u8 mask, u8 value)
 {
u8 tmp;
 
@@ -112,15 +113,20 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
switch (mode) {
case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_TRANSMIT);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_TRANSMIT);
case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_RECEIVE);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_RECEIVE);
case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_SYNTHESIZER);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_SYNTHESIZER);
case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_STANDBY);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_STANDBY);
case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_SLEEP);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_SLEEP);
default:
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
@@ -133,16 +139,21 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
 
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 {
-   return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE, 
data_mode);
+   return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE,
+  data_mode);
 }
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
switch (modulation) {
case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  DATAMODUL_MODULATION_TYPE_OOK);
case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  DATAMODUL_MODULATION_TYPE_FSK);
default:
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
@@ -172,13 +183,21 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
case FSK:
switch (mod_shaping) {
case SHAPING_OFF:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  
MASK_DATAMODUL_MODULATION_SHAPE,
+  
DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_1_0:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  
MASK_DATAMODUL_MODULATION_SHAPE,
+  
DATAMODUL_MODULATION_SHAPE_1_0);
case SHAPING_0_5:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_5);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+

[PATCH] staging: pi433: break long lines in rf69.c

2018-04-06 Thread Simon Sandström
Breaks long lines in rf69.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 182 ++-
 1 file changed, 129 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 5b0554823263..90280e9b006d 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -97,7 +97,8 @@ static int rf69_clear_bit(struct spi_device *spi, u8 reg, u8 
mask)
return rf69_write_reg(spi, reg, tmp);
 }
 
-static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg, u8 mask, 
u8 value)
+static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg,
+ u8 mask, u8 value)
 {
u8 tmp;
 
@@ -112,15 +113,20 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
switch (mode) {
case transmit:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_TRANSMIT);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_TRANSMIT);
case receive:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_RECEIVE);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_RECEIVE);
case synthesizer:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_SYNTHESIZER);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_SYNTHESIZER);
case standby:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_STANDBY);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_STANDBY);
case mode_sleep:
-   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE, 
OPMODE_MODE_SLEEP);
+   return rf69_read_mod_write(spi, REG_OPMODE, MASK_OPMODE_MODE,
+  OPMODE_MODE_SLEEP);
default:
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
@@ -133,16 +139,21 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
 
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 {
-   return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE, 
data_mode);
+   return rf69_read_mod_write(spi, REG_DATAMODUL, MASK_DATAMODUL_MODE,
+  data_mode);
 }
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
switch (modulation) {
case OOK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  DATAMODUL_MODULATION_TYPE_OOK);
case FSK:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  MASK_DATAMODUL_MODULATION_TYPE,
+  DATAMODUL_MODULATION_TYPE_FSK);
default:
dev_dbg(>dev, "set: illegal input param");
return -EINVAL;
@@ -172,13 +183,21 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
case FSK:
switch (mod_shaping) {
case SHAPING_OFF:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_NONE);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  
MASK_DATAMODUL_MODULATION_SHAPE,
+  
DATAMODUL_MODULATION_SHAPE_NONE);
case SHAPING_1_0:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_1_0);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  
MASK_DATAMODUL_MODULATION_SHAPE,
+  
DATAMODUL_MODULATION_SHAPE_1_0);
case SHAPING_0_5:
-   return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_SHAPE, DATAMODUL_MODULATION_SHAPE_0_5);
+   return rf69_read_mod_write(spi, REG_DATAMODUL,
+  

[PATCH] staging: pi433: break long lines in pi433_if.c

2018-04-06 Thread Simon Sandström
Breaks long lines in pi433_if.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/pi433_if.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..795cf77e002c 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -593,14 +593,18 @@ pi433_tx_thread(void *data)
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
-   dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
+   dev_dbg(device->dev,
+   "reading tx_cfg from fifo failed: got %d 
byte(s), expected %d",
+   retval, (unsigned int)sizeof(tx_cfg));
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
-   dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
+   dev_dbg(device->dev,
+   "reading msg size from fifo failed: got %d, 
expected %d",
+   retval, (unsigned int)sizeof(size_t));
mutex_unlock(>tx_fifo_lock);
continue;
}
@@ -623,7 +627,11 @@ pi433_tx_thread(void *data)
 
/* add length byte, if requested */
if (tx_cfg.enable_length_byte  == OPTION_ON)
-   device->buffer[position++] = size - 1; /* according to 
spec length byte itself must be excluded from the length calculation */
+   /*
+* according to spec, length byte itself must be
+* excluded from the length calculation
+*/
+   device->buffer[position++] = size - 1;
 
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
@@ -856,7 +864,8 @@ pi433_write(struct file *filp, const char __user *buf,
 
 abort:
dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
+   /* TODO: find a solution to not discard already stored valid entries */
+   kfifo_reset(>tx_fifo);
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
@@ -1042,7 +1051,7 @@ static int setup_gpio(struct pi433_device *device)
/* configure irq */
device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
if (device->irq_num[i] < 0) {
-   device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc 
*)device->irq_num[i];
+   device->gpiod[i] = ERR_PTR(-EINVAL);
return device->irq_num[i];
}
retval = request_irq(device->irq_num[i],
-- 
2.11.0



[PATCH] staging: pi433: break long lines in pi433_if.c

2018-04-06 Thread Simon Sandström
Breaks long lines in pi433_if.c, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/pi433_if.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d1e0ddbc79ce..795cf77e002c 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -593,14 +593,18 @@ pi433_tx_thread(void *data)
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
if (retval != sizeof(tx_cfg)) {
-   dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg));
+   dev_dbg(device->dev,
+   "reading tx_cfg from fifo failed: got %d 
byte(s), expected %d",
+   retval, (unsigned int)sizeof(tx_cfg));
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
if (retval != sizeof(size_t)) {
-   dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t));
+   dev_dbg(device->dev,
+   "reading msg size from fifo failed: got %d, 
expected %d",
+   retval, (unsigned int)sizeof(size_t));
mutex_unlock(>tx_fifo_lock);
continue;
}
@@ -623,7 +627,11 @@ pi433_tx_thread(void *data)
 
/* add length byte, if requested */
if (tx_cfg.enable_length_byte  == OPTION_ON)
-   device->buffer[position++] = size - 1; /* according to 
spec length byte itself must be excluded from the length calculation */
+   /*
+* according to spec, length byte itself must be
+* excluded from the length calculation
+*/
+   device->buffer[position++] = size - 1;
 
/* add adr byte, if requested */
if (tx_cfg.enable_address_byte == OPTION_ON)
@@ -856,7 +864,8 @@ pi433_write(struct file *filp, const char __user *buf,
 
 abort:
dev_dbg(device->dev, "write to fifo failed: 0x%x", retval);
-   kfifo_reset(>tx_fifo); // TODO: maybe find a solution, not to 
discard already stored, valid entries
+   /* TODO: find a solution to not discard already stored valid entries */
+   kfifo_reset(>tx_fifo);
mutex_unlock(>tx_fifo_lock);
return -EAGAIN;
 }
@@ -1042,7 +1051,7 @@ static int setup_gpio(struct pi433_device *device)
/* configure irq */
device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
if (device->irq_num[i] < 0) {
-   device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc 
*)device->irq_num[i];
+   device->gpiod[i] = ERR_PTR(-EINVAL);
return device->irq_num[i];
}
retval = request_irq(device->irq_num[i],
-- 
2.11.0



[PATCH] staging: pi433: break long lines

2018-04-06 Thread Simon Sandström
Breaks long lines in rf69.h, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.h | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index b9f6850e3316..c131ffbdc2db 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -28,7 +28,8 @@
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
-int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping 
mod_shaping);
+int rf69_set_modulation_shaping(struct spi_device *spi,
+   enum mod_shaping mod_shaping);
 int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
 int rf69_set_deviation(struct spi_device *spi, u32 deviation);
 int rf69_set_frequency(struct spi_device *spi, u32 frequency);
@@ -36,28 +37,37 @@ int rf69_enable_amplifier(struct spi_device *spi, u8 
amplifier_mask);
 int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
-int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
+int rf69_set_antenna_impedance(struct spi_device *spi,
+  enum antenna_impedance antenna_impedance);
 int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain);
-int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
-int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
-int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
+int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse,
+  u8 exponent);
+int rf69_set_bandwidth_during_afc(struct spi_device *spi,
+ enum mantisse mantisse,
+ u8 exponent);
+int rf69_set_ook_threshold_dec(struct spi_device *spi,
+  enum threshold_decrement threshold_decrement);
 int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
 int rf69_enable_sync(struct spi_device *spi);
 int rf69_disable_sync(struct spi_device *spi);
-int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
+int rf69_set_fifo_fill_condition(struct spi_device *spi,
+enum fifo_fill_condition fifo_fill_condition);
 int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]);
-int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format);
+int rf69_set_packet_format(struct spi_device *spi,
+  enum packet_format packet_format);
 int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
-int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
+int rf69_set_address_filtering(struct spi_device *spi,
+  enum address_filtering address_filtering);
 int rf69_set_payload_length(struct spi_device *spi, u8 payload_length);
 int rf69_set_node_address(struct spi_device *spi, u8 node_address);
 int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address);
-int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition);
+int rf69_set_tx_start_condition(struct spi_device *spi,
+   enum tx_start_condition tx_start_condition);
 int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc);
 
-- 
2.11.0



[PATCH] staging: pi433: break long lines

2018-04-06 Thread Simon Sandström
Breaks long lines in rf69.h, fixing checkpatch.pl warnings:
"WARNING: line over 80 characters"

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.h | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index b9f6850e3316..c131ffbdc2db 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -28,7 +28,8 @@
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
-int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping 
mod_shaping);
+int rf69_set_modulation_shaping(struct spi_device *spi,
+   enum mod_shaping mod_shaping);
 int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
 int rf69_set_deviation(struct spi_device *spi, u32 deviation);
 int rf69_set_frequency(struct spi_device *spi, u32 frequency);
@@ -36,28 +37,37 @@ int rf69_enable_amplifier(struct spi_device *spi, u8 
amplifier_mask);
 int rf69_disable_amplifier(struct spi_device *spi, u8 amplifier_mask);
 int rf69_set_output_power_level(struct spi_device *spi, u8 power_level);
 int rf69_set_pa_ramp(struct spi_device *spi, enum pa_ramp pa_ramp);
-int rf69_set_antenna_impedance(struct spi_device *spi, enum antenna_impedance 
antenna_impedance);
+int rf69_set_antenna_impedance(struct spi_device *spi,
+  enum antenna_impedance antenna_impedance);
 int rf69_set_lna_gain(struct spi_device *spi, enum lna_gain lna_gain);
-int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse, u8 
exponent);
-int rf69_set_bandwidth_during_afc(struct spi_device *spi, enum mantisse 
mantisse, u8 exponent);
-int rf69_set_ook_threshold_dec(struct spi_device *spi, enum 
threshold_decrement threshold_decrement);
+int rf69_set_bandwidth(struct spi_device *spi, enum mantisse mantisse,
+  u8 exponent);
+int rf69_set_bandwidth_during_afc(struct spi_device *spi,
+ enum mantisse mantisse,
+ u8 exponent);
+int rf69_set_ook_threshold_dec(struct spi_device *spi,
+  enum threshold_decrement threshold_decrement);
 int rf69_set_dio_mapping(struct spi_device *spi, u8 dio_number, u8 value);
 bool rf69_get_flag(struct spi_device *spi, enum flag flag);
 int rf69_set_rssi_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_preamble_length(struct spi_device *spi, u16 preamble_length);
 int rf69_enable_sync(struct spi_device *spi);
 int rf69_disable_sync(struct spi_device *spi);
-int rf69_set_fifo_fill_condition(struct spi_device *spi, enum 
fifo_fill_condition fifo_fill_condition);
+int rf69_set_fifo_fill_condition(struct spi_device *spi,
+enum fifo_fill_condition fifo_fill_condition);
 int rf69_set_sync_size(struct spi_device *spi, u8 sync_size);
 int rf69_set_sync_values(struct spi_device *spi, u8 sync_values[8]);
-int rf69_set_packet_format(struct spi_device *spi, enum packet_format 
packet_format);
+int rf69_set_packet_format(struct spi_device *spi,
+  enum packet_format packet_format);
 int rf69_enable_crc(struct spi_device *spi);
 int rf69_disable_crc(struct spi_device *spi);
-int rf69_set_address_filtering(struct spi_device *spi, enum address_filtering 
address_filtering);
+int rf69_set_address_filtering(struct spi_device *spi,
+  enum address_filtering address_filtering);
 int rf69_set_payload_length(struct spi_device *spi, u8 payload_length);
 int rf69_set_node_address(struct spi_device *spi, u8 node_address);
 int rf69_set_broadcast_address(struct spi_device *spi, u8 broadcast_address);
-int rf69_set_tx_start_condition(struct spi_device *spi, enum 
tx_start_condition tx_start_condition);
+int rf69_set_tx_start_condition(struct spi_device *spi,
+   enum tx_start_condition tx_start_condition);
 int rf69_set_fifo_threshold(struct spi_device *spi, u8 threshold);
 int rf69_set_dagc(struct spi_device *spi, enum dagc dagc);
 
-- 
2.11.0



Re: rf69_get_lna_gain

2017-12-14 Thread Simon Sandström
On Thu, Dec 14, 2017 at 06:08:11PM +0200, Marcus Wolf wrote:
> Hi!
> 
> This is an information for all of you, doing experiments with real hardware!
> 
> I wanted to explain, what this lna_gain stuff is used for:
> 
> If you are receiving messages from different sender (let's say several
> thermometers), it may happen (e. g. due to different distance and different
> battery level) that the automatic gain control of the receiver amp isn't
> able to work correctly. E.g. if it gets a very strong singal first and a
> very weak afterwards, it is possible, that the agc isn't capable to
> recognize the second telegram predictable.
> 
> The procedure, need to be done in such a case is:
> Switch on agc. Wait for a correct telegram to be received. Read the
> lna_gain_current value and store it. This is the gain setting for optimal
> reception for one of your sender. You now can set gain_select to this value,
> in order to receive stuff from this sender (instead of using agc).
> If you want to receive stuff from an other sender, you may want to try with
> different other settings. As soon, as you have success, you can store this
> value and use it for receiving stuff from that sender.
> 
> Since I have just a 35m² flat, it is quite hard to have a setup, to test
> such stuff. In summer I did some experiments on the pavement, but the
> experimental code never was integrated in the productional source repo,
> because I focused on tx first. Deeper use of rx is planned for late spring
> next year.
> 
> If you want to do experiments with rx of signals with different strength,
> maybe you want to save a copy of the abstracions (rf69_set_lna_gain and
> rf69_get_lna_gain) befor they get deleted in staging-next.
> 
> Regards,
> 
> Marcus
> 

Hi Marcus,

There is no need to make backups of code as it's still there in the git
history. If we ever need to re-introduce rf69_get_lna_gain, or any other
function that is removed due to not being used right now, it's just a
simple matter of reverting the commit that removed them. Either revert
them directly or use the revert as a base for re-introducing the
functionality.

So you don't have to feel like we're throwing away work that you've
probably spent lots of time on. It will still be available for us when
we actually need it. But right now, from what I've read in this thread,
the functionality isn't used at all right now (dead code) and should
therefore be removed.


Regards,
Simon


Re: rf69_get_lna_gain

2017-12-14 Thread Simon Sandström
On Thu, Dec 14, 2017 at 06:08:11PM +0200, Marcus Wolf wrote:
> Hi!
> 
> This is an information for all of you, doing experiments with real hardware!
> 
> I wanted to explain, what this lna_gain stuff is used for:
> 
> If you are receiving messages from different sender (let's say several
> thermometers), it may happen (e. g. due to different distance and different
> battery level) that the automatic gain control of the receiver amp isn't
> able to work correctly. E.g. if it gets a very strong singal first and a
> very weak afterwards, it is possible, that the agc isn't capable to
> recognize the second telegram predictable.
> 
> The procedure, need to be done in such a case is:
> Switch on agc. Wait for a correct telegram to be received. Read the
> lna_gain_current value and store it. This is the gain setting for optimal
> reception for one of your sender. You now can set gain_select to this value,
> in order to receive stuff from this sender (instead of using agc).
> If you want to receive stuff from an other sender, you may want to try with
> different other settings. As soon, as you have success, you can store this
> value and use it for receiving stuff from that sender.
> 
> Since I have just a 35m² flat, it is quite hard to have a setup, to test
> such stuff. In summer I did some experiments on the pavement, but the
> experimental code never was integrated in the productional source repo,
> because I focused on tx first. Deeper use of rx is planned for late spring
> next year.
> 
> If you want to do experiments with rx of signals with different strength,
> maybe you want to save a copy of the abstracions (rf69_set_lna_gain and
> rf69_get_lna_gain) befor they get deleted in staging-next.
> 
> Regards,
> 
> Marcus
> 

Hi Marcus,

There is no need to make backups of code as it's still there in the git
history. If we ever need to re-introduce rf69_get_lna_gain, or any other
function that is removed due to not being used right now, it's just a
simple matter of reverting the commit that removed them. Either revert
them directly or use the revert as a base for re-introducing the
functionality.

So you don't have to feel like we're throwing away work that you've
probably spent lots of time on. It will still be available for us when
we actually need it. But right now, from what I've read in this thread,
the functionality isn't used at all right now (dead code) and should
therefore be removed.


Regards,
Simon


[PATCH 2/3] staging: pi433: Remove function entry dev_dbg()

2017-12-09 Thread Simon Sandström
ftrace can be used to trace function calls, so there is no need to use
dev_dbg() here.

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 156 ---
 1 file changed, 156 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 39920240c05c..04a74423c325 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -64,10 +64,6 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg, u8 mask, u
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: mode");
-#endif
-
switch (mode) {
case transmit:return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
case receive: return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_RECEIVE);
@@ -91,10 +87,6 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: modulation");
-#endif
-
switch (modulation) {
case OOK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
case FSK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
@@ -108,10 +100,6 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 {
u8 currentValue;
 
-#ifdef DEBUG
-   dev_dbg(>dev, "get: mode");
-#endif
-
currentValue = rf69_read_reg(spi, REG_DATAMODUL);
 
switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO 
improvement: change 3 to define
@@ -124,10 +112,6 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 int rf69_set_modulation_shaping(struct spi_device *spi,
enum mod_shaping mod_shaping)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: mod shaping");
-#endif
-
switch (rf69_get_modulation(spi)) {
case FSK:
switch (mod_shaping) {
@@ -162,10 +146,6 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
u8 msb;
u8 lsb;
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: bit rate");
-#endif
-
// check input value
bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
if (bitRate < bitRate_min) {
@@ -199,10 +179,6 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: deviation");
-#endif
-
// TODO: Dependency to bitrate
if (deviation < 600 || deviation > 50) {
dev_dbg(>dev, "set_deviation: illegal input param");
@@ -248,10 +224,6 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: frequency");
-#endif
-
// calculat f step
f_step = F_OSC * factor;
do_div(f_step, 524288); //  524288 = 2^19
@@ -297,10 +269,6 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask)
 
 int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: power level");
-#endif
-
// TODO: Dependency to PA0,1,2 setting
powerLevel += 18;
 
@@ -316,10 +284,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: pa ramp");
-#endif
-
switch (paRamp) {
case ramp3400:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
case ramp2000:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
@@ -345,10 +309,6 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp 
paRamp)
 
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance 
antennaImpedance)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: antenna impedance");
-#endif
-
switch (antennaImpedance) {
case fiftyOhm:  return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN);
case twohundretOhm: return rf69_set_bit(spi, REG_LNA, MASK_LNA_ZIN);
@@ -360,10 +320,6 @@ int rf69_set_antenna_impedance(struct spi_device *spi, 
enum antennaImpedance ant
 
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: lna gain");
-#endif
-
switch (lnaGain) {
case automatic:  return rf69_read_mod_write(spi, REG_LNA, 
MASK_LNA_GAIN, LNA_GAIN_AUTO);
case max:return rf69_read_mod_write(spi, REG_LNA, 
MASK_LNA_GAIN, L

[PATCH 2/3] staging: pi433: Remove function entry dev_dbg()

2017-12-09 Thread Simon Sandström
ftrace can be used to trace function calls, so there is no need to use
dev_dbg() here.

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 156 ---
 1 file changed, 156 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 39920240c05c..04a74423c325 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -64,10 +64,6 @@ static inline int rf69_read_mod_write(struct spi_device 
*spi, u8 reg, u8 mask, u
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: mode");
-#endif
-
switch (mode) {
case transmit:return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
case receive: return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_RECEIVE);
@@ -91,10 +87,6 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: modulation");
-#endif
-
switch (modulation) {
case OOK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
case FSK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_FSK);
@@ -108,10 +100,6 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 {
u8 currentValue;
 
-#ifdef DEBUG
-   dev_dbg(>dev, "get: mode");
-#endif
-
currentValue = rf69_read_reg(spi, REG_DATAMODUL);
 
switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO 
improvement: change 3 to define
@@ -124,10 +112,6 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 int rf69_set_modulation_shaping(struct spi_device *spi,
enum mod_shaping mod_shaping)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: mod shaping");
-#endif
-
switch (rf69_get_modulation(spi)) {
case FSK:
switch (mod_shaping) {
@@ -162,10 +146,6 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
u8 msb;
u8 lsb;
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: bit rate");
-#endif
-
// check input value
bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
if (bitRate < bitRate_min) {
@@ -199,10 +179,6 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: deviation");
-#endif
-
// TODO: Dependency to bitrate
if (deviation < 600 || deviation > 50) {
dev_dbg(>dev, "set_deviation: illegal input param");
@@ -248,10 +224,6 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-#ifdef DEBUG
-   dev_dbg(>dev, "set: frequency");
-#endif
-
// calculat f step
f_step = F_OSC * factor;
do_div(f_step, 524288); //  524288 = 2^19
@@ -297,10 +269,6 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask)
 
 int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: power level");
-#endif
-
// TODO: Dependency to PA0,1,2 setting
powerLevel += 18;
 
@@ -316,10 +284,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: pa ramp");
-#endif
-
switch (paRamp) {
case ramp3400:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
case ramp2000:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_2000);
@@ -345,10 +309,6 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp 
paRamp)
 
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance 
antennaImpedance)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: antenna impedance");
-#endif
-
switch (antennaImpedance) {
case fiftyOhm:  return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN);
case twohundretOhm: return rf69_set_bit(spi, REG_LNA, MASK_LNA_ZIN);
@@ -360,10 +320,6 @@ int rf69_set_antenna_impedance(struct spi_device *spi, 
enum antennaImpedance ant
 
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
 {
-#ifdef DEBUG
-   dev_dbg(>dev, "set: lna gain");
-#endif
-
switch (lnaGain) {
case automatic:  return rf69_read_mod_write(spi, REG_LNA, 
MASK_LNA_GAIN, LNA_GAIN_AUTO);
case max:return rf69_read_mod_write(spi, REG_LNA, 
MASK_LNA_GAIN, LNA_GAIN_MAX);
@@ -382,10 +338

[PATCH 1/3] staging: pi433: Remove indentation on #ifdef blocks

2017-12-09 Thread Simon Sandström
ifdef blocks should not increase indentation level.

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 314 +--
 1 file changed, 153 insertions(+), 161 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 8b6d68f10e8a..39920240c05c 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -64,9 +64,9 @@ static inline int rf69_read_mod_write(struct spi_device *spi, 
u8 reg, u8 mask, u
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: mode");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: mode");
+#endif
 
switch (mode) {
case transmit:return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
@@ -91,9 +91,9 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: modulation");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: modulation");
+#endif
 
switch (modulation) {
case OOK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
@@ -108,9 +108,9 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 {
u8 currentValue;
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "get: mode");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "get: mode");
+#endif
 
currentValue = rf69_read_reg(spi, REG_DATAMODUL);
 
@@ -124,9 +124,9 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 int rf69_set_modulation_shaping(struct spi_device *spi,
enum mod_shaping mod_shaping)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: mod shaping");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: mod shaping");
+#endif
 
switch (rf69_get_modulation(spi)) {
case FSK:
@@ -162,9 +162,9 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
u8 msb;
u8 lsb;
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: bit rate");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: bit rate");
+#endif
 
// check input value
bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
@@ -199,9 +199,9 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: deviation");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: deviation");
+#endif
 
// TODO: Dependency to bitrate
if (deviation < 600 || deviation > 50) {
@@ -248,9 +248,9 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: frequency");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: frequency");
+#endif
 
// calculat f step
f_step = F_OSC * factor;
@@ -297,9 +297,9 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask)
 
 int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: power level");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: power level");
+#endif
 
// TODO: Dependency to PA0,1,2 setting
powerLevel += 18;
@@ -316,9 +316,9 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: pa ramp");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: pa ramp");
+#endif
 
switch (paRamp) {
case ramp3400:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
@@ -345,9 +345,9 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp 
paRamp)
 
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance 
antennaImpedance)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: antenna impedance");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: antenna impedance");
+#endif
 
switch (antennaImpedance) {
case fiftyOhm:  return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN);
@@ -360,9 +360,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum 
antennaImpedance ant
 
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: lna 

[PATCH 0/3] staging: pi433: Refactor usage of dev_dbg and #ifdef DEBUG

2017-12-09 Thread Simon Sandström
These patches refactors the usage of dev_dbg and #ifdef DEBUG in rf69.c.
All dev_dbg() calls that just prints the function name are removed, since
we have ftrace. For all other calls the #ifdef DEBUG block around them are
removed.

There are still two more defines used in rf69.c: DEBUG_FIFO_ACCESS and
DEBUG_VALUES. Perhaps they should be removed as well?

- Simon

---

Simon Sandström (3):
  staging: pi433: Remove indentation on #ifdef blocks
  staging: pi433: Remove function entry dev_dbg()
  staging: pi433: Remove unnecessary #ifdef DEBUG around dev_dbg

 drivers/staging/pi433/rf69.c | 232 ++-
 1 file changed, 32 insertions(+), 200 deletions(-)

-- 
2.11.0



[PATCH 1/3] staging: pi433: Remove indentation on #ifdef blocks

2017-12-09 Thread Simon Sandström
ifdef blocks should not increase indentation level.

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 314 +--
 1 file changed, 153 insertions(+), 161 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 8b6d68f10e8a..39920240c05c 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -64,9 +64,9 @@ static inline int rf69_read_mod_write(struct spi_device *spi, 
u8 reg, u8 mask, u
 
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: mode");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: mode");
+#endif
 
switch (mode) {
case transmit:return rf69_read_mod_write(spi, REG_OPMODE, 
MASK_OPMODE_MODE, OPMODE_MODE_TRANSMIT);
@@ -91,9 +91,9 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
 
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: modulation");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: modulation");
+#endif
 
switch (modulation) {
case OOK: return rf69_read_mod_write(spi, REG_DATAMODUL, 
MASK_DATAMODUL_MODULATION_TYPE, DATAMODUL_MODULATION_TYPE_OOK);
@@ -108,9 +108,9 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 {
u8 currentValue;
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "get: mode");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "get: mode");
+#endif
 
currentValue = rf69_read_reg(spi, REG_DATAMODUL);
 
@@ -124,9 +124,9 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 int rf69_set_modulation_shaping(struct spi_device *spi,
enum mod_shaping mod_shaping)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: mod shaping");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: mod shaping");
+#endif
 
switch (rf69_get_modulation(spi)) {
case FSK:
@@ -162,9 +162,9 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
u8 msb;
u8 lsb;
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: bit rate");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: bit rate");
+#endif
 
// check input value
bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
@@ -199,9 +199,9 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: deviation");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: deviation");
+#endif
 
// TODO: Dependency to bitrate
if (deviation < 600 || deviation > 50) {
@@ -248,9 +248,9 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
u8 lsb;
u64 factor = 100; // to improve precision of calculation
 
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: frequency");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: frequency");
+#endif
 
// calculat f step
f_step = F_OSC * factor;
@@ -297,9 +297,9 @@ int rf69_disable_amplifier(struct spi_device *spi, u8 
amplifier_mask)
 
 int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: power level");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: power level");
+#endif
 
// TODO: Dependency to PA0,1,2 setting
powerLevel += 18;
@@ -316,9 +316,9 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
 
 int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: pa ramp");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: pa ramp");
+#endif
 
switch (paRamp) {
case ramp3400:  return rf69_write_reg(spi, REG_PARAMP, PARAMP_3400);
@@ -345,9 +345,9 @@ int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp 
paRamp)
 
 int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance 
antennaImpedance)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: antenna impedance");
-   #endif
+#ifdef DEBUG
+   dev_dbg(>dev, "set: antenna impedance");
+#endif
 
switch (antennaImpedance) {
case fiftyOhm:  return rf69_clear_bit(spi, REG_LNA, MASK_LNA_ZIN);
@@ -360,9 +360,9 @@ int rf69_set_antenna_impedance(struct spi_device *spi, enum 
antennaImpedance ant
 
 int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
 {
-   #ifdef DEBUG
-   dev_dbg(>dev, "set: lna gain")

[PATCH 0/3] staging: pi433: Refactor usage of dev_dbg and #ifdef DEBUG

2017-12-09 Thread Simon Sandström
These patches refactors the usage of dev_dbg and #ifdef DEBUG in rf69.c.
All dev_dbg() calls that just prints the function name are removed, since
we have ftrace. For all other calls the #ifdef DEBUG block around them are
removed.

There are still two more defines used in rf69.c: DEBUG_FIFO_ACCESS and
DEBUG_VALUES. Perhaps they should be removed as well?

- Simon

---

Simon Sandström (3):
  staging: pi433: Remove indentation on #ifdef blocks
  staging: pi433: Remove function entry dev_dbg()
  staging: pi433: Remove unnecessary #ifdef DEBUG around dev_dbg

 drivers/staging/pi433/rf69.c | 232 ++-
 1 file changed, 32 insertions(+), 200 deletions(-)

-- 
2.11.0



[PATCH 3/3] staging: pi433: Remove unnecessary #ifdef DEBUG around dev_dbg

2017-12-09 Thread Simon Sandström
dev_dbg() already depends on DEBUG.

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 04a74423c325..6e38e6a515a4 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -767,9 +767,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
int retval;
 
if (size > FIFO_SIZE) {
-#ifdef DEBUG
dev_dbg(>dev, "read fifo: passed in buffer bigger then 
internal buffer\n");
-#endif
return -EMSGSIZE;
}
 
@@ -801,9 +799,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, 
unsigned int size)
u8 local_buffer[FIFO_SIZE + 1];
 
if (size > FIFO_SIZE) {
-#ifdef DEBUG
dev_dbg(>dev, "read fifo: passed in buffer bigger then 
internal buffer\n");
-#endif
return -EMSGSIZE;
}
 
-- 
2.11.0



[PATCH 3/3] staging: pi433: Remove unnecessary #ifdef DEBUG around dev_dbg

2017-12-09 Thread Simon Sandström
dev_dbg() already depends on DEBUG.

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 04a74423c325..6e38e6a515a4 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -767,9 +767,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
int retval;
 
if (size > FIFO_SIZE) {
-#ifdef DEBUG
dev_dbg(>dev, "read fifo: passed in buffer bigger then 
internal buffer\n");
-#endif
return -EMSGSIZE;
}
 
@@ -801,9 +799,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, 
unsigned int size)
u8 local_buffer[FIFO_SIZE + 1];
 
if (size > FIFO_SIZE) {
-#ifdef DEBUG
dev_dbg(>dev, "read fifo: passed in buffer bigger then 
internal buffer\n");
-#endif
return -EMSGSIZE;
}
 
-- 
2.11.0



[PATCH] staging: pi433: Add spaces around & and + operator

2017-12-07 Thread Simon Sandström
Fixes checkpatch warning: "spaces preferred around that '&'".

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7140fa2ea592..33a01318e840 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -82,7 +82,6 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
-
 }
 
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
@@ -173,8 +172,8 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
// calculate reg settings
bitRate_reg = (F_OSC / bitRate);
 
-   msb = (bitRate_reg&0xff00)   >>  8;
-   lsb = (bitRate_reg&0xff);
+   msb = (bitRate_reg & 0xff00) >> 8;
+   lsb = (bitRate_reg & 0xff);
 
// transmit to RF 69
retval = rf69_write_reg(spi, REG_BITRATE_MSB, msb);
@@ -214,8 +213,8 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
f_reg = deviation * factor;
do_div(f_reg, f_step);
 
-   msb = (f_reg&0xff00)   >>  8;
-   lsb = (f_reg&0xff);
+   msb = (f_reg & 0xff00) >> 8;
+   lsb = (f_reg & 0xff);
 
// check msb
if (msb & ~FDEVMASB_MASK) {
@@ -264,9 +263,9 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
f_reg = frequency * factor;
do_div(f_reg, f_step);
 
-   msb = (f_reg&0xff) >> 16;
-   mid = (f_reg&0xff00)   >>  8;
-   lsb = (f_reg&0xff);
+   msb = (f_reg & 0xff) >> 16;
+   mid = (f_reg & 0xff00)   >>  8;
+   lsb = (f_reg & 0xff);
 
// write to chip
retval = rf69_write_reg(spi, REG_FRF_MSB, msb);
@@ -685,8 +684,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 
preambleLength)
/* no value check needed - u16 exactly matches register size */
 
/* calculate reg settings */
-   msb = (preambleLength&0xff00)   >>  8;
-   lsb = (preambleLength&0xff);
+   msb = (preambleLength & 0xff00) >> 8;
+   lsb = (preambleLength & 0xff);
 
/* transmit to chip */
retval = rf69_write_reg(spi, REG_PREAMBLE_MSB, msb);
@@ -930,14 +929,14 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
memset(, 0, sizeof(transfer));
transfer.tx_buf = local_buffer;
transfer.rx_buf = local_buffer;
-   transfer.len= size+1;
+   transfer.len= size + 1;
 
retval = spi_sync_transfer(spi, , 1);
 
-   #ifdef DEBUG_FIFO_ACCESS
-   for (i = 0; i < size; i++)
-   dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i+1]);
-   #endif
+#ifdef DEBUG_FIFO_ACCESS
+   for (i = 0; i < size; i++)
+   dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i + 1]);
+#endif
 
memcpy(buffer, _buffer[1], size);  // TODO: ohne memcopy w�re 
sch�ner
 
-- 
2.11.0



[PATCH] staging: pi433: Add spaces around & and + operator

2017-12-07 Thread Simon Sandström
Fixes checkpatch warning: "spaces preferred around that '&'".

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7140fa2ea592..33a01318e840 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -82,7 +82,6 @@ int rf69_set_mode(struct spi_device *spi, enum mode mode)
// we are using packet mode, so this check is not really needed
// but waiting for mode ready is necessary when going from sleep 
because the FIFO may not be immediately available from previous mode
//while (_mode == RF69_MODE_SLEEP && (READ_REG(REG_IRQFLAGS1) & 
RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady
-
 }
 
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode)
@@ -173,8 +172,8 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
// calculate reg settings
bitRate_reg = (F_OSC / bitRate);
 
-   msb = (bitRate_reg&0xff00)   >>  8;
-   lsb = (bitRate_reg&0xff);
+   msb = (bitRate_reg & 0xff00) >> 8;
+   lsb = (bitRate_reg & 0xff);
 
// transmit to RF 69
retval = rf69_write_reg(spi, REG_BITRATE_MSB, msb);
@@ -214,8 +213,8 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
f_reg = deviation * factor;
do_div(f_reg, f_step);
 
-   msb = (f_reg&0xff00)   >>  8;
-   lsb = (f_reg&0xff);
+   msb = (f_reg & 0xff00) >> 8;
+   lsb = (f_reg & 0xff);
 
// check msb
if (msb & ~FDEVMASB_MASK) {
@@ -264,9 +263,9 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
f_reg = frequency * factor;
do_div(f_reg, f_step);
 
-   msb = (f_reg&0xff) >> 16;
-   mid = (f_reg&0xff00)   >>  8;
-   lsb = (f_reg&0xff);
+   msb = (f_reg & 0xff) >> 16;
+   mid = (f_reg & 0xff00)   >>  8;
+   lsb = (f_reg & 0xff);
 
// write to chip
retval = rf69_write_reg(spi, REG_FRF_MSB, msb);
@@ -685,8 +684,8 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 
preambleLength)
/* no value check needed - u16 exactly matches register size */
 
/* calculate reg settings */
-   msb = (preambleLength&0xff00)   >>  8;
-   lsb = (preambleLength&0xff);
+   msb = (preambleLength & 0xff00) >> 8;
+   lsb = (preambleLength & 0xff);
 
/* transmit to chip */
retval = rf69_write_reg(spi, REG_PREAMBLE_MSB, msb);
@@ -930,14 +929,14 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
memset(, 0, sizeof(transfer));
transfer.tx_buf = local_buffer;
transfer.rx_buf = local_buffer;
-   transfer.len= size+1;
+   transfer.len= size + 1;
 
retval = spi_sync_transfer(spi, , 1);
 
-   #ifdef DEBUG_FIFO_ACCESS
-   for (i = 0; i < size; i++)
-   dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i+1]);
-   #endif
+#ifdef DEBUG_FIFO_ACCESS
+   for (i = 0; i < size; i++)
+   dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i + 1]);
+#endif
 
memcpy(buffer, _buffer[1], size);  // TODO: ohne memcopy w�re 
sch�ner
 
-- 
2.11.0



[PATCH] staging: pi433: Fix ISO-8859 encoded non-english comments

2017-12-07 Thread Simon Sandström
Some comments, like "without memcpy would be nice", are removed.
Other comments are just translated to english.
rf69.c is now plain ASCII.

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/rf69.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7140fa2ea592..5ec225024fe6 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -190,7 +190,6 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
 int rf69_set_deviation(struct spi_device *spi, u32 deviation)
 {
int retval;
-// u32 f_max; TODO: Abh�ngigkeit von Bitrate beachten!!
u64 f_reg;
u64 f_step;
u8 msb;
@@ -201,7 +200,8 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
dev_dbg(>dev, "set: deviation");
#endif
 
-   if (deviation < 600 || deviation > 50) { //TODO: Abh�ngigkeit von 
Bitrate beachten!!
+   // TODO: Dependency to bitrate
+   if (deviation < 600 || deviation > 50) {
dev_dbg(>dev, "set_deviation: illegal input param");
return -EINVAL;
}
@@ -298,7 +298,8 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
dev_dbg(>dev, "set: power level");
#endif
 
-   powerLevel += 18; // TODO Abh�ngigkeit von PA0,1,2 setting
+   // TODO: Dependency to PA0,1,2 setting
+   powerLevel += 18;
 
// check input value
if (powerLevel > 0x1f) {
@@ -939,7 +940,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i+1]);
#endif
 
-   memcpy(buffer, _buffer[1], size);  // TODO: ohne memcopy w�re 
sch�ner
+   memcpy(buffer, _buffer[1], size);
 
return retval;
 }
@@ -960,7 +961,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, 
unsigned int size)
}
 
local_buffer[0] = spi_address;
-   memcpy(_buffer[1], buffer, size);  // TODO: ohne memcopy w�re 
sch�ner
+   memcpy(_buffer[1], buffer, size);
 
#ifdef DEBUG_FIFO_ACCESS
for (i = 0; i < size; i++)
-- 
2.11.0



[PATCH] staging: pi433: Fix ISO-8859 encoded non-english comments

2017-12-07 Thread Simon Sandström
Some comments, like "without memcpy would be nice", are removed.
Other comments are just translated to english.
rf69.c is now plain ASCII.

Signed-off-by: Simon Sandström 
---
 drivers/staging/pi433/rf69.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7140fa2ea592..5ec225024fe6 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -190,7 +190,6 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
 int rf69_set_deviation(struct spi_device *spi, u32 deviation)
 {
int retval;
-// u32 f_max; TODO: Abh�ngigkeit von Bitrate beachten!!
u64 f_reg;
u64 f_step;
u8 msb;
@@ -201,7 +200,8 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
dev_dbg(>dev, "set: deviation");
#endif
 
-   if (deviation < 600 || deviation > 50) { //TODO: Abh�ngigkeit von 
Bitrate beachten!!
+   // TODO: Dependency to bitrate
+   if (deviation < 600 || deviation > 50) {
dev_dbg(>dev, "set_deviation: illegal input param");
return -EINVAL;
}
@@ -298,7 +298,8 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 
powerLevel)
dev_dbg(>dev, "set: power level");
#endif
 
-   powerLevel += 18; // TODO Abh�ngigkeit von PA0,1,2 setting
+   // TODO: Dependency to PA0,1,2 setting
+   powerLevel += 18;
 
// check input value
if (powerLevel > 0x1f) {
@@ -939,7 +940,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
dev_dbg(>dev, "%d - 0x%x\n", i, local_buffer[i+1]);
#endif
 
-   memcpy(buffer, _buffer[1], size);  // TODO: ohne memcopy w�re 
sch�ner
+   memcpy(buffer, _buffer[1], size);
 
return retval;
 }
@@ -960,7 +961,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, 
unsigned int size)
}
 
local_buffer[0] = spi_address;
-   memcpy(_buffer[1], buffer, size);  // TODO: ohne memcopy w�re 
sch�ner
+   memcpy(_buffer[1], buffer, size);
 
#ifdef DEBUG_FIFO_ACCESS
for (i = 0; i < size; i++)
-- 
2.11.0



Re: [PATCH 1/6] staging: pi433: Split rf69_set_crc_enabled into two functions

2017-12-07 Thread Simon Sandström
On Thu, Dec 07, 2017 at 03:38:57PM +0100, Greg KH wrote:
> On Wed, Dec 06, 2017 at 09:42:19PM +0100, Simon Sandström wrote:
> > Splits rf69_set_crc_enabled(dev, enabled) into
> > rf69_enable_crc(dev) and rf69_disable_crc(dev).
> > 
> > Signed-off-by: Simon Sandström <si...@nikanor.nu>
> > ---
> >  drivers/staging/pi433/pi433_if.c | 22 --
> >  drivers/staging/pi433/rf69.c | 18 ++
> >  drivers/staging/pi433/rf69.h |  4 ++--
> >  3 files changed, 28 insertions(+), 16 deletions(-)
> 
> This series did not apply at all.
> 
> What tree and branch did you make it against?
> 
> Please redo it against my staging.git tree, the staging-next branch
> should be fine, or the staging-testing will work as well.
> 
> thanks,
> 
> greg k-h

Hmm. Haven't you already applied these?

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing=39252a4bcf63d9dbc168b9ef56eb4ca42e045b9d

>patch "staging: pi433: Split rf69_set_crc_enabled into two functions" added to 
>staging-testing
>
>This is a note to let you know that I've just added the patch titled
>
>staging: pi433: Split rf69_set_crc_enabled into two functions
>
> ...


Regards,
Simon


Re: [PATCH 1/6] staging: pi433: Split rf69_set_crc_enabled into two functions

2017-12-07 Thread Simon Sandström
On Thu, Dec 07, 2017 at 03:38:57PM +0100, Greg KH wrote:
> On Wed, Dec 06, 2017 at 09:42:19PM +0100, Simon Sandström wrote:
> > Splits rf69_set_crc_enabled(dev, enabled) into
> > rf69_enable_crc(dev) and rf69_disable_crc(dev).
> > 
> > Signed-off-by: Simon Sandström 
> > ---
> >  drivers/staging/pi433/pi433_if.c | 22 --
> >  drivers/staging/pi433/rf69.c | 18 ++
> >  drivers/staging/pi433/rf69.h |  4 ++--
> >  3 files changed, 28 insertions(+), 16 deletions(-)
> 
> This series did not apply at all.
> 
> What tree and branch did you make it against?
> 
> Please redo it against my staging.git tree, the staging-next branch
> should be fine, or the staging-testing will work as well.
> 
> thanks,
> 
> greg k-h

Hmm. Haven't you already applied these?

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing=39252a4bcf63d9dbc168b9ef56eb4ca42e045b9d

>patch "staging: pi433: Split rf69_set_crc_enabled into two functions" added to 
>staging-testing
>
>This is a note to let you know that I've just added the patch titled
>
>staging: pi433: Split rf69_set_crc_enabled into two functions
>
> ...


Regards,
Simon


[PATCH 5/6] staging: pi433: Move enum option_on_off to pi433_if.h

2017-12-06 Thread Simon Sandström
The enum is now only used for ioctl, so move it pi433_if.h.

Signed-off-by: Simon Sandström <si...@nikanor.nu>
---
 drivers/staging/pi433/pi433_if.h  | 5 +
 drivers/staging/pi433/rf69_enum.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index bcfe29840889..c8697d144e2b 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -37,6 +37,11 @@
 
 /*---*/
 
+enum option_on_off {
+   OPTION_OFF,
+   OPTION_ON
+};
+
 /* IOCTL structs and commands */
 
 /**
diff --git a/drivers/staging/pi433/rf69_enum.h 
b/drivers/staging/pi433/rf69_enum.h
index b0715b4eb6ac..4e64e38ae4ff 100644
--- a/drivers/staging/pi433/rf69_enum.h
+++ b/drivers/staging/pi433/rf69_enum.h
@@ -18,11 +18,6 @@
 #ifndef RF69_ENUM_H
 #define RF69_ENUM_H
 
-enum option_on_off {
-   OPTION_OFF,
-   OPTION_ON
-};
-
 enum mode {
mode_sleep,
standby,
-- 
2.11.0



  1   2   >