brintos

brintos / linux-shallow public Read only

0
0
Text · 2.6 KiB · 79952d8 Raw
84 lines · c
1/*2 * Internal Header for the Direct Rendering Manager3 *4 * Copyright 2018 Intel Corporation5 *6 * Permission is hereby granted, free of charge, to any person obtaining a7 * copy of this software and associated documentation files (the "Software"),8 * to deal in the Software without restriction, including without limitation9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,10 * and/or sell copies of the Software, and to permit persons to whom the11 * Software is furnished to do so, subject to the following conditions:12 *13 * The above copyright notice and this permission notice (including the next14 * paragraph) shall be included in all copies or substantial portions of the15 * Software.16 *17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL20 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR23 * OTHER DEALINGS IN THE SOFTWARE.24 */25 26#ifndef _DRM_UTIL_H_27#define _DRM_UTIL_H_28 29/**30 * DOC: drm utils31 *32 * Macros and inline functions that does not naturally belong in other places33 */34 35#include <linux/interrupt.h>36#include <linux/kgdb.h>37#include <linux/preempt.h>38#include <linux/smp.h>39 40/*41 * Use EXPORT_SYMBOL_FOR_TESTS_ONLY() for functions that shall42 * only be visible for drmselftests.43 */44#if defined(CONFIG_DRM_EXPORT_FOR_TESTS)45#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)46#else47#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x)48#endif49 50/**51 * for_each_if - helper for handling conditionals in various for_each macros52 * @condition: The condition to check53 *54 * Typical use::55 *56 *	#define for_each_foo_bar(x, y) \'57 *		list_for_each_entry(x, y->list, head) \'58 *			for_each_if(x->something == SOMETHING)59 *60 * The for_each_if() macro makes the use of for_each_foo_bar() less error61 * prone.62 */63#define for_each_if(condition) if (!(condition)) {} else64 65/**66 * drm_can_sleep - returns true if currently okay to sleep67 *68 * This function shall not be used in new code.69 * The check for running in atomic context may not work - see linux/preempt.h.70 *71 * FIXME: All users of drm_can_sleep should be removed (see todo.rst)72 *73 * Returns:74 * False if kgdb is active, we are in atomic context or irqs are disabled.75 */76static inline bool drm_can_sleep(void)77{78	if (in_atomic() || in_dbg_master() || irqs_disabled())79		return false;80	return true;81}82 83#endif84