]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/i386/kernel/microcode.c
[PATCH] Regression in 2.6.19-rc microcode driver
[linux-2.6-omap-h63xx.git] / arch / i386 / kernel / microcode.c
index 467901ebb99230f4c5555b9fb56a4acdaa7cc374..23f5984d06540f9c42183b232ad98e488b5218ae 100644 (file)
@@ -187,8 +187,7 @@ static int microcode_sanity_check(void *mc)
 
        total_size = get_totalsize(mc_header);
        data_size = get_datasize(mc_header);
-       if ((data_size + MC_HEADER_SIZE > total_size)
-               || (data_size < DEFAULT_UCODE_DATASIZE)) {
+       if (data_size + MC_HEADER_SIZE > total_size) {
                printk(KERN_ERR "microcode: error! "
                        "Bad data size in microcode data file\n");
                return -EINVAL;
@@ -365,8 +364,7 @@ static long get_next_ucode(void **mc, long offset)
                return -EFAULT;
        }
        total_size = get_totalsize(&mc_header);
-       if ((offset + total_size > user_buffer_size)
-               || (total_size < DEFAULT_UCODE_TOTALSIZE)) {
+       if (offset + total_size > user_buffer_size) {
                printk(KERN_ERR "microcode: error! Bad total size in microcode "
                                "data file\n");
                return -EINVAL;
@@ -432,11 +430,6 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
 {
        ssize_t ret;
 
-       if (len < DEFAULT_UCODE_TOTALSIZE) {
-               printk(KERN_ERR "microcode: not enough data\n"); 
-               return -EINVAL;
-       }
-
        if ((len >> PAGE_SHIFT) > num_physpages) {
                printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages);
                return -EINVAL;
@@ -508,8 +501,7 @@ static long get_next_ucode_from_buffer(void **mc, void *buf,
        mc_header = (microcode_header_t *)(buf + offset);
        total_size = get_totalsize(mc_header);
 
-       if ((offset + total_size > size)
-               || (total_size < DEFAULT_UCODE_TOTALSIZE)) {
+       if (offset + total_size > size) {
                printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
                return -EINVAL;
        }
@@ -585,7 +577,7 @@ static void microcode_init_cpu(int cpu)
        set_cpus_allowed(current, cpumask_of_cpu(cpu));
        mutex_lock(&microcode_mutex);
        collect_cpu_info(cpu);
-       if (uci->valid)
+       if (uci->valid && system_state == SYSTEM_RUNNING)
                cpu_request_microcode(cpu);
        mutex_unlock(&microcode_mutex);
        set_cpus_allowed(current, old);
@@ -664,14 +656,18 @@ static struct attribute_group mc_attr_group = {
 
 static int mc_sysdev_add(struct sys_device *sys_dev)
 {
-       int cpu = sys_dev->id;
+       int err, cpu = sys_dev->id;
        struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 
        if (!cpu_online(cpu))
                return 0;
+
        pr_debug("Microcode:CPU %d added\n", cpu);
        memset(uci, 0, sizeof(*uci));
-       sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
+
+       err = sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
+       if (err)
+               return err;
 
        microcode_init_cpu(cpu);
        return 0;