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

Merge tag 'for-4.21/libata-20181221' of git://git.kernel.dk/linux-block

Pull libata updates from Jens Axboe:
"Here are the libata changes for this merge window. Nothing major in
here. This contains:

- GPIO descriptor conversions (Linus Walleij)

- rcar deferred probing fix (Sergei Shtylyov)"

* tag 'for-4.21/libata-20181221' of git://git.kernel.dk/linux-block:
sata_rcar: fix deferred probing
ata: palmld: Introduce state container
ata: palmld: Convert to GPIO descriptors
ata: rb532_cf: Convert to use GPIO descriptors
ata: sata_highbank: Convert to use GPIO descriptors
ata: pxa: Drop <linux/gpio.h> include

+96 -104
+2
arch/arm/mach-pxa/palm27x.h
··· 12 12 #ifndef __INCLUDE_MACH_PALM27X__ 13 13 #define __INCLUDE_MACH_PALM27X__ 14 14 15 + #include <linux/gpio/machine.h> 16 + 15 17 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 16 18 extern void __init palm27x_mmc_init(int detect, int ro, int power, 17 19 int power_inverted);
+12
arch/arm/mach-pxa/palmld.c
··· 288 288 .id = -1, 289 289 }; 290 290 291 + static struct gpiod_lookup_table palmld_ide_gpio_table = { 292 + .dev_id = "pata_palmld", 293 + .table = { 294 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_PWEN, 295 + "power", GPIO_ACTIVE_HIGH), 296 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_RESET, 297 + "reset", GPIO_ACTIVE_LOW), 298 + { }, 299 + }, 300 + }; 301 + 291 302 static void __init palmld_ide_init(void) 292 303 { 304 + gpiod_add_lookup_table(&palmld_ide_gpio_table); 293 305 platform_device_register(&palmld_ide_device); 294 306 } 295 307 #else
-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
+44 -39
drivers/ata/pata_palmld.c
··· 26 26 #include <linux/irq.h> 27 27 #include <linux/platform_device.h> 28 28 #include <linux/delay.h> 29 - #include <linux/gpio.h> 29 + #include <linux/gpio/consumer.h> 30 30 31 31 #include <scsi/scsi_host.h> 32 32 #include <mach/palmld.h> 33 33 34 34 #define DRV_NAME "pata_palmld" 35 35 36 - static struct gpio palmld_hdd_gpios[] = { 37 - { GPIO_NR_PALMLD_IDE_PWEN, GPIOF_INIT_HIGH, "HDD Power" }, 38 - { GPIO_NR_PALMLD_IDE_RESET, GPIOF_INIT_LOW, "HDD Reset" }, 36 + struct palmld_pata { 37 + struct ata_host *host; 38 + struct gpio_desc *power; 39 + struct gpio_desc *reset; 39 40 }; 40 41 41 42 static struct scsi_host_template palmld_sht = { ··· 51 50 52 51 static int palmld_pata_probe(struct platform_device *pdev) 53 52 { 54 - struct ata_host *host; 53 + struct palmld_pata *lda; 55 54 struct ata_port *ap; 56 55 void __iomem *mem; 56 + struct device *dev = &pdev->dev; 57 57 int ret; 58 58 59 + lda = devm_kzalloc(dev, sizeof(*lda), GFP_KERNEL); 60 + if (!lda) 61 + return -ENOMEM; 62 + 59 63 /* allocate host */ 60 - host = ata_host_alloc(&pdev->dev, 1); 61 - if (!host) { 62 - ret = -ENOMEM; 63 - goto err1; 64 - } 64 + lda->host = ata_host_alloc(dev, 1); 65 + if (!lda->host) 66 + return -ENOMEM; 65 67 66 68 /* remap drive's physical memory address */ 67 - mem = devm_ioremap(&pdev->dev, PALMLD_IDE_PHYS, 0x1000); 68 - if (!mem) { 69 - ret = -ENOMEM; 70 - goto err1; 69 + mem = devm_ioremap(dev, PALMLD_IDE_PHYS, 0x1000); 70 + if (!mem) 71 + return -ENOMEM; 72 + 73 + /* request and activate power and reset GPIOs */ 74 + lda->power = devm_gpiod_get(dev, "power", GPIOD_OUT_HIGH); 75 + if (IS_ERR(lda->power)) 76 + return PTR_ERR(lda->power); 77 + lda->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); 78 + if (IS_ERR(lda->reset)) { 79 + gpiod_set_value(lda->power, 0); 80 + return PTR_ERR(lda->reset); 71 81 } 72 82 73 - /* request and activate power GPIO, IRQ GPIO */ 74 - ret = gpio_request_array(palmld_hdd_gpios, 75 - ARRAY_SIZE(palmld_hdd_gpios)); 76 - if (ret) 77 - goto err1; 78 - 79 - /* reset the drive */ 80 - gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 0); 83 + /* Assert reset to reset the drive */ 84 + gpiod_set_value(lda->reset, 1); 81 85 msleep(30); 82 - gpio_set_value(GPIO_NR_PALMLD_IDE_RESET, 1); 86 + gpiod_set_value(lda->reset, 0); 83 87 msleep(30); 84 88 85 89 /* setup the ata port */ 86 - ap = host->ports[0]; 90 + ap = lda->host->ports[0]; 87 91 ap->ops = &palmld_port_ops; 88 92 ap->pio_mask = ATA_PIO4; 89 93 ap->flags |= ATA_FLAG_PIO_POLLING; ··· 102 96 ata_sff_std_ports(&ap->ioaddr); 103 97 104 98 /* activate host */ 105 - ret = ata_host_activate(host, 0, NULL, IRQF_TRIGGER_RISING, 106 - &palmld_sht); 107 - if (ret) 108 - goto err2; 99 + ret = ata_host_activate(lda->host, 0, NULL, IRQF_TRIGGER_RISING, 100 + &palmld_sht); 101 + /* power down on failure */ 102 + if (ret) { 103 + gpiod_set_value(lda->power, 0); 104 + return ret; 105 + } 109 106 110 - return ret; 111 - 112 - err2: 113 - gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios)); 114 - err1: 115 - return ret; 107 + platform_set_drvdata(pdev, lda); 108 + return 0; 116 109 } 117 110 118 - static int palmld_pata_remove(struct platform_device *dev) 111 + static int palmld_pata_remove(struct platform_device *pdev) 119 112 { 120 - ata_platform_remove_one(dev); 113 + struct palmld_pata *lda = platform_get_drvdata(pdev); 114 + 115 + ata_platform_remove_one(pdev); 121 116 122 117 /* power down the HDD */ 123 - gpio_set_value(GPIO_NR_PALMLD_IDE_PWEN, 0); 124 - 125 - gpio_free_array(palmld_hdd_gpios, ARRAY_SIZE(palmld_hdd_gpios)); 118 + gpiod_set_value(lda->power, 0); 126 119 127 120 return 0; 128 121 }
-1
drivers/ata/pata_pxa.c
··· 25 25 #include <linux/libata.h> 26 26 #include <linux/platform_device.h> 27 27 #include <linux/dmaengine.h> 28 - #include <linux/gpio.h> 29 28 #include <linux/slab.h> 30 29 #include <linux/completion.h> 31 30
+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 }
+16 -19
drivers/ata/sata_highbank.c
··· 31 31 #include <linux/interrupt.h> 32 32 #include <linux/delay.h> 33 33 #include <linux/export.h> 34 - #include <linux/gpio.h> 35 - #include <linux/of_gpio.h> 34 + #include <linux/gpio/consumer.h> 36 35 37 36 #include "ahci.h" 38 37 ··· 84 85 /* number of extra clocks that the SGPIO PIC controller expects */ 85 86 u32 pre_clocks; 86 87 u32 post_clocks; 87 - unsigned sgpio_gpio[SGPIO_PINS]; 88 + struct gpio_desc *sgpio_gpiod[SGPIO_PINS]; 88 89 u32 sgpio_pattern; 89 90 u32 port_to_sgpio[SGPIO_PORTS]; 90 91 }; ··· 130 131 */ 131 132 static void ecx_led_cycle_clock(struct ecx_plat_data *pdata) 132 133 { 133 - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1); 134 + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1); 134 135 udelay(50); 135 - gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0); 136 + gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0); 136 137 udelay(50); 137 138 } 138 139 ··· 163 164 for (i = 0; i < pdata->pre_clocks; i++) 164 165 ecx_led_cycle_clock(pdata); 165 166 166 - gpio_set_value(pdata->sgpio_gpio[SLOAD], 1); 167 + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1); 167 168 ecx_led_cycle_clock(pdata); 168 - gpio_set_value(pdata->sgpio_gpio[SLOAD], 0); 169 + gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0); 169 170 /* 170 171 * bit-bang out the SGPIO pattern, by consuming a bit and then 171 172 * clocking it out. 172 173 */ 173 174 for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) { 174 - gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1); 175 + gpiod_set_value(pdata->sgpio_gpiod[SDATA], sgpio_out & 1); 175 176 sgpio_out >>= 1; 176 177 ecx_led_cycle_clock(pdata); 177 178 } ··· 192 193 struct device_node *np = dev->of_node; 193 194 struct ecx_plat_data *pdata = hpriv->plat_data; 194 195 int i; 195 - int err; 196 196 197 197 for (i = 0; i < SGPIO_PINS; i++) { 198 - err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i); 199 - if (err < 0) 200 - return; 198 + struct gpio_desc *gpiod; 201 199 202 - pdata->sgpio_gpio[i] = err; 203 - err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO"); 204 - if (err) { 205 - pr_err("sata_highbank gpio_request %d failed: %d\n", 206 - i, err); 207 - return; 200 + gpiod = devm_gpiod_get_index(dev, "calxeda,sgpio", i, 201 + GPIOD_OUT_HIGH); 202 + if (IS_ERR(gpiod)) { 203 + dev_err(dev, "failed to get GPIO %d\n", i); 204 + continue; 208 205 } 209 - gpio_direction_output(pdata->sgpio_gpio[i], 1); 206 + gpiod_set_consumer_name(gpiod, "CX SGPIO"); 207 + 208 + pdata->sgpio_gpiod[i] = gpiod; 210 209 } 211 210 of_property_read_u32_array(np, "calxeda,led-order", 212 211 pdata->port_to_sgpio,
+3 -1
drivers/ata/sata_rcar.c
··· 891 891 int ret = 0; 892 892 893 893 irq = platform_get_irq(pdev, 0); 894 - if (irq <= 0) 894 + if (irq < 0) 895 + return irq; 896 + if (!irq) 895 897 return -EINVAL; 896 898 897 899 priv = devm_kzalloc(dev, sizeof(struct sata_rcar_priv), GFP_KERNEL);