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