Lines Matching +full:lock +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-only
27 struct mutex lock; member
35 unsigned int offset) in exar_update() argument
40 mutex_lock(&exar_gpio->lock); in exar_update()
41 temp = readb(exar_gpio->regs + reg); in exar_update()
42 temp &= ~BIT(offset); in exar_update()
44 temp |= BIT(offset); in exar_update()
45 writeb(temp, exar_gpio->regs + reg); in exar_update()
46 mutex_unlock(&exar_gpio->lock); in exar_update()
50 unsigned int offset) in exar_set_direction() argument
53 unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? in exar_set_direction()
55 unsigned int bit = (offset + exar_gpio->first_pin) % 8; in exar_set_direction()
66 mutex_lock(&exar_gpio->lock); in exar_get()
67 value = readb(exar_gpio->regs + reg); in exar_get()
68 mutex_unlock(&exar_gpio->lock); in exar_get()
73 static int exar_get_direction(struct gpio_chip *chip, unsigned int offset) in exar_get_direction() argument
76 unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? in exar_get_direction()
78 unsigned int bit = (offset + exar_gpio->first_pin) % 8; in exar_get_direction()
86 static int exar_get_value(struct gpio_chip *chip, unsigned int offset) in exar_get_value() argument
89 unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? in exar_get_value()
91 unsigned int bit = (offset + exar_gpio->first_pin) % 8; in exar_get_value()
96 static void exar_set_value(struct gpio_chip *chip, unsigned int offset, in exar_set_value() argument
100 unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? in exar_set_value()
102 unsigned int bit = (offset + exar_gpio->first_pin) % 8; in exar_set_value()
107 static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, in exar_direction_output() argument
110 exar_set_value(chip, offset, value); in exar_direction_output()
111 return exar_set_direction(chip, 0, offset); in exar_direction_output()
114 static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) in exar_direction_input() argument
116 return exar_set_direction(chip, 1, offset); in exar_direction_input()
121 struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent); in gpio_exar_probe()
129 * device - use it. in gpio_exar_probe()
133 return -ENOMEM; in gpio_exar_probe()
135 ret = device_property_read_u32(&pdev->dev, "exar,first-pin", in gpio_exar_probe()
140 ret = device_property_read_u32(&pdev->dev, "ngpios", &ngpios); in gpio_exar_probe()
144 exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL); in gpio_exar_probe()
146 return -ENOMEM; in gpio_exar_probe()
148 mutex_init(&exar_gpio->lock); in gpio_exar_probe()
156 sprintf(exar_gpio->name, "exar_gpio%d", index); in gpio_exar_probe()
157 exar_gpio->gpio_chip.label = exar_gpio->name; in gpio_exar_probe()
158 exar_gpio->gpio_chip.parent = &pdev->dev; in gpio_exar_probe()
159 exar_gpio->gpio_chip.direction_output = exar_direction_output; in gpio_exar_probe()
160 exar_gpio->gpio_chip.direction_input = exar_direction_input; in gpio_exar_probe()
161 exar_gpio->gpio_chip.get_direction = exar_get_direction; in gpio_exar_probe()
162 exar_gpio->gpio_chip.get = exar_get_value; in gpio_exar_probe()
163 exar_gpio->gpio_chip.set = exar_set_value; in gpio_exar_probe()
164 exar_gpio->gpio_chip.base = -1; in gpio_exar_probe()
165 exar_gpio->gpio_chip.ngpio = ngpios; in gpio_exar_probe()
166 exar_gpio->regs = p; in gpio_exar_probe()
167 exar_gpio->index = index; in gpio_exar_probe()
168 exar_gpio->first_pin = first_pin; in gpio_exar_probe()
170 ret = devm_gpiochip_add_data(&pdev->dev, in gpio_exar_probe()
171 &exar_gpio->gpio_chip, exar_gpio); in gpio_exar_probe()
182 mutex_destroy(&exar_gpio->lock); in gpio_exar_probe()
190 ida_simple_remove(&ida_index, exar_gpio->index); in gpio_exar_remove()
191 mutex_destroy(&exar_gpio->lock); in gpio_exar_remove()