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-q6v4.c b/arch/arm/mach-msm/pil-q6v4.c
index b0bce02..17f5a41 100644
--- a/arch/arm/mach-msm/pil-q6v4.c
+++ b/arch/arm/mach-msm/pil-q6v4.c
@@ -71,6 +71,7 @@
bool vreg_enabled;
struct clk *xo;
struct delayed_work work;
+ struct pil_device *pil;
};
static int pil_q6v4_init_image(struct pil_desc *pil, const u8 *metadata,
@@ -421,6 +422,7 @@
desc->name = pdata->name;
desc->depends_on = pdata->depends;
desc->dev = &pdev->dev;
+ desc->owner = THIS_MODULE;
if (pas_supported(pdata->pas_id) > 0) {
desc->ops = &pil_q6v4_ops_trusted;
@@ -443,9 +445,11 @@
}
INIT_DELAYED_WORK(&drv->work, pil_q6v4_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_pil;
+ }
return 0;
err_pil:
flush_delayed_work_sync(&drv->work);
@@ -464,6 +468,7 @@
clk_put(drv->xo);
regulator_put(drv->vreg);
regulator_put(drv->pll_supply);
+ msm_pil_unregister(drv->pil);
return 0;
}