2019-06-05 01:12:41

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 0/6] staging: kpc2000: kpc_spi: Assorted minor fixups

Primarily just a bunch of unused / unnecessarily used struct member
cleanup patches with the exception of one patch which removes an
unnecessary cast to a (void *) in a couple of functions.

Geordan Neukum (6):
staging: kpc2000: kpc_spi: remove unnecessary struct member phys
staging: kpc2000: kpc_spi: remove unnecessary struct member pin_dir
staging: kpc2000: kpc_spi: remove unnecessary struct member word_len
staging: kpc2000: kpc_spi: remove unnecessary struct member
chip_select
staging: kpc2000: kpc_spi: remove unnecessary ulong repr of i/o addr
staging: kpc2000: kpc_spi: remove unnecessary cast in
[read|write]_reg()

drivers/staging/kpc2000/kpc2000_spi.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)

--
2.21.0


2019-06-05 01:12:41

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 6/6] staging: kpc2000: kpc_spi: remove unnecessary cast in [read|write]_reg()

The kpc_spi driver unnecessarily casts from a (u64 __iomem *) to a (void
*) when invoking readq and writeq which both take a (void __iomem *) arg.
There is no need for this cast, and it actually harms us by discarding
the sparse cookie, __iomem. Make the driver stop performing this casting
operation.

Signed-off-by: Geordan Neukum <[email protected]>
---
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 4f517afc6239..28132e9e260d 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -167,7 +167,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){
return cs->conf_cache;
}
- val = readq((void*)addr);
+ val = readq(addr);
return val;
}

@@ -176,7 +176,7 @@ kp_spi_write_reg(struct kp_spi_controller_state *cs, int idx, u64 val)
{
u64 __iomem *addr = cs->base;
addr += idx;
- writeq(val, (void*)addr);
+ writeq(val, addr);
if (idx == KP_SPI_REG_CONFIG)
cs->conf_cache = val;
}
--
2.21.0

2019-06-05 01:12:41

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 1/6] staging: kpc2000: kpc_spi: remove unnecessary struct member phys

The structure kp_spi_controller_state, defined in the kpc2000_spi
driver, contains a member named phys which is never used after
initialization. Therefore, it should be removed for simplicity's sake.

Signed-off-by: Geordan Neukum <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 32d3ec532e26..20c396bcd904 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -110,7 +110,6 @@ struct kp_spi {

struct kp_spi_controller_state {
void __iomem *base;
- unsigned long phys;
unsigned char chip_select;
int word_len;
s64 conf_cache;
@@ -270,7 +269,6 @@ kp_spi_setup(struct spi_device *spidev)
return -ENOMEM;
}
cs->base = kpspi->base;
- cs->phys = kpspi->phys;
cs->chip_select = spidev->chip_select;
cs->word_len = spidev->bits_per_word;
cs->conf_cache = -1;
--
2.21.0

2019-06-05 01:12:41

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 5/6] staging: kpc2000: kpc_spi: remove unnecessary ulong repr of i/o addr

The kpc_spi driver stashes off an unsigned long representation of the
i/o mapping returned by devm_ioremap_nocache(). This is unnecessary, as
the only use of the unsigned long repr is to eventually be re-cast to
an (u64 __iomem *). Instead of casting the (void __iomem *) to an
(unsigned long) then a (u64 __iomem *), just remove this intermediate
step. As this intermediary is no longer used, also remove it from its
structure.

Signed-off-by: Geordan Neukum <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 07b0327d8bef..4f517afc6239 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -103,7 +103,6 @@ static struct spi_board_info p2kr0_board_info[] = {
struct kp_spi {
struct spi_master *master;
u64 __iomem *base;
- unsigned long phys;
struct device *dev;
};

@@ -462,9 +461,8 @@ kp_spi_probe(struct platform_device *pldev)
goto free_master;
}

- kpspi->phys = (unsigned long)devm_ioremap_nocache(&pldev->dev, r->start,
- resource_size(r));
- kpspi->base = (u64 __iomem *)kpspi->phys;
+ kpspi->base = devm_ioremap_nocache(&pldev->dev, r->start,
+ resource_size(r));

status = spi_register_master(master);
if (status < 0) {
--
2.21.0

2019-06-05 01:13:24

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 4/6] staging: kpc2000: kpc_spi: remove unnecessary struct member chip_select

The structure kp_spi_controller_state, defined in the kpc2000_spi
driver, contains a member named chip_select which is never used after
initialization. Therefore, it should be removed for simplicity's sake.

Signed-off-by: Geordan Neukum <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 61296335313b..07b0327d8bef 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -109,7 +109,6 @@ struct kp_spi {

struct kp_spi_controller_state {
void __iomem *base;
- unsigned char chip_select;
s64 conf_cache;
};

@@ -267,7 +266,6 @@ kp_spi_setup(struct spi_device *spidev)
return -ENOMEM;
}
cs->base = kpspi->base;
- cs->chip_select = spidev->chip_select;
cs->conf_cache = -1;
spidev->controller_state = cs;
}
--
2.21.0

2019-06-05 01:14:06

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 2/6] staging: kpc2000: kpc_spi: remove unnecessary struct member pin_dir

The structure kpc_spi, defined in in the kpc2000_spi driver, contains
a member named pin_dir which is never used after initialization.
Therefore, it should be removed for simplicity's sake.

Signed-off-by: Geordan Neukum <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 20c396bcd904..1d89cb3b861f 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -105,7 +105,6 @@ struct kp_spi {
u64 __iomem *base;
unsigned long phys;
struct device *dev;
- unsigned int pin_dir:1;
};

struct kp_spi_controller_state {
@@ -460,7 +459,6 @@ kp_spi_probe(struct platform_device *pldev)
if (pldev->id != -1) {
master->bus_num = pldev->id;
}
- kpspi->pin_dir = 0;

r = platform_get_resource(pldev, IORESOURCE_MEM, 0);
if (r == NULL) {
--
2.21.0

2019-06-05 01:15:16

by Geordan Neukum

[permalink] [raw]
Subject: [PATCH 3/6] staging: kpc2000: kpc_spi: remove unnecessary struct member word_len

The structure kp_spi_controller_state, defined in the kpc2000_spi
driver, contains a member named word_len which is never used after
initialization. Therefore, it should be removed for simplicity's sake.

Signed-off-by: Geordan Neukum <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 1d89cb3b861f..61296335313b 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -110,7 +110,6 @@ struct kp_spi {
struct kp_spi_controller_state {
void __iomem *base;
unsigned char chip_select;
- int word_len;
s64 conf_cache;
};

@@ -269,7 +268,6 @@ kp_spi_setup(struct spi_device *spidev)
}
cs->base = kpspi->base;
cs->chip_select = spidev->chip_select;
- cs->word_len = spidev->bits_per_word;
cs->conf_cache = -1;
spidev->controller_state = cs;
}
@@ -369,7 +367,6 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m)
if (transfer->bits_per_word) {
word_len = transfer->bits_per_word;
}
- cs->word_len = word_len;
sc.bitfield.wl = word_len-1;

/* ...chip select */
--
2.21.0