gpioctl.c (cfe30d02adda7c3b5c76156ac52d50d8cab325d9) | gpioctl.c (22e3858c246fd280db467292d0828875f0068e4c) |
---|---|
1/*- 2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> 29__FBSDID("$FreeBSD$"); 30 31#include <fcntl.h> 32#include <getopt.h> | 1/*- 2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> 29__FBSDID("$FreeBSD$"); 30 31#include <fcntl.h> 32#include <getopt.h> |
33#include <paths.h> |
|
33#include <stdio.h> 34#include <stdarg.h> 35#include <stdlib.h> 36#include <string.h> 37#include <unistd.h> 38 39#include <sys/gpio.h> 40 --- 17 unchanged lines hidden (view full) --- 58}; 59 60int str2cap(const char *str); 61 62static void 63usage(void) 64{ 65 fprintf(stderr, "Usage:\n"); | 34#include <stdio.h> 35#include <stdarg.h> 36#include <stdlib.h> 37#include <string.h> 38#include <unistd.h> 39 40#include <sys/gpio.h> 41 --- 17 unchanged lines hidden (view full) --- 59}; 60 61int str2cap(const char *str); 62 63static void 64usage(void) 65{ 66 fprintf(stderr, "Usage:\n"); |
66 fprintf(stderr, "\tgpioctl -f ctldev -l [-v]\n"); 67 fprintf(stderr, "\tgpioctl -f ctldev -t pin\n"); 68 fprintf(stderr, "\tgpioctl -f ctldev -c pin flag ...\n"); 69 fprintf(stderr, "\tgpioctl -f ctldev pin [0|1]\n"); | 67 fprintf(stderr, "\tgpioctl [-f ctldev] -l [-v]\n"); 68 fprintf(stderr, "\tgpioctl [-f ctldev] -t pin\n"); 69 fprintf(stderr, "\tgpioctl [-f ctldev] -c pin flag ...\n"); 70 fprintf(stderr, "\tgpioctl [-f ctldev] pin [0|1]\n"); |
70 exit(1); 71} 72 73static const char * 74cap2str(uint32_t cap) 75{ 76 struct flag_desc * pdesc = gpio_flags; 77 while (pdesc->name) { --- 102 unchanged lines hidden (view full) --- 180} 181 182int 183main(int argc, char **argv) 184{ 185 int i; 186 struct gpio_pin pin; 187 struct gpio_req req; | 71 exit(1); 72} 73 74static const char * 75cap2str(uint32_t cap) 76{ 77 struct flag_desc * pdesc = gpio_flags; 78 while (pdesc->name) { --- 102 unchanged lines hidden (view full) --- 181} 182 183int 184main(int argc, char **argv) 185{ 186 int i; 187 struct gpio_pin pin; 188 struct gpio_req req; |
189 char defctlfile[] = _PATH_DEVGPIOC "0"; |
|
188 char *ctlfile = NULL; 189 int pinn, pinv, fd, ch; 190 int flags, flag, ok; 191 int config, toggle, verbose, list; 192 193 config = toggle = verbose = list = pinn = 0; 194 195 while ((ch = getopt(argc, argv, "c:f:lt:v")) != -1) { --- 25 unchanged lines hidden (view full) --- 221 } 222 } 223 argv += optind; 224 argc -= optind; 225 for (i = 0; i < argc; i++) 226 printf("%d/%s\n", i, argv[i]); 227 228 if (ctlfile == NULL) | 190 char *ctlfile = NULL; 191 int pinn, pinv, fd, ch; 192 int flags, flag, ok; 193 int config, toggle, verbose, list; 194 195 config = toggle = verbose = list = pinn = 0; 196 197 while ((ch = getopt(argc, argv, "c:f:lt:v")) != -1) { --- 25 unchanged lines hidden (view full) --- 223 } 224 } 225 argv += optind; 226 argc -= optind; 227 for (i = 0; i < argc; i++) 228 printf("%d/%s\n", i, argv[i]); 229 230 if (ctlfile == NULL) |
229 fail("No gpioctl device provided\n"); | 231 ctlfile = defctlfile; |
230 231 fd = open(ctlfile, O_RDONLY); 232 if (fd < 0) { 233 perror("open"); 234 exit(1); 235 } 236 237 if (list) { --- 86 unchanged lines hidden --- | 232 233 fd = open(ctlfile, O_RDONLY); 234 if (fd < 0) { 235 perror("open"); 236 exit(1); 237 } 238 239 if (list) { --- 86 unchanged lines hidden --- |