Listing 4. Controlling the Power of a PCI Slot

buff = kmalloc (count + 1, GFP_KERNEL); if (!buff)
        return -ENOMEM;
memset (buff, 0x00, count + 1);

if (copy_from_user ((void *)buff,
                    (void *)ubuff, count)) {
        retval = -EFAULT;
        goto exit;
}

lpower = simple_strtoul (buff, NULL, 10);
power = (u8)(lpower & 0xff);

switch (power) {
case 0:
        retval = slot->ops->disable_slot(slot);
        break;

case 1:
        retval = slot->ops->enable_slot(slot);
        break;

default:
        err ("Illegal value specified for power\n");
        retval = -EFAULT;
}