drivers/net/ethernet/intel/e1000e/param.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/e1000e/param.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/e1000e/param.c
Extension
.c
Size
13298 bytes
Lines
528
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct e1000_option {
	enum { enable_option, range_option, list_option } type;
	const char *name;
	const char *err;
	int def;
	union {
		/* range_option info */
		struct {
			int min;
			int max;
		} r;
		/* list_option info */
		struct {
			int nr;
			struct e1000_opt_list {
				int i;
				char *str;
			} *p;
		} l;
	} arg;
};

static int e1000_validate_option(unsigned int *value,
				 const struct e1000_option *opt,
				 struct e1000_adapter *adapter)
{
	if (*value == OPTION_UNSET) {
		*value = opt->def;
		return 0;
	}

	switch (opt->type) {
	case enable_option:
		switch (*value) {
		case OPTION_ENABLED:
			dev_info(&adapter->pdev->dev, "%s Enabled\n",
				 opt->name);
			return 0;
		case OPTION_DISABLED:
			dev_info(&adapter->pdev->dev, "%s Disabled\n",
				 opt->name);
			return 0;
		}
		break;
	case range_option:
		if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) {
			dev_info(&adapter->pdev->dev, "%s set to %i\n",
				 opt->name, *value);
			return 0;
		}
		break;
	case list_option: {
		int i;
		struct e1000_opt_list *ent;

		for (i = 0; i < opt->arg.l.nr; i++) {
			ent = &opt->arg.l.p[i];
			if (*value == ent->i) {
				if (ent->str[0] != '\0')
					dev_info(&adapter->pdev->dev, "%s\n",
						 ent->str);
				return 0;
			}
		}
	}
		break;
	default:
		BUG();
	}

	dev_info(&adapter->pdev->dev, "Invalid %s value specified (%i) %s\n",
		 opt->name, *value, opt->err);
	*value = opt->def;
	return -1;
}

/**
 * e1000e_check_options - Range Checking for Command Line Parameters
 * @adapter: board private structure
 *
 * This routine checks all command line parameters for valid user
 * input.  If an invalid value is given, or if no user specified
 * value exists, a default value is used.  The final value is stored
 * in a variable in the adapter structure.
 **/
void e1000e_check_options(struct e1000_adapter *adapter)
{
	struct e1000_hw *hw = &adapter->hw;
	int bd = adapter->bd_number;

Annotation

Implementation Notes