Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: rb532_cf: Convert to use GPIO descriptors

Pass a GPIO descriptor for the device instead of a hardcoded
GPIO number from the global GPIO numberspace. Use gpio
descriptors throughout.

Cut the now completely unused platform data for the CF slot.

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Waldemar Brodkorb <wbx@openadk.org>
Cc: Matt Redfearn <matt.redfearn@mips.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Linus Walleij and committed by
Jens Axboe
cd56f35e 83a7faac

+19 -44
-6
arch/mips/include/asm/mach-rc32434/rb.h
··· 71 71 struct net_device *dev; 72 72 }; 73 73 74 - struct cf_device { 75 - int gpio_pin; 76 - void *dev; 77 - struct gendisk *gd; 78 - }; 79 - 80 74 struct mpmc_device { 81 75 unsigned char state; 82 76 spinlock_t lock;
+9 -3
arch/mips/rb532/devices.c
··· 23 23 #include <linux/mtd/platnand.h> 24 24 #include <linux/mtd/mtd.h> 25 25 #include <linux/gpio.h> 26 + #include <linux/gpio/machine.h> 26 27 #include <linux/gpio_keys.h> 27 28 #include <linux/input.h> 28 29 #include <linux/serial_8250.h> ··· 128 127 } 129 128 }; 130 129 131 - static struct cf_device cf_slot0_data = { 132 - .gpio_pin = CF_GPIO_NUM 130 + static struct gpiod_lookup_table cf_slot0_gpio_table = { 131 + .dev_id = "pata-rb532-cf", 132 + .table = { 133 + GPIO_LOOKUP("gpio0", CF_GPIO_NUM, 134 + NULL, GPIO_ACTIVE_HIGH), 135 + { }, 136 + }, 133 137 }; 134 138 135 139 static struct platform_device cf_slot0 = { 136 140 .id = -1, 137 141 .name = "pata-rb532-cf", 138 - .dev.platform_data = &cf_slot0_data, 139 142 .resource = cf_slot0_res, 140 143 .num_resources = ARRAY_SIZE(cf_slot0_res), 141 144 }; ··· 310 305 311 306 dev_set_drvdata(&korina_dev0.dev, &korina_dev0_data); 312 307 308 + gpiod_add_lookup_table(&cf_slot0_gpio_table); 313 309 return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs)); 314 310 } 315 311
+10 -35
drivers/ata/pata_rb532_cf.c
··· 27 27 #include <linux/io.h> 28 28 #include <linux/interrupt.h> 29 29 #include <linux/irq.h> 30 - #include <linux/gpio.h> 30 + #include <linux/gpio/consumer.h> 31 31 32 32 #include <linux/libata.h> 33 33 #include <scsi/scsi_host.h> ··· 49 49 50 50 struct rb532_cf_info { 51 51 void __iomem *iobase; 52 - unsigned int gpio_line; 52 + struct gpio_desc *gpio_line; 53 53 unsigned int irq; 54 54 }; 55 55 ··· 60 60 struct ata_host *ah = dev_instance; 61 61 struct rb532_cf_info *info = ah->private_data; 62 62 63 - if (gpio_get_value(info->gpio_line)) { 63 + if (gpiod_get_value(info->gpio_line)) { 64 64 irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); 65 65 ata_sff_interrupt(info->irq, dev_instance); 66 66 } else { ··· 106 106 static int rb532_pata_driver_probe(struct platform_device *pdev) 107 107 { 108 108 int irq; 109 - int gpio; 109 + struct gpio_desc *gpiod; 110 110 struct resource *res; 111 111 struct ata_host *ah; 112 - struct cf_device *pdata; 113 112 struct rb532_cf_info *info; 114 113 int ret; 115 114 ··· 124 125 return -ENOENT; 125 126 } 126 127 127 - pdata = dev_get_platdata(&pdev->dev); 128 - if (!pdata) { 129 - dev_err(&pdev->dev, "no platform data specified\n"); 130 - return -EINVAL; 131 - } 132 - 133 - gpio = pdata->gpio_pin; 134 - if (gpio < 0) { 128 + gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN); 129 + if (IS_ERR(gpiod)) { 135 130 dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq); 136 - return -ENOENT; 131 + return PTR_ERR(gpiod); 137 132 } 138 - 139 - ret = gpio_request(gpio, DRV_NAME); 140 - if (ret) { 141 - dev_err(&pdev->dev, "GPIO request failed\n"); 142 - return ret; 143 - } 133 + gpiod_set_consumer_name(gpiod, DRV_NAME); 144 134 145 135 /* allocate host */ 146 136 ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS); ··· 141 153 return -ENOMEM; 142 154 143 155 ah->private_data = info; 144 - info->gpio_line = gpio; 156 + info->gpio_line = gpiod; 145 157 info->irq = irq; 146 158 147 159 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, ··· 149 161 if (!info->iobase) 150 162 return -ENOMEM; 151 163 152 - ret = gpio_direction_input(gpio); 153 - if (ret) { 154 - dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n", 155 - ret); 156 - goto err_free_gpio; 157 - } 158 - 159 164 rb532_pata_setup_ports(ah); 160 165 161 166 ret = ata_host_activate(ah, irq, rb532_pata_irq_handler, 162 167 IRQF_TRIGGER_LOW, &rb532_pata_sht); 163 168 if (ret) 164 - goto err_free_gpio; 169 + return ret; 165 170 166 171 return 0; 167 - 168 - err_free_gpio: 169 - gpio_free(gpio); 170 - 171 - return ret; 172 172 } 173 173 174 174 static int rb532_pata_driver_remove(struct platform_device *pdev) ··· 165 189 struct rb532_cf_info *info = ah->private_data; 166 190 167 191 ata_host_detach(ah); 168 - gpio_free(info->gpio_line); 169 192 170 193 return 0; 171 194 }