linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Juergen Beisert <j.beisert@pengutronix.de>,
	linux-fbdev-devel@lists.sourceforge.net
Subject: Re: [PATCH] i.MX Framebuffer: Use	iowrite/ioread instead of direct pointer deref
Date: Wed, 20 Aug 2008 18:31:09 +0200	[thread overview]
Message-ID: <20080820163109.GU4713@pengutronix.de> (raw)
In-Reply-To: <20080820173159.4bc56e34.krzysztof.h1@poczta.fm>

On Wed, Aug 20, 2008 at 05:31:59PM +0200, Krzysztof Helt wrote:
> On Tue, 19 Aug 2008 17:06:41 +0200
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
> 
> > From: Juergen Beisert <j.beisert@pengutronix.de>
> > 
> > This patch prepares the current i.MX1 framebuffer driver for usage in the
> > whole i.MX family. It switches to iowrite/ioread for register accesses.
> > Also it moves the register definitions to the driver where they belong.
> > 
> > Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>
> > ---
> >  drivers/video/imxfb.c |  208 ++++++++++++++++++++++++++++++++++++++++---------
> >  drivers/video/imxfb.h |    4 +-
> >  2 files changed, 173 insertions(+), 39 deletions(-)
> > 
> > diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
> > index a990d43..0622589 100644
> > --- a/drivers/video/imxfb.c
> > +++ b/drivers/video/imxfb.c
> > @@ -16,7 +16,6 @@
> >   *	linux-arm-kernel@lists.arm.linux.org.uk
> >   */
> >  
> > -//#define DEBUG 1
> >  
> >  #include <linux/module.h>
> >  #include <linux/kernel.h>
> > @@ -33,7 +32,6 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/dma-mapping.h>
> >  
> > -#include <mach/hardware.h>
> >  #include <asm/io.h>
> >  #include <mach/imxfb.h>
> >  
> > @@ -44,6 +42,124 @@
> >  
> >  #include "imxfb.h"
> >  
> > +#define DRIVER_NAME "imx-fb"
> > +
> 
> All constants below should really be put into the imxfb.h. There is already such a file.

AFAIK the-new-beautiful-way is not to have these header files next to
the .c files at all and put this stuff into the .c file. So maybe it's
better to move the rest of imxfb.h here aswell.


> 
> > +#define LCDC_SSA	0x00
> > +
> > +#define LCDC_SIZE	0x04
> > +#define SIZE_XMAX(x)	((((x) >> 4) & 0x3f) << 20)
> > +#ifdef CONFIG_ARCH_IMX
> 
> Is it possible to use this driver without CONFIG_ARCH_IMX defined?

Oops, not yet. These are the differences between IMX and MX2, the
architecture I'm currently preparing this driver for. This shouldn't
show up in this patch of course.


 >  
> > -#define LCDC_PALETTE(x) __REG2(IMX_LCDC_BASE+0x800, (x)<<2)
> >  static int
> >  imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
> >  		       u_int trans, struct fb_info *info)
> > @@ -81,7 +196,7 @@ imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
> >  		      (CNVT_TOHW(green,4) << 4) |
> >  		      CNVT_TOHW(blue,  4);
> >  
> > -		LCDC_PALETTE(regno) = val;
> > +		iowrite32(val, fbi->regs + 0x800 + (regno << 2));
> 
> One may define an inline function imxfb_write(fbi, val, reg) :
> 
>  imxfb_iowrite(fbi, val, reg) 
> {
> 	iowrite32(val, fbi->regs + reg);
> }
> 
> It would make the code more readable. The imxfb_ioread() could be used as well.
>

Well, I think this is a matter of taste, I prefer not using wrappers
around the access functions.



>  	strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
> >  
> > @@ -465,7 +588,7 @@ static int __init imxfb_map_video_memory(struct fb_info *info)
> >  	struct imxfb_info *fbi = info->par;
> >  
> >  	fbi->map_size = PAGE_ALIGN(info->fix.smem_len);
> > -	fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
> > +	fbi->map_cpu = dma_alloc_writecombine(&fbi->pdev->dev, fbi->map_size,
> 
> Use &pdev->dev instead &fbi->pdev->dev

ok

> 
> >  					&fbi->map_dma,GFP_KERNEL);
> >  
> >  	if (fbi->map_cpu) {
> > @@ -506,14 +629,21 @@ static int __init imxfb_probe(struct platform_device *pdev)
> >  
> >  	platform_set_drvdata(pdev, info);
> >  
> > -	ret = imxfb_init_fbinfo(&pdev->dev);
> > +	ret = imxfb_init_fbinfo(pdev);
> >  	if( ret < 0 )
> >  		goto failed_init;
> >  
> > -	res = request_mem_region(res->start, res->end - res->start + 1, "IMXFB");
> > +	res = request_mem_region(res->start, res->end - res->start + 1,
> > +				DRIVER_NAME);
> 
> There is a function resource_size(res) which does (res->end - res->start + 1).
> It seems useful here and at few places below.

ok, haven't seen it so far, thanks

 >  
> > -static int imxfb_remove(struct platform_device *pdev)
> > +static int __devexit imxfb_remove(struct platform_device *pdev)
> >  {
> >  	struct fb_info *info = platform_get_drvdata(pdev);
> >  	struct imxfb_info *fbi = info->par;
> > @@ -586,6 +718,7 @@ static int imxfb_remove(struct platform_device *pdev)
> >  	kfree(info->pseudo_palette);
> >  	framebuffer_release(info);
> >  
> > +	iounmap(fbi->regs);
> 
> The fbi pointed does not exist here (after framebuffer_release(info)).

Ack

 >  
> >  struct imxfb_info {
> > -	struct device		*dev;
> > +	struct platform_device  *pdev;
> 
> Is this field really useful? It can be dropped.

ok

-- 
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

  reply	other threads:[~2008-08-20 16:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-19 15:06 i.MX Framebuffer patches Sascha Hauer
2008-08-19 15:06 ` [PATCH] i.MX Framebuffer: remove gpio setup function Sascha Hauer
2008-08-20 15:52   ` Krzysztof Helt
2008-08-19 15:06 ` [PATCH] i.MX Framebuffer: Use iowrite/ioread instead of direct pointer deref Sascha Hauer
2008-08-20 15:31   ` Krzysztof Helt
2008-08-20 16:31     ` Sascha Hauer [this message]
2008-08-20 17:42       ` Krzysztof Helt
2008-08-20 20:23         ` Geert Uytterhoeven
2008-08-19 15:06 ` [PATCH] i.MX Framebuffer: Cleanup Coding style Sascha Hauer
2008-08-20 15:35   ` Krzysztof Helt
2008-08-20 16:15     ` Sascha Hauer
2008-08-20 17:35       ` Krzysztof Helt
2008-08-21  7:13         ` Sascha Hauer
2008-08-19 15:06 ` [PATCH] i.MX Framebuffer: rename imxfb_mach_info to imx_fb_platform_data Sascha Hauer
2008-08-20 15:51   ` Krzysztof Helt
2008-08-20 16:18     ` Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2008-09-02 11:24 i.MX framebuffer patches Sascha Hauer
2008-09-02 11:24 ` [PATCH] i.MX Framebuffer: Use iowrite/ioread instead of direct pointer deref Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080820163109.GU4713@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=j.beisert@pengutronix.de \
    --cc=krzysztof.h1@poczta.fm \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).