diff mbox

mmc: omap_hsmmc: fix max value of clkd

Message ID 1348240872-16068-1-git-send-email-balajitk@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Balaji T K Sept. 21, 2012, 3:21 p.m. UTC
clock divisor can take a max value of 1023
update code as per TRM so that card init can be handled with
higher IP clock frequencies from which clock to the card is
derived.

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

Venkatraman S Sept. 21, 2012, 4:58 p.m. UTC | #1
On Fri, Sep 21, 2012 at 8:51 PM, Balaji T K <balajitk@ti.com> wrote:
> clock divisor can take a max value of 1023
> update code as per TRM so that card init can be handled with
> higher IP clock frequencies from which clock to the card is
> derived.
>
This is difficult to read without some punctuation / capitalization.

> Signed-off-by: Balaji T K <balajitk@ti.com>
> ---
>  drivers/mmc/host/omap_hsmmc.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index d9af5f1..073b9ff 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -75,6 +75,7 @@
>  #define ICE                    0x1
>  #define ICS                    0x2
>  #define CEN                    (1 << 2)
> +#define CLKD_MAX               0x3FF

It'd be nice to have a comment on what 3FF stands for and it's
relation to clock in MHz.

>  #define CLKD_MASK              0x0000FFC0
>  #define CLKD_SHIFT             6
>  #define DTO_MASK               0x000F0000
> @@ -478,8 +479,8 @@ static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios)
>
>         if (ios->clock) {
>                 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock);
> -               if (dsor > 250)
> -                       dsor = 250;
> +               if (dsor > CLKD_MAX)
> +                       dsor = CLKD_MAX;

Can these two lines be written in one line as
"dsor &= CLKD_MAX; " ?

>         }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Felipe Balbi Sept. 21, 2012, 5:14 p.m. UTC | #2
On Fri, Sep 21, 2012 at 10:28:00PM +0530, S, Venkatraman wrote:
> On Fri, Sep 21, 2012 at 8:51 PM, Balaji T K <balajitk@ti.com> wrote:
> > clock divisor can take a max value of 1023
> > update code as per TRM so that card init can be handled with
> > higher IP clock frequencies from which clock to the card is
> > derived.
> >
> This is difficult to read without some punctuation / capitalization.
> 
> > Signed-off-by: Balaji T K <balajitk@ti.com>
> > ---
> >  drivers/mmc/host/omap_hsmmc.c |    5 +++--
> >  1 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> > index d9af5f1..073b9ff 100644
> > --- a/drivers/mmc/host/omap_hsmmc.c
> > +++ b/drivers/mmc/host/omap_hsmmc.c
> > @@ -75,6 +75,7 @@
> >  #define ICE                    0x1
> >  #define ICS                    0x2
> >  #define CEN                    (1 << 2)
> > +#define CLKD_MAX               0x3FF
> 
> It'd be nice to have a comment on what 3FF stands for and it's
> relation to clock in MHz.
> 
> >  #define CLKD_MASK              0x0000FFC0
> >  #define CLKD_SHIFT             6
> >  #define DTO_MASK               0x000F0000
> > @@ -478,8 +479,8 @@ static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios)
> >
> >         if (ios->clock) {
> >                 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock);
> > -               if (dsor > 250)
> > -                       dsor = 250;
> > +               if (dsor > CLKD_MAX)
> > +                       dsor = CLKD_MAX;
> 
> Can these two lines be written in one line as
> "dsor &= CLKD_MAX; " ?

maybe:

dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock);
dsor = clamp_t(u16, dsor, 0, CLKD_MAX);
diff mbox

Patch

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index d9af5f1..073b9ff 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -75,6 +75,7 @@ 
 #define ICE			0x1
 #define ICS			0x2
 #define CEN			(1 << 2)
+#define CLKD_MAX		0x3FF
 #define CLKD_MASK		0x0000FFC0
 #define CLKD_SHIFT		6
 #define DTO_MASK		0x000F0000
@@ -478,8 +479,8 @@  static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios)
 
 	if (ios->clock) {
 		dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock);
-		if (dsor > 250)
-			dsor = 250;
+		if (dsor > CLKD_MAX)
+			dsor = CLKD_MAX;
 	}
 
 	return dsor;