Path: blob/master/drivers/gpu/drm/nouveau/nouveau_util.c
15112 views
/*1* Copyright (C) 2010 Nouveau Project2*3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining6* a copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sublicense, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial15* portions of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE21* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION22* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION23* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25*/2627#include <linux/ratelimit.h>2829#include "nouveau_util.h"3031static DEFINE_RATELIMIT_STATE(nouveau_ratelimit_state, 3 * HZ, 20);3233void34nouveau_bitfield_print(const struct nouveau_bitfield *bf, u32 value)35{36while (bf->name) {37if (value & bf->mask) {38printk(" %s", bf->name);39value &= ~bf->mask;40}4142bf++;43}4445if (value)46printk(" (unknown bits 0x%08x)", value);47}4849const struct nouveau_enum *50nouveau_enum_find(const struct nouveau_enum *en, u32 value)51{52while (en->name) {53if (en->value == value)54return en;55en++;56}5758return NULL;59}6061void62nouveau_enum_print(const struct nouveau_enum *en, u32 value)63{64en = nouveau_enum_find(en, value);65if (en) {66printk("%s", en->name);67return;68}6970printk("(unknown enum 0x%08x)", value);71}7273int74nouveau_ratelimit(void)75{76return __ratelimit(&nouveau_ratelimit_state);77}787980