Skip to contentSkip to conversation

spi/imx: two spi-imx cleanup

PATCH In review Hui Wang 2 participants 5 messages Jul 10, 2012 – Jul 12, 2012 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Hui Wang

author
#0 lore raw

cover spi/imx: two spi-imx cleanup

Two straight-forward cleanup

Hui Wang (2):
spi/imx: remove redundant config.speed_hz setting spi/imx: use gpio_is_valid to determine if a gpio is valid

 drivers/spi/spi-imx.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
Signature · 9 lines
1.7.6


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

A message that is not in the archive (sent off-list or not yet received): 1341913463-10128-1-git-send-email-jason77.wang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#2 lore raw

PATCH 1/2 spi/imx: remove redundant config.speed_hz setting

The config.speed_hz is just setted at the two lines ahead of it, obviously we don't need to copy the code to set the config.speed_hz again. Remove it for a cleanup.

Cc Sascha Hauer <[email protected]>
Cc Grant Likely <grant.likely-s3s/[email protected]>
---
 drivers/spi/spi-imx.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/spi/spi-imx.c +0 -2
index 47877d6..c12052f 100644
@@ -688,8 +688,6 @@ static int spi_imx_setupxfer(struct spi_device *spi,
 		config.speed_hz = spi->max_speed_hz;
 	if (!config.bpw)
 		config.bpw = spi->bits_per_word;
-	if (!config.speed_hz)
-		config.speed_hz = spi->max_speed_hz;
 
 	/* Initialize the functions for transfer */
 	if (config.bpw <= 8) {
Signature · 9 lines
1.7.6


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

A message that is not in the archive (sent off-list or not yet received): 1341913463-10128-2-git-send-email-jason77.wang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

PATCH 2/2 spi/imx: use gpio_is_valid to determine if a gpio is

Use gpio_is_valid() to replace "gpio >= 0" or "gpio < 0".

Cc Sascha Hauer <[email protected]>
Cc Grant Likely <grant.likely-s3s/[email protected]>
---
 drivers/spi/spi-imx.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/spi/spi-imx.c +6 -6
index c12052f..e834ff8 100644
@@ -626,7 +626,7 @@ static void spi_imx_chipselect(struct spi_device *spi, int is_active)
 	int active = is_active != BITBANG_CS_INACTIVE;
 	int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
 
-	if (gpio < 0)
+	if (!gpio_is_valid(gpio))
 		return;
 
 	gpio_set_value(gpio, dev_is_lowactive ^ active);
@@ -736,7 +736,7 @@ static int spi_imx_setup(struct spi_device *spi)
 	dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
 		 spi->mode, spi->bits_per_word, spi->max_speed_hz);
 
-	if (gpio >= 0)
+	if (gpio_is_valid(gpio))
 		gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
 
 	spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
@@ -789,11 +789,11 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
 
 	for (i = 0; i < master->num_chipselect; i++) {
 		int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);
-		if (cs_gpio < 0 && mxc_platform_info)
+		if (!gpio_is_valid(cs_gpio) && mxc_platform_info)
 			cs_gpio = mxc_platform_info->chipselect[i];
 
 		spi_imx->chipselect[i] = cs_gpio;
-		if (cs_gpio < 0)
+		if (!gpio_is_valid(cs_gpio))
 			continue;
 
 		ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
@@ -895,7 +895,7 @@ out_release_mem:
 	release_mem_region(res->start, resource_size(res));
 out_gpio_free:
 	while (--i >= 0) {
-		if (spi_imx->chipselect[i] >= 0)
+		if (gpio_is_valid(spi_imx->chipselect[i]))
 			gpio_free(spi_imx->chipselect[i]);
 	}
 	spi_master_put(master);
@@ -920,7 +920,7 @@ static int __devexit spi_imx_remove(struct platform_device *pdev)
 	iounmap(spi_imx->base);
 
 	for (i = 0; i < master->num_chipselect; i++)
-		if (spi_imx->chipselect[i] >= 0)
+		if (gpio_is_valid(spi_imx->chipselect[i]))
 			gpio_free(spi_imx->chipselect[i]);
 
 	spi_master_put(master);
Signature · 9 lines
1.7.6


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Acked-by
#5 lore raw
In reply to a message not in the archive
Quoted 5 lines · Hui Wang

Two straight-forward cleanup

Hui Wang (2):
spi/imx: remove redundant config.speed_hz setting spi/imx: use gpio_is_valid to determine if a gpio is valid

both:

Quoted 8 lines
 drivers/spi/spi-imx.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.6
Signature · 11 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#7 lore raw

Hi Mark,

Understand from Grant's mail's discussion that you are picking up the spi change, Could you please queue these two patches in your tree?

Regards,
Hui.

Quoted 4 lines · Sascha Hauer
Quoted 2 lines · Hui Wang

Two straight-forward cleanup

Quoted 21 lines
Quoted 4 lines

Hui Wang (2):
spi/imx: remove redundant config.speed_hz setting spi/imx: use gpio_is_valid to determine if a gpio is valid

both:

Quoted 8 lines
 drivers/spi/spi-imx.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/