Re: [PATCH 5/8] x86, mce: introduce mce_sysdev_init()

From: Hidetoshi Seto
Date: Mon Jun 20 2011 - 00:48:38 EST


(2011/06/18 1:32), Borislav Petkov wrote:
>> @@ -1953,6 +1953,39 @@ static __cpuinit void mce_sysdev_remove(unsigned int cpu)
>> cpumask_clear_cpu(cpu, mce_sysdev_initialized);
>> }
>>
>> +static __init int mce_sysdev_init(void)
>> +{
>> + int err, i;
>> +
>> + zalloc_cpumask_var(&mce_sysdev_initialized, GFP_KERNEL);
>> +
>> + /* init attributes for each mce_banks */
>> + for (i = 0; i < banks; i++) {
>> + struct mce_bank *b = &mce_banks[i];
>> + struct sysdev_attribute *a = &b->attr;
>> +
>> + sysfs_attr_init(&a->attr);
>> + a->attr.name = b->attrname;
>> + snprintf(b->attrname, ATTR_LEN, "bank%d", i);
>> +
>> + a->attr.mode = 0644;
>> + a->show = show_bank;
>> + a->store = set_bank;
>> + }
>> +
>> + err = sysdev_class_register(&mce_sysdev_class);
>> + if (err)
>> + return err;
>> +
>> + for_each_online_cpu(i) {
>> + err = mce_sysdev_create(i);
>> + if (err)
>> + return err;
>> + }
>
> Yeah, let's handle the error case here and unwind to a sane state:
>
> if (err)
> goto sysdev_unwind;
> ...
>
> sysdev_unwind:
> while (--i > 0)
> mce_sysdev_remove(i);
>

Nice!
I'll do it.


Thanks,
H.Seto

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/