Message ID | 1596034301-5428-5-git-send-email-claudiu.beznea@microchip.com |
---|---|
State | Changes Requested |
Delegated to: | Eugen Hristev |
Headers | show |
Series | clk: at91: add sama7g5 support | expand |
On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea <claudiu.beznea@microchip.com> wrote: > > Clock re-parenting is not binding the clock's device to its new > parent device, it only calls the clock's ops->set_parent() API. The > changes in this commit re-parent the clock device to its new parent > so that subsequent operations like clk_get_parent() to point to the > proper parent. > > Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> > --- > drivers/clk/clk-uclass.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) Reviewed-by: Simon Glass <sjg@chromium.org> But please add a sandbox test. > > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c > index aa1f11a27c41..b390a6b01c06 100644 > --- a/drivers/clk/clk-uclass.c > +++ b/drivers/clk/clk-uclass.c > @@ -14,6 +14,7 @@ > #include <errno.h> > #include <log.h> > #include <malloc.h> > +#include <dm/device-internal.h> > #include <dm/devres.h> > #include <dm/read.h> > #include <linux/bug.h> > @@ -511,6 +512,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate) > int clk_set_parent(struct clk *clk, struct clk *parent) > { > const struct clk_ops *ops; > + int ret; > > debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent); > if (!clk_valid(clk)) > @@ -520,7 +522,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent) > if (!ops->set_parent) > return -ENOSYS; > > - return ops->set_parent(clk, parent); > + ret = ops->set_parent(clk, parent); > + if (ret) > + return ret; > + > + if (CONFIG_IS_ENABLED(CLK_CCF)) > + ret = device_reparent(clk->dev, parent->dev); > + > + return ret; > } > > int clk_enable(struct clk *clk) > -- > 2.7.4 >
On 04.08.2020 05:00, Simon Glass wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea > <claudiu.beznea@microchip.com> wrote: >> >> Clock re-parenting is not binding the clock's device to its new >> parent device, it only calls the clock's ops->set_parent() API. The >> changes in this commit re-parent the clock device to its new parent >> so that subsequent operations like clk_get_parent() to point to the >> proper parent. >> >> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> >> --- >> drivers/clk/clk-uclass.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) > > Reviewed-by: Simon Glass <sjg@chromium.org> > > But please add a sandbox test. Sure! > > >> >> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c >> index aa1f11a27c41..b390a6b01c06 100644 >> --- a/drivers/clk/clk-uclass.c >> +++ b/drivers/clk/clk-uclass.c >> @@ -14,6 +14,7 @@ >> #include <errno.h> >> #include <log.h> >> #include <malloc.h> >> +#include <dm/device-internal.h> >> #include <dm/devres.h> >> #include <dm/read.h> >> #include <linux/bug.h> >> @@ -511,6 +512,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate) >> int clk_set_parent(struct clk *clk, struct clk *parent) >> { >> const struct clk_ops *ops; >> + int ret; >> >> debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent); >> if (!clk_valid(clk)) >> @@ -520,7 +522,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent) >> if (!ops->set_parent) >> return -ENOSYS; >> >> - return ops->set_parent(clk, parent); >> + ret = ops->set_parent(clk, parent); >> + if (ret) >> + return ret; >> + >> + if (CONFIG_IS_ENABLED(CLK_CCF)) >> + ret = device_reparent(clk->dev, parent->dev); >> + >> + return ret; >> } >> >> int clk_enable(struct clk *clk) >> -- >> 2.7.4 >>
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index aa1f11a27c41..b390a6b01c06 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -14,6 +14,7 @@ #include <errno.h> #include <log.h> #include <malloc.h> +#include <dm/device-internal.h> #include <dm/devres.h> #include <dm/read.h> #include <linux/bug.h> @@ -511,6 +512,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate) int clk_set_parent(struct clk *clk, struct clk *parent) { const struct clk_ops *ops; + int ret; debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent); if (!clk_valid(clk)) @@ -520,7 +522,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent) if (!ops->set_parent) return -ENOSYS; - return ops->set_parent(clk, parent); + ret = ops->set_parent(clk, parent); + if (ret) + return ret; + + if (CONFIG_IS_ENABLED(CLK_CCF)) + ret = device_reparent(clk->dev, parent->dev); + + return ret; } int clk_enable(struct clk *clk)
Clock re-parenting is not binding the clock's device to its new parent device, it only calls the clock's ops->set_parent() API. The changes in this commit re-parent the clock device to its new parent so that subsequent operations like clk_get_parent() to point to the proper parent. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> --- drivers/clk/clk-uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)