~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/gpio/gpiolib.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include <linux/idr.h>
13
13
#include <linux/slab.h>
14
14
 
 
15
#define CREATE_TRACE_POINTS
 
16
#include <trace/events/gpio.h>
15
17
 
16
18
/* Optional implementation infrastructure for GPIO interfaces.
17
19
 *
1165
1167
 
1166
1168
        return chip;
1167
1169
}
 
1170
EXPORT_SYMBOL_GPL(gpiochip_find);
1168
1171
 
1169
1172
/* These "optional" allocation calls help prevent drivers from stomping
1170
1173
 * on each other, and help provide better diagnostics in debugfs.
1293
1296
 * @array:      array of the 'struct gpio'
1294
1297
 * @num:        how many GPIOs in the array
1295
1298
 */
1296
 
int gpio_request_array(struct gpio *array, size_t num)
 
1299
int gpio_request_array(const struct gpio *array, size_t num)
1297
1300
{
1298
1301
        int i, err;
1299
1302
 
1316
1319
 * @array:      array of the 'struct gpio'
1317
1320
 * @num:        how many GPIOs in the array
1318
1321
 */
1319
 
void gpio_free_array(struct gpio *array, size_t num)
 
1322
void gpio_free_array(const struct gpio *array, size_t num)
1320
1323
{
1321
1324
        while (num--)
1322
1325
                gpio_free((array++)->gpio);
1404
1407
        status = chip->direction_input(chip, gpio);
1405
1408
        if (status == 0)
1406
1409
                clear_bit(FLAG_IS_OUT, &desc->flags);
 
1410
 
 
1411
        trace_gpio_direction(chip->base + gpio, 1, status);
1407
1412
lose:
1408
1413
        return status;
1409
1414
fail:
1457
1462
        status = chip->direction_output(chip, gpio, value);
1458
1463
        if (status == 0)
1459
1464
                set_bit(FLAG_IS_OUT, &desc->flags);
 
1465
        trace_gpio_value(chip->base + gpio, 0, value);
 
1466
        trace_gpio_direction(chip->base + gpio, 0, status);
1460
1467
lose:
1461
1468
        return status;
1462
1469
fail:
1546
1553
int __gpio_get_value(unsigned gpio)
1547
1554
{
1548
1555
        struct gpio_chip        *chip;
 
1556
        int value;
1549
1557
 
1550
1558
        chip = gpio_to_chip(gpio);
1551
1559
        WARN_ON(chip->can_sleep);
1552
 
        return chip->get ? chip->get(chip, gpio - chip->base) : 0;
 
1560
        value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
 
1561
        trace_gpio_value(gpio, 1, value);
 
1562
        return value;
1553
1563
}
1554
1564
EXPORT_SYMBOL_GPL(__gpio_get_value);
1555
1565
 
1568
1578
 
1569
1579
        chip = gpio_to_chip(gpio);
1570
1580
        WARN_ON(chip->can_sleep);
 
1581
        trace_gpio_value(gpio, 0, value);
1571
1582
        chip->set(chip, gpio - chip->base, value);
1572
1583
}
1573
1584
EXPORT_SYMBOL_GPL(__gpio_set_value);
1618
1629
int gpio_get_value_cansleep(unsigned gpio)
1619
1630
{
1620
1631
        struct gpio_chip        *chip;
 
1632
        int value;
1621
1633
 
1622
1634
        might_sleep_if(extra_checks);
1623
1635
        chip = gpio_to_chip(gpio);
1624
 
        return chip->get ? chip->get(chip, gpio - chip->base) : 0;
 
1636
        value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
 
1637
        trace_gpio_value(gpio, 1, value);
 
1638
        return value;
1625
1639
}
1626
1640
EXPORT_SYMBOL_GPL(gpio_get_value_cansleep);
1627
1641
 
1631
1645
 
1632
1646
        might_sleep_if(extra_checks);
1633
1647
        chip = gpio_to_chip(gpio);
 
1648
        trace_gpio_value(gpio, 0, value);
1634
1649
        chip->set(chip, gpio - chip->base, value);
1635
1650
}
1636
1651
EXPORT_SYMBOL_GPL(gpio_set_value_cansleep);
1656
1671
                        chip->get
1657
1672
                                ? (chip->get(chip, i) ? "hi" : "lo")
1658
1673
                                : "?  ");
1659
 
 
1660
 
                if (!is_out) {
1661
 
                        int             irq = gpio_to_irq(gpio);
1662
 
                        struct irq_desc *desc = irq_to_desc(irq);
1663
 
 
1664
 
                        /* This races with request_irq(), set_irq_type(),
1665
 
                         * and set_irq_wake() ... but those are "rare".
1666
 
                         *
1667
 
                         * More significantly, trigger type flags aren't
1668
 
                         * currently maintained by genirq.
1669
 
                         */
1670
 
                        if (irq >= 0 && desc->action) {
1671
 
                                char *trigger;
1672
 
 
1673
 
                                switch (desc->status & IRQ_TYPE_SENSE_MASK) {
1674
 
                                case IRQ_TYPE_NONE:
1675
 
                                        trigger = "(default)";
1676
 
                                        break;
1677
 
                                case IRQ_TYPE_EDGE_FALLING:
1678
 
                                        trigger = "edge-falling";
1679
 
                                        break;
1680
 
                                case IRQ_TYPE_EDGE_RISING:
1681
 
                                        trigger = "edge-rising";
1682
 
                                        break;
1683
 
                                case IRQ_TYPE_EDGE_BOTH:
1684
 
                                        trigger = "edge-both";
1685
 
                                        break;
1686
 
                                case IRQ_TYPE_LEVEL_HIGH:
1687
 
                                        trigger = "level-high";
1688
 
                                        break;
1689
 
                                case IRQ_TYPE_LEVEL_LOW:
1690
 
                                        trigger = "level-low";
1691
 
                                        break;
1692
 
                                default:
1693
 
                                        trigger = "?trigger?";
1694
 
                                        break;
1695
 
                                }
1696
 
 
1697
 
                                seq_printf(s, " irq-%d %s%s",
1698
 
                                        irq, trigger,
1699
 
                                        (desc->status & IRQ_WAKEUP)
1700
 
                                                ? " wakeup" : "");
1701
 
                        }
1702
 
                }
1703
 
 
1704
1674
                seq_printf(s, "\n");
1705
1675
        }
1706
1676
}