From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: VIC: Allocate VIC PM device from slab
Date: Tue, 1 Jun 2010 11:36:53 +0100 [thread overview]
Message-ID: <1275388613-2496-2-git-send-email-ben-linux@fluff.org> (raw)
In-Reply-To: <1275388613-2496-1-git-send-email-ben-linux@fluff.org>
The original assertion about the inability to allocate the VIC device is
wrong, and that we have the ability to allocate memory when registering
the VIC (tested on s3c6400_defconfig with SMDK6410).
Change to allocating the device at init time, putting it on a list
instead of having a static array of vics.
Note, since this is just for the PM, it does not affect the exisiting
VIC operations.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
arch/arm/common/vic.c | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index ba65f6e..b1f1a9e 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -21,6 +21,7 @@
#include <linux/init.h>
#include <linux/list.h>
+#include <linux/slab.h>
#include <linux/io.h>
#include <linux/sysdev.h>
#include <linux/device.h>
@@ -44,6 +45,7 @@
*/
struct vic_device {
struct sys_device sysdev;
+ struct list_head list;
void __iomem *base;
int irq;
@@ -55,10 +57,7 @@ struct vic_device {
u32 protect;
};
-/* we cannot allocate memory when VICs are initially registered */
-static struct vic_device vic_devices[CONFIG_ARM_VIC_NR];
-
-static int vic_id;
+static LIST_HEAD(vic_list);
static inline struct vic_device *to_vic(struct sys_device *sys)
{
@@ -147,11 +146,11 @@ struct sysdev_class vic_class = {
*/
static int __init vic_pm_init(void)
{
- struct vic_device *dev = vic_devices;
+ struct vic_device *dev;
int err;
- int id;
+ int id = 0;
- if (vic_id == 0)
+ if (list_empty(&vic_list))
return 0;
err = sysdev_class_register(&vic_class);
@@ -160,8 +159,8 @@ static int __init vic_pm_init(void)
return err;
}
- for (id = 0; id < vic_id; id++, dev++) {
- dev->sysdev.id = id;
+ list_for_each_entry(dev, &vic_list, list) {
+ dev->sysdev.id = id++;
dev->sysdev.cls = &vic_class;
err = sysdev_register(&dev->sysdev);
@@ -190,15 +189,14 @@ static void __init vic_pm_register(void __iomem *base, unsigned int irq, u32 res
{
struct vic_device *v;
- if (vic_id >= ARRAY_SIZE(vic_devices))
- printk(KERN_ERR "%s: too few VICs, increase CONFIG_ARM_VIC_NR\n", __func__);
- else {
- v = &vic_devices[vic_id];
+ v = kzalloc(sizeof(struct vic_device), GFP_KERNEL);
+ if (v) {
+ list_add_tail(&v->list, &vic_list);
v->base = base;
- v->resume_sources = resume_sources;
v->irq = irq;
- vic_id++;
- }
+ v->resume_sources = resume_sources;
+ } else
+ printk(KERN_ERR "%s: cannot add vic at %p\n", __func__, base);
}
#else
static inline void vic_pm_register(void __iomem *base, unsigned int irq, u32 arg1) { }
@@ -230,11 +228,10 @@ static void vic_unmask_irq(unsigned int irq)
#if defined(CONFIG_PM)
static struct vic_device *vic_from_irq(unsigned int irq)
{
- struct vic_device *v = vic_devices;
unsigned int base_irq = irq & ~31;
- int id;
+ struct vic_device *v;
- for (id = 0; id < vic_id; id++, v++) {
+ list_for_each_entry(v, &vic_list, list) {
if (v->irq == base_irq)
return v;
}
--
1.6.3.3
prev parent reply other threads:[~2010-06-01 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-01 10:36 VIC dynamic PM Ben Dooks
2010-06-01 10:36 ` Ben Dooks [this message]
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=1275388613-2496-2-git-send-email-ben-linux@fluff.org \
--to=ben-linux@fluff.org \
--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;
as well as URLs for NNTP newsgroup(s).