优质代码-动态设备号

以下代码,是计算动态设备号的:

    if (misc->minor == MISC_DYNAMIC_MINOR) {
        int i = DYNAMIC_MINORS;
        while (--i >= 0)
            if ( (misc_minors[i>>3] & (1 << (i&7))) == 0)
                break;
        if (i<0) {
            mutex_unlock(&misc_mtx);
            return -EBUSY;
        }
        misc->minor = i;
    }

    if (misc->minor < DYNAMIC_MINORS)
        misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);

你可能感兴趣的:(优质代码-动态设备号)