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

mfd: intel_quark_i2c_gpio: Use clkdev_create()

Convert this driver to use clkdev_create() instead of
clk_register_clkdevs(). The latter API is only used by this driver,
although this driver only allocates one clk to add anyway.
Furthermore, this driver allocates the clk_lookup structure with
devm, but clkdev_drop() will free that structure when passed,
leading to a double free when this driver is removed. Clean it
all up and pave the way for the removal of clk_register_clkdevs().

Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Stephen Boyd and committed by
Lee Jones
c4726abc 36f90b0a

+9 -17
+9 -17
drivers/mfd/intel_quark_i2c_gpio.c
··· 52 52 /* The Quark I2C controller source clock */ 53 53 #define INTEL_QUARK_I2C_CLK_HZ 33000000 54 54 55 - #define INTEL_QUARK_I2C_NCLK 1 56 - 57 55 struct intel_quark_mfd { 58 56 struct pci_dev *pdev; 59 57 struct clk *i2c_clk; ··· 126 128 static int intel_quark_register_i2c_clk(struct intel_quark_mfd *quark_mfd) 127 129 { 128 130 struct pci_dev *pdev = quark_mfd->pdev; 129 - struct clk_lookup *i2c_clk_lookup; 130 131 struct clk *i2c_clk; 131 - int ret; 132 - 133 - i2c_clk_lookup = devm_kcalloc(&pdev->dev, INTEL_QUARK_I2C_NCLK, 134 - sizeof(*i2c_clk_lookup), GFP_KERNEL); 135 - if (!i2c_clk_lookup) 136 - return -ENOMEM; 137 - 138 - i2c_clk_lookup[0].dev_id = INTEL_QUARK_I2C_CONTROLLER_CLK; 139 132 140 133 i2c_clk = clk_register_fixed_rate(&pdev->dev, 141 134 INTEL_QUARK_I2C_CONTROLLER_CLK, NULL, 142 135 CLK_IS_ROOT, INTEL_QUARK_I2C_CLK_HZ); 136 + if (IS_ERR(i2c_clk)) 137 + return PTR_ERR(i2c_clk); 143 138 144 - quark_mfd->i2c_clk_lookup = i2c_clk_lookup; 145 139 quark_mfd->i2c_clk = i2c_clk; 140 + quark_mfd->i2c_clk_lookup = clkdev_create(i2c_clk, NULL, 141 + INTEL_QUARK_I2C_CONTROLLER_CLK); 146 142 147 - ret = clk_register_clkdevs(i2c_clk, i2c_clk_lookup, 148 - INTEL_QUARK_I2C_NCLK); 149 - if (ret) 150 - dev_err(&pdev->dev, "Fixed clk register failed: %d\n", ret); 143 + if (!quark_mfd->i2c_clk_lookup) { 144 + dev_err(&pdev->dev, "Fixed clk register failed\n"); 145 + return -ENOMEM; 146 + } 151 147 152 - return ret; 148 + return 0; 153 149 } 154 150 155 151 static void intel_quark_unregister_i2c_clk(struct pci_dev *pdev)