staging: kpc2000: kpc_spi: Assorted small fixes
cover staging: kpc2000: kpc_spi: Assorted small fixes
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(-)
Signature · 1 line
2.21.0
PATCH 1/5 staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines
The kpc2000_spi.c file contains instances of unnecessary consecutive newlines which negatively impact the readability of the file. Remove all unnecessary consecutive newlines.
--- drivers/staging/kpc2000/kpc2000_spi.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/staging/kpc2000/kpc2000_spi.c +0 -13
@@ -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 ,
Signature · 1 line
2.21.0
PATCH 4/5 staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word()
In reply to Geordan NeukumThe 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.
--- drivers/staging/kpc2000/kpc2000_spi.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/staging/kpc2000/kpc2000_spi.c +0 -14
@@ -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) {
Signature · 1 line
2.21.0
PATCH 5/5 staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space
In reply to Geordan NeukumThe 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.
--- drivers/staging/kpc2000/kpc2000_spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/kpc2000/kpc2000_spi.c +2 -1
@@ -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);
Signature · 1 line
2.21.0
PATCH 2/5 staging: kpc2000: kpc_spi: column-align switch and subordinate cases
In reply to Geordan NeukumThe 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.
--- drivers/staging/kpc2000/kpc2000_spi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/kpc2000/kpc2000_spi.c +7 -7
@@ -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;
Signature · 1 line
2.21.0
PATCH 3/5 staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct
In reply to Geordan NeukumThe kp_spi structure contains a member 'fifo_depth'. This member is never used. Therefore, it should be removed.
--- drivers/staging/kpc2000/kpc2000_spi.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/kpc2000/kpc2000_spi.c +0 -1
@@ -105,7 +105,6 @@ struct kp_spi {u64 __iomem *base;unsigned long phys;struct device *dev; -int fifo_depth; unsigned int pin_dir:1; };
Signature · 1 line
2.21.0
Greg Kroah-Hartman
maintainerRe: [PATCH 5/5] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space
In reply to Geordan NeukumQuoted 14 lines · Geordan Neukum
The
kpc_spidriver does not unmap its I/O space upon error cases in theprobe()function or uponremove(). Make the driver clean up after itself more maintainably by migrating to using the managed resource API.Signed-off-by Geordan Neukum <[email protected]>--- drivers/staging/kpc2000/kpc2000_spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/kpc2000/kpc2000_spi.c +0
-0
drivers/staging/kpc2000/kpc2000_spi.c kp_spi_probe(struct platform_device *pldev) · line 475
Quoted 6 lines
drivers/staging/kpc2000/kpc2000_spi.c +2
-1@@ -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?
drivers/staging/kpc2000/kpc2000_spi.c kp_spi_probe(struct platform_device *pldev) · line 476
Quoted 1 line
drivers/staging/kpc2000/kpc2000_spi.c +0
-0kpspi->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