@@ -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,
};
/*----------------------------------------------------------------------*/