From patchwork Tue Dec 28 17:36:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 437041 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBSHaA4a015190 for ; Tue, 28 Dec 2010 17:36:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754212Ab0L1RgJ (ORCPT ); Tue, 28 Dec 2010 12:36:09 -0500 Received: from na3sys009aog110.obsmtp.com ([74.125.149.203]:56585 "EHLO na3sys009aog110.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753447Ab0L1RgI (ORCPT ); Tue, 28 Dec 2010 12:36:08 -0500 Received: from source ([209.85.215.48]) by na3sys009aob110.postini.com ([74.125.148.12]) with SMTP ID DSNKTRogB3Wl5DtYRruWemOAF9/F0xo3ooBl@postini.com; Tue, 28 Dec 2010 09:36:08 PST Received: by mail-ew0-f48.google.com with SMTP id 20so2052425ewy.7 for ; Tue, 28 Dec 2010 09:36:07 -0800 (PST) Received: by 10.213.4.209 with SMTP id 17mr1678201ebs.4.1293557767072; Tue, 28 Dec 2010 09:36:07 -0800 (PST) Received: from localhost (cs181221087.pp.htv.fi [82.181.221.87]) by mx.google.com with ESMTPS id b52sm9872061eei.13.2010.12.28.09.36.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 28 Dec 2010 09:36:06 -0800 (PST) Date: Tue, 28 Dec 2010 19:36:04 +0200 From: Felipe Balbi To: Felipe Balbi Cc: Linux Kernel Mailing List , Linux OMAP Mailing List , Tony Lindgren , David Brownell , Thomas Gleixner , Mark Brown Subject: Re: [RFC/PATCH 0/3] TWL4030 IRQ Changes Message-ID: <20101228173604.GH2239@legolas.emea.dhcp.ti.com> Reply-To: balbi@ti.com References: <20101228161657.GF2239@legolas.emea.dhcp.ti.com> <1293556459-28613-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1293556459-28613-1-git-send-email-balbi@ti.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 28 Dec 2010 17:36:11 +0000 (UTC) diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index ff7bb93..ad6197c 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c @@ -447,10 +447,14 @@ struct sih_agent { /*----------------------------------------------------------------------*/ -static void twl4030_sih_mask(unsigned irq) +/* REVISIT define it here until IRQ Subsystem exports its implementation */ +#define irq_data_to_desc(data) container_of(data, struct irq_desc, irq_data) + +static void twl4030_sih_mask(struct irq_data *data) { - struct sih_agent *agent = get_irq_chip_data(irq); - const struct sih *sih = agent->sih; + struct irq_desc *d = irq_data_to_desc(data); + struct sih_agent *agent; + const struct sih *sih; union { u8 bytes[4]; @@ -458,7 +462,13 @@ static void twl4030_sih_mask(unsigned irq) } imr; int status; + int irq = data->irq; + if (!d) + return; + + agent = d->chip_data; + sih = agent->sih; agent->imr |= BIT(irq - agent->irq_base); /* byte[0] gets overwritten as we write ... */ @@ -472,10 +482,11 @@ static void twl4030_sih_mask(unsigned irq) "write", status); } -static void twl4030_sih_unmask(unsigned irq) +static void twl4030_sih_unmask(struct irq_data *data) { - struct sih_agent *agent = get_irq_chip_data(irq); - const struct sih *sih = agent->sih; + struct irq_desc *d = irq_data_to_desc(data); + struct sih_agent *agent; + const struct sih *sih; union { u8 bytes[4]; @@ -483,7 +494,13 @@ static void twl4030_sih_unmask(unsigned irq) } imr; int status; + int irq = data->irq; + + if (!d) + return; + agent = d->chip_data; + sih = agent->sih; agent->imr &= ~BIT(irq - agent->irq_base); /* byte[0] gets overwritten as we write ... */ @@ -497,14 +514,15 @@ static void twl4030_sih_unmask(unsigned irq) "write", status); } -static int twl4030_sih_set_type(unsigned irq, unsigned trigger) +static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger) { - struct sih_agent *agent = get_irq_chip_data(irq); - const struct sih *sih = agent->sih; - struct irq_desc *desc = irq_to_desc(irq); + struct irq_desc *d = irq_data_to_desc(data); + struct sih_agent *agent; + const struct sih *sih; int status = 0; + int irq = data->irq; - if (!desc) { + if (!d) { pr_err("twl4030: Invalid IRQ: %d\n", irq); return -EINVAL; } @@ -512,12 +530,15 @@ static int twl4030_sih_set_type(unsigned irq, unsigned trigger) if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) return -EINVAL; - if ((desc->status & IRQ_TYPE_SENSE_MASK) != trigger) { + agent = d->chip_data; + sih = agent->sih; + + if ((d->status & IRQ_TYPE_SENSE_MASK) != trigger) { u8 bytes[6]; u32 edge_change; - desc->status &= ~IRQ_TYPE_SENSE_MASK; - desc->status |= trigger; + d->status &= ~IRQ_TYPE_SENSE_MASK; + d->status |= trigger; agent->edge_change |= BIT(irq - agent->irq_base); edge_change = agent->edge_change; @@ -537,7 +558,6 @@ static int twl4030_sih_set_type(unsigned irq, unsigned trigger) /* Modify only the bits we know must change */ while (edge_change) { int i = fls(edge_change) - 1; - struct irq_desc *d = irq_to_desc(i + agent->irq_base); int byte = 1 + (i >> 2); int off = (i & 0x3) * 2; @@ -570,27 +590,43 @@ static int twl4030_sih_set_type(unsigned irq, unsigned trigger) return status; } -static void twl4030_sih_bus_lock(unsigned int irq) +static void twl4030_sih_bus_lock(struct irq_data *data) { - struct sih_agent *agent = get_irq_chip_data(irq); + struct irq_desc *d = irq_data_to_desc(data); + struct sih_agent *agent; + int irq = data->irq; + + if (!d) { + pr_err("twl4030: Invalid IRQ: %d\n", irq); + return; + } + agent = d->chip_data; mutex_lock(&agent->irq_lock); } -static void twl4030_sih_bus_sync_unlock(unsigned int irq) +static void twl4030_sih_bus_sync_unlock(struct irq_data *data) { - struct sih_agent *agent = get_irq_chip_data(irq); + struct irq_desc *d = irq_data_to_desc(data); + struct sih_agent *agent; + int irq = data->irq; + + if (!d) { + pr_err("twl4030: Invalid IRQ: %d\n", irq); + return; + } + agent = d->chip_data; mutex_unlock(&agent->irq_lock); } static struct irq_chip twl4030_sih_irq_chip = { - .name = "twl4030", - .mask = twl4030_sih_mask, - .unmask = twl4030_sih_unmask, - .set_type = twl4030_sih_set_type, - .bus_lock = twl4030_sih_bus_lock, - .bus_sync_unlock = twl4030_sih_bus_sync_unlock, + .name = "twl4030", + .irq_mask = twl4030_sih_mask, + .irq_unmask = twl4030_sih_unmask, + .irq_set_type = twl4030_sih_set_type, + .irq_bus_lock = twl4030_sih_bus_lock, + .irq_bus_sync_unlock = twl4030_sih_bus_sync_unlock, }; /*----------------------------------------------------------------------*/