linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes
@ 2019-06-02 15:58 Geordan Neukum
  2019-06-02 15:58 ` [PATCH 1/5] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines Geordan Neukum
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

This patch set contains a few small fixups to the kpc_spi driver. There
is certainly nothing groundbreaking in this patch set. It is limited to
style fixups, removing unused things, and using the managed resource API
for mapping I/O space.

Geordan Neukum (5):
  staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines
  staging: kpc2000: kpc_spi: column-align switch and subordinate cases
  staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct
  staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word()
  staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space

 drivers/staging/kpc2000/kpc2000_spi.c | 45 ++++++---------------------
 1 file changed, 9 insertions(+), 36 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines
  2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
@ 2019-06-02 15:58 ` Geordan Neukum
  2019-06-02 15:58 ` [PATCH 2/5] staging: kpc2000: kpc_spi: column-align switch and subordinate cases Geordan Neukum
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

The kpc2000_spi.c file contains instances of unnecessary consecutive
newlines which negatively impact the readability of the file. Remove
all unnecessary consecutive newlines.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 drivers/staging/kpc2000/kpc2000_spi.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 9a23808ffaa1..ef7e062bf52c 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -97,8 +97,6 @@ static struct spi_board_info p2kr0_board_info[] = {
 #define KP_SPI_REG_STATUS_RXFFE 0x40
 #define KP_SPI_REG_STATUS_RXFFF 0x80
 
-
-
 /******************
  * SPI Structures *
  ******************/
@@ -111,7 +109,6 @@ struct kp_spi {
 	unsigned int        pin_dir:1;
 };
 
-
 struct kp_spi_controller_state {
 	void __iomem   *base;
 	unsigned long   phys;
@@ -120,7 +117,6 @@ struct kp_spi_controller_state {
 	s64             conf_cache;
 };
 
-
 union kp_spi_config {
 	/* use this to access individual elements */
 	struct __attribute__((packed)) spi_config_bitfield {
@@ -141,8 +137,6 @@ union kp_spi_config {
 	u32 reg;
 };
 
-
-
 union kp_spi_status {
 	struct __attribute__((packed)) spi_status_bitfield {
 		unsigned int rx    :  1; /* Rx Status       */
@@ -158,8 +152,6 @@ union kp_spi_status {
 	u32 reg;
 };
 
-
-
 union kp_spi_ffctrl {
 	struct __attribute__((packed)) spi_ffctrl_bitfield {
 		unsigned int ffstart :  1; /* FIFO Start */
@@ -168,8 +160,6 @@ union kp_spi_ffctrl {
 	u32 reg;
 };
 
-
-
 /***************
  * SPI Helpers *
  ***************/
@@ -445,8 +435,6 @@ kp_spi_cleanup(struct spi_device *spidev)
 	}
 }
 
-
-
 /******************
  * Probe / Remove *
  ******************/
@@ -538,7 +526,6 @@ kp_spi_remove(struct platform_device *pldev)
 	return 0;
 }
 
-
 static struct platform_driver kp_spi_driver = {
 	.driver = {
 		.name =     KP_DRIVER_NAME_SPI,
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] staging: kpc2000: kpc_spi: column-align switch and subordinate cases
  2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
  2019-06-02 15:58 ` [PATCH 1/5] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines Geordan Neukum
@ 2019-06-02 15:58 ` Geordan Neukum
  2019-06-02 15:58 ` [PATCH 3/5] staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct Geordan Neukum
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

The linux style guide prescribes that switch statements and their
subordinate case labels should be column-aligned rather than
double-indenting the case label. Make kpc2000_spi.c follow the desired
style with respect to switch/case alignment.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 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 ef7e062bf52c..13c4651e1fac 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -502,13 +502,13 @@ kp_spi_probe(struct platform_device *pldev)
 	}
 
 	switch ((drvdata->card_id & 0xFFFF0000) >> 16){
-		case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0:
-			NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info);
-			break;
-		default:
-			dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n");
-			goto free_master;
-			break;
+	case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0:
+		NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info);
+		break;
+	default:
+		dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n");
+		goto free_master;
+		break;
 	}
 
 	return status;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct
  2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
  2019-06-02 15:58 ` [PATCH 1/5] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines Geordan Neukum
  2019-06-02 15:58 ` [PATCH 2/5] staging: kpc2000: kpc_spi: column-align switch and subordinate cases Geordan Neukum
@ 2019-06-02 15:58 ` Geordan Neukum
  2019-06-02 15:58 ` [PATCH 4/5] staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word() Geordan Neukum
  2019-06-02 15:58 ` [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space Geordan Neukum
  4 siblings, 0 replies; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

The kp_spi structure contains a member 'fifo_depth'. This member is
never used. Therefore, it should be removed.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 drivers/staging/kpc2000/kpc2000_spi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 13c4651e1fac..049b1e324031 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;
-	int                 fifo_depth;
 	unsigned int        pin_dir:1;
 };
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word()
  2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
                   ` (2 preceding siblings ...)
  2019-06-02 15:58 ` [PATCH 3/5] staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct Geordan Neukum
@ 2019-06-02 15:58 ` Geordan Neukum
  2019-06-02 15:58 ` [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space Geordan Neukum
  4 siblings, 0 replies; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

The static function kp_spi_bytes_per_word() is defined in kpc2000_spi.c,
but it is completely unused. As this function is unused, it can and
should be removed.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 drivers/staging/kpc2000/kpc2000_spi.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 049b1e324031..b513432a26ed 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -162,20 +162,6 @@ union kp_spi_ffctrl {
 /***************
  * SPI Helpers *
  ***************/
-	static inline int
-kp_spi_bytes_per_word(int word_len)
-{
-	if (word_len <= 8){
-		return 1;
-	}
-	else if (word_len <= 16) {
-		return 2;
-	}
-	else { /* word_len <= 32 */
-		return 4;
-	}
-}
-
 	static inline u64
 kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx)
 {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space
  2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
                   ` (3 preceding siblings ...)
  2019-06-02 15:58 ` [PATCH 4/5] staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word() Geordan Neukum
@ 2019-06-02 15:58 ` Geordan Neukum
  2019-06-03 12:16   ` Greg Kroah-Hartman
  4 siblings, 1 reply; 7+ messages in thread
From: Geordan Neukum @ 2019-06-02 15:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jeremy Sowden, Mao Wenan, YueHaibing, Nathan Chancellor,
	Geordan Neukum, Dan Carpenter, devel, linux-kernel

The kpc_spi driver does not unmap its I/O space upon error cases in the
probe() function or upon remove(). Make the driver clean up after itself
more maintainably by migrating to using the managed resource API.

Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
---
 drivers/staging/kpc2000/kpc2000_spi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index b513432a26ed..32d3ec532e26 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -471,7 +471,8 @@ kp_spi_probe(struct platform_device *pldev)
 		goto free_master;
 	}
 
-	kpspi->phys = (unsigned long)ioremap_nocache(r->start, resource_size(r));
+	kpspi->phys = (unsigned long)devm_ioremap_nocache(&pldev->dev, r->start,
+							  resource_size(r));
 	kpspi->base = (u64 __iomem *)kpspi->phys;
 
 	status = spi_register_master(master);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space
  2019-06-02 15:58 ` [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space Geordan Neukum
@ 2019-06-03 12:16   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-03 12:16 UTC (permalink / raw)
  To: Geordan Neukum
  Cc: devel, YueHaibing, Mao Wenan, linux-kernel, Nathan Chancellor,
	Dan Carpenter

On Sun, Jun 02, 2019 at 03:58:37PM +0000, Geordan Neukum wrote:
> The kpc_spi driver does not unmap its I/O space upon error cases in the
> probe() function or upon remove(). Make the driver clean up after itself
> more maintainably by migrating to using the managed resource API.
> 
> Signed-off-by: Geordan Neukum <gneukum1@gmail.com>
> ---
>  drivers/staging/kpc2000/kpc2000_spi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
> index b513432a26ed..32d3ec532e26 100644
> --- a/drivers/staging/kpc2000/kpc2000_spi.c
> +++ b/drivers/staging/kpc2000/kpc2000_spi.c
> @@ -471,7 +471,8 @@ kp_spi_probe(struct platform_device *pldev)
>  		goto free_master;
>  	}
>  
> -	kpspi->phys = (unsigned long)ioremap_nocache(r->start, resource_size(r));
> +	kpspi->phys = (unsigned long)devm_ioremap_nocache(&pldev->dev, r->start,
> +							  resource_size(r));

Why is this being cast?  This should just be an __iomem *, right?

>  	kpspi->base = (u64 __iomem *)kpspi->phys;

Then that cast will go away :)

Anyway, something for a future patch, this one is fine, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-06-03 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-02 15:58 [PATCH 0/5] staging: kpc2000: kpc_spi: Assorted small fixes Geordan Neukum
2019-06-02 15:58 ` [PATCH 1/5] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines Geordan Neukum
2019-06-02 15:58 ` [PATCH 2/5] staging: kpc2000: kpc_spi: column-align switch and subordinate cases Geordan Neukum
2019-06-02 15:58 ` [PATCH 3/5] staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct Geordan Neukum
2019-06-02 15:58 ` [PATCH 4/5] staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word() Geordan Neukum
2019-06-02 15:58 ` [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space Geordan Neukum
2019-06-03 12:16   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).