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

clk: keystone: sci-clk: split out the fw clock parsing to own function

This makes it both easier to see what the probe does, and also makes it
possible to add alternative implementations for the clock data source.

Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Tero Kristo <t-kristo@ti.com>

+41 -27
+41 -27
drivers/clk/keystone/sci-clk.c
··· 403 403 }; 404 404 MODULE_DEVICE_TABLE(of, ti_sci_clk_of_match); 405 405 406 - /** 407 - * ti_sci_clk_probe - Probe function for the TI SCI clock driver 408 - * @pdev: platform device pointer to be probed 409 - * 410 - * Probes the TI SCI clock device. Allocates a new clock provider 411 - * and registers this to the common clock framework. Also applies 412 - * any required flags to the identified clocks via clock lists 413 - * supplied from DT. Returns 0 for success, negative error value 414 - * for failure. 415 - */ 416 - static int ti_sci_clk_probe(struct platform_device *pdev) 406 + static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) 417 407 { 418 - struct device *dev = &pdev->dev; 419 - struct device_node *np = dev->of_node; 420 - struct sci_clk_provider *provider; 421 - const struct ti_sci_handle *handle; 422 408 int ret; 423 409 int num_clks = 0; 424 410 struct sci_clk **clks = NULL; ··· 415 429 int dev_id = 0; 416 430 u8 num_parents; 417 431 int gap_size = 0; 418 - 419 - handle = devm_ti_sci_get_handle(dev); 420 - if (IS_ERR(handle)) 421 - return PTR_ERR(handle); 422 - 423 - provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL); 424 - if (!provider) 425 - return -ENOMEM; 426 - 427 - provider->sci = handle; 428 - provider->ops = &handle->ops.clk_ops; 429 - provider->dev = dev; 432 + struct device *dev = provider->dev; 430 433 431 434 while (1) { 432 435 ret = provider->ops->get_num_parents(provider->sci, dev_id, ··· 475 500 provider->num_clocks = num_clks; 476 501 477 502 devm_kfree(dev, clks); 503 + 504 + return 0; 505 + } 506 + 507 + /** 508 + * ti_sci_clk_probe - Probe function for the TI SCI clock driver 509 + * @pdev: platform device pointer to be probed 510 + * 511 + * Probes the TI SCI clock device. Allocates a new clock provider 512 + * and registers this to the common clock framework. Also applies 513 + * any required flags to the identified clocks via clock lists 514 + * supplied from DT. Returns 0 for success, negative error value 515 + * for failure. 516 + */ 517 + static int ti_sci_clk_probe(struct platform_device *pdev) 518 + { 519 + struct device *dev = &pdev->dev; 520 + struct device_node *np = dev->of_node; 521 + struct sci_clk_provider *provider; 522 + const struct ti_sci_handle *handle; 523 + int ret; 524 + 525 + handle = devm_ti_sci_get_handle(dev); 526 + if (IS_ERR(handle)) 527 + return PTR_ERR(handle); 528 + 529 + provider = devm_kzalloc(dev, sizeof(*provider), GFP_KERNEL); 530 + if (!provider) 531 + return -ENOMEM; 532 + 533 + provider->sci = handle; 534 + provider->ops = &handle->ops.clk_ops; 535 + provider->dev = dev; 536 + 537 + ret = ti_sci_scan_clocks_from_fw(provider); 538 + if (ret) { 539 + dev_err(dev, "scan clocks from FW failed: %d\n", ret); 540 + return ret; 541 + } 478 542 479 543 ret = ti_sci_init_clocks(provider); 480 544 if (ret) {