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

Configure Feed

Select the types of activity you want to include in your feed.

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