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

nfc: s3fwrn5: use devm_clk_get_optional_enabled() helper

Because we enable the clock immediately after acquiring it in probe,
we can combine the 2 operations and use devm_clk_get_optional_enabled()
helper.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Dmitry Torokhov and committed by
David S. Miller
f8f797f3 92c7076e

+5 -14
+5 -14
drivers/nfc/s3fwrn5/i2c.c
··· 209 209 if (ret < 0) 210 210 return ret; 211 211 212 - phy->clk = devm_clk_get_optional(&client->dev, NULL); 213 - if (IS_ERR(phy->clk)) 214 - return dev_err_probe(&client->dev, PTR_ERR(phy->clk), 215 - "failed to get clock\n"); 216 - 217 212 /* 218 213 * S3FWRN5 depends on a clock input ("XI" pin) to function properly. 219 214 * Depending on the hardware configuration this could be an always-on 220 215 * oscillator or some external clock that must be explicitly enabled. 221 216 * Make sure the clock is running before starting S3FWRN5. 222 217 */ 223 - ret = clk_prepare_enable(phy->clk); 224 - if (ret < 0) { 225 - dev_err(&client->dev, "failed to enable clock: %d\n", ret); 226 - return ret; 227 - } 218 + phy->clk = devm_clk_get_optional_enabled(&client->dev, NULL); 219 + if (IS_ERR(phy->clk)) 220 + return dev_err_probe(&client->dev, PTR_ERR(phy->clk), 221 + "failed to get clock\n"); 228 222 229 223 ret = s3fwrn5_probe(&phy->common.ndev, phy, &phy->i2c_dev->dev, 230 224 &i2c_phy_ops); 231 225 if (ret < 0) 232 - goto disable_clk; 226 + return ret; 233 227 234 228 ret = devm_request_threaded_irq(&client->dev, phy->i2c_dev->irq, NULL, 235 229 s3fwrn5_i2c_irq_thread_fn, IRQF_ONESHOT, ··· 235 241 236 242 s3fwrn5_remove: 237 243 s3fwrn5_remove(phy->common.ndev); 238 - disable_clk: 239 - clk_disable_unprepare(phy->clk); 240 244 return ret; 241 245 } 242 246 ··· 243 251 struct s3fwrn5_i2c_phy *phy = i2c_get_clientdata(client); 244 252 245 253 s3fwrn5_remove(phy->common.ndev); 246 - clk_disable_unprepare(phy->clk); 247 254 } 248 255 249 256 static const struct i2c_device_id s3fwrn5_i2c_id_table[] = {