Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 6/7] ARM: pxa: move gpio-pxa.h into include directory
Date: Tue, 11 Oct 2011 22:42:57 +0200	[thread overview]
Message-ID: <3002440.xxjcQDzptB@wuerfel> (raw)
In-Reply-To: <CAKnu2Mr3cWfo3SJYkBU2cXeKELhmVOv+Qes=SCWRBaSB-Sue3g@mail.gmail.com>

On Tuesday 11 October 2011 21:51:28 Linus Walleij wrote:
> 2011/10/11 Haojian Zhuang <haojian.zhuang@marvell.com>:
> 
> > Merge the gpio-pxa.h in arch-pxa and arch-mmp. Move the new gpio-pxa.h
> > into include directory.
> (...)
> >  arch/arm/plat-pxa/include/plat/gpio-pxa.h  |   80 ---------------------------
> >  drivers/gpio/gpio-pxa.c                    |   42 ++++++++++++++-
> >  include/linux/gpio-pxa.h                   |   81 ++++++++++++++++++++++++++++
> 
> This seems like a fully valid merge of common pxa GPIO include
> files. And I guess if both are not using plat-pxa it cannot reside
> in <plat/gpio-pxa.h>?
> 
> Grant: shall this be <linux/gpio-pxa.h> or <linux/gpio/pxa.h> or so?

Hmm, more fundamentally, does this even need to be a header file?

Most of the header file looks like it should not be visible in the entire
kernel, so better move as much as possible into the gpio-pxa.c file.
I'm not sure how much remains in the end, but that should probably
determine the location (drivers/gpio/gpio-pxa.h, asm/gpio-pxa.h
or linux/gpio-pxa.h). In general, everything should be as local
as possible.

One more thing regarding the contents of the header:

> +/* GPIO Pin Level Registers */
> +#define PXA_GPLR(x)	(*(volatile u32 *)(pxa_gpio_regs.gplr	\
> +			+ PXA_BANK_OFF((x >> 5))))
> +/* GPIO Pin Direction Registers */
> +#define PXA_GPDR(x)	(*(volatile u32 *)(pxa_gpio_regs.gpdr	\
> +			+ PXA_BANK_OFF((x >> 5))))

When these get moved into the driver itself, it's probably a good
idea to turn these into proper accessors, something like

enum pxa_gpio_reg {
	GPLR,
	GPDR,
	GPSR,
	GPCR,
	GRER,
	GFER,
	GEDR,
};
static void __iomem *pxa_gpio_reg_base;
static inline u32 pxa_gpio_read(unsigned int bank, enum pxa_gpio_reg reg)
{
	unsigned offset = (bank < 3) ? bank << 2 : 0x100 + ((bank - 3) << 2);
	return readl_relaxed(pxa_gpio_reg_base + offset + 12 * reg);
}
static inline void pxa_gpio_write(unsigned int bank, unsigned int reg, u32 val)
{
	unsigned offset = (bank < 3) ? bank << 2 : 0x100 + ((bank - 3) << 2);
	return writel_relaxed(val, pxa_gpio_reg_base + offset + 12 * reg);
}

That should let you get rid of most of the macros and the incorrect
'volatile' access.

	Arnd

  reply	other threads:[~2011-10-11 20:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11 13:17 [PATCH v3 0/7] clean pxa gpio driver Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 1/7] ARM: pxa: rename IRQ_GPIO to PXA_GPIO_TO_IRQ Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 2/7] ARM: pxa: use chained interrupt for GPIO0 and GPIO1 Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 3/7] ARM: pxa: rename gpio_to_irq and irq_to_gpio Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 4/7] ARM: pxa: rename NR_BUILTIN_GPIO Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 5/7] ARM: pxa: change gpio driver to platform driver Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 6/7] ARM: pxa: move gpio-pxa.h into include directory Haojian Zhuang
2011-10-11 19:51   ` Linus Walleij
2011-10-11 20:42     ` Arnd Bergmann [this message]
2011-10-12  2:31       ` Haojian Zhuang
2011-10-11 13:17 ` [PATCH v3 7/7] ARM: pxa: add clk support in gpio driver Haojian Zhuang

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=3002440.xxjcQDzptB@wuerfel \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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