Hello Steven, Le 12/07/12 06:31, Steven J. Hill a écrit : [snip]
+ +#define __BUILD_CP0_SYSFS(reg) \ +static DEFINE_PER_CPU(unsigned int, cpu_config##reg); \ +static ssize_t show_config##reg(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ \ + struct cpu *cpu = container_of(dev, struct cpu, dev); \ + int n = snprintf(buf, PAGE_SIZE-2, "%x\n", \ + per_cpu(cpu_config##reg, cpu->dev.id)); \ + return n; \ +} \ +static DEVICE_ATTR(config##reg, 0444, show_config##reg, NULL); + +__BUILD_CP0_SYSFS(0) +__BUILD_CP0_SYSFS(1) +__BUILD_CP0_SYSFS(2) +__BUILD_CP0_SYSFS(3) +__BUILD_CP0_SYSFS(4) +__BUILD_CP0_SYSFS(5) +__BUILD_CP0_SYSFS(6) +__BUILD_CP0_SYSFS(7) + +static void read_c0_registers(void *arg) +{ + struct device *dev = get_cpu_device(smp_processor_id()); + struct cpu *cpu; + int ok; + + if (dev != NULL) { + cpu = container_of(dev, struct cpu, dev); + per_cpu(cpu_config0, cpu->dev.id) = read_c0_config(); + device_create_file(dev, &dev_attr_config0); + ok = per_cpu(cpu_config0, cpu->dev.id) & MIPS_CONF_M; + } else
Is there any reason you are not using a macro here too? -- Florian