0001
0002 #ifndef __LINUX_GPIO_CONSUMER_H
0003 #define __LINUX_GPIO_CONSUMER_H
0004
0005 #include <linux/bits.h>
0006 #include <linux/bug.h>
0007 #include <linux/compiler_types.h>
0008 #include <linux/err.h>
0009
0010 struct device;
0011 struct gpio_desc;
0012 struct gpio_array;
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct gpio_descs {
0023 struct gpio_array *info;
0024 unsigned int ndescs;
0025 struct gpio_desc *desc[];
0026 };
0027
0028 #define GPIOD_FLAGS_BIT_DIR_SET BIT(0)
0029 #define GPIOD_FLAGS_BIT_DIR_OUT BIT(1)
0030 #define GPIOD_FLAGS_BIT_DIR_VAL BIT(2)
0031 #define GPIOD_FLAGS_BIT_OPEN_DRAIN BIT(3)
0032 #define GPIOD_FLAGS_BIT_NONEXCLUSIVE BIT(4)
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 enum gpiod_flags {
0047 GPIOD_ASIS = 0,
0048 GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET,
0049 GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT,
0050 GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT |
0051 GPIOD_FLAGS_BIT_DIR_VAL,
0052 GPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN,
0053 GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN,
0054 };
0055
0056 #ifdef CONFIG_GPIOLIB
0057
0058
0059 int gpiod_count(struct device *dev, const char *con_id);
0060
0061
0062 struct gpio_desc *__must_check gpiod_get(struct device *dev,
0063 const char *con_id,
0064 enum gpiod_flags flags);
0065 struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
0066 const char *con_id,
0067 unsigned int idx,
0068 enum gpiod_flags flags);
0069 struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
0070 const char *con_id,
0071 enum gpiod_flags flags);
0072 struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev,
0073 const char *con_id,
0074 unsigned int index,
0075 enum gpiod_flags flags);
0076 struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
0077 const char *con_id,
0078 enum gpiod_flags flags);
0079 struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev,
0080 const char *con_id,
0081 enum gpiod_flags flags);
0082 void gpiod_put(struct gpio_desc *desc);
0083 void gpiod_put_array(struct gpio_descs *descs);
0084
0085 struct gpio_desc *__must_check devm_gpiod_get(struct device *dev,
0086 const char *con_id,
0087 enum gpiod_flags flags);
0088 struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
0089 const char *con_id,
0090 unsigned int idx,
0091 enum gpiod_flags flags);
0092 struct gpio_desc *__must_check devm_gpiod_get_optional(struct device *dev,
0093 const char *con_id,
0094 enum gpiod_flags flags);
0095 struct gpio_desc *__must_check
0096 devm_gpiod_get_index_optional(struct device *dev, const char *con_id,
0097 unsigned int index, enum gpiod_flags flags);
0098 struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev,
0099 const char *con_id,
0100 enum gpiod_flags flags);
0101 struct gpio_descs *__must_check
0102 devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
0103 enum gpiod_flags flags);
0104 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc);
0105 void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc);
0106 void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs);
0107
0108 int gpiod_get_direction(struct gpio_desc *desc);
0109 int gpiod_direction_input(struct gpio_desc *desc);
0110 int gpiod_direction_output(struct gpio_desc *desc, int value);
0111 int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
0112 int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
0113 int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
0114
0115
0116 int gpiod_get_value(const struct gpio_desc *desc);
0117 int gpiod_get_array_value(unsigned int array_size,
0118 struct gpio_desc **desc_array,
0119 struct gpio_array *array_info,
0120 unsigned long *value_bitmap);
0121 void gpiod_set_value(struct gpio_desc *desc, int value);
0122 int gpiod_set_array_value(unsigned int array_size,
0123 struct gpio_desc **desc_array,
0124 struct gpio_array *array_info,
0125 unsigned long *value_bitmap);
0126 int gpiod_get_raw_value(const struct gpio_desc *desc);
0127 int gpiod_get_raw_array_value(unsigned int array_size,
0128 struct gpio_desc **desc_array,
0129 struct gpio_array *array_info,
0130 unsigned long *value_bitmap);
0131 void gpiod_set_raw_value(struct gpio_desc *desc, int value);
0132 int gpiod_set_raw_array_value(unsigned int array_size,
0133 struct gpio_desc **desc_array,
0134 struct gpio_array *array_info,
0135 unsigned long *value_bitmap);
0136
0137
0138 int gpiod_get_value_cansleep(const struct gpio_desc *desc);
0139 int gpiod_get_array_value_cansleep(unsigned int array_size,
0140 struct gpio_desc **desc_array,
0141 struct gpio_array *array_info,
0142 unsigned long *value_bitmap);
0143 void gpiod_set_value_cansleep(struct gpio_desc *desc, int value);
0144 int gpiod_set_array_value_cansleep(unsigned int array_size,
0145 struct gpio_desc **desc_array,
0146 struct gpio_array *array_info,
0147 unsigned long *value_bitmap);
0148 int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc);
0149 int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
0150 struct gpio_desc **desc_array,
0151 struct gpio_array *array_info,
0152 unsigned long *value_bitmap);
0153 void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value);
0154 int gpiod_set_raw_array_value_cansleep(unsigned int array_size,
0155 struct gpio_desc **desc_array,
0156 struct gpio_array *array_info,
0157 unsigned long *value_bitmap);
0158
0159 int gpiod_set_config(struct gpio_desc *desc, unsigned long config);
0160 int gpiod_set_debounce(struct gpio_desc *desc, unsigned int debounce);
0161 int gpiod_set_transitory(struct gpio_desc *desc, bool transitory);
0162 void gpiod_toggle_active_low(struct gpio_desc *desc);
0163
0164 int gpiod_is_active_low(const struct gpio_desc *desc);
0165 int gpiod_cansleep(const struct gpio_desc *desc);
0166
0167 int gpiod_to_irq(const struct gpio_desc *desc);
0168 int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
0169
0170
0171 struct gpio_desc *gpio_to_desc(unsigned gpio);
0172 int desc_to_gpio(const struct gpio_desc *desc);
0173
0174
0175 struct fwnode_handle;
0176
0177 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
0178 const char *propname, int index,
0179 enum gpiod_flags dflags,
0180 const char *label);
0181 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
0182 const char *con_id, int index,
0183 enum gpiod_flags flags,
0184 const char *label);
0185 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
0186 struct fwnode_handle *child,
0187 const char *con_id, int index,
0188 enum gpiod_flags flags,
0189 const char *label);
0190
0191 #else
0192
0193 #include <linux/kernel.h>
0194
0195 static inline int gpiod_count(struct device *dev, const char *con_id)
0196 {
0197 return 0;
0198 }
0199
0200 static inline struct gpio_desc *__must_check gpiod_get(struct device *dev,
0201 const char *con_id,
0202 enum gpiod_flags flags)
0203 {
0204 return ERR_PTR(-ENOSYS);
0205 }
0206 static inline struct gpio_desc *__must_check
0207 gpiod_get_index(struct device *dev,
0208 const char *con_id,
0209 unsigned int idx,
0210 enum gpiod_flags flags)
0211 {
0212 return ERR_PTR(-ENOSYS);
0213 }
0214
0215 static inline struct gpio_desc *__must_check
0216 gpiod_get_optional(struct device *dev, const char *con_id,
0217 enum gpiod_flags flags)
0218 {
0219 return NULL;
0220 }
0221
0222 static inline struct gpio_desc *__must_check
0223 gpiod_get_index_optional(struct device *dev, const char *con_id,
0224 unsigned int index, enum gpiod_flags flags)
0225 {
0226 return NULL;
0227 }
0228
0229 static inline struct gpio_descs *__must_check
0230 gpiod_get_array(struct device *dev, const char *con_id,
0231 enum gpiod_flags flags)
0232 {
0233 return ERR_PTR(-ENOSYS);
0234 }
0235
0236 static inline struct gpio_descs *__must_check
0237 gpiod_get_array_optional(struct device *dev, const char *con_id,
0238 enum gpiod_flags flags)
0239 {
0240 return NULL;
0241 }
0242
0243 static inline void gpiod_put(struct gpio_desc *desc)
0244 {
0245 might_sleep();
0246
0247
0248 WARN_ON(desc);
0249 }
0250
0251 static inline void devm_gpiod_unhinge(struct device *dev,
0252 struct gpio_desc *desc)
0253 {
0254 might_sleep();
0255
0256
0257 WARN_ON(desc);
0258 }
0259
0260 static inline void gpiod_put_array(struct gpio_descs *descs)
0261 {
0262 might_sleep();
0263
0264
0265 WARN_ON(descs);
0266 }
0267
0268 static inline struct gpio_desc *__must_check
0269 devm_gpiod_get(struct device *dev,
0270 const char *con_id,
0271 enum gpiod_flags flags)
0272 {
0273 return ERR_PTR(-ENOSYS);
0274 }
0275 static inline
0276 struct gpio_desc *__must_check
0277 devm_gpiod_get_index(struct device *dev,
0278 const char *con_id,
0279 unsigned int idx,
0280 enum gpiod_flags flags)
0281 {
0282 return ERR_PTR(-ENOSYS);
0283 }
0284
0285 static inline struct gpio_desc *__must_check
0286 devm_gpiod_get_optional(struct device *dev, const char *con_id,
0287 enum gpiod_flags flags)
0288 {
0289 return NULL;
0290 }
0291
0292 static inline struct gpio_desc *__must_check
0293 devm_gpiod_get_index_optional(struct device *dev, const char *con_id,
0294 unsigned int index, enum gpiod_flags flags)
0295 {
0296 return NULL;
0297 }
0298
0299 static inline struct gpio_descs *__must_check
0300 devm_gpiod_get_array(struct device *dev, const char *con_id,
0301 enum gpiod_flags flags)
0302 {
0303 return ERR_PTR(-ENOSYS);
0304 }
0305
0306 static inline struct gpio_descs *__must_check
0307 devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
0308 enum gpiod_flags flags)
0309 {
0310 return NULL;
0311 }
0312
0313 static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc)
0314 {
0315 might_sleep();
0316
0317
0318 WARN_ON(desc);
0319 }
0320
0321 static inline void devm_gpiod_put_array(struct device *dev,
0322 struct gpio_descs *descs)
0323 {
0324 might_sleep();
0325
0326
0327 WARN_ON(descs);
0328 }
0329
0330
0331 static inline int gpiod_get_direction(const struct gpio_desc *desc)
0332 {
0333
0334 WARN_ON(desc);
0335 return -ENOSYS;
0336 }
0337 static inline int gpiod_direction_input(struct gpio_desc *desc)
0338 {
0339
0340 WARN_ON(desc);
0341 return -ENOSYS;
0342 }
0343 static inline int gpiod_direction_output(struct gpio_desc *desc, int value)
0344 {
0345
0346 WARN_ON(desc);
0347 return -ENOSYS;
0348 }
0349 static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value)
0350 {
0351
0352 WARN_ON(desc);
0353 return -ENOSYS;
0354 }
0355 static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
0356 unsigned long flags)
0357 {
0358 WARN_ON(desc);
0359 return -ENOSYS;
0360 }
0361 static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
0362 unsigned long flags)
0363 {
0364 WARN_ON(desc);
0365 return -ENOSYS;
0366 }
0367 static inline int gpiod_get_value(const struct gpio_desc *desc)
0368 {
0369
0370 WARN_ON(desc);
0371 return 0;
0372 }
0373 static inline int gpiod_get_array_value(unsigned int array_size,
0374 struct gpio_desc **desc_array,
0375 struct gpio_array *array_info,
0376 unsigned long *value_bitmap)
0377 {
0378
0379 WARN_ON(desc_array);
0380 return 0;
0381 }
0382 static inline void gpiod_set_value(struct gpio_desc *desc, int value)
0383 {
0384
0385 WARN_ON(desc);
0386 }
0387 static inline int gpiod_set_array_value(unsigned int array_size,
0388 struct gpio_desc **desc_array,
0389 struct gpio_array *array_info,
0390 unsigned long *value_bitmap)
0391 {
0392
0393 WARN_ON(desc_array);
0394 return 0;
0395 }
0396 static inline int gpiod_get_raw_value(const struct gpio_desc *desc)
0397 {
0398
0399 WARN_ON(desc);
0400 return 0;
0401 }
0402 static inline int gpiod_get_raw_array_value(unsigned int array_size,
0403 struct gpio_desc **desc_array,
0404 struct gpio_array *array_info,
0405 unsigned long *value_bitmap)
0406 {
0407
0408 WARN_ON(desc_array);
0409 return 0;
0410 }
0411 static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value)
0412 {
0413
0414 WARN_ON(desc);
0415 }
0416 static inline int gpiod_set_raw_array_value(unsigned int array_size,
0417 struct gpio_desc **desc_array,
0418 struct gpio_array *array_info,
0419 unsigned long *value_bitmap)
0420 {
0421
0422 WARN_ON(desc_array);
0423 return 0;
0424 }
0425
0426 static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc)
0427 {
0428
0429 WARN_ON(desc);
0430 return 0;
0431 }
0432 static inline int gpiod_get_array_value_cansleep(unsigned int array_size,
0433 struct gpio_desc **desc_array,
0434 struct gpio_array *array_info,
0435 unsigned long *value_bitmap)
0436 {
0437
0438 WARN_ON(desc_array);
0439 return 0;
0440 }
0441 static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
0442 {
0443
0444 WARN_ON(desc);
0445 }
0446 static inline int gpiod_set_array_value_cansleep(unsigned int array_size,
0447 struct gpio_desc **desc_array,
0448 struct gpio_array *array_info,
0449 unsigned long *value_bitmap)
0450 {
0451
0452 WARN_ON(desc_array);
0453 return 0;
0454 }
0455 static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc)
0456 {
0457
0458 WARN_ON(desc);
0459 return 0;
0460 }
0461 static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size,
0462 struct gpio_desc **desc_array,
0463 struct gpio_array *array_info,
0464 unsigned long *value_bitmap)
0465 {
0466
0467 WARN_ON(desc_array);
0468 return 0;
0469 }
0470 static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc,
0471 int value)
0472 {
0473
0474 WARN_ON(desc);
0475 }
0476 static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size,
0477 struct gpio_desc **desc_array,
0478 struct gpio_array *array_info,
0479 unsigned long *value_bitmap)
0480 {
0481
0482 WARN_ON(desc_array);
0483 return 0;
0484 }
0485
0486 static inline int gpiod_set_config(struct gpio_desc *desc, unsigned long config)
0487 {
0488
0489 WARN_ON(desc);
0490 return -ENOSYS;
0491 }
0492
0493 static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned int debounce)
0494 {
0495
0496 WARN_ON(desc);
0497 return -ENOSYS;
0498 }
0499
0500 static inline int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
0501 {
0502
0503 WARN_ON(desc);
0504 return -ENOSYS;
0505 }
0506
0507 static inline void gpiod_toggle_active_low(struct gpio_desc *desc)
0508 {
0509
0510 WARN_ON(desc);
0511 }
0512
0513 static inline int gpiod_is_active_low(const struct gpio_desc *desc)
0514 {
0515
0516 WARN_ON(desc);
0517 return 0;
0518 }
0519 static inline int gpiod_cansleep(const struct gpio_desc *desc)
0520 {
0521
0522 WARN_ON(desc);
0523 return 0;
0524 }
0525
0526 static inline int gpiod_to_irq(const struct gpio_desc *desc)
0527 {
0528
0529 WARN_ON(desc);
0530 return -EINVAL;
0531 }
0532
0533 static inline int gpiod_set_consumer_name(struct gpio_desc *desc,
0534 const char *name)
0535 {
0536
0537 WARN_ON(desc);
0538 return -EINVAL;
0539 }
0540
0541 static inline struct gpio_desc *gpio_to_desc(unsigned gpio)
0542 {
0543 return NULL;
0544 }
0545
0546 static inline int desc_to_gpio(const struct gpio_desc *desc)
0547 {
0548
0549 WARN_ON(desc);
0550 return -EINVAL;
0551 }
0552
0553
0554 struct fwnode_handle;
0555
0556 static inline
0557 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
0558 const char *propname, int index,
0559 enum gpiod_flags dflags,
0560 const char *label)
0561 {
0562 return ERR_PTR(-ENOSYS);
0563 }
0564
0565 static inline
0566 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
0567 const char *con_id, int index,
0568 enum gpiod_flags flags,
0569 const char *label)
0570 {
0571 return ERR_PTR(-ENOSYS);
0572 }
0573
0574 static inline
0575 struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
0576 struct fwnode_handle *fwnode,
0577 const char *con_id, int index,
0578 enum gpiod_flags flags,
0579 const char *label)
0580 {
0581 return ERR_PTR(-ENOSYS);
0582 }
0583
0584 #endif
0585
0586 static inline
0587 struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
0588 struct fwnode_handle *fwnode,
0589 const char *con_id,
0590 enum gpiod_flags flags,
0591 const char *label)
0592 {
0593 return devm_fwnode_gpiod_get_index(dev, fwnode, con_id, 0,
0594 flags, label);
0595 }
0596
0597 static inline
0598 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
0599 const char *con_id, int index,
0600 struct fwnode_handle *child,
0601 enum gpiod_flags flags,
0602 const char *label)
0603 {
0604 return devm_fwnode_gpiod_get_index(dev, child, con_id, index,
0605 flags, label);
0606 }
0607
0608 static inline
0609 struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
0610 const char *con_id,
0611 struct fwnode_handle *child,
0612 enum gpiod_flags flags,
0613 const char *label)
0614 {
0615 return devm_fwnode_gpiod_get_index(dev, child, con_id, 0, flags, label);
0616 }
0617
0618 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO)
0619 struct device_node;
0620
0621 struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
0622 const char *propname, int index,
0623 enum gpiod_flags dflags,
0624 const char *label);
0625
0626 #else
0627
0628 struct device_node;
0629
0630 static inline
0631 struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
0632 const char *propname, int index,
0633 enum gpiod_flags dflags,
0634 const char *label)
0635 {
0636 return ERR_PTR(-ENOSYS);
0637 }
0638
0639 #endif
0640
0641 #ifdef CONFIG_GPIOLIB
0642 struct device_node;
0643
0644 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
0645 const struct device_node *node,
0646 const char *propname, int index,
0647 enum gpiod_flags dflags,
0648 const char *label);
0649
0650 #else
0651
0652 struct device_node;
0653
0654 static inline
0655 struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
0656 const struct device_node *node,
0657 const char *propname, int index,
0658 enum gpiod_flags dflags,
0659 const char *label)
0660 {
0661 return ERR_PTR(-ENOSYS);
0662 }
0663
0664 #endif
0665
0666 struct acpi_gpio_params {
0667 unsigned int crs_entry_index;
0668 unsigned int line_index;
0669 bool active_low;
0670 };
0671
0672 struct acpi_gpio_mapping {
0673 const char *name;
0674 const struct acpi_gpio_params *data;
0675 unsigned int size;
0676
0677
0678 #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
0679
0680
0681
0682
0683
0684
0685 #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1)
0686
0687 #define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER BIT(2)
0688
0689 unsigned int quirks;
0690 };
0691
0692 struct acpi_device;
0693
0694 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI)
0695
0696 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
0697 const struct acpi_gpio_mapping *gpios);
0698 void acpi_dev_remove_driver_gpios(struct acpi_device *adev);
0699
0700 int devm_acpi_dev_add_driver_gpios(struct device *dev,
0701 const struct acpi_gpio_mapping *gpios);
0702
0703 struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label);
0704
0705 #else
0706
0707 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
0708 const struct acpi_gpio_mapping *gpios)
0709 {
0710 return -ENXIO;
0711 }
0712 static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
0713
0714 static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
0715 const struct acpi_gpio_mapping *gpios)
0716 {
0717 return -ENXIO;
0718 }
0719
0720 static inline struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin,
0721 char *label)
0722 {
0723 return ERR_PTR(-ENOSYS);
0724 }
0725
0726 #endif
0727
0728
0729 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
0730
0731 int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
0732 int gpiod_export_link(struct device *dev, const char *name,
0733 struct gpio_desc *desc);
0734 void gpiod_unexport(struct gpio_desc *desc);
0735
0736 #else
0737
0738 static inline int gpiod_export(struct gpio_desc *desc,
0739 bool direction_may_change)
0740 {
0741 return -ENOSYS;
0742 }
0743
0744 static inline int gpiod_export_link(struct device *dev, const char *name,
0745 struct gpio_desc *desc)
0746 {
0747 return -ENOSYS;
0748 }
0749
0750 static inline void gpiod_unexport(struct gpio_desc *desc)
0751 {
0752 }
0753
0754 #endif
0755
0756 #endif