glamo: Drop unused IRQ polling code, fix some minor indentation/style issues

Thibaut Girka thib at sitedethib.com
Wed Jun 9 22:29:54 CEST 2010


Le mercredi 09 juin 2010 à 22:09 +0200, Michael Trimarchi a écrit : 
> Send the patch inline to the mail body

Ok, here it is:

From 4fed0939b160e4cb67f98d5a5c591ef2c02d790c Mon Sep 17 00:00:00 2001
From: Thibaut Girka <thib at sitedethib.com>
Date: Wed, 9 Jun 2010 21:49:22 +0200
Subject: [PATCH] glamo: drop unused irq polling code ; correct
indentation/space VS tab

---
drivers/mfd/glamo/glamo-core.c |   32 ++++++++--------
drivers/mfd/glamo/glamo-core.h |   11 ++---
drivers/mfd/glamo/glamo-fb.c   |   24 ++++++------
drivers/mfd/glamo/glamo-gpio.c |   10 ++--
drivers/mfd/glamo/glamo-mci.c  |   84
+++++++++------------------------------
5 files changed, 58 insertions(+), 103 deletions(-)

diff --git a/drivers/mfd/glamo/glamo-core.c
b/drivers/mfd/glamo/glamo-core.c
index 23073fe..b8baf5d 100644
--- a/drivers/mfd/glamo/glamo-core.c
+++ b/drivers/mfd/glamo/glamo-core.c
@@ -103,7 +103,7 @@ static const struct reg_range reg_range[] = {
};

static inline void __reg_write(struct glamo_core *glamo,
- uint16_t reg, uint16_t val)
+        uint16_t reg, uint16_t val)
{
writew(val, glamo->base + reg);
}
@@ -119,7 +119,7 @@ EXPORT_SYMBOL_GPL(glamo_reg_write);


static inline uint16_t __reg_read(struct glamo_core *glamo,
- uint16_t reg)
+   uint16_t reg)
{
return readw(glamo->base + reg);
}
@@ -136,8 +136,8 @@ uint16_t glamo_reg_read(struct glamo_core *glamo,
uint16_t reg)
EXPORT_SYMBOL_GPL(glamo_reg_read);

static void __reg_set_bit_mask(struct glamo_core *glamo,
- uint16_t reg, uint16_t mask,
- uint16_t val)
+        uint16_t reg, uint16_t mask,
+        uint16_t val)
{
uint16_t tmp;

@@ -150,8 +150,8 @@ static void __reg_set_bit_mask(struct glamo_core
*glamo,
}

static void reg_set_bit_mask(struct glamo_core *glamo,
- uint16_t reg, uint16_t mask,
- uint16_t val)
+      uint16_t reg, uint16_t mask,
+      uint16_t val)
{
spin_lock(&glamo->lock);
__reg_set_bit_mask(glamo, reg, mask, val);
@@ -168,7 +168,7 @@ static inline void __reg_set_bit(struct glamo_core
*glamo,
}

static inline void __reg_clear_bit(struct glamo_core *glamo,
- uint16_t reg, uint16_t bit)
+    uint16_t reg, uint16_t bit)
{
uint16_t tmp;
tmp = __reg_read(glamo, reg);
@@ -177,7 +177,7 @@ static inline void __reg_clear_bit(struct glamo_core
*glamo,
}

static void __reg_write_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
+       uint16_t count, uint16_t *values)
{
uint16_t end;
for (end = reg + count * 2; reg < end; reg += 2, ++values)
@@ -185,7 +185,7 @@ static void __reg_write_batch(struct glamo_core
*glamo, uint16_t reg,
}

static void __reg_read_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
+      uint16_t count, uint16_t *values)
{
uint16_t end;
for (end = reg + count * 2; reg < end; reg += 2, ++values)
@@ -193,7 +193,7 @@ static void __reg_read_batch(struct glamo_core
*glamo, uint16_t reg,
}

void glamo_reg_write_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
+    uint16_t count, uint16_t *values)
{
spin_lock(&glamo->lock);
__reg_write_batch(glamo, reg, count, values);
@@ -202,7 +202,7 @@ void glamo_reg_write_batch(struct glamo_core *glamo,
uint16_t reg,
EXPORT_SYMBOL(glamo_reg_write_batch);

void glamo_reg_read_batch(struct glamo_core *glamo, uint16_t reg,
- uint16_t count, uint16_t *values)
+   uint16_t count, uint16_t *values)
{
spin_lock(&glamo->lock);
__reg_read_batch(glamo, reg, count, values);
@@ -330,7 +330,7 @@ static void glamo_irq_demux_handler(unsigned int
irq, struct irq_desc *desc)
int i;

if (unlikely((desc->status &
- (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
+      (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
(IRQ_PENDING | IRQ_MASKED))) {
/* dealing with pending IRQ, unmasking */
desc->chip->unmask(irq);
@@ -356,7 +356,7 @@ sysfs
*/

static ssize_t regs_write(struct device *dev, struct device_attribute
*attr,
- const char *buf, size_t count)
+   const char *buf, size_t count)
{
struct glamo_core *glamo = dev_get_drvdata(dev);
unsigned int reg;
@@ -364,7 +364,7 @@ static ssize_t regs_write(struct device *dev, struct
device_attribute *attr,

sscanf(buf, "%u %u", &reg, &val);
printk(KERN_INFO"reg 0x%02x <-- 0x%04x\n",
- reg, val);
+        reg, val);

glamo_reg_write(glamo, reg, val);

@@ -372,7 +372,7 @@ static ssize_t regs_write(struct device *dev, struct
device_attribute *attr,
}

static ssize_t regs_read(struct device *dev, struct device_attribute
*attr,
- char *buf)
+ char *buf)
{
struct glamo_core *glamo = dev_get_drvdata(dev);
int i, n;
@@ -562,6 +562,7 @@ int __glamo_engine_disable(struct glamo_core *glamo,
enum glamo_engine engine)

return 0;
}
+
int glamo_engine_disable(struct glamo_core *glamo, enum glamo_engine
engine)
{
int ret = 0;
@@ -995,7 +996,6 @@ static int __devinit glamo_probe(struct
platform_device *pdev)
set_irq_type(glamo->irq, IRQ_TYPE_EDGE_FALLING);
set_irq_data(glamo->irq, glamo);
set_irq_chained_handler(glamo->irq, glamo_irq_demux_handler);
- glamo->irq_works = 1;

ret = mfd_add_devices(&pdev->dev, pdev->id, glamo_cells,
ARRAY_SIZE(glamo_cells), mem, glamo->irq_base);
diff --git a/drivers/mfd/glamo/glamo-core.h
b/drivers/mfd/glamo/glamo-core.h
index 17017b0..34ec7c4 100644
--- a/drivers/mfd/glamo/glamo-core.h
+++ b/drivers/mfd/glamo/glamo-core.h
@@ -17,20 +17,19 @@
#define GLAMO_FB_SIZE (GLAMO_INTERNAL_RAM_SIZE - GLAMO_MMC_BUFFER_SIZE)

enum glamo_pll {
-    GLAMO_PLL1,
-    GLAMO_PLL2,
+ GLAMO_PLL1,
+ GLAMO_PLL2,
};

enum glamo_engine_state {
-    GLAMO_ENGINE_DISABLED,
-    GLAMO_ENGINE_SUSPENDED,
-    GLAMO_ENGINE_ENABLED,
+ GLAMO_ENGINE_DISABLED,
+ GLAMO_ENGINE_SUSPENDED,
+ GLAMO_ENGINE_ENABLED,
};

struct glamo_core {
int irq;
int irq_base;
- int irq_works; /* 0 means PCB does not support Glamo IRQ */
struct resource *mem;
void __iomem *base;
struct platform_device *pdev;
diff --git a/drivers/mfd/glamo/glamo-fb.c b/drivers/mfd/glamo/glamo-fb.c
index cffb180..d7cd776 100644
--- a/drivers/mfd/glamo/glamo-fb.c
+++ b/drivers/mfd/glamo/glamo-fb.c
@@ -93,7 +93,7 @@ static void glamo_output_disable(struct glamofb_handle
*gfb)


static int reg_read(struct glamofb_handle *glamo,
-    u_int16_t reg)
+     u_int16_t reg)
{
int i = 0;

@@ -104,7 +104,7 @@ static int reg_read(struct glamofb_handle *glamo,
}

static void reg_write(struct glamofb_handle *glamo,
- uint16_t reg, uint16_t val)
+       uint16_t reg, uint16_t val)
{
int i = 0;

@@ -142,7 +142,7 @@ static struct glamo_script glamo_regs[] = {
};

static int glamofb_run_script(struct glamofb_handle *glamo,
- struct glamo_script *script, int len)
+       struct glamo_script *script, int len)
{
int i;

@@ -161,7 +161,7 @@ static int glamofb_run_script(struct glamofb_handle
*glamo,
}

static int glamofb_check_var(struct fb_var_screeninfo *var,
- struct fb_info *info)
+      struct fb_info *info)
{
struct glamofb_handle *glamo = info->par;

@@ -219,8 +219,8 @@ static int glamofb_check_var(struct
fb_var_screeninfo *var,
}

static void reg_set_bit_mask(struct glamofb_handle *glamo,
- uint16_t reg, uint16_t mask,
- uint16_t val)
+      uint16_t reg, uint16_t mask,
+      uint16_t val)
{
u_int16_t tmp;

@@ -663,7 +663,7 @@ int glamofb_cmd_mode(struct glamofb_handle *gfb, int
on)
dev_dbg(gfb->dev, "waiting for lcd idle: ");
timeout = 2000000;
while (!(reg_read(gfb, GLAMO_REG_LCD_STATUS2) & (1 << 12)) &&
-       (timeout--))
+        (timeout--))
cpu_relax();
if (timeout < 0) {
printk(KERN_ERR"*************"
@@ -786,16 +786,16 @@ static int __init glamofb_probe(struct
platform_device *pdev)
}

glamofb->reg = request_mem_region(glamofb->reg->start,
-       resource_size(glamofb->reg),
-       pdev->name);
+   resource_size(glamofb->reg),
+   pdev->name);
if (!glamofb->reg) {
dev_err(&pdev->dev, "failed to request mmio region\n");
goto out_free;
}

glamofb->fb_res = request_mem_region(glamofb->fb_res->start,
- resource_size(glamofb->fb_res),
- pdev->name);
+      resource_size(glamofb->fb_res),
+      pdev->name);
if (!glamofb->fb_res) {
dev_err(&pdev->dev, "failed to request vram region\n");
goto out_release_reg;
@@ -814,7 +814,7 @@ static int __init glamofb_probe(struct
platform_device *pdev)
fbinfo->fix.smem_len = (__u32) resource_size(glamofb->fb_res);

fbinfo->screen_base = ioremap(glamofb->fb_res->start,
-    resource_size(glamofb->fb_res));
+       resource_size(glamofb->fb_res));
if (!fbinfo->screen_base) {
dev_err(&pdev->dev, "failed to ioremap() vram memory\n");
goto out_release_fb;
diff --git a/drivers/mfd/glamo/glamo-gpio.c
b/drivers/mfd/glamo/glamo-gpio.c
index 30ee6ed..fb6f876 100644
--- a/drivers/mfd/glamo/glamo-gpio.c
+++ b/drivers/mfd/glamo/glamo-gpio.c
@@ -111,7 +111,7 @@ static void glamo_gpio_free(struct gpio_chip *chip,
unsigned offset)
}

static int glamo_gpio_direction_output(struct gpio_chip *chip, unsigned
offset,
- int value)
+        int value)
{
struct glamo_core *glamo = chip_to_glamo(chip);
unsigned int reg = REG_OF_GPIO(offset);
@@ -119,7 +119,7 @@ static int glamo_gpio_direction_output(struct
gpio_chip *chip, unsigned offset,

spin_lock(&glamo->lock);
tmp = readw(glamo->base + reg);
-    tmp &= ~DIRECTION_BIT(offset);
+ tmp &= ~DIRECTION_BIT(offset);

if (value)
tmp |= OUTPUT_BIT(offset);
@@ -153,14 +153,14 @@ static const struct __devinit gpio_chip
glamo_gpio_chip = {
.label = "glamo",
.request = glamo_gpio_request,
.free = glamo_gpio_free,
- .direction_input = glamo_gpio_direction_input,
+ .direction_input = glamo_gpio_direction_input,
.get = glamo_gpio_get,
- .direction_output = glamo_gpio_direction_output,
+ .direction_output = glamo_gpio_direction_output,
.set = glamo_gpio_set,
.base = -1,
.ngpio = GLAMO_NR_GPIO,
.can_sleep = 0,
- .owner             = THIS_MODULE,
+ .owner = THIS_MODULE,
};

static int __devinit glamo_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/mfd/glamo/glamo-mci.c
b/drivers/mfd/glamo/glamo-mci.c
index 3b0b948..5fa19d8 100644
--- a/drivers/mfd/glamo/glamo-mci.c
+++ b/drivers/mfd/glamo/glamo-mci.c
@@ -115,20 +115,20 @@ module_param(sd_post_power_clock, int, 0644);


static inline void glamo_reg_write(struct glamo_mci_host *glamo,
- uint16_t reg, uint16_t val)
+    uint16_t reg, uint16_t val)
{
writew(val, glamo->mmio_base + reg);
}

static inline uint16_t glamo_reg_read(struct glamo_mci_host *glamo,
-    uint16_t reg)
+       uint16_t reg)
{
return readw(glamo->mmio_base + reg);
}

static void glamo_reg_set_bit_mask(struct glamo_mci_host *glamo,
- uint16_t reg, uint16_t mask,
- uint16_t val)
+    uint16_t reg, uint16_t mask,
+    uint16_t val)
{
uint16_t tmp;

@@ -158,14 +158,14 @@ static void glamo_mci_reset(struct glamo_mci_host
*host)

static void glamo_mci_clock_disable(struct glamo_mci_host *host)
{
-    glamo_engine_suspend(host->core, GLAMO_ENGINE_MMC);
+ glamo_engine_suspend(host->core, GLAMO_ENGINE_MMC);
}

static void glamo_mci_clock_enable(struct glamo_mci_host *host)
{
del_timer_sync(&host->disable_timer);

-    glamo_engine_enable(host->core, GLAMO_ENGINE_MMC);
+ glamo_engine_enable(host->core, GLAMO_ENGINE_MMC);
}

static void glamo_mci_disable_timer(unsigned long data)
@@ -249,7 +249,7 @@ static int glamo_mci_wait_idle(struct glamo_mci_host
*host,
}

static void glamo_mci_request_done(struct glamo_mci_host *host, struct
-mmc_request *mrq)
+ mmc_request *mrq)
{
mod_timer(&host->disable_timer, jiffies + HZ / 16);
mmc_request_done(host->mmc, mrq);
@@ -309,7 +309,7 @@ done:
static void glamo_mci_read_worker(struct work_struct *work)
{
struct glamo_mci_host *host = container_of(work, struct glamo_mci_host,
- read_work);
+    read_work);
struct mmc_command *cmd;
uint16_t status;
uint16_t blocks_ready;
@@ -331,7 +331,7 @@ static void glamo_mci_read_worker(struct work_struct
*work)
cmd->error = -EILSEQ;
if (cmd->error) {
dev_info(&host->pdev->dev, "Error after cmd: 0x%x\n",
- status);
+ status);
goto done;
}

@@ -380,7 +380,7 @@ static void glamo_mci_send_command(struct
glamo_mci_host *host,

/* if we can't do it, reject as busy */
if (!(glamo_reg_read(host, GLAMO_REG_MMC_RB_STAT1) &
- GLAMO_STAT1_MMC_IDLE)) {
+     GLAMO_STAT1_MMC_IDLE)) {
cmd->error = -EBUSY;
return;
}
@@ -556,7 +556,6 @@ static void glamo_mci_send_command(struct
glamo_mci_host *host,
if (cmd->data && (cmd->data->flags & MMC_DATA_READ))
schedule_work(&host->read_work);
#endif
-
}

static int glamo_mci_prepare_pio(struct glamo_mci_host *host,
@@ -577,45 +576,8 @@ static int glamo_mci_prepare_pio(struct
glamo_mci_host *host,
return 0;
}

-static int glamo_mci_irq_poll(struct glamo_mci_host *host,
- struct mmc_command *cmd)
-{
- int timeout = 1000000;
- uint16_t status;
- /*
- * if the glamo INT# line isn't wired (*cough* it can happen)
- * I'm afraid we have to spin on the IRQ status bit and "be
- * our own INT# line"
- */
- /*
- * we have faith we will get an "interrupt"...
- * but something insane like suspend problems can mean
- * we spin here forever, so we timeout after a LONG time
- */
- do {
- status = glamo_reg_read(host, GLAMO_REG_IRQ_STATUS);
- } while ((--timeout) && !(status & GLAMO_IRQ_MMC));
-
- if (timeout <= 0) {
- if (cmd->data->error)
- cmd->data->error = -ETIMEDOUT;
- dev_err(&host->pdev->dev, "Payload timeout\n");
- return -ETIMEDOUT;
- }
- /* ack this interrupt source */
- writew(GLAMO_IRQ_MMC, host->core->base +
-    GLAMO_REG_IRQ_CLEAR);
-
- /* yay we are an interrupt controller! -- call the ISR
- * it will stop clock to card
- */
- glamo_mci_irq(host->irq, host);
-
- return 0;
-}
-
static void glamo_mci_send_request(struct mmc_host *mmc,
- struct mmc_request *mrq)
+    struct mmc_request *mrq)
{
struct glamo_mci_host *host = mmc_priv(mmc);
struct mmc_command *cmd = mrq->cmd;
@@ -643,12 +605,6 @@ static void glamo_mci_send_request(struct mmc_host
*mmc,
if (!cmd->data || cmd->error)
goto done;

-
- if (!host->core->irq_works) {
- if (glamo_mci_irq_poll(host, mrq->cmd))
- goto done;
- }
-
/*
* Otherwise can can use the interrupt as async completion --
* if there is read data coming, or we wait for write data to complete,
@@ -664,7 +620,7 @@ done:
}

static void glamo_mci_set_power_mode(struct glamo_mci_host *host,
- unsigned char power_mode)
+      unsigned char power_mode)
{
int ret;

@@ -719,7 +675,7 @@ static void glamo_mci_set_ios(struct mmc_host *mmc,
struct mmc_ios *ios)
rate = glamo_mci_set_card_clock(host, ios->clock);

if ((ios->power_mode == MMC_POWER_ON) ||
- (ios->power_mode == MMC_POWER_UP)) {
+     (ios->power_mode == MMC_POWER_UP)) {
dev_info(&host->pdev->dev,
"powered (vdd = %hu) clk: %dkHz div=%hu (req: %ukHz). "
"Bus width=%d\n", ios->vdd,
@@ -837,7 +793,7 @@ static int glamo_mci_probe(struct platform_device
*pdev)
goto probe_iounmap_mmio;
}
host->data_base = ioremap(host->data_mem->start,
-       resource_size(host->data_mem));
+   resource_size(host->data_mem));

if (host->data_base == 0) {
dev_err(&pdev->dev, "failed to ioremap() io memory region.\n");
@@ -846,7 +802,7 @@ static int glamo_mci_probe(struct platform_device
*pdev)
}

ret = request_threaded_irq(host->irq, NULL, glamo_mci_irq, IRQF_SHARED,
-    pdev->name, host);
+    pdev->name, host);
if (ret) {
dev_err(&pdev->dev, "failed to register irq.\n");
goto probe_iounmap_data;
@@ -927,9 +883,9 @@ static int glamo_mci_remove(struct platform_device
*pdev)
iounmap(host->mmio_base);
iounmap(host->data_base);
release_mem_region(host->mmio_mem->start,
- resource_size(host->mmio_mem));
+    resource_size(host->mmio_mem));
release_mem_region(host->data_mem->start,
- resource_size(host->data_mem));
+    resource_size(host->data_mem));

regulator_put(host->regulator);

@@ -964,7 +920,7 @@ static int glamo_mci_resume(struct device *dev)

glamo_mci_reset(host);
glamo_engine_enable(host->core, GLAMO_ENGINE_MMC);
-    mdelay(10);
+ mdelay(10);

ret = mmc_resume_host(host->mmc);

@@ -976,8 +932,8 @@ static int glamo_mci_resume(struct device *dev)
static struct dev_pm_ops glamo_mci_pm_ops = {
.suspend    = glamo_mci_suspend,
.resume     = glamo_mci_resume,
-    .freeze     = glamo_mci_suspend,
-    .thaw       = glamo_mci_resume,
+ .freeze     = glamo_mci_suspend,
+ .thaw       = glamo_mci_resume,
};
#define GLAMO_MCI_PM_OPS (&glamo_mci_pm_ops)

-- 
1.7.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Ceci est une partie de message
 =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url : http://lists.openmoko.org/pipermail/openmoko-kernel/attachments/20100609/fe622fbf/attachment.pgp 


More information about the openmoko-kernel mailing list