msm: pil: Make register code into a bus

Make struct pil_device into a wrapper around struct device so
that we can group all pil devices in the system onto one logical
pil bus. This will allow us to make 'online' sysfs nodes that
userspace can poll on in a later patch. Also, add an unregister
function so that devices can be removed if a module is removed.

Change-Id: I5e6c4286e3fb2149bdf2311fe23588364349eb54
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/pil-riva.c b/arch/arm/mach-msm/pil-riva.c
index bd49fc0..198572c 100644
--- a/arch/arm/mach-msm/pil-riva.c
+++ b/arch/arm/mach-msm/pil-riva.c
@@ -86,6 +86,7 @@
 	bool use_cxo;
 	struct delayed_work work;
 	struct regulator *pll_supply;
+	struct pil_device *pil;
 };
 
 static int pil_riva_make_proxy_votes(struct device *dev)
@@ -390,6 +391,7 @@
 
 	desc->name = "wcnss";
 	desc->dev = &pdev->dev;
+	desc->owner = THIS_MODULE;
 
 	if (pas_supported(PAS_RIVA) > 0) {
 		desc->ops = &pil_riva_ops_trusted;
@@ -406,9 +408,11 @@
 	}
 	INIT_DELAYED_WORK(&drv->work, pil_riva_remove_proxy_votes);
 
-	ret = msm_pil_register(desc);
-	if (ret)
+	drv->pil = msm_pil_register(desc);
+	if (IS_ERR(drv->pil)) {
+		ret = PTR_ERR(drv->pil);
 		goto err_register;
+	}
 	return 0;
 err_register:
 	flush_delayed_work_sync(&drv->work);
@@ -421,6 +425,7 @@
 static int __devexit pil_riva_remove(struct platform_device *pdev)
 {
 	struct riva_data *drv = platform_get_drvdata(pdev);
+	msm_pil_unregister(drv->pil);
 	flush_delayed_work_sync(&drv->work);
 	clk_put(drv->xo);
 	regulator_put(drv->pll_supply);