Date: Tue, 11 Jul 2000 20:15:46 -0600 From: Warner Losh <imp@village.org> To: "Gary T. Corcoran" <gcorcoran@lucent.com> Cc: Mike Smith <msmith@FreeBSD.ORG>, FreeBSD Hackers <freebsd-hackers@FreeBSD.ORG> Subject: Re: Module parameters? Message-ID: <200007120215.UAA09795@harmony.village.org> In-Reply-To: Your message of "Tue, 11 Jul 2000 22:01:47 EDT." <396BD18B.9155B046@lucent.com> References: <396BD18B.9155B046@lucent.com> <396BC2C5.E89AD827@lucent.com> <200007112355.QAA00803@mass.osd.bsdi.com> <200007112352.RAA08554@harmony.village.org> <200007120148.TAA09591@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Something like the following? I know that there's more routines that need to be written. parse_int, parse_string, parse_bool, parse_enum should be enough. Comments? struct driver_param { const char *name; int (*fnp)(const char *, void *, void *); size_t off; void *argp; }; int get_parameters(device_t dev, struct driver_param *param, size_t nparam) { int i; caddr_t sc; const char *name; int unit; char buffer[1024]; const char *cp; sc = device_get_softc(dev); name = device_get_name(dev); unit = device_get_unit(dev); for (i = 0; i < nparam; i++) { snprintf(buffer, "hints.%s.%d.%s", name, unit, param[i].name); cp = getenv (buffer); if (cp) { if (param[i].fnp(cp, (void *) (sc + param[i].off), param[i].argp) == 0) continue; } snprintf(buffer, "hints.%s.%d.%s", name, -1, param[i].name); cp = getenv (buffer); if (cp) { if (param[i].fnp(cp, (void *) (sc + param[i].off), param[i].argp) == 0) continue; } } return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007120215.UAA09795>