diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /include/linux/switch.h | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'include/linux/switch.h')
| -rw-r--r-- | include/linux/switch.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/switch.h b/include/linux/switch.h new file mode 100644 index 00000000000..3e4c748e343 --- /dev/null +++ b/include/linux/switch.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * Switch class driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Google, Inc. | ||
| 5 | * Author: Mike Lockwood <lockwood@android.com> | ||
| 6 | * | ||
| 7 | * This software is licensed under the terms of the GNU General Public | ||
| 8 | * License version 2, as published by the Free Software Foundation, and | ||
| 9 | * may be copied, distributed, and modified under those terms. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef __LINUX_SWITCH_H__ | ||
| 19 | #define __LINUX_SWITCH_H__ | ||
| 20 | |||
| 21 | struct switch_dev { | ||
| 22 | const char *name; | ||
| 23 | struct device *dev; | ||
| 24 | int index; | ||
| 25 | int state; | ||
| 26 | |||
| 27 | ssize_t (*print_name)(struct switch_dev *sdev, char *buf); | ||
| 28 | ssize_t (*print_state)(struct switch_dev *sdev, char *buf); | ||
| 29 | }; | ||
| 30 | |||
| 31 | struct gpio_switch_platform_data { | ||
| 32 | const char *name; | ||
| 33 | unsigned gpio; | ||
| 34 | |||
| 35 | /* if NULL, switch_dev.name will be printed */ | ||
| 36 | const char *name_on; | ||
| 37 | const char *name_off; | ||
| 38 | /* if NULL, "0" or "1" will be printed */ | ||
| 39 | const char *state_on; | ||
| 40 | const char *state_off; | ||
| 41 | }; | ||
| 42 | |||
| 43 | extern int switch_dev_register(struct switch_dev *sdev); | ||
| 44 | extern void switch_dev_unregister(struct switch_dev *sdev); | ||
| 45 | |||
| 46 | static inline int switch_get_state(struct switch_dev *sdev) | ||
| 47 | { | ||
| 48 | return sdev->state; | ||
| 49 | } | ||
| 50 | |||
| 51 | extern void switch_set_state(struct switch_dev *sdev, int state); | ||
| 52 | |||
| 53 | #endif /* __LINUX_SWITCH_H__ */ | ||
