kasan: enable instrumentation of global variables
[linux-2.6/btrfs-unstable.git] / drivers / gpio / gpio-ucb1400.c
blobd502825159b9b4925e4e129f02fd5a7da7f3bc96
1 /*
2 * Philips UCB1400 GPIO driver
4 * Author: Marek Vasut <marek.vasut@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include <linux/module.h>
13 #include <linux/ucb1400.h>
15 static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off)
17 struct ucb1400_gpio *gpio;
18 gpio = container_of(gc, struct ucb1400_gpio, gc);
19 ucb1400_gpio_set_direction(gpio->ac97, off, 0);
20 return 0;
23 static int ucb1400_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val)
25 struct ucb1400_gpio *gpio;
26 gpio = container_of(gc, struct ucb1400_gpio, gc);
27 ucb1400_gpio_set_direction(gpio->ac97, off, 1);
28 ucb1400_gpio_set_value(gpio->ac97, off, val);
29 return 0;
32 static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off)
34 struct ucb1400_gpio *gpio;
35 gpio = container_of(gc, struct ucb1400_gpio, gc);
36 return ucb1400_gpio_get_value(gpio->ac97, off);
39 static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val)
41 struct ucb1400_gpio *gpio;
42 gpio = container_of(gc, struct ucb1400_gpio, gc);
43 ucb1400_gpio_set_value(gpio->ac97, off, val);
46 static int ucb1400_gpio_probe(struct platform_device *dev)
48 struct ucb1400_gpio *ucb = dev_get_platdata(&dev->dev);
49 int err = 0;
51 if (!(ucb && ucb->gpio_offset)) {
52 err = -EINVAL;
53 goto err;
56 platform_set_drvdata(dev, ucb);
58 ucb->gc.label = "ucb1400_gpio";
59 ucb->gc.base = ucb->gpio_offset;
60 ucb->gc.ngpio = 10;
61 ucb->gc.owner = THIS_MODULE;
63 ucb->gc.direction_input = ucb1400_gpio_dir_in;
64 ucb->gc.direction_output = ucb1400_gpio_dir_out;
65 ucb->gc.get = ucb1400_gpio_get;
66 ucb->gc.set = ucb1400_gpio_set;
67 ucb->gc.can_sleep = true;
69 err = gpiochip_add(&ucb->gc);
70 if (err)
71 goto err;
73 if (ucb->gpio_setup)
74 err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio);
76 err:
77 return err;
81 static int ucb1400_gpio_remove(struct platform_device *dev)
83 int err = 0;
84 struct ucb1400_gpio *ucb = platform_get_drvdata(dev);
86 if (ucb && ucb->gpio_teardown) {
87 err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio);
88 if (err)
89 return err;
92 gpiochip_remove(&ucb->gc);
93 return err;
96 static struct platform_driver ucb1400_gpio_driver = {
97 .probe = ucb1400_gpio_probe,
98 .remove = ucb1400_gpio_remove,
99 .driver = {
100 .name = "ucb1400_gpio"
104 module_platform_driver(ucb1400_gpio_driver);
106 MODULE_DESCRIPTION("Philips UCB1400 GPIO driver");
107 MODULE_LICENSE("GPL");
108 MODULE_ALIAS("platform:ucb1400_gpio");