Commit f8e2ff26 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] omap3isp: Modify clocks registration to avoid circular references

The clock core code is going to be modified so clk_get() takes
reference on the clock provider module. Until the potential circular
reference issue is properly addressed, we pass NULL as the first
argument to clk_register(), in order to disallow sub-devices taking
a reference on the ISP module back trough clk_get(). This should
prevent locking the modules in memory.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 088f8300
...@@ -290,9 +290,11 @@ static int isp_xclk_init(struct isp_device *isp) ...@@ -290,9 +290,11 @@ static int isp_xclk_init(struct isp_device *isp)
struct clk_init_data init; struct clk_init_data init;
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i)
isp->xclks[i].clk = ERR_PTR(-EINVAL);
for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) { for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
struct isp_xclk *xclk = &isp->xclks[i]; struct isp_xclk *xclk = &isp->xclks[i];
struct clk *clk;
xclk->isp = isp; xclk->isp = isp;
xclk->id = i == 0 ? ISP_XCLK_A : ISP_XCLK_B; xclk->id = i == 0 ? ISP_XCLK_A : ISP_XCLK_B;
...@@ -305,10 +307,15 @@ static int isp_xclk_init(struct isp_device *isp) ...@@ -305,10 +307,15 @@ static int isp_xclk_init(struct isp_device *isp)
init.num_parents = 1; init.num_parents = 1;
xclk->hw.init = &init; xclk->hw.init = &init;
/*
clk = devm_clk_register(isp->dev, &xclk->hw); * The first argument is NULL in order to avoid circular
if (IS_ERR(clk)) * reference, as this driver takes reference on the
return PTR_ERR(clk); * sensor subdevice modules and the sensors would take
* reference on this module through clk_get().
*/
xclk->clk = clk_register(NULL, &xclk->hw);
if (IS_ERR(xclk->clk))
return PTR_ERR(xclk->clk);
if (pdata->xclks[i].con_id == NULL && if (pdata->xclks[i].con_id == NULL &&
pdata->xclks[i].dev_id == NULL) pdata->xclks[i].dev_id == NULL)
...@@ -320,7 +327,7 @@ static int isp_xclk_init(struct isp_device *isp) ...@@ -320,7 +327,7 @@ static int isp_xclk_init(struct isp_device *isp)
xclk->lookup->con_id = pdata->xclks[i].con_id; xclk->lookup->con_id = pdata->xclks[i].con_id;
xclk->lookup->dev_id = pdata->xclks[i].dev_id; xclk->lookup->dev_id = pdata->xclks[i].dev_id;
xclk->lookup->clk = clk; xclk->lookup->clk = xclk->clk;
clkdev_add(xclk->lookup); clkdev_add(xclk->lookup);
} }
...@@ -335,6 +342,9 @@ static void isp_xclk_cleanup(struct isp_device *isp) ...@@ -335,6 +342,9 @@ static void isp_xclk_cleanup(struct isp_device *isp)
for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) { for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
struct isp_xclk *xclk = &isp->xclks[i]; struct isp_xclk *xclk = &isp->xclks[i];
if (!IS_ERR(xclk->clk))
clk_unregister(xclk->clk);
if (xclk->lookup) if (xclk->lookup)
clkdev_drop(xclk->lookup); clkdev_drop(xclk->lookup);
} }
......
...@@ -135,6 +135,7 @@ struct isp_xclk { ...@@ -135,6 +135,7 @@ struct isp_xclk {
struct isp_device *isp; struct isp_device *isp;
struct clk_hw hw; struct clk_hw hw;
struct clk_lookup *lookup; struct clk_lookup *lookup;
struct clk *clk;
enum isp_xclk_id id; enum isp_xclk_id id;
spinlock_t lock; /* Protects enabled and divider */ spinlock_t lock; /* Protects enabled and divider */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment