diff options
author | Konstantin Ozerkov <kozerkov@parallels.com> | 2011-11-09 10:28:54 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-11-09 12:33:07 -0500 |
commit | 65c397d6b58d5e401bee7c24608d3a33a220a63a (patch) | |
tree | 20279d96327c3983dae721169dc501e73f7d0af4 | |
parent | 55c0008be67a27944b6705251d9a8d4c56c67701 (diff) |
ALSA: intel8x0: move virtual environment detection code into one place
This is refactoring patch: preparation for add improved detection code.
Now all detection code placed in one place.
Signed-off-by: Konstantin Ozerkov <kozerkov@parallels.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/intel8x0.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index c3b9bd0e188e..2d4bb4c9a030 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -2937,6 +2937,24 @@ static unsigned int sis_codec_bits[3] = { | |||
2937 | ICH_PCR, ICH_SCR, ICH_SIS_TCR | 2937 | ICH_PCR, ICH_SCR, ICH_SIS_TCR |
2938 | }; | 2938 | }; |
2939 | 2939 | ||
2940 | static int __devinit snd_intel8x0_inside_vm(void) | ||
2941 | { | ||
2942 | int result = inside_vm; | ||
2943 | |||
2944 | if (result < 0) { | ||
2945 | /* detect KVM and Parallels virtual environments */ | ||
2946 | result = kvm_para_available(); | ||
2947 | #if defined(__i386__) || defined(__x86_64__) | ||
2948 | result = result || boot_cpu_has(X86_FEATURE_HYPERVISOR); | ||
2949 | #endif | ||
2950 | } | ||
2951 | |||
2952 | if (result) | ||
2953 | printk(KERN_INFO "intel8x0: enable KVM optimization\n"); | ||
2954 | |||
2955 | return result; | ||
2956 | } | ||
2957 | |||
2940 | static int __devinit snd_intel8x0_create(struct snd_card *card, | 2958 | static int __devinit snd_intel8x0_create(struct snd_card *card, |
2941 | struct pci_dev *pci, | 2959 | struct pci_dev *pci, |
2942 | unsigned long device_type, | 2960 | unsigned long device_type, |
@@ -3004,9 +3022,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card, | |||
3004 | if (xbox) | 3022 | if (xbox) |
3005 | chip->xbox = 1; | 3023 | chip->xbox = 1; |
3006 | 3024 | ||
3007 | chip->inside_vm = inside_vm; | 3025 | chip->inside_vm = snd_intel8x0_inside_vm(); |
3008 | if (inside_vm) | ||
3009 | printk(KERN_INFO "intel8x0: enable KVM optimization\n"); | ||
3010 | 3026 | ||
3011 | if (pci->vendor == PCI_VENDOR_ID_INTEL && | 3027 | if (pci->vendor == PCI_VENDOR_ID_INTEL && |
3012 | pci->device == PCI_DEVICE_ID_INTEL_440MX) | 3028 | pci->device == PCI_DEVICE_ID_INTEL_440MX) |
@@ -3250,14 +3266,6 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, | |||
3250 | buggy_irq = 0; | 3266 | buggy_irq = 0; |
3251 | } | 3267 | } |
3252 | 3268 | ||
3253 | if (inside_vm < 0) { | ||
3254 | /* detect KVM and Parallels virtual environments */ | ||
3255 | inside_vm = kvm_para_available(); | ||
3256 | #if defined(__i386__) || defined(__x86_64__) | ||
3257 | inside_vm = inside_vm || boot_cpu_has(X86_FEATURE_HYPERVISOR); | ||
3258 | #endif | ||
3259 | } | ||
3260 | |||
3261 | if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, | 3269 | if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, |
3262 | &chip)) < 0) { | 3270 | &chip)) < 0) { |
3263 | snd_card_free(card); | 3271 | snd_card_free(card); |