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

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: exynos: Simplify probe() with local 'dev' and 'np'

Simplify the probe function by using local 'dev' and 'np' variables
instead of full pointer dereferences. This makes several lines shorter,
which allows to avoid wrapping making code more readable.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Krzysztof Kozlowski and committed by
Jonathan Cameron
5b758ebc 48de61f6

+16 -20
+16 -20
drivers/iio/adc/exynos_adc.c
··· 552 552 static int exynos_adc_probe(struct platform_device *pdev) 553 553 { 554 554 struct exynos_adc *info = NULL; 555 + struct device *dev = &pdev->dev; 555 556 struct device_node *np = pdev->dev.of_node; 556 557 struct iio_dev *indio_dev = NULL; 557 558 int ret; 558 559 int irq; 559 560 560 - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct exynos_adc)); 561 + indio_dev = devm_iio_device_alloc(dev, sizeof(struct exynos_adc)); 561 562 if (!indio_dev) 562 563 return -ENOMEM; 563 564 ··· 566 565 567 566 info->data = exynos_adc_get_data(pdev); 568 567 if (!info->data) 569 - return dev_err_probe(&pdev->dev, -EINVAL, "failed getting exynos_adc_data\n"); 568 + return dev_err_probe(dev, -EINVAL, "failed getting exynos_adc_data\n"); 570 569 571 570 info->regs = devm_platform_ioremap_resource(pdev, 0); 572 571 if (IS_ERR(info->regs)) ··· 574 573 575 574 576 575 if (info->data->needs_adc_phy) { 577 - info->pmu_map = syscon_regmap_lookup_by_phandle( 578 - pdev->dev.of_node, 579 - "samsung,syscon-phandle"); 576 + info->pmu_map = syscon_regmap_lookup_by_phandle(np, "samsung,syscon-phandle"); 580 577 if (IS_ERR(info->pmu_map)) 581 - return dev_err_probe(&pdev->dev, PTR_ERR(info->pmu_map), 578 + return dev_err_probe(dev, PTR_ERR(info->pmu_map), 582 579 "syscon regmap lookup failed.\n"); 583 580 } 584 581 ··· 584 585 if (irq < 0) 585 586 return irq; 586 587 info->irq = irq; 587 - info->dev = &pdev->dev; 588 + info->dev = dev; 588 589 589 590 init_completion(&info->completion); 590 591 591 - info->clk = devm_clk_get(&pdev->dev, "adc"); 592 + info->clk = devm_clk_get(dev, "adc"); 592 593 if (IS_ERR(info->clk)) 593 - return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), "failed getting clock\n"); 594 + return dev_err_probe(dev, PTR_ERR(info->clk), "failed getting clock\n"); 594 595 595 596 if (info->data->needs_sclk) { 596 - info->sclk = devm_clk_get(&pdev->dev, "sclk"); 597 + info->sclk = devm_clk_get(dev, "sclk"); 597 598 if (IS_ERR(info->sclk)) 598 - return dev_err_probe(&pdev->dev, PTR_ERR(info->sclk), 599 + return dev_err_probe(dev, PTR_ERR(info->sclk), 599 600 "failed getting sclk clock\n"); 600 601 } 601 602 602 - info->vdd = devm_regulator_get(&pdev->dev, "vdd"); 603 + info->vdd = devm_regulator_get(dev, "vdd"); 603 604 if (IS_ERR(info->vdd)) 604 - return dev_err_probe(&pdev->dev, PTR_ERR(info->vdd), 605 - "failed getting regulator"); 605 + return dev_err_probe(dev, PTR_ERR(info->vdd), "failed getting regulator"); 606 606 607 607 ret = regulator_enable(info->vdd); 608 608 if (ret) ··· 617 619 618 620 platform_set_drvdata(pdev, indio_dev); 619 621 620 - indio_dev->name = dev_name(&pdev->dev); 622 + indio_dev->name = dev_name(dev); 621 623 indio_dev->info = &exynos_adc_iio_info; 622 624 indio_dev->modes = INDIO_DIRECT_MODE; 623 625 indio_dev->channels = exynos_adc_iio_channels; ··· 625 627 626 628 mutex_init(&info->lock); 627 629 628 - ret = request_irq(info->irq, exynos_adc_isr, 629 - 0, dev_name(&pdev->dev), info); 630 + ret = request_irq(info->irq, exynos_adc_isr, 0, dev_name(dev), info); 630 631 if (ret < 0) { 631 - dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", 632 - info->irq); 632 + dev_err(dev, "failed requesting irq, irq = %d\n", info->irq); 633 633 goto err_disable_clk; 634 634 } 635 635 ··· 640 644 641 645 ret = of_platform_populate(np, exynos_adc_match, NULL, &indio_dev->dev); 642 646 if (ret < 0) { 643 - dev_err(&pdev->dev, "failed adding child nodes\n"); 647 + dev_err(dev, "failed adding child nodes\n"); 644 648 goto err_of_populate; 645 649 } 646 650