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

gpio: tb10x: Use devm_gpiochip_add_data() for gpio registration

Use devm_gpiochip_add_data() for GPIO registration and clean the
error path.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>

+6 -16
+6 -16
drivers/gpio/gpio-tb10x.c
··· 205 205 tb10x_gpio->gc.can_sleep = false; 206 206 207 207 208 - ret = gpiochip_add_data(&tb10x_gpio->gc, tb10x_gpio); 208 + ret = devm_gpiochip_add_data(&pdev->dev, &tb10x_gpio->gc, tb10x_gpio); 209 209 if (ret < 0) { 210 210 dev_err(&pdev->dev, "Could not add gpiochip.\n"); 211 - goto fail_gpiochip_registration; 211 + return ret; 212 212 } 213 213 214 214 platform_set_drvdata(pdev, tb10x_gpio); ··· 219 219 ret = platform_get_irq(pdev, 0); 220 220 if (ret < 0) { 221 221 dev_err(&pdev->dev, "No interrupt specified.\n"); 222 - goto fail_get_irq; 222 + return ret; 223 223 } 224 224 225 225 tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq; ··· 229 229 IRQF_TRIGGER_NONE | IRQF_SHARED, 230 230 dev_name(&pdev->dev), tb10x_gpio); 231 231 if (ret != 0) 232 - goto fail_request_irq; 232 + return ret; 233 233 234 234 tb10x_gpio->domain = irq_domain_add_linear(dn, 235 235 tb10x_gpio->gc.ngpio, 236 236 &irq_generic_chip_ops, NULL); 237 237 if (!tb10x_gpio->domain) { 238 - ret = -ENOMEM; 239 - goto fail_irq_domain; 238 + return -ENOMEM; 240 239 } 241 240 242 241 ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain, ··· 243 244 handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE, 244 245 IRQ_GC_INIT_MASK_CACHE); 245 246 if (ret) 246 - goto fail_irq_domain; 247 + return ret; 247 248 248 249 gc = tb10x_gpio->domain->gc->gc[0]; 249 250 gc->reg_base = tb10x_gpio->base; ··· 257 258 } 258 259 259 260 return 0; 260 - 261 - fail_irq_domain: 262 - fail_request_irq: 263 - fail_get_irq: 264 - gpiochip_remove(&tb10x_gpio->gc); 265 - fail_gpiochip_registration: 266 - fail_ioremap: 267 - return ret; 268 261 } 269 262 270 263 static int tb10x_gpio_remove(struct platform_device *pdev) ··· 269 278 kfree(tb10x_gpio->domain->gc); 270 279 irq_domain_remove(tb10x_gpio->domain); 271 280 } 272 - gpiochip_remove(&tb10x_gpio->gc); 273 281 274 282 return 0; 275 283 }