summaryrefslogtreecommitdiffstats
path: root/drivers/memory
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2018-03-27 19:40:38 -0400
committerFlorian Fainelli <f.fainelli@gmail.com>2018-05-09 15:15:26 -0400
commitb1d0973e9a1b4742ec80f3cf59ecc84a0998465b (patch)
tree8a297620e6d29da78786614b73b7c18a1f4a808f /drivers/memory
parent60cc43fc888428bb2f18f08997432d426a243338 (diff)
memory: brcmstb: dpfe: Remove need for dpfe_dev
We can hook sysfs objects to the parent platform device that we are created from, no need to have a synthetic dpfe_dev just for that. This incidentally removes the need for having an index, since we are guaranteed to have an unique path in the sysfs hiearchy. Acked-by: Markus Mayer <mmayer@broadcom.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Diffstat (limited to 'drivers/memory')
-rw-r--r--drivers/memory/brcmstb_dpfe.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index e9c1485c32b9..04599eccd604 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -176,7 +176,6 @@ struct private_data {
176 void __iomem *dmem; 176 void __iomem *dmem;
177 void __iomem *imem; 177 void __iomem *imem;
178 struct device *dev; 178 struct device *dev;
179 unsigned int index;
180 struct mutex lock; 179 struct mutex lock;
181}; 180};
182 181
@@ -674,10 +673,8 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
674{ 673{
675 struct device *dev = &pdev->dev; 674 struct device *dev = &pdev->dev;
676 struct private_data *priv; 675 struct private_data *priv;
677 struct device *dpfe_dev;
678 struct init_data init; 676 struct init_data init;
679 struct resource *res; 677 struct resource *res;
680 u32 index;
681 int ret; 678 int ret;
682 679
683 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 680 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -687,11 +684,6 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
687 mutex_init(&priv->lock); 684 mutex_init(&priv->lock);
688 platform_set_drvdata(pdev, priv); 685 platform_set_drvdata(pdev, priv);
689 686
690 /* Cell index is optional; default to 0 if not present. */
691 ret = of_property_read_u32(dev->of_node, "cell-index", &index);
692 if (ret)
693 index = 0;
694
695 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dpfe-cpu"); 687 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dpfe-cpu");
696 priv->regs = devm_ioremap_resource(dev, res); 688 priv->regs = devm_ioremap_resource(dev, res);
697 if (IS_ERR(priv->regs)) { 689 if (IS_ERR(priv->regs)) {
@@ -715,35 +707,20 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
715 707
716 ret = brcmstb_dpfe_download_firmware(pdev, &init); 708 ret = brcmstb_dpfe_download_firmware(pdev, &init);
717 if (ret) 709 if (ret)
718 goto err; 710 return ret;
719
720 dpfe_dev = devm_kzalloc(dev, sizeof(*dpfe_dev), GFP_KERNEL);
721 if (!dpfe_dev) {
722 ret = -ENOMEM;
723 goto err;
724 }
725
726 priv->dev = dpfe_dev;
727 priv->index = index;
728 711
729 dpfe_dev->parent = dev; 712 ret = sysfs_create_groups(&pdev->dev.kobj, dpfe_groups);
730 dpfe_dev->groups = dpfe_groups; 713 if (!ret)
731 dpfe_dev->of_node = dev->of_node; 714 dev_info(dev, "registered.\n");
732 dev_set_drvdata(dpfe_dev, priv);
733 dev_set_name(dpfe_dev, "dpfe%u", index);
734 715
735 ret = device_register(dpfe_dev); 716 return ret;
736 if (ret) 717}
737 goto err;
738 718
739 dev_info(dev, "registered.\n"); 719static int brcmstb_dpfe_remove(struct platform_device *pdev)
720{
721 sysfs_remove_groups(&pdev->dev.kobj, dpfe_groups);
740 722
741 return 0; 723 return 0;
742
743err:
744 dev_err(dev, "failed to initialize -- error %d\n", ret);
745
746 return ret;
747} 724}
748 725
749static const struct of_device_id brcmstb_dpfe_of_match[] = { 726static const struct of_device_id brcmstb_dpfe_of_match[] = {
@@ -758,6 +735,7 @@ static struct platform_driver brcmstb_dpfe_driver = {
758 .of_match_table = brcmstb_dpfe_of_match, 735 .of_match_table = brcmstb_dpfe_of_match,
759 }, 736 },
760 .probe = brcmstb_dpfe_probe, 737 .probe = brcmstb_dpfe_probe,
738 .remove = brcmstb_dpfe_remove,
761 .resume = brcmstb_dpfe_resume, 739 .resume = brcmstb_dpfe_resume,
762}; 740};
763 741