Commit 05432837 authored by Laurent Pinchart's avatar Laurent Pinchart

fbdev: sh_mobile_meram: Make variables unsigned where applicable

Many variables, such as loop counters, sizes and offsets, should be
unsigned integers. Make them so.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent d272f428
...@@ -104,7 +104,7 @@ struct sh_mobile_meram_priv { ...@@ -104,7 +104,7 @@ struct sh_mobile_meram_priv {
void __iomem *base; void __iomem *base;
struct mutex lock; struct mutex lock;
unsigned long used_icb; unsigned long used_icb;
int used_meram_cache_regions; unsigned int used_meram_cache_regions;
unsigned long used_meram_cache[SH_MOBILE_MERAM_ICB_NUM]; unsigned long used_meram_cache[SH_MOBILE_MERAM_ICB_NUM];
unsigned long cmn_saved_regs[CMN_REGS_SIZE]; unsigned long cmn_saved_regs[CMN_REGS_SIZE];
unsigned long icb_saved_regs[ICB_REGS_SIZE * SH_MOBILE_MERAM_ICB_NUM]; unsigned long icb_saved_regs[ICB_REGS_SIZE * SH_MOBILE_MERAM_ICB_NUM];
...@@ -120,24 +120,25 @@ struct sh_mobile_meram_priv { ...@@ -120,24 +120,25 @@ struct sh_mobile_meram_priv {
#define MERAM_ICB_OFFSET(base, idx, off) ((base) + (off) + (idx) * 0x20) #define MERAM_ICB_OFFSET(base, idx, off) ((base) + (off) + (idx) * 0x20)
static inline void meram_write_icb(void __iomem *base, int idx, int off, static inline void meram_write_icb(void __iomem *base, unsigned int idx,
unsigned long val) unsigned int off, unsigned long val)
{ {
iowrite32(val, MERAM_ICB_OFFSET(base, idx, off)); iowrite32(val, MERAM_ICB_OFFSET(base, idx, off));
} }
static inline unsigned long meram_read_icb(void __iomem *base, int idx, int off) static inline unsigned long meram_read_icb(void __iomem *base, unsigned int idx,
unsigned int off)
{ {
return ioread32(MERAM_ICB_OFFSET(base, idx, off)); return ioread32(MERAM_ICB_OFFSET(base, idx, off));
} }
static inline void meram_write_reg(void __iomem *base, int off, static inline void meram_write_reg(void __iomem *base, unsigned int off,
unsigned long val) unsigned long val)
{ {
iowrite32(val, base + off); iowrite32(val, base + off);
} }
static inline unsigned long meram_read_reg(void __iomem *base, int off) static inline unsigned long meram_read_reg(void __iomem *base, unsigned int off)
{ {
return ioread32(base + off); return ioread32(base + off);
} }
...@@ -158,8 +159,8 @@ static inline unsigned long meram_read_reg(void __iomem *base, int off) ...@@ -158,8 +159,8 @@ static inline unsigned long meram_read_reg(void __iomem *base, int off)
static inline int meram_check_overlap(struct sh_mobile_meram_priv *priv, static inline int meram_check_overlap(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb_cfg *new) struct sh_mobile_meram_icb_cfg *new)
{ {
int i; unsigned int used_start, used_end, meram_start, meram_end;
int used_start, used_end, meram_start, meram_end; unsigned int i;
/* valid ICB? */ /* valid ICB? */
if (new->marker_icb & ~0x1f || new->cache_icb & ~0x1f) if (new->marker_icb & ~0x1f || new->cache_icb & ~0x1f)
...@@ -190,7 +191,7 @@ static inline int meram_check_overlap(struct sh_mobile_meram_priv *priv, ...@@ -190,7 +191,7 @@ static inline int meram_check_overlap(struct sh_mobile_meram_priv *priv,
static inline void meram_mark(struct sh_mobile_meram_priv *priv, static inline void meram_mark(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb_cfg *new) struct sh_mobile_meram_icb_cfg *new)
{ {
int n; unsigned int n;
if (new->marker_icb < 0 || new->cache_icb < 0) if (new->marker_icb < 0 || new->cache_icb < 0)
return; return;
...@@ -213,8 +214,8 @@ static inline void meram_mark(struct sh_mobile_meram_priv *priv, ...@@ -213,8 +214,8 @@ static inline void meram_mark(struct sh_mobile_meram_priv *priv,
static inline void meram_unmark(struct sh_mobile_meram_priv *priv, static inline void meram_unmark(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb_cfg *icb) struct sh_mobile_meram_icb_cfg *icb)
{ {
int i;
unsigned long pattern; unsigned long pattern;
unsigned int i;
if (icb->marker_icb < 0 || icb->cache_icb < 0) if (icb->marker_icb < 0 || icb->cache_icb < 0)
return; return;
...@@ -304,12 +305,15 @@ static inline void meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata, ...@@ -304,12 +305,15 @@ static inline void meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata,
static int meram_init(struct sh_mobile_meram_priv *priv, static int meram_init(struct sh_mobile_meram_priv *priv,
struct sh_mobile_meram_icb_cfg *icb, struct sh_mobile_meram_icb_cfg *icb,
int xres, int yres, int *out_pitch) unsigned int xres, unsigned int yres,
unsigned int *out_pitch)
{ {
unsigned long total_byte_count = MERAM_CALC_BYTECOUNT(xres, yres); unsigned long total_byte_count = MERAM_CALC_BYTECOUNT(xres, yres);
unsigned long bnm; unsigned long bnm;
int lcdc_pitch, xpitch, line_cnt; unsigned int lcdc_pitch;
int save_lines; unsigned int xpitch;
unsigned int line_cnt;
unsigned int save_lines;
/* adjust pitch to 1024, 2048, 4096 or 8192 */ /* adjust pitch to 1024, 2048, 4096 or 8192 */
lcdc_pitch = (xres - 1) | 1023; lcdc_pitch = (xres - 1) | 1023;
...@@ -386,16 +390,18 @@ static void meram_deinit(struct sh_mobile_meram_priv *priv, ...@@ -386,16 +390,18 @@ static void meram_deinit(struct sh_mobile_meram_priv *priv,
static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata,
struct sh_mobile_meram_cfg *cfg, struct sh_mobile_meram_cfg *cfg,
int xres, int yres, int pixelformat, unsigned int xres, unsigned int yres,
unsigned int pixelformat,
unsigned long base_addr_y, unsigned long base_addr_y,
unsigned long base_addr_c, unsigned long base_addr_c,
unsigned long *icb_addr_y, unsigned long *icb_addr_y,
unsigned long *icb_addr_c, unsigned long *icb_addr_c,
int *pitch) unsigned int *pitch)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct sh_mobile_meram_priv *priv; struct sh_mobile_meram_priv *priv;
int n, out_pitch; unsigned int out_pitch;
unsigned int n;
int error = 0; int error = 0;
if (!pdata || !pdata->priv || !pdata->pdev || !cfg) if (!pdata || !pdata->priv || !pdata->pdev || !cfg)
...@@ -538,21 +544,21 @@ static int sh_mobile_meram_runtime_suspend(struct device *dev) ...@@ -538,21 +544,21 @@ static int sh_mobile_meram_runtime_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
int k, j; unsigned int i, j;
for (k = 0; k < CMN_REGS_SIZE; k++) for (i = 0; i < CMN_REGS_SIZE; i++)
priv->cmn_saved_regs[k] = meram_read_reg(priv->base, priv->cmn_saved_regs[i] = meram_read_reg(priv->base,
common_regs[k]); common_regs[i]);
for (j = 0; j < 32; j++) { for (i = 0; i < 32; i++) {
if (!test_bit(j, &priv->used_icb)) if (!test_bit(i, &priv->used_icb))
continue; continue;
for (k = 0; k < ICB_REGS_SIZE; k++) { for (j = 0; j < ICB_REGS_SIZE; j++) {
priv->icb_saved_regs[j * ICB_REGS_SIZE + k] = priv->icb_saved_regs[i * ICB_REGS_SIZE + j] =
meram_read_icb(priv->base, j, icb_regs[k]); meram_read_icb(priv->base, i, icb_regs[j]);
/* Reset ICB on resume */ /* Reset ICB on resume */
if (icb_regs[k] == MExxCTL) if (icb_regs[j] == MExxCTL)
priv->icb_saved_regs[j * ICB_REGS_SIZE + k] |= priv->icb_saved_regs[i * ICB_REGS_SIZE + j] |=
MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF; MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF;
} }
} }
...@@ -563,20 +569,20 @@ static int sh_mobile_meram_runtime_resume(struct device *dev) ...@@ -563,20 +569,20 @@ static int sh_mobile_meram_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev); struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
int k, j; unsigned int i, j;
for (j = 0; j < 32; j++) { for (i = 0; i < 32; i++) {
if (!test_bit(j, &priv->used_icb)) if (!test_bit(i, &priv->used_icb))
continue; continue;
for (k = 0; k < ICB_REGS_SIZE; k++) { for (j = 0; j < ICB_REGS_SIZE; j++) {
meram_write_icb(priv->base, j, icb_regs[k], meram_write_icb(priv->base, i, icb_regs[j],
priv->icb_saved_regs[j * ICB_REGS_SIZE + k]); priv->icb_saved_regs[i * ICB_REGS_SIZE + j]);
} }
} }
for (k = 0; k < CMN_REGS_SIZE; k++) for (i = 0; i < CMN_REGS_SIZE; i++)
meram_write_reg(priv->base, common_regs[k], meram_write_reg(priv->base, common_regs[i],
priv->cmn_saved_regs[k]); priv->cmn_saved_regs[i]);
return 0; return 0;
} }
......
...@@ -46,11 +46,13 @@ struct sh_mobile_meram_ops { ...@@ -46,11 +46,13 @@ struct sh_mobile_meram_ops {
/* register usage of meram */ /* register usage of meram */
int (*meram_register)(struct sh_mobile_meram_info *meram_dev, int (*meram_register)(struct sh_mobile_meram_info *meram_dev,
struct sh_mobile_meram_cfg *cfg, struct sh_mobile_meram_cfg *cfg,
int xres, int yres, int pixelformat, unsigned int xres, unsigned int yres,
unsigned int pixelformat,
unsigned long base_addr_y, unsigned long base_addr_y,
unsigned long base_addr_c, unsigned long base_addr_c,
unsigned long *icb_addr_y, unsigned long *icb_addr_y,
unsigned long *icb_addr_c, int *pitch); unsigned long *icb_addr_c,
unsigned int *pitch);
/* unregister usage of meram */ /* unregister usage of meram */
int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev, int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev,
......
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