Commit d2f94dcc authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Andi Shyti
Browse files

i2c: designware: Use temporary variable for struct device



Use temporary variable for struct device to make code neater.

Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
parent 157a6849
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -207,6 +207,7 @@ static const struct software_node dgpu_node = {
static int i2c_dw_pci_probe(struct pci_dev *pdev,
			    const struct pci_device_id *id)
{
	struct device *device = &pdev->dev;
	struct dw_i2c_dev *dev;
	struct i2c_adapter *adap;
	int r;
@@ -214,25 +215,22 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
	struct dw_scl_sda_cfg *cfg;

	if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers))
		return dev_err_probe(&pdev->dev, -EINVAL,
				     "Invalid driver data %ld\n",
		return dev_err_probe(device, -EINVAL, "Invalid driver data %ld\n",
				     id->driver_data);

	controller = &dw_pci_controllers[id->driver_data];

	r = pcim_enable_device(pdev);
	if (r)
		return dev_err_probe(&pdev->dev, r,
				     "Failed to enable I2C PCI device\n");
		return dev_err_probe(device, r, "Failed to enable I2C PCI device\n");

	pci_set_master(pdev);

	r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
	if (r)
		return dev_err_probe(&pdev->dev, r,
				     "I/O memory remapping failed\n");
		return dev_err_probe(device, r, "I/O memory remapping failed\n");

	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
	dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;

@@ -242,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,

	dev->get_clk_rate_khz = controller->get_clk_rate_khz;
	dev->base = pcim_iomap_table(pdev)[0];
	dev->dev = &pdev->dev;
	dev->dev = device;
	dev->irq = pci_irq_vector(pdev, 0);
	dev->flags |= controller->flags;

@@ -281,14 +279,14 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
	if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) {
		dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node);
		if (IS_ERR(dev->slave))
			return dev_err_probe(dev->dev, PTR_ERR(dev->slave),
			return dev_err_probe(device, PTR_ERR(dev->slave),
					     "register UCSI failed\n");
	}

	pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
	pm_runtime_use_autosuspend(&pdev->dev);
	pm_runtime_put_autosuspend(&pdev->dev);
	pm_runtime_allow(&pdev->dev);
	pm_runtime_set_autosuspend_delay(device, 1000);
	pm_runtime_use_autosuspend(device);
	pm_runtime_put_autosuspend(device);
	pm_runtime_allow(device);

	return 0;
}
@@ -296,11 +294,12 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
static void i2c_dw_pci_remove(struct pci_dev *pdev)
{
	struct dw_i2c_dev *dev = pci_get_drvdata(pdev);
	struct device *device = &pdev->dev;

	i2c_dw_disable(dev);

	pm_runtime_forbid(&pdev->dev);
	pm_runtime_get_noresume(&pdev->dev);
	pm_runtime_forbid(device);
	pm_runtime_get_noresume(device);

	i2c_del_adapter(&dev->adapter);
}
+23 −25
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)

static int dw_i2c_plat_probe(struct platform_device *pdev)
{
	struct device *device = &pdev->dev;
	struct i2c_adapter *adap;
	struct dw_i2c_dev *dev;
	int irq, ret;
@@ -213,15 +214,15 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
	if (irq < 0)
		return irq;

	dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL);
	dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;

	dev->flags = (uintptr_t)device_get_match_data(&pdev->dev);
	if (device_property_present(&pdev->dev, "wx,i2c-snps-model"))
	dev->flags = (uintptr_t)device_get_match_data(device);
	if (device_property_present(device, "wx,i2c-snps-model"))
		dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;

	dev->dev = &pdev->dev;
	dev->dev = device;
	dev->irq = irq;
	platform_set_drvdata(pdev, dev);

@@ -229,7 +230,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
	if (ret)
		return ret;

	dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
	dev->rst = devm_reset_control_get_optional_exclusive(device, NULL);
	if (IS_ERR(dev->rst))
		return PTR_ERR(dev->rst);

@@ -246,13 +247,13 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
	i2c_dw_configure(dev);

	/* Optional interface clock */
	dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
	dev->pclk = devm_clk_get_optional(device, "pclk");
	if (IS_ERR(dev->pclk)) {
		ret = PTR_ERR(dev->pclk);
		goto exit_reset;
	}

	dev->clk = devm_clk_get_optional(&pdev->dev, NULL);
	dev->clk = devm_clk_get_optional(device, NULL);
	if (IS_ERR(dev->clk)) {
		ret = PTR_ERR(dev->clk);
		goto exit_reset;
@@ -280,28 +281,24 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
					I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
	adap->nr = -1;

	if (dev->flags & ACCESS_NO_IRQ_SUSPEND) {
		dev_pm_set_driver_flags(&pdev->dev,
					DPM_FLAG_SMART_PREPARE);
	} else {
		dev_pm_set_driver_flags(&pdev->dev,
					DPM_FLAG_SMART_PREPARE |
					DPM_FLAG_SMART_SUSPEND);
	}
	if (dev->flags & ACCESS_NO_IRQ_SUSPEND)
		dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE);
	else
		dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE | DPM_FLAG_SMART_SUSPEND);

	device_enable_async_suspend(&pdev->dev);
	device_enable_async_suspend(device);

	/* The code below assumes runtime PM to be disabled. */
	WARN_ON(pm_runtime_enabled(&pdev->dev));
	WARN_ON(pm_runtime_enabled(device));

	pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
	pm_runtime_use_autosuspend(&pdev->dev);
	pm_runtime_set_active(&pdev->dev);
	pm_runtime_set_autosuspend_delay(device, 1000);
	pm_runtime_use_autosuspend(device);
	pm_runtime_set_active(device);

	if (dev->shared_with_punit)
		pm_runtime_get_noresume(&pdev->dev);
		pm_runtime_get_noresume(device);

	pm_runtime_enable(&pdev->dev);
	pm_runtime_enable(device);

	ret = i2c_dw_probe(dev);
	if (ret)
@@ -319,15 +316,16 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
static void dw_i2c_plat_remove(struct platform_device *pdev)
{
	struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
	struct device *device = &pdev->dev;

	pm_runtime_get_sync(&pdev->dev);
	pm_runtime_get_sync(device);

	i2c_del_adapter(&dev->adapter);

	i2c_dw_disable(dev);

	pm_runtime_dont_use_autosuspend(&pdev->dev);
	pm_runtime_put_sync(&pdev->dev);
	pm_runtime_dont_use_autosuspend(device);
	pm_runtime_put_sync(device);
	dw_i2c_plat_pm_cleanup(dev);

	i2c_dw_remove_lock_support(dev);