diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-03-09 10:00:27 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-03-09 10:00:27 -0500 |
commit | 70aba44b6cade8dc63261c4f97d5e83b0c02d07a (patch) | |
tree | 8d6682d63567b7dc06d998aaea33a4f358b5f14a | |
parent | 7b1e5dc86c0030314f8f6e828177a6c5bb7b9006 (diff) |
Revert "gpio: lp3943: Drop pin_used and lp3943_gpio_request/lp3943_gpio_free"
This reverts commit 3fab91ea284a3b795327dda915a3c150a49e4be2.
-rw-r--r-- | drivers/gpio/gpio-lp3943.c | 22 | ||||
-rw-r--r-- | include/linux/mfd/lp3943.h | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-lp3943.c b/drivers/gpio/gpio-lp3943.c index fdec94b0cfb0..6dc6725403ec 100644 --- a/drivers/gpio/gpio-lp3943.c +++ b/drivers/gpio/gpio-lp3943.c | |||
@@ -45,6 +45,26 @@ struct lp3943_gpio { | |||
45 | u16 input_mask; /* 1 = GPIO is input direction, 0 = output */ | 45 | u16 input_mask; /* 1 = GPIO is input direction, 0 = output */ |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
49 | { | ||
50 | struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); | ||
51 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
52 | |||
53 | /* Return an error if the pin is already assigned */ | ||
54 | if (test_and_set_bit(offset, &lp3943->pin_used)) | ||
55 | return -EBUSY; | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static void lp3943_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
61 | { | ||
62 | struct lp3943_gpio *lp3943_gpio = gpiochip_get_data(chip); | ||
63 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
64 | |||
65 | clear_bit(offset, &lp3943->pin_used); | ||
66 | } | ||
67 | |||
48 | static int lp3943_gpio_set_mode(struct lp3943_gpio *lp3943_gpio, u8 offset, | 68 | static int lp3943_gpio_set_mode(struct lp3943_gpio *lp3943_gpio, u8 offset, |
49 | u8 val) | 69 | u8 val) |
50 | { | 70 | { |
@@ -157,6 +177,8 @@ static int lp3943_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | |||
157 | static const struct gpio_chip lp3943_gpio_chip = { | 177 | static const struct gpio_chip lp3943_gpio_chip = { |
158 | .label = "lp3943", | 178 | .label = "lp3943", |
159 | .owner = THIS_MODULE, | 179 | .owner = THIS_MODULE, |
180 | .request = lp3943_gpio_request, | ||
181 | .free = lp3943_gpio_free, | ||
160 | .direction_input = lp3943_gpio_direction_input, | 182 | .direction_input = lp3943_gpio_direction_input, |
161 | .get = lp3943_gpio_get, | 183 | .get = lp3943_gpio_get, |
162 | .direction_output = lp3943_gpio_direction_output, | 184 | .direction_output = lp3943_gpio_direction_output, |
diff --git a/include/linux/mfd/lp3943.h b/include/linux/mfd/lp3943.h index d3a738118b27..3490db782988 100644 --- a/include/linux/mfd/lp3943.h +++ b/include/linux/mfd/lp3943.h | |||
@@ -94,12 +94,18 @@ struct lp3943_reg_cfg { | |||
94 | * @regmap: Used for I2C communication on accessing registers | 94 | * @regmap: Used for I2C communication on accessing registers |
95 | * @pdata: LP3943 platform specific data | 95 | * @pdata: LP3943 platform specific data |
96 | * @mux_cfg: Register configuration for pin MUX | 96 | * @mux_cfg: Register configuration for pin MUX |
97 | * @pin_used: Bit mask for output pin used. | ||
98 | * This bitmask is used for pin assignment management. | ||
99 | * 1 = pin used, 0 = available. | ||
100 | * Only LSB 16 bits are used, but it is unsigned long type | ||
101 | * for atomic bitwise operations. | ||
97 | */ | 102 | */ |
98 | struct lp3943 { | 103 | struct lp3943 { |
99 | struct device *dev; | 104 | struct device *dev; |
100 | struct regmap *regmap; | 105 | struct regmap *regmap; |
101 | struct lp3943_platform_data *pdata; | 106 | struct lp3943_platform_data *pdata; |
102 | const struct lp3943_reg_cfg *mux_cfg; | 107 | const struct lp3943_reg_cfg *mux_cfg; |
108 | unsigned long pin_used; | ||
103 | }; | 109 | }; |
104 | 110 | ||
105 | int lp3943_read_byte(struct lp3943 *lp3943, u8 reg, u8 *read); | 111 | int lp3943_read_byte(struct lp3943 *lp3943, u8 reg, u8 *read); |