tools/gpio/gpio-hammer.c

Source file repositories/reference/linux-study-clean/tools/gpio/gpio-hammer.c

File Facts

System
Linux kernel
Corpus path
tools/gpio/gpio-hammer.c
Extension
.c
Size
3876 bytes
Lines
177
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (c) {
		case 'c':
			loops = strtoul(optarg, NULL, 10);
			break;
		case 'n':
			device_name = optarg;
			break;
		case 'o':
			/*
			 * Avoid overflow. Do not immediately error, we want to
			 * be able to accurately report on the amount of times
			 * '-o' was given to give an accurate error message
			 */
			if (i < GPIOHANDLES_MAX)
				lines[i] = strtoul(optarg, NULL, 10);

			i++;
			break;
		case '?':
			print_usage();
			return -1;
		}
	}

	if (i >= GPIOHANDLES_MAX) {
		fprintf(stderr,
			"Only %d occurrences of '-o' are allowed, %d were found\n",
			GPIOHANDLES_MAX, i + 1);
		return -1;
	}

	num_lines = i;

	if (!device_name || !num_lines) {
		print_usage();
		return -1;
	}
	return hammer_device(device_name, lines, num_lines, loops);
}

Annotation

Implementation Notes