Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: idio-16: Remove unused legacy interface

All idio-16 library consumers have migrated to the new interface
leveraging the gpio-regmap API. Legacy interface functions and code are
removed as no longer needed.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/651cff1cc3eb57b455a8048121cf6a4d4367f018.1680618405.git.william.gray@linaro.org/
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

William Breathitt Gray and committed by
Bartosz Golaszewski
98aaff7c 73d8f3ef

+1 -195
+1 -130
drivers/gpio/gpio-idio-16.c
··· 3 3 * GPIO library for the ACCES IDIO-16 family 4 4 * Copyright (C) 2022 William Breathitt Gray 5 5 */ 6 - #include <linux/bitmap.h> 6 + #include <linux/bits.h> 7 7 #include <linux/device.h> 8 8 #include <linux/err.h> 9 9 #include <linux/export.h> 10 10 #include <linux/gpio/regmap.h> 11 - #include <linux/io.h> 12 11 #include <linux/module.h> 13 12 #include <linux/regmap.h> 14 - #include <linux/spinlock.h> 15 13 #include <linux/types.h> 16 14 17 15 #include "gpio-idio-16.h" ··· 166 168 return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config)); 167 169 } 168 170 EXPORT_SYMBOL_GPL(devm_idio_16_regmap_register); 169 - 170 - /** 171 - * idio_16_get - get signal value at signal offset 172 - * @reg: ACCES IDIO-16 device registers 173 - * @state: ACCES IDIO-16 device state 174 - * @offset: offset of signal to get 175 - * 176 - * Returns the signal value (0=low, 1=high) for the signal at @offset. 177 - */ 178 - int idio_16_get(struct idio_16 __iomem *const reg, 179 - struct idio_16_state *const state, const unsigned long offset) 180 - { 181 - const unsigned long mask = BIT(offset); 182 - 183 - if (offset < IDIO_16_NOUT) 184 - return test_bit(offset, state->out_state); 185 - 186 - if (offset < 24) 187 - return !!(ioread8(&reg->in0_7) & (mask >> IDIO_16_NOUT)); 188 - 189 - if (offset < 32) 190 - return !!(ioread8(&reg->in8_15) & (mask >> 24)); 191 - 192 - return -EINVAL; 193 - } 194 - EXPORT_SYMBOL_GPL(idio_16_get); 195 - 196 - /** 197 - * idio_16_get_multiple - get multiple signal values at multiple signal offsets 198 - * @reg: ACCES IDIO-16 device registers 199 - * @state: ACCES IDIO-16 device state 200 - * @mask: mask of signals to get 201 - * @bits: bitmap to store signal values 202 - * 203 - * Stores in @bits the values (0=low, 1=high) for the signals defined by @mask. 204 - */ 205 - void idio_16_get_multiple(struct idio_16 __iomem *const reg, 206 - struct idio_16_state *const state, 207 - const unsigned long *const mask, 208 - unsigned long *const bits) 209 - { 210 - unsigned long flags; 211 - const unsigned long out_mask = GENMASK(IDIO_16_NOUT - 1, 0); 212 - 213 - spin_lock_irqsave(&state->lock, flags); 214 - 215 - bitmap_replace(bits, bits, state->out_state, &out_mask, IDIO_16_NOUT); 216 - if (*mask & GENMASK(23, 16)) 217 - bitmap_set_value8(bits, ioread8(&reg->in0_7), 16); 218 - if (*mask & GENMASK(31, 24)) 219 - bitmap_set_value8(bits, ioread8(&reg->in8_15), 24); 220 - 221 - spin_unlock_irqrestore(&state->lock, flags); 222 - } 223 - EXPORT_SYMBOL_GPL(idio_16_get_multiple); 224 - 225 - /** 226 - * idio_16_set - set signal value at signal offset 227 - * @reg: ACCES IDIO-16 device registers 228 - * @state: ACCES IDIO-16 device state 229 - * @offset: offset of signal to set 230 - * @value: value of signal to set 231 - * 232 - * Assigns output @value for the signal at @offset. 233 - */ 234 - void idio_16_set(struct idio_16 __iomem *const reg, 235 - struct idio_16_state *const state, const unsigned long offset, 236 - const unsigned long value) 237 - { 238 - unsigned long flags; 239 - 240 - if (offset >= IDIO_16_NOUT) 241 - return; 242 - 243 - spin_lock_irqsave(&state->lock, flags); 244 - 245 - __assign_bit(offset, state->out_state, value); 246 - if (offset < 8) 247 - iowrite8(bitmap_get_value8(state->out_state, 0), &reg->out0_7); 248 - else 249 - iowrite8(bitmap_get_value8(state->out_state, 8), &reg->out8_15); 250 - 251 - spin_unlock_irqrestore(&state->lock, flags); 252 - } 253 - EXPORT_SYMBOL_GPL(idio_16_set); 254 - 255 - /** 256 - * idio_16_set_multiple - set signal values at multiple signal offsets 257 - * @reg: ACCES IDIO-16 device registers 258 - * @state: ACCES IDIO-16 device state 259 - * @mask: mask of signals to set 260 - * @bits: bitmap of signal output values 261 - * 262 - * Assigns output values defined by @bits for the signals defined by @mask. 263 - */ 264 - void idio_16_set_multiple(struct idio_16 __iomem *const reg, 265 - struct idio_16_state *const state, 266 - const unsigned long *const mask, 267 - const unsigned long *const bits) 268 - { 269 - unsigned long flags; 270 - 271 - spin_lock_irqsave(&state->lock, flags); 272 - 273 - bitmap_replace(state->out_state, state->out_state, bits, mask, 274 - IDIO_16_NOUT); 275 - if (*mask & GENMASK(7, 0)) 276 - iowrite8(bitmap_get_value8(state->out_state, 0), &reg->out0_7); 277 - if (*mask & GENMASK(15, 8)) 278 - iowrite8(bitmap_get_value8(state->out_state, 8), &reg->out8_15); 279 - 280 - spin_unlock_irqrestore(&state->lock, flags); 281 - } 282 - EXPORT_SYMBOL_GPL(idio_16_set_multiple); 283 - 284 - /** 285 - * idio_16_state_init - initialize idio_16_state structure 286 - * @state: ACCES IDIO-16 device state 287 - * 288 - * Initializes the ACCES IDIO-16 device @state for use in idio-16 library 289 - * functions. 290 - */ 291 - void idio_16_state_init(struct idio_16_state *const state) 292 - { 293 - spin_lock_init(&state->lock); 294 - } 295 - EXPORT_SYMBOL_GPL(idio_16_state_init); 296 171 297 172 MODULE_AUTHOR("William Breathitt Gray"); 298 173 MODULE_DESCRIPTION("ACCES IDIO-16 GPIO Library");
-65
drivers/gpio/gpio-idio-16.h
··· 3 3 #ifndef _IDIO_16_H_ 4 4 #define _IDIO_16_H_ 5 5 6 - #include <linux/spinlock.h> 7 - #include <linux/types.h> 8 - 9 6 struct device; 10 7 struct regmap; 11 8 struct regmap_irq; ··· 26 29 bool no_status; 27 30 bool filters; 28 31 }; 29 - 30 - /** 31 - * struct idio_16 - IDIO-16 registers structure 32 - * @out0_7: Read: FET Drive Outputs 0-7 33 - * Write: FET Drive Outputs 0-7 34 - * @in0_7: Read: Isolated Inputs 0-7 35 - * Write: Clear Interrupt 36 - * @irq_ctl: Read: Enable IRQ 37 - * Write: Disable IRQ 38 - * @filter_ctl: Read: Activate Input Filters 0-15 39 - * Write: Deactivate Input Filters 0-15 40 - * @out8_15: Read: FET Drive Outputs 8-15 41 - * Write: FET Drive Outputs 8-15 42 - * @in8_15: Read: Isolated Inputs 8-15 43 - * Write: Unused 44 - * @irq_status: Read: Interrupt status 45 - * Write: Unused 46 - */ 47 - struct idio_16 { 48 - u8 out0_7; 49 - u8 in0_7; 50 - u8 irq_ctl; 51 - u8 filter_ctl; 52 - u8 out8_15; 53 - u8 in8_15; 54 - u8 irq_status; 55 - }; 56 - 57 - #define IDIO_16_NOUT 16 58 - 59 - /** 60 - * struct idio_16_state - IDIO-16 state structure 61 - * @lock: synchronization lock for accessing device state 62 - * @out_state: output signals state 63 - */ 64 - struct idio_16_state { 65 - spinlock_t lock; 66 - DECLARE_BITMAP(out_state, IDIO_16_NOUT); 67 - }; 68 - 69 - /** 70 - * idio_16_get_direction - get the I/O direction for a signal offset 71 - * @offset: offset of signal to get direction 72 - * 73 - * Returns the signal direction (0=output, 1=input) for the signal at @offset. 74 - */ 75 - static inline int idio_16_get_direction(const unsigned long offset) 76 - { 77 - return (offset >= IDIO_16_NOUT) ? 1 : 0; 78 - } 79 - 80 - int idio_16_get(struct idio_16 __iomem *reg, struct idio_16_state *state, 81 - unsigned long offset); 82 - void idio_16_get_multiple(struct idio_16 __iomem *reg, 83 - struct idio_16_state *state, 84 - const unsigned long *mask, unsigned long *bits); 85 - void idio_16_set(struct idio_16 __iomem *reg, struct idio_16_state *state, 86 - unsigned long offset, unsigned long value); 87 - void idio_16_set_multiple(struct idio_16 __iomem *reg, 88 - struct idio_16_state *state, 89 - const unsigned long *mask, const unsigned long *bits); 90 - void idio_16_state_init(struct idio_16_state *state); 91 32 92 33 int devm_idio_16_regmap_register(struct device *dev, const struct idio_16_regmap_config *config); 93 34