Subject: [PATCH] [acpi video] Clean up the device init path - Split POST querying into 2 functions - Call each of those, and video_bus_check() from video_bus_init() - Export that function only, and have that be the only one that's called from video_bus_add() Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/video/bus-device.c | 90 ++++++++++++++++++++++--------- drivers/acpi/drivers/video/bus-driver.c | 10 ++- drivers/acpi/drivers/video/video.h | 3 - 3 files changed, 73 insertions(+), 30 deletions(-) applies-to: ec932b550d28ff0a27a616f69173509da88d9137 f5f29bf8995b09890e63970c4f2f6f1a5cc2b758 diff --git a/drivers/acpi/drivers/video/bus-device.c b/drivers/acpi/drivers/video/bus-device.c index 232c138..a9f7cb8 100644 --- a/drivers/acpi/drivers/video/bus-device.c +++ b/drivers/acpi/drivers/video/bus-device.c @@ -129,13 +129,12 @@ void video_bus_check(struct acpi_video_b /** - * video_bus_post_options - Query the POST info on the bus + * get_post_options - Query the POST info on the bus * @vb: The ACPI video bus * * If the device is capable of POSTing, then get the integer mask * stored at _VPO, which will tell us what devices it is capable of - * executing the POST on, and get the integer at _GPD, which will - * tell us which device has been POSTed. + * executing the POST on. * * The device should always be capable of posting the on-board video, * but apparently the BIOS may incorrectly tell us that it cannot. @@ -146,40 +145,81 @@ void video_bus_check(struct acpi_video_b * later checked e.g. * if (options & 4) ... * Assuming that we want to keep that bit, the mask has changed to 0x7. + */ + +static int get_post_options(struct acpi_video_bus * vb) +{ + unsigned long o; + int ret; + + ret = get_int(vb->v_ad, "_VPO", &o); + + if (!ret) { + vb->v_post_options = o & 0x7; + + /* + * Make sure integrated video can post. + * Warn user if it cannot. + */ + if (!(o & ACPI_VIDEO_BUS_POST_INTEGRATED)) { + err("The motherboard VGA device is not"); + err("listed as a possible POST device."); + err("This indicates a BIOS bug."); + err("Please contact the manufacturer."); + err("options = %#01lx", o); + } + } + return ret; +} + + +/** + * get_post_info - Query which devices have been posted + * @vb: The ACPI device bus. * + * Get the integer at _GPD, which will tell us which device + * has been POSTed. * * Q: Should we really cache _GPD, or should we call it every time * we're asked for it? */ -int video_bus_post_options(struct acpi_video_bus * vb) +static int get_post_info(struct acpi_video_bus * vb) { - unsigned long o; - int ret = 0; + unsigned long info; + int ret; + + ret = get_int(vb->v_ad, "_GPD", &info); + if (!ret) + vb->v_post_id = info & 0x07; + return ret; +} - if (can_post(vb->v_ad)) { - ret = get_int(vb->v_ad, "_VPO", &o); - if (!ret) { - vb->v_post_options = o & 0x7; +int video_bus_init(struct acpi_video_bus * vb) +{ + int ret = 0; + + /* + * Determine the options enabled on this bus + */ + video_bus_check(vb); - /* - * Make sure integrated video can post. - * Warn user if it cannot. - */ - if (!(o & ACPI_VIDEO_BUS_POST_INTEGRATED)) { - err("The motherboard VGA device is not"); - err("listed as a possible POST device."); - err("This indicate a BIOS bug."); - err("Please contact the manufacturer."); - err("options = %#01lx", o); - } - } else + if (can_post(vb->v_ad)) { + /* + * Figure out which devices we can POST + */ + ret = get_post_options(vb); + if (ret) return ret; - ret = get_int(vb->v_ad, "_GPD", &o); - if (!ret) - vb->v_post_id = o & 0x7; + /* + * And figure out which devices have been POSTed + */ + ret = get_post_info(vb); + if (ret) + return ret; } + return ret; } diff --git a/drivers/acpi/drivers/video/bus-driver.c b/drivers/acpi/drivers/video/bus-driver.c index c49417d..f6cda3b 100644 --- a/drivers/acpi/drivers/video/bus-driver.c +++ b/drivers/acpi/drivers/video/bus-driver.c @@ -20,6 +20,7 @@ static int video_bus_probe(struct acpi_d static int video_bus_add(struct acpi_dev * ad) { struct acpi_video_bus * av; + int ret; av = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); if (!av) @@ -27,8 +28,11 @@ static int video_bus_add(struct acpi_dev av->v_ad = ad; - video_bus_check(av); - video_bus_post_options(av); + ret = video_bus_init(av); + if (ret) { + kfree(av); + return ret; + } dev_set_drvdata(&ad->dev, av); @@ -37,7 +41,7 @@ static int video_bus_add(struct acpi_dev av->v_can_switch ? "multi-head" : "", av->v_has_rom ? "rom" : "", av->v_can_post ? "post" : ""); - return 0; + return ret; } static int video_bus_remove(struct acpi_dev * ad) diff --git a/drivers/acpi/drivers/video/video.h b/drivers/acpi/drivers/video/video.h index f4635a1..a2988f3 100644 --- a/drivers/acpi/drivers/video/video.h +++ b/drivers/acpi/drivers/video/video.h @@ -29,5 +29,4 @@ struct acpi_video_bus { extern int video_bus_test(struct acpi_dev * ad); -extern void video_bus_check(struct acpi_video_bus * vb); -extern int video_bus_post_options(struct acpi_video_bus * vb); +extern int video_bus_init(struct acpi_video_bus * vb); --- 0.99.9.GIT