aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl4030-irq.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-06-30 05:51:07 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2011-10-24 08:09:11 -0400
commit848684246fc180a9b96f1b373a1ad70bc3ee725f (patch)
treecc4cfa4147a85b22ede217af9d60c419958af4d1 /drivers/mfd/twl4030-irq.c
parent7750c9b0d24c78c1f6b10d9ce0508945f250e5b2 (diff)
mfd: Drop twl4030-irq's mask_work
... we can do the synchronization with the hardware when calling bus_sync_unlock as we're supposed to. While at that, also make variable names uniform on all functions. Signed-off-by: Felipe Balbi <balbi@ti.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/twl4030-irq.c')
-rw-r--r--drivers/mfd/twl4030-irq.c82
1 files changed, 34 insertions, 48 deletions
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index e1e0944af2e6..bf62389fc7e5 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -430,7 +430,6 @@ struct sih_agent {
430 430
431 u32 imr; 431 u32 imr;
432 bool imr_change_pending; 432 bool imr_change_pending;
433 struct work_struct mask_work;
434 433
435 u32 edge_change; 434 u32 edge_change;
436 struct work_struct edge_work; 435 struct work_struct edge_work;
@@ -438,37 +437,6 @@ struct sih_agent {
438 struct mutex irq_lock; 437 struct mutex irq_lock;
439}; 438};
440 439
441static void twl4030_sih_do_mask(struct work_struct *work)
442{
443 struct sih_agent *agent;
444 const struct sih *sih;
445 union {
446 u8 bytes[4];
447 u32 word;
448 } imr;
449 int status;
450
451 agent = container_of(work, struct sih_agent, mask_work);
452
453 /* see what work we have */
454 if (agent->imr_change_pending) {
455 sih = agent->sih;
456 /* byte[0] gets overwritten as we write ... */
457 imr.word = cpu_to_le32(agent->imr << 8);
458 agent->imr_change_pending = false;
459 } else
460 sih = NULL;
461 if (!sih)
462 return;
463
464 /* write the whole mask ... simpler than subsetting it */
465 status = twl_i2c_write(sih->module, imr.bytes,
466 sih->mask[irq_line].imr_offset, sih->bytes_ixr);
467 if (status)
468 pr_err("twl4030: %s, %s --> %d\n", __func__,
469 "write", status);
470}
471
472static void twl4030_sih_do_edge(struct work_struct *work) 440static void twl4030_sih_do_edge(struct work_struct *work)
473{ 441{
474 struct sih_agent *agent; 442 struct sih_agent *agent;
@@ -537,32 +505,30 @@ static void twl4030_sih_do_edge(struct work_struct *work)
537 505
538static void twl4030_sih_mask(struct irq_data *data) 506static void twl4030_sih_mask(struct irq_data *data)
539{ 507{
540 struct sih_agent *sih = irq_data_get_irq_chip_data(data); 508 struct sih_agent *agent = irq_data_get_irq_chip_data(data);
541 509
542 sih->imr |= BIT(data->irq - sih->irq_base); 510 agent->imr |= BIT(data->irq - agent->irq_base);
543 sih->imr_change_pending = true; 511 agent->imr_change_pending = true;
544 queue_work(wq, &sih->mask_work);
545} 512}
546 513
547static void twl4030_sih_unmask(struct irq_data *data) 514static void twl4030_sih_unmask(struct irq_data *data)
548{ 515{
549 struct sih_agent *sih = irq_data_get_irq_chip_data(data); 516 struct sih_agent *agent = irq_data_get_irq_chip_data(data);
550 517
551 sih->imr &= ~BIT(data->irq - sih->irq_base); 518 agent->imr &= ~BIT(data->irq - agent->irq_base);
552 sih->imr_change_pending = true; 519 agent->imr_change_pending = true;
553 queue_work(wq, &sih->mask_work);
554} 520}
555 521
556static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger) 522static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger)
557{ 523{
558 struct sih_agent *sih = irq_data_get_irq_chip_data(data); 524 struct sih_agent *agent = irq_data_get_irq_chip_data(data);
559 525
560 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) 526 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
561 return -EINVAL; 527 return -EINVAL;
562 528
563 if (irqd_get_trigger_type(data) != trigger) { 529 if (irqd_get_trigger_type(data) != trigger) {
564 sih->edge_change |= BIT(data->irq - sih->irq_base); 530 agent->edge_change |= BIT(data->irq - agent->irq_base);
565 queue_work(wq, &sih->edge_work); 531 queue_work(wq, &agent->edge_work);
566 } 532 }
567 533
568 return 0; 534 return 0;
@@ -570,16 +536,37 @@ static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger)
570 536
571static void twl4030_sih_bus_lock(struct irq_data *data) 537static void twl4030_sih_bus_lock(struct irq_data *data)
572{ 538{
573 struct sih_agent *sih = irq_data_get_irq_chip_data(data); 539 struct sih_agent *agent = irq_data_get_irq_chip_data(data);
574 540
575 mutex_lock(&sih->irq_lock); 541 mutex_lock(&agent->irq_lock);
576} 542}
577 543
578static void twl4030_sih_bus_sync_unlock(struct irq_data *data) 544static void twl4030_sih_bus_sync_unlock(struct irq_data *data)
579{ 545{
580 struct sih_agent *sih = irq_data_get_irq_chip_data(data); 546 struct sih_agent *agent = irq_data_get_irq_chip_data(data);
547 const struct sih *sih = agent->sih;
548 int status;
549
550 if (agent->imr_change_pending) {
551 union {
552 u32 word;
553 u8 bytes[4];
554 } imr;
555
556 /* byte[0] gets overwriten as we write ... */
557 imr.word = cpu_to_le32(agent->imr << 8);
558 agent->imr_change_pending = false;
559
560 /* write the whole mask ... simpler than subsetting it */
561 status = twl_i2c_write(sih->module, imr.bytes,
562 sih->mask[irq_line].imr_offset,
563 sih->bytes_ixr);
564 if (status)
565 pr_err("twl4030: %s, %s --> %d\n", __func__,
566 "write", status);
567 }
581 568
582 mutex_unlock(&sih->irq_lock); 569 mutex_unlock(&agent->irq_lock);
583} 570}
584 571
585static struct irq_chip twl4030_sih_irq_chip = { 572static struct irq_chip twl4030_sih_irq_chip = {
@@ -685,7 +672,6 @@ int twl4030_sih_setup(int module)
685 agent->sih = sih; 672 agent->sih = sih;
686 agent->imr = ~0; 673 agent->imr = ~0;
687 mutex_init(&agent->irq_lock); 674 mutex_init(&agent->irq_lock);
688 INIT_WORK(&agent->mask_work, twl4030_sih_do_mask);
689 INIT_WORK(&agent->edge_work, twl4030_sih_do_edge); 675 INIT_WORK(&agent->edge_work, twl4030_sih_do_edge);
690 676
691 for (i = 0; i < sih->bits; i++) { 677 for (i = 0; i < sih->bits; i++) {