From 9c8acae4f7ca027b2b3315410db2952d7662dafd Mon Sep 17 00:00:00 2001 From: mdodd Date: Mon, 28 Oct 2002 02:00:09 +0000 Subject: [PATCH] Handle hints for the atspeaker device. Document same. --- sys/dev/speaker/spkr.c | 26 +++++++++++++++++++++++++- sys/i386/conf/NOTES | 2 ++ sys/i386/isa/spkr.c | 26 +++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index 522e6c60c09c..e560fe694341 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -602,12 +602,36 @@ static dev_t atspeaker_dev; static int atspeaker_probe(device_t dev) { - return(ISA_PNP_PROBE(device_get_parent(dev), dev, atspeaker_ids)); + int error; + + error = ISA_PNP_PROBE(device_get_parent(dev), dev, atspeaker_ids); + + /* PnP match */ + if (error == 0) + return (0); + + /* No match */ + if (error == ENXIO) + return (ENXIO); + + /* Not configured by hints. */ + if (strncmp(device_get_name(dev), "atspeaker", 9)) + return (ENXIO); + + device_set_desc(dev, "AT speaker"); + + return (0); } static int atspeaker_attach(device_t dev) { + + if (atspeaker_dev) { + device_printf(dev, "Already attached!\n"); + return (ENXIO); + } + atspeaker_dev = make_dev(&spkr_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "speaker"); return (0); diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index a65e29d0991f..d863da686f2a 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -245,6 +245,8 @@ options CLK_USE_TSC_CALIBRATION # MISCELLANEOUS DEVICES AND OPTIONS device speaker #Play IBM BASIC-style noises out your speaker +hint.atspeaker.0.at="isa" +hint.atspeaker.0.port="0x61" device gzip #Exec gzipped a.out's. REQUIRES COMPAT_AOUT! device apm_saver # Requires APM diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c index 522e6c60c09c..e560fe694341 100644 --- a/sys/i386/isa/spkr.c +++ b/sys/i386/isa/spkr.c @@ -602,12 +602,36 @@ static dev_t atspeaker_dev; static int atspeaker_probe(device_t dev) { - return(ISA_PNP_PROBE(device_get_parent(dev), dev, atspeaker_ids)); + int error; + + error = ISA_PNP_PROBE(device_get_parent(dev), dev, atspeaker_ids); + + /* PnP match */ + if (error == 0) + return (0); + + /* No match */ + if (error == ENXIO) + return (ENXIO); + + /* Not configured by hints. */ + if (strncmp(device_get_name(dev), "atspeaker", 9)) + return (ENXIO); + + device_set_desc(dev, "AT speaker"); + + return (0); } static int atspeaker_attach(device_t dev) { + + if (atspeaker_dev) { + device_printf(dev, "Already attached!\n"); + return (ENXIO); + } + atspeaker_dev = make_dev(&spkr_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "speaker"); return (0);