max3191x          118 drivers/gpio/gpio-max3191x.c static unsigned int max3191x_wordlen(struct max3191x_chip *max3191x)
max3191x          120 drivers/gpio/gpio-max3191x.c 	return max3191x->mode == STATUS_BYTE_ENABLED ? 2 : 1;
max3191x          123 drivers/gpio/gpio-max3191x.c static int max3191x_readout_locked(struct max3191x_chip *max3191x)
max3191x          125 drivers/gpio/gpio-max3191x.c 	struct device *dev = max3191x->gpio.parent;
max3191x          129 drivers/gpio/gpio-max3191x.c 	val = spi_sync(spi, &max3191x->mesg);
max3191x          135 drivers/gpio/gpio-max3191x.c 	for (i = 0; i < max3191x->nchips; i++) {
max3191x          136 drivers/gpio/gpio-max3191x.c 		if (max3191x->mode == STATUS_BYTE_ENABLED) {
max3191x          137 drivers/gpio/gpio-max3191x.c 			u8 in	  = ((u8 *)max3191x->xfer.rx_buf)[i * 2];
max3191x          138 drivers/gpio/gpio-max3191x.c 			u8 status = ((u8 *)max3191x->xfer.rx_buf)[i * 2 + 1];
max3191x          141 drivers/gpio/gpio-max3191x.c 			__assign_bit(i, max3191x->crc_error, val);
max3191x          147 drivers/gpio/gpio-max3191x.c 			__assign_bit(i, max3191x->overtemp, ot);
max3191x          152 drivers/gpio/gpio-max3191x.c 			if (!max3191x->ignore_uv) {
max3191x          154 drivers/gpio/gpio-max3191x.c 				__assign_bit(i, max3191x->undervolt1, uv1);
max3191x          160 drivers/gpio/gpio-max3191x.c 				__assign_bit(i, max3191x->undervolt2, val);
max3191x          167 drivers/gpio/gpio-max3191x.c 		if (max3191x->fault_pins && !max3191x->ignore_uv) {
max3191x          170 drivers/gpio/gpio-max3191x.c 				(max3191x->fault_pins->ndescs == 1)
max3191x          171 drivers/gpio/gpio-max3191x.c 					? max3191x->fault_pins->desc[0]
max3191x          172 drivers/gpio/gpio-max3191x.c 					: max3191x->fault_pins->desc[i];
max3191x          180 drivers/gpio/gpio-max3191x.c 			__assign_bit(i, max3191x->fault, val);
max3191x          190 drivers/gpio/gpio-max3191x.c static bool max3191x_chip_is_faulting(struct max3191x_chip *max3191x,
max3191x          194 drivers/gpio/gpio-max3191x.c 	if (!max3191x->ignore_uv && test_bit(chipnum, max3191x->fault))
max3191x          197 drivers/gpio/gpio-max3191x.c 	if (max3191x->mode == STATUS_BYTE_DISABLED)
max3191x          200 drivers/gpio/gpio-max3191x.c 	return test_bit(chipnum, max3191x->crc_error) ||
max3191x          201 drivers/gpio/gpio-max3191x.c 	       test_bit(chipnum, max3191x->overtemp)  ||
max3191x          202 drivers/gpio/gpio-max3191x.c 	       (!max3191x->ignore_uv &&
max3191x          203 drivers/gpio/gpio-max3191x.c 		test_bit(chipnum, max3191x->undervolt1));
max3191x          208 drivers/gpio/gpio-max3191x.c 	struct max3191x_chip *max3191x = gpiochip_get_data(gpio);
max3191x          209 drivers/gpio/gpio-max3191x.c 	int ret, chipnum, wordlen = max3191x_wordlen(max3191x);
max3191x          212 drivers/gpio/gpio-max3191x.c 	mutex_lock(&max3191x->lock);
max3191x          213 drivers/gpio/gpio-max3191x.c 	ret = max3191x_readout_locked(max3191x);
max3191x          218 drivers/gpio/gpio-max3191x.c 	if (max3191x_chip_is_faulting(max3191x, chipnum)) {
max3191x          223 drivers/gpio/gpio-max3191x.c 	in = ((u8 *)max3191x->xfer.rx_buf)[chipnum * wordlen];
max3191x          227 drivers/gpio/gpio-max3191x.c 	mutex_unlock(&max3191x->lock);
max3191x          234 drivers/gpio/gpio-max3191x.c 	struct max3191x_chip *max3191x = gpiochip_get_data(gpio);
max3191x          235 drivers/gpio/gpio-max3191x.c 	int ret, bit = 0, wordlen = max3191x_wordlen(max3191x);
max3191x          237 drivers/gpio/gpio-max3191x.c 	mutex_lock(&max3191x->lock);
max3191x          238 drivers/gpio/gpio-max3191x.c 	ret = max3191x_readout_locked(max3191x);
max3191x          246 drivers/gpio/gpio-max3191x.c 		if (max3191x_chip_is_faulting(max3191x, chipnum)) {
max3191x          251 drivers/gpio/gpio-max3191x.c 		in = ((u8 *)max3191x->xfer.rx_buf)[chipnum * wordlen];
max3191x          261 drivers/gpio/gpio-max3191x.c 	mutex_unlock(&max3191x->lock);
max3191x          268 drivers/gpio/gpio-max3191x.c 	struct max3191x_chip *max3191x = gpiochip_get_data(gpio);
max3191x          274 drivers/gpio/gpio-max3191x.c 	if (!max3191x->db0_pins || !max3191x->db1_pins)
max3191x          299 drivers/gpio/gpio-max3191x.c 	if (max3191x->db0_pins->ndescs == 1)
max3191x          304 drivers/gpio/gpio-max3191x.c 	mutex_lock(&max3191x->lock);
max3191x          305 drivers/gpio/gpio-max3191x.c 	gpiod_set_value_cansleep(max3191x->db0_pins->desc[chipnum], db0_val);
max3191x          306 drivers/gpio/gpio-max3191x.c 	gpiod_set_value_cansleep(max3191x->db1_pins->desc[chipnum], db1_val);
max3191x          307 drivers/gpio/gpio-max3191x.c 	mutex_unlock(&max3191x->lock);
max3191x          361 drivers/gpio/gpio-max3191x.c 	struct max3191x_chip *max3191x;
max3191x          364 drivers/gpio/gpio-max3191x.c 	max3191x = devm_kzalloc(dev, sizeof(*max3191x), GFP_KERNEL);
max3191x          365 drivers/gpio/gpio-max3191x.c 	if (!max3191x)
max3191x          367 drivers/gpio/gpio-max3191x.c 	spi_set_drvdata(spi, max3191x);
max3191x          369 drivers/gpio/gpio-max3191x.c 	max3191x->nchips = 1;
max3191x          371 drivers/gpio/gpio-max3191x.c 				 &max3191x->nchips);
max3191x          373 drivers/gpio/gpio-max3191x.c 	n = BITS_TO_LONGS(max3191x->nchips);
max3191x          374 drivers/gpio/gpio-max3191x.c 	max3191x->crc_error   = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL);
max3191x          375 drivers/gpio/gpio-max3191x.c 	max3191x->undervolt1  = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL);
max3191x          376 drivers/gpio/gpio-max3191x.c 	max3191x->undervolt2  = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL);
max3191x          377 drivers/gpio/gpio-max3191x.c 	max3191x->overtemp    = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL);
max3191x          378 drivers/gpio/gpio-max3191x.c 	max3191x->fault       = devm_kcalloc(dev, n, sizeof(long), GFP_KERNEL);
max3191x          379 drivers/gpio/gpio-max3191x.c 	max3191x->xfer.rx_buf = devm_kcalloc(dev, max3191x->nchips,
max3191x          381 drivers/gpio/gpio-max3191x.c 	if (!max3191x->crc_error || !max3191x->undervolt1 ||
max3191x          382 drivers/gpio/gpio-max3191x.c 	    !max3191x->overtemp  || !max3191x->undervolt2 ||
max3191x          383 drivers/gpio/gpio-max3191x.c 	    !max3191x->fault     || !max3191x->xfer.rx_buf)
max3191x          386 drivers/gpio/gpio-max3191x.c 	max3191x->modesel_pins = devm_gpiod_get_array_optional_count(dev,
max3191x          387 drivers/gpio/gpio-max3191x.c 				 "maxim,modesel", GPIOD_ASIS, max3191x->nchips);
max3191x          388 drivers/gpio/gpio-max3191x.c 	max3191x->fault_pins   = devm_gpiod_get_array_optional_count(dev,
max3191x          389 drivers/gpio/gpio-max3191x.c 				 "maxim,fault", GPIOD_IN, max3191x->nchips);
max3191x          390 drivers/gpio/gpio-max3191x.c 	max3191x->db0_pins     = devm_gpiod_get_array_optional_count(dev,
max3191x          391 drivers/gpio/gpio-max3191x.c 				 "maxim,db0", GPIOD_OUT_LOW, max3191x->nchips);
max3191x          392 drivers/gpio/gpio-max3191x.c 	max3191x->db1_pins     = devm_gpiod_get_array_optional_count(dev,
max3191x          393 drivers/gpio/gpio-max3191x.c 				 "maxim,db1", GPIOD_OUT_LOW, max3191x->nchips);
max3191x          395 drivers/gpio/gpio-max3191x.c 	max3191x->mode = device_property_read_bool(dev, "maxim,modesel-8bit")
max3191x          397 drivers/gpio/gpio-max3191x.c 	if (max3191x->modesel_pins)
max3191x          399 drivers/gpio/gpio-max3191x.c 				 max3191x->modesel_pins->ndescs,
max3191x          400 drivers/gpio/gpio-max3191x.c 				 max3191x->modesel_pins->desc,
max3191x          401 drivers/gpio/gpio-max3191x.c 				 max3191x->modesel_pins->info, max3191x->mode);
max3191x          403 drivers/gpio/gpio-max3191x.c 	max3191x->ignore_uv = device_property_read_bool(dev,
max3191x          406 drivers/gpio/gpio-max3191x.c 	if (max3191x->db0_pins && max3191x->db1_pins &&
max3191x          407 drivers/gpio/gpio-max3191x.c 	    max3191x->db0_pins->ndescs != max3191x->db1_pins->ndescs) {
max3191x          409 drivers/gpio/gpio-max3191x.c 		devm_gpiod_put_array(dev, max3191x->db0_pins);
max3191x          410 drivers/gpio/gpio-max3191x.c 		devm_gpiod_put_array(dev, max3191x->db1_pins);
max3191x          411 drivers/gpio/gpio-max3191x.c 		max3191x->db0_pins = NULL;
max3191x          412 drivers/gpio/gpio-max3191x.c 		max3191x->db1_pins = NULL;
max3191x          415 drivers/gpio/gpio-max3191x.c 	max3191x->xfer.len = max3191x->nchips * max3191x_wordlen(max3191x);
max3191x          416 drivers/gpio/gpio-max3191x.c 	spi_message_init_with_transfers(&max3191x->mesg, &max3191x->xfer, 1);
max3191x          418 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.label = spi->modalias;
max3191x          419 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.owner = THIS_MODULE;
max3191x          420 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.parent = dev;
max3191x          421 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.base = -1;
max3191x          422 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.ngpio = max3191x->nchips * MAX3191X_NGPIO;
max3191x          423 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.can_sleep = true;
max3191x          425 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.get_direction = max3191x_get_direction;
max3191x          426 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.direction_input = max3191x_direction_input;
max3191x          427 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.direction_output = max3191x_direction_output;
max3191x          428 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.set = max3191x_set;
max3191x          429 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.set_multiple = max3191x_set_multiple;
max3191x          430 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.get = max3191x_get;
max3191x          431 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.get_multiple = max3191x_get_multiple;
max3191x          432 drivers/gpio/gpio-max3191x.c 	max3191x->gpio.set_config = max3191x_set_config;
max3191x          434 drivers/gpio/gpio-max3191x.c 	mutex_init(&max3191x->lock);
max3191x          436 drivers/gpio/gpio-max3191x.c 	ret = gpiochip_add_data(&max3191x->gpio, max3191x);
max3191x          438 drivers/gpio/gpio-max3191x.c 		mutex_destroy(&max3191x->lock);
max3191x          447 drivers/gpio/gpio-max3191x.c 	struct max3191x_chip *max3191x = spi_get_drvdata(spi);
max3191x          449 drivers/gpio/gpio-max3191x.c 	gpiochip_remove(&max3191x->gpio);
max3191x          450 drivers/gpio/gpio-max3191x.c 	mutex_destroy(&max3191x->lock);