drivers/char/ipmi/ipmi_si_hardcode.c

Source file repositories/reference/linux-study-clean/drivers/char/ipmi/ipmi_si_hardcode.c

File Facts

System
Linux kernel
Corpus path
drivers/char/ipmi/ipmi_si_hardcode.c
Extension
.c
Size
5287 bytes
Lines
154
Domain
Driver Families
Bucket
drivers/char
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

if (t < 0) {
			pr_warn("Interface type specified for interface %d, was invalid: %s\n",
				i, si_type_str);
			return;
		}
		p.type = t;
	}

	p.regsize = regsizes[i];
	p.regspacing = regspacings[i];
	p.slave_addr = slave_addrs[i];
	p.addr_source = SI_HARDCODED;
	p.regshift = regshifts[i];
	p.addr = addr;
	p.space = addr_space;

	ipmi_platform_add("hardcode-ipmi-si", i, &p);
}

void __init ipmi_hardcode_init(void)
{
	unsigned int i;
	char *str;
	char *si_type[SI_MAX_PARMS];

	memset(si_type, 0, sizeof(si_type));

	/* Parse out the si_type string into its components. */
	str = si_type_str;
	if (*str != '\0') {
		for (i = 0; (i < SI_MAX_PARMS) && (*str != '\0'); i++) {
			si_type[i] = str;
			str = strchr(str, ',');
			if (str) {
				*str = '\0';
				str++;
			} else {
				break;
			}
		}
	}

	for (i = 0; i < SI_MAX_PARMS; i++) {
		if (i < num_ports && ports[i])
			ipmi_hardcode_init_one(si_type[i], i, ports[i],
					       IPMI_IO_ADDR_SPACE);
		if (i < num_addrs && addrs[i])
			ipmi_hardcode_init_one(si_type[i], i, addrs[i],
					       IPMI_MEM_ADDR_SPACE);
	}
}


void ipmi_si_hardcode_exit(void)
{
	ipmi_remove_platform_device_by_name("hardcode-ipmi-si");
}

/*
 * Returns true of the given address exists as a hardcoded address,
 * false if not.
 */
int ipmi_si_hardcode_match(int addr_space, unsigned long addr)
{
	unsigned int i;

	if (addr_space == IPMI_IO_ADDR_SPACE) {
		for (i = 0; i < num_ports; i++) {
			if (ports[i] == addr)
				return 1;
		}
	} else {
		for (i = 0; i < num_addrs; i++) {
			if (addrs[i] == addr)
				return 1;
		}
	}

	return 0;
}

Annotation

Implementation Notes