diff mbox

[v6,2/4] amba: Add helper macros for (un)preparing AMBA clock

Message ID 1411379189-3017-3-git-send-email-k.kozlowski@samsung.com (mailing list archive)
State Superseded
Headers show

Commit Message

Krzysztof Kozlowski Sept. 22, 2014, 9:46 a.m. UTC
Add amba_pclk_prepare() and amba_pclk_unprepare() macros for handling
the AMBA bus clock by device drivers.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 include/linux/amba/bus.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ulf Hansson Sept. 22, 2014, 6:56 p.m. UTC | #1
On 22 September 2014 11:46, Krzysztof Kozlowski <k.kozlowski@samsung.com> wrote:
> Add amba_pclk_prepare() and amba_pclk_unprepare() macros for handling
> the AMBA bus clock by device drivers.
>
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
>  include/linux/amba/bus.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
> index fdd7e1b61f60..ad52027a9cbf 100644
> --- a/include/linux/amba/bus.h
> +++ b/include/linux/amba/bus.h
> @@ -92,6 +92,12 @@ void amba_release_regions(struct amba_device *);
>  #define amba_pclk_disable(d)   \
>         do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
>
> +#define amba_pclk_prepare(d)   \
> +       (IS_ERR((d)->pclk) ? 0 : clk_prepare((d)->pclk))

You don't need the IS_ERR, because amba_probe will fail if it won't be
able to fetch the clock.

Same comment below.

Kind regards
Uffe

> +
> +#define amba_pclk_unprepare(d) \
> +       do { if (!IS_ERR((d)->pclk)) clk_unprepare((d)->pclk); } while (0)
> +
>  /* Some drivers don't use the struct amba_device */
>  #define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
>  #define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krzysztof Kozlowski Sept. 23, 2014, 7:30 a.m. UTC | #2
On pon, 2014-09-22 at 20:56 +0200, Ulf Hansson wrote:
> On 22 September 2014 11:46, Krzysztof Kozlowski <k.kozlowski@samsung.com> wrote:
> > Add amba_pclk_prepare() and amba_pclk_unprepare() macros for handling
> > the AMBA bus clock by device drivers.
> >
> > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > ---
> >  include/linux/amba/bus.h | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
> > index fdd7e1b61f60..ad52027a9cbf 100644
> > --- a/include/linux/amba/bus.h
> > +++ b/include/linux/amba/bus.h
> > @@ -92,6 +92,12 @@ void amba_release_regions(struct amba_device *);
> >  #define amba_pclk_disable(d)   \
> >         do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
> >
> > +#define amba_pclk_prepare(d)   \
> > +       (IS_ERR((d)->pclk) ? 0 : clk_prepare((d)->pclk))
> 
> You don't need the IS_ERR, because amba_probe will fail if it won't be
> able to fetch the clock.
> 
> Same comment below.

Right, I followed the convention for amba_pclk_enable but this is not
needed. I'll change it and send new version.

Best regards,
Krzysztof

> 
> Kind regards
> Uffe
> 
> > +
> > +#define amba_pclk_unprepare(d) \
> > +       do { if (!IS_ERR((d)->pclk)) clk_unprepare((d)->pclk); } while (0)
> > +
> >  /* Some drivers don't use the struct amba_device */
> >  #define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
> >  #define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)
> > --
> > 1.9.1
> >

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index fdd7e1b61f60..ad52027a9cbf 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -92,6 +92,12 @@  void amba_release_regions(struct amba_device *);
 #define amba_pclk_disable(d)	\
 	do { if (!IS_ERR((d)->pclk)) clk_disable((d)->pclk); } while (0)
 
+#define amba_pclk_prepare(d)	\
+	(IS_ERR((d)->pclk) ? 0 : clk_prepare((d)->pclk))
+
+#define amba_pclk_unprepare(d)	\
+	do { if (!IS_ERR((d)->pclk)) clk_unprepare((d)->pclk); } while (0)
+
 /* Some drivers don't use the struct amba_device */
 #define AMBA_CONFIG_BITS(a) (((a) >> 24) & 0xff)
 #define AMBA_REV_BITS(a) (((a) >> 20) & 0x0f)