Faster mtotdev() and htotdev()