Commit 6b1e3fca authored by Marek Vasut's avatar Marek Vasut Committed by Eric Miao

ARM: pxa: Use gpio arrays in palmld_hdd driver

Use gpio_request_array() / gpio_free_array(), this makes the code
cleaner and less error prone.

This patch also properly frees GPIOs in case ata_host_activate() call fails.
Signed-off-by: default avatarMarek Vasut <marek.vasut@gmail.com>
parent e27af7ed
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
#define DRV_NAME "pata_palmld" #define DRV_NAME "pata_palmld"
static struct gpio palmld_hdd_gpios[] = {
{ GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" },
{ GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" },
};
static struct scsi_host_template palmld_sht = { static struct scsi_host_template palmld_sht = {
ATA_PIO_SHT(DRV_NAME), ATA_PIO_SHT(DRV_NAME),
}; };
...@@ -52,28 +57,23 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev) ...@@ -52,28 +57,23 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev)
/* allocate host */ /* allocate host */
host = ata_host_alloc(&pdev->dev, 1); host = ata_host_alloc(&pdev->dev, 1);
if (!host) if (!host) {
return -ENOMEM; ret = -ENOMEM;
goto err1;
}
/* remap drive's physical memory address */ /* remap drive's physical memory address */
mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000); mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000);
if (!mem) if (!mem) {
return -ENOMEM; ret = -ENOMEM;
goto err1;
}
/* request and activate power GPIO, IRQ GPIO */ /* request and activate power GPIO, IRQ GPIO */
ret = gpio_request(GPIO_NR_PALMLD_IDE_PWEN, "HDD PWR"); ret = gpio_request_array(palmld_hdd_gpios,
ARRAY_SIZE(palmld_hdd_gpios));
if (ret) if (ret)
goto err1; goto err1;
ret = gpio_direction_output(GPIO_NR_PALMLD_IDE_PWEN, 1);
if (ret)
goto err2;
ret = gpio_request(GPIO_NR_PALMLD_IDE_RESET, "HDD RST");
if (ret)
goto err2;
ret = gpio_direction_output(GPIO_NR_PALMLD_IDE_RESET, 0);
if (ret)
goto err3;
/* reset the drive */ /* reset the drive */
gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0); gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0);
...@@ -96,13 +96,15 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev) ...@@ -96,13 +96,15 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev)
ata_sff_std_ports(&ap->ioaddr); ata_sff_std_ports(&ap->ioaddr);
/* activate host */ /* activate host */
return ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING, ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING,
&palmld_sht); &palmld_sht);
if (ret)
goto err2;
return ret;
err3:
gpio_free(GPIO_NR_PALMLD_IDE_RESET);
err2: err2:
gpio_free(GPIO_NR_PALMLD_IDE_PWEN); gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
err1: err1:
return ret; return ret;
} }
...@@ -116,8 +118,7 @@ static __devexit int palmld_pata_remove(struct platform_device *dev) ...@@ -116,8 +118,7 @@ static __devexit int palmld_pata_remove(struct platform_device *dev)
/* power down the HDD */ /* power down the HDD */
gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0);
gpio_free(GPIO_NR_PALMLD_IDE_RESET); gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios));
gpio_free(GPIO_NR_PALMLD_IDE_PWEN);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment