Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
match.c
Go to the documentation of this file.
1 #include <asm/cpu_device_id.h>
2 #include <asm/processor.h>
3 #include <linux/cpu.h>
4 #include <linux/module.h>
5 #include <linux/slab.h>
6 
31 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
32 {
33  const struct x86_cpu_id *m;
34  struct cpuinfo_x86 *c = &boot_cpu_data;
35 
36  for (m = match; m->vendor | m->family | m->model | m->feature; m++) {
37  if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)
38  continue;
39  if (m->family != X86_FAMILY_ANY && c->x86 != m->family)
40  continue;
41  if (m->model != X86_MODEL_ANY && c->x86_model != m->model)
42  continue;
43  if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
44  continue;
45  return m;
46  }
47  return NULL;
48 }
50 
52  struct device_attribute *attr,
53  char *bufptr)
54 {
55  int size = PAGE_SIZE;
56  int i, n;
57  char *buf = bufptr;
58 
59  n = snprintf(buf, size, "x86cpu:vendor:%04X:family:%04X:"
60  "model:%04X:feature:",
61  boot_cpu_data.x86_vendor,
62  boot_cpu_data.x86,
63  boot_cpu_data.x86_model);
64  size -= n;
65  buf += n;
66  size -= 1;
67  for (i = 0; i < NCAPINTS*32; i++) {
68  if (boot_cpu_has(i)) {
69  n = snprintf(buf, size, ",%04X", i);
70  if (n >= size) {
71  WARN(1, "x86 features overflow page\n");
72  break;
73  }
74  size -= n;
75  buf += n;
76  }
77  }
78  *buf++ = '\n';
79  return buf - bufptr;
80 }
81 
83 {
84  char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
85  if (buf) {
87  add_uevent_var(env, "MODALIAS=%s", buf);
88  kfree(buf);
89  }
90  return 0;
91 }