1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __LINUX_GPIO_CONSUMER_H 3 #define __LINUX_GPIO_CONSUMER_H 4 5 #include <linux/bug.h> 6 #include <linux/err.h> 7 #include <linux/kernel.h> 8 9 struct device; 10 11 /** 12 * Opaque descriptor for a GPIO. These are obtained using gpiod_get() and are 13 * preferable to the old integer-based handles. 14 * 15 * Contrary to integers, a pointer to a gpio_desc is guaranteed to be valid 16 * until the GPIO is released. 17 */ 18 struct gpio_desc; 19 20 /** 21 * Opaque descriptor for a structure of GPIO array attributes. This structure 22 * is attached to struct gpiod_descs obtained from gpiod_get_array() and can be 23 * passed back to get/set array functions in order to activate fast processing 24 * path if applicable. 25 */ 26 struct gpio_array; 27 28 /** 29 * Struct containing an array of descriptors that can be obtained using 30 * gpiod_get_array(). 31 */ 32 struct gpio_descs { 33 struct gpio_array *info; 34 unsigned int ndescs; 35 struct gpio_desc *desc[]; 36 }; 37 38 #define GPIOD_FLAGS_BIT_DIR_SET BIT(0) 39 #define GPIOD_FLAGS_BIT_DIR_OUT BIT(1) 40 #define GPIOD_FLAGS_BIT_DIR_VAL BIT(2) 41 #define GPIOD_FLAGS_BIT_OPEN_DRAIN BIT(3) 42 #define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4) 43 44 /** 45 * Optional flags that can be passed to one of gpiod_* to configure direction 46 * and output value. These values cannot be OR'd. 47 */ 48 enum gpiod_flags { 49 GPIOD_ASIS = 0, 50 GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET, 51 GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT, 52 GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT | 53 GPIOD_FLAGS_BIT_DIR_VAL, 54 GPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN, 55 GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN, 56 }; 57 58 #ifdef CONFIG_GPIOLIB 59 60 /* Return the number of GPIOs associated with a device / function */ 61 int gpiod_count(struct device *dev, const char *con_id); 62 63 /* Acquire and dispose GPIOs */ 64 struct gpio_desc *__must_check gpiod_get(struct device *dev, 65 const char *con_id, 66 enum gpiod_flags flags); 67 struct gpio_desc *__must_check gpiod_get_index(struct device *dev, 68 const char *con_id, 69 unsigned int idx, 70 enum gpiod_flags flags); 71 struct gpio_desc *__must_check gpiod_get_optional(struct device *dev, 72 const char *con_id, 73 enum gpiod_flags flags); 74 struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev, 75 const char *con_id, 76 unsigned int index, 77 enum gpiod_flags flags); 78 struct gpio_descs *__must_check gpiod_get_array(struct device *dev, 79 const char *con_id, 80 enum gpiod_flags flags); 81 struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev, 82 const char *con_id, 83 enum gpiod_flags flags); 84 void gpiod_put(struct gpio_desc *desc); 85 void gpiod_put_array(struct gpio_descs *descs); 86 87 struct gpio_desc *__must_check devm_gpiod_get(struct device *dev, 88 const char *con_id, 89 enum gpiod_flags flags); 90 struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, 91 const char *con_id, 92 unsigned int idx, 93 enum gpiod_flags flags); 94 struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev, 95 const char *con_id, 96 enum gpiod_flags flags); 97 struct gpio_desc *__must_check 98 devm_gpiod_get_index_optional(struct device *dev, const char *con_id, 99 unsigned int index, enum gpiod_flags flags); 100 struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev, 101 const char *con_id, 102 enum gpiod_flags flags); 103 struct gpio_descs *__must_check 104 devm_gpiod_get_array_optional(struct device *dev, const char *con_id, 105 enum gpiod_flags flags); 106 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); 107 void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc); 108 void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs); 109 110 int gpiod_get_direction(struct gpio_desc *desc); 111 int gpiod_direction_input(struct gpio_desc *desc); 112 int gpiod_direction_output(struct gpio_desc *desc, int value); 113 int gpiod_direction_output_raw(struct gpio_desc *desc, int value); 114 115 /* Value get/set from non-sleeping context */ 116 int gpiod_get_value(const struct gpio_desc *desc); 117 int gpiod_get_array_value(unsigned int array_size, 118 struct gpio_desc **desc_array, 119 struct gpio_array *array_info, 120 unsigned long *value_bitmap); 121 void gpiod_set_value(struct gpio_desc *desc, int value); 122 int gpiod_set_array_value(unsigned int array_size, 123 struct gpio_desc **desc_array, 124 struct gpio_array *array_info, 125 unsigned long *value_bitmap); 126 int gpiod_get_raw_value(const struct gpio_desc *desc); 127 int gpiod_get_raw_array_value(unsigned int array_size, 128 struct gpio_desc **desc_array, 129 struct gpio_array *array_info, 130 unsigned long *value_bitmap); 131 void gpiod_set_raw_value(struct gpio_desc *desc, int value); 132 int gpiod_set_raw_array_value(unsigned int array_size, 133 struct gpio_desc **desc_array, 134 struct gpio_array *array_info, 135 unsigned long *value_bitmap); 136 137 /* Value get/set from sleeping context */ 138 int gpiod_get_value_cansleep(const struct gpio_desc *desc); 139 int gpiod_get_array_value_cansleep(unsigned int array_size, 140 struct gpio_desc **desc_array, 141 struct gpio_array *array_info, 142 unsigned long *value_bitmap); 143 void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); 144 int gpiod_set_array_value_cansleep(unsigned int array_size, 145 struct gpio_desc **desc_array, 146 struct gpio_array *array_info, 147 unsigned long *value_bitmap); 148 int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); 149 int gpiod_get_raw_array_value_cansleep(unsigned int array_size, 150 struct gpio_desc **desc_array, 151 struct gpio_array *array_info, 152 unsigned long *value_bitmap); 153 void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); 154 int gpiod_set_raw_array_value_cansleep(unsigned int array_size, 155 struct gpio_desc **desc_array, 156 struct gpio_array *array_info, 157 unsigned long *value_bitmap); 158 159 int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); 160 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); 161 162 int gpiod_is_active_low(const struct gpio_desc *desc); 163 int gpiod_cansleep(const struct gpio_desc *desc); 164 165 int gpiod_to_irq(const struct gpio_desc *desc); 166 int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name); 167 168 /* Convert between the old gpio_ and new gpiod_ interfaces */ 169 struct gpio_desc *gpio_to_desc(unsigned gpio); 170 int desc_to_gpio(const struct gpio_desc *desc); 171 172 /* Child properties interface */ 173 struct fwnode_handle; 174 175 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 176 const char *propname, int index, 177 enum gpiod_flags dflags, 178 const char *label); 179 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 180 const char *con_id, int index, 181 enum gpiod_flags flags, 182 const char *label); 183 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, 184 struct fwnode_handle *child, 185 const char *con_id, int index, 186 enum gpiod_flags flags, 187 const char *label); 188 189 #else /* CONFIG_GPIOLIB */ 190 191 static inline int gpiod_count(struct device *dev, const char *con_id) 192 { 193 return 0; 194 } 195 196 static inline struct gpio_desc *__must_check gpiod_get(struct device *dev, 197 const char *con_id, 198 enum gpiod_flags flags) 199 { 200 return ERR_PTR(-ENOSYS); 201 } 202 static inline struct gpio_desc *__must_check 203 gpiod_get_index(struct device *dev, 204 const char *con_id, 205 unsigned int idx, 206 enum gpiod_flags flags) 207 { 208 return ERR_PTR(-ENOSYS); 209 } 210 211 static inline struct gpio_desc *__must_check 212 gpiod_get_optional(struct device *dev, const char *con_id, 213 enum gpiod_flags flags) 214 { 215 return NULL; 216 } 217 218 static inline struct gpio_desc *__must_check 219 gpiod_get_index_optional(struct device *dev, const char *con_id, 220 unsigned int index, enum gpiod_flags flags) 221 { 222 return NULL; 223 } 224 225 static inline struct gpio_descs *__must_check 226 gpiod_get_array(struct device *dev, const char *con_id, 227 enum gpiod_flags flags) 228 { 229 return ERR_PTR(-ENOSYS); 230 } 231 232 static inline struct gpio_descs *__must_check 233 gpiod_get_array_optional(struct device *dev, const char *con_id, 234 enum gpiod_flags flags) 235 { 236 return NULL; 237 } 238 239 static inline void gpiod_put(struct gpio_desc *desc) 240 { 241 might_sleep(); 242 243 /* GPIO can never have been requested */ 244 WARN_ON(desc); 245 } 246 247 static inline void devm_gpiod_unhinge(struct device *dev, 248 struct gpio_desc *desc) 249 { 250 might_sleep(); 251 252 /* GPIO can never have been requested */ 253 WARN_ON(desc); 254 } 255 256 static inline void gpiod_put_array(struct gpio_descs *descs) 257 { 258 might_sleep(); 259 260 /* GPIO can never have been requested */ 261 WARN_ON(descs); 262 } 263 264 static inline struct gpio_desc *__must_check 265 devm_gpiod_get(struct device *dev, 266 const char *con_id, 267 enum gpiod_flags flags) 268 { 269 return ERR_PTR(-ENOSYS); 270 } 271 static inline 272 struct gpio_desc *__must_check 273 devm_gpiod_get_index(struct device *dev, 274 const char *con_id, 275 unsigned int idx, 276 enum gpiod_flags flags) 277 { 278 return ERR_PTR(-ENOSYS); 279 } 280 281 static inline struct gpio_desc *__must_check 282 devm_gpiod_get_optional(struct device *dev, const char *con_id, 283 enum gpiod_flags flags) 284 { 285 return NULL; 286 } 287 288 static inline struct gpio_desc *__must_check 289 devm_gpiod_get_index_optional(struct device *dev, const char *con_id, 290 unsigned int index, enum gpiod_flags flags) 291 { 292 return NULL; 293 } 294 295 static inline struct gpio_descs *__must_check 296 devm_gpiod_get_array(struct device *dev, const char *con_id, 297 enum gpiod_flags flags) 298 { 299 return ERR_PTR(-ENOSYS); 300 } 301 302 static inline struct gpio_descs *__must_check 303 devm_gpiod_get_array_optional(struct device *dev, const char *con_id, 304 enum gpiod_flags flags) 305 { 306 return NULL; 307 } 308 309 static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) 310 { 311 might_sleep(); 312 313 /* GPIO can never have been requested */ 314 WARN_ON(desc); 315 } 316 317 static inline void devm_gpiod_put_array(struct device *dev, 318 struct gpio_descs *descs) 319 { 320 might_sleep(); 321 322 /* GPIO can never have been requested */ 323 WARN_ON(descs); 324 } 325 326 327 static inline int gpiod_get_direction(const struct gpio_desc *desc) 328 { 329 /* GPIO can never have been requested */ 330 WARN_ON(desc); 331 return -ENOSYS; 332 } 333 static inline int gpiod_direction_input(struct gpio_desc *desc) 334 { 335 /* GPIO can never have been requested */ 336 WARN_ON(desc); 337 return -ENOSYS; 338 } 339 static inline int gpiod_direction_output(struct gpio_desc *desc, int value) 340 { 341 /* GPIO can never have been requested */ 342 WARN_ON(desc); 343 return -ENOSYS; 344 } 345 static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value) 346 { 347 /* GPIO can never have been requested */ 348 WARN_ON(desc); 349 return -ENOSYS; 350 } 351 352 353 static inline int gpiod_get_value(const struct gpio_desc *desc) 354 { 355 /* GPIO can never have been requested */ 356 WARN_ON(desc); 357 return 0; 358 } 359 static inline int gpiod_get_array_value(unsigned int array_size, 360 struct gpio_desc **desc_array, 361 struct gpio_array *array_info, 362 unsigned long *value_bitmap) 363 { 364 /* GPIO can never have been requested */ 365 WARN_ON(desc_array); 366 return 0; 367 } 368 static inline void gpiod_set_value(struct gpio_desc *desc, int value) 369 { 370 /* GPIO can never have been requested */ 371 WARN_ON(desc); 372 } 373 static inline int gpiod_set_array_value(unsigned int array_size, 374 struct gpio_desc **desc_array, 375 struct gpio_array *array_info, 376 unsigned long *value_bitmap) 377 { 378 /* GPIO can never have been requested */ 379 WARN_ON(desc_array); 380 return 0; 381 } 382 static inline int gpiod_get_raw_value(const struct gpio_desc *desc) 383 { 384 /* GPIO can never have been requested */ 385 WARN_ON(desc); 386 return 0; 387 } 388 static inline int gpiod_get_raw_array_value(unsigned int array_size, 389 struct gpio_desc **desc_array, 390 struct gpio_array *array_info, 391 unsigned long *value_bitmap) 392 { 393 /* GPIO can never have been requested */ 394 WARN_ON(desc_array); 395 return 0; 396 } 397 static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) 398 { 399 /* GPIO can never have been requested */ 400 WARN_ON(desc); 401 } 402 static inline int gpiod_set_raw_array_value(unsigned int array_size, 403 struct gpio_desc **desc_array, 404 struct gpio_array *array_info, 405 unsigned long *value_bitmap) 406 { 407 /* GPIO can never have been requested */ 408 WARN_ON(desc_array); 409 return 0; 410 } 411 412 static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) 413 { 414 /* GPIO can never have been requested */ 415 WARN_ON(desc); 416 return 0; 417 } 418 static inline int gpiod_get_array_value_cansleep(unsigned int array_size, 419 struct gpio_desc **desc_array, 420 struct gpio_array *array_info, 421 unsigned long *value_bitmap) 422 { 423 /* GPIO can never have been requested */ 424 WARN_ON(desc_array); 425 return 0; 426 } 427 static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) 428 { 429 /* GPIO can never have been requested */ 430 WARN_ON(desc); 431 } 432 static inline int gpiod_set_array_value_cansleep(unsigned int array_size, 433 struct gpio_desc **desc_array, 434 struct gpio_array *array_info, 435 unsigned long *value_bitmap) 436 { 437 /* GPIO can never have been requested */ 438 WARN_ON(desc_array); 439 return 0; 440 } 441 static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) 442 { 443 /* GPIO can never have been requested */ 444 WARN_ON(desc); 445 return 0; 446 } 447 static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size, 448 struct gpio_desc **desc_array, 449 struct gpio_array *array_info, 450 unsigned long *value_bitmap) 451 { 452 /* GPIO can never have been requested */ 453 WARN_ON(desc_array); 454 return 0; 455 } 456 static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, 457 int value) 458 { 459 /* GPIO can never have been requested */ 460 WARN_ON(desc); 461 } 462 static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, 463 struct gpio_desc **desc_array, 464 struct gpio_array *array_info, 465 unsigned long *value_bitmap) 466 { 467 /* GPIO can never have been requested */ 468 WARN_ON(desc_array); 469 return 0; 470 } 471 472 static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) 473 { 474 /* GPIO can never have been requested */ 475 WARN_ON(desc); 476 return -ENOSYS; 477 } 478 479 static inline int gpiod_set_transitory(struct gpio_desc *desc, bool transitory) 480 { 481 /* GPIO can never have been requested */ 482 WARN_ON(desc); 483 return -ENOSYS; 484 } 485 486 static inline int gpiod_is_active_low(const struct gpio_desc *desc) 487 { 488 /* GPIO can never have been requested */ 489 WARN_ON(desc); 490 return 0; 491 } 492 static inline int gpiod_cansleep(const struct gpio_desc *desc) 493 { 494 /* GPIO can never have been requested */ 495 WARN_ON(desc); 496 return 0; 497 } 498 499 static inline int gpiod_to_irq(const struct gpio_desc *desc) 500 { 501 /* GPIO can never have been requested */ 502 WARN_ON(desc); 503 return -EINVAL; 504 } 505 506 static inline int gpiod_set_consumer_name(struct gpio_desc *desc, 507 const char *name) 508 { 509 /* GPIO can never have been requested */ 510 WARN_ON(desc); 511 return -EINVAL; 512 } 513 514 static inline struct gpio_desc *gpio_to_desc(unsigned gpio) 515 { 516 return NULL; 517 } 518 519 static inline int desc_to_gpio(const struct gpio_desc *desc) 520 { 521 /* GPIO can never have been requested */ 522 WARN_ON(desc); 523 return -EINVAL; 524 } 525 526 /* Child properties interface */ 527 struct fwnode_handle; 528 529 static inline 530 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 531 const char *propname, int index, 532 enum gpiod_flags dflags, 533 const char *label) 534 { 535 return ERR_PTR(-ENOSYS); 536 } 537 538 static inline 539 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 540 const char *con_id, int index, 541 enum gpiod_flags flags, 542 const char *label) 543 { 544 return ERR_PTR(-ENOSYS); 545 } 546 547 static inline 548 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, 549 struct fwnode_handle *fwnode, 550 const char *con_id, int index, 551 enum gpiod_flags flags, 552 const char *label) 553 { 554 return ERR_PTR(-ENOSYS); 555 } 556 557 #endif /* CONFIG_GPIOLIB */ 558 559 static inline 560 struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev, 561 struct fwnode_handle *fwnode, 562 const char *con_id, 563 enum gpiod_flags flags, 564 const char *label) 565 { 566 return devm_fwnode_gpiod_get_index(dev, fwnode, con_id, 0, 567 flags, label); 568 } 569 570 static inline 571 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, 572 const char *con_id, int index, 573 struct fwnode_handle *child, 574 enum gpiod_flags flags, 575 const char *label) 576 { 577 return devm_fwnode_gpiod_get_index(dev, child, con_id, index, 578 flags, label); 579 } 580 581 static inline 582 struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev, 583 const char *con_id, 584 struct fwnode_handle *child, 585 enum gpiod_flags flags, 586 const char *label) 587 { 588 return devm_fwnode_gpiod_get_index(dev, child, con_id, 0, flags, label); 589 } 590 591 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO) 592 struct device_node; 593 594 struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, 595 const char *propname, int index, 596 enum gpiod_flags dflags, 597 const char *label); 598 599 #else /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ 600 601 struct device_node; 602 603 static inline 604 struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, 605 const char *propname, int index, 606 enum gpiod_flags dflags, 607 const char *label) 608 { 609 return ERR_PTR(-ENOSYS); 610 } 611 612 #endif /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ 613 614 #ifdef CONFIG_GPIOLIB 615 struct device_node; 616 617 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, 618 struct device_node *node, 619 const char *propname, int index, 620 enum gpiod_flags dflags, 621 const char *label); 622 623 #else /* CONFIG_GPIOLIB */ 624 625 struct device_node; 626 627 static inline 628 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, 629 struct device_node *node, 630 const char *propname, int index, 631 enum gpiod_flags dflags, 632 const char *label) 633 { 634 return ERR_PTR(-ENOSYS); 635 } 636 637 #endif /* CONFIG_GPIOLIB */ 638 639 struct acpi_gpio_params { 640 unsigned int crs_entry_index; 641 unsigned int line_index; 642 bool active_low; 643 }; 644 645 struct acpi_gpio_mapping { 646 const char *name; 647 const struct acpi_gpio_params *data; 648 unsigned int size; 649 650 /* Ignore IoRestriction field */ 651 #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0) 652 /* 653 * When ACPI GPIO mapping table is in use the index parameter inside it 654 * refers to the GPIO resource in _CRS method. That index has no 655 * distinction of actual type of the resource. When consumer wants to 656 * get GpioIo type explicitly, this quirk may be used. 657 */ 658 #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) 659 660 unsigned int quirks; 661 }; 662 663 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI) 664 665 struct acpi_device; 666 667 int acpi_dev_add_driver_gpios(struct acpi_device *adev, 668 const struct acpi_gpio_mapping *gpios); 669 void acpi_dev_remove_driver_gpios(struct acpi_device *adev); 670 671 int devm_acpi_dev_add_driver_gpios(struct device *dev, 672 const struct acpi_gpio_mapping *gpios); 673 void devm_acpi_dev_remove_driver_gpios(struct device *dev); 674 675 #else /* CONFIG_GPIOLIB && CONFIG_ACPI */ 676 677 struct acpi_device; 678 679 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev, 680 const struct acpi_gpio_mapping *gpios) 681 { 682 return -ENXIO; 683 } 684 static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {} 685 686 static inline int devm_acpi_dev_add_driver_gpios(struct device *dev, 687 const struct acpi_gpio_mapping *gpios) 688 { 689 return -ENXIO; 690 } 691 static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {} 692 693 #endif /* CONFIG_GPIOLIB && CONFIG_ACPI */ 694 695 696 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) 697 698 int gpiod_export(struct gpio_desc *desc, bool direction_may_change); 699 int gpiod_export_link(struct device *dev, const char *name, 700 struct gpio_desc *desc); 701 void gpiod_unexport(struct gpio_desc *desc); 702 703 #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ 704 705 static inline int gpiod_export(struct gpio_desc *desc, 706 bool direction_may_change) 707 { 708 return -ENOSYS; 709 } 710 711 static inline int gpiod_export_link(struct device *dev, const char *name, 712 struct gpio_desc *desc) 713 { 714 return -ENOSYS; 715 } 716 717 static inline void gpiod_unexport(struct gpio_desc *desc) 718 { 719 } 720 721 #endif /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ 722 723 #endif 724