From c665a74def4b0ba5f52d21f8bd5314cb7addd0a4 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 10 May 2013 19:18:34 +0200 Subject: [PATCH] Fix WARNING on Linux 3.9 (Closes GH-55) Patch by amonakov. This stops the following error: bbswitch: disabling discrete graphics ------------[ cut here ]------------ WARNING: at drivers/pci/pci.c:1393 pci_disable_device+0x84/0x90() Hardware name: B7130 [44B blob data] Modules linked in: bbswitch(O+) ip_set_hash_ip xt_set ip_set nfnetlink ipt_REJECT xt_recent xt_tcpudp xt_owner nf_conntrack_ipv6 nf_defrag Pid: 2653, comm: modprobe Tainted: G O 3.9.1-1-custom #1 Call Trace: [] warn_slowpath_common+0x70/0xa0 [] warn_slowpath_fmt+0x4c/0x50 [] ? pci_bus_write_config_word+0x1c/0x20 [] pci_disable_device+0x84/0x90 [] bbswitch_off+0xa6/0x1d0 [bbswitch] [] bbswitch_init+0x248/0x1000 [bbswitch] [] ? 0xffffffffa0103fff [] do_one_initcall+0x10a/0x160 [] load_module+0x1d40/0x24a0 [] ? store_uevent+0x40/0x40 [] sys_finit_module+0x7e/0x80 [] system_call_fastpath+0x1a/0x1f ---[ end trace 1b312a60aa1b0ed6 ]--- pci 0000:01:00.0: Refused to change power state, currently in D0 --- bbswitch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bbswitch.c b/bbswitch.c index 77ad752..39388b5 100644 --- a/bbswitch.c +++ b/bbswitch.c @@ -456,6 +456,12 @@ static int __init bbswitch_init(void) { dis_dev_get(); + if (!is_card_disabled()) { + /* We think the card is enabled, so ensure the kernel does as well */ + if (pci_enable_device(dis_dev)) + pr_warn("failed to enable %s\n", dev_name(&dis_dev->dev)); + } + if (load_state == CARD_ON) bbswitch_on(); else if (load_state == CARD_OFF)