summaryrefslogtreecommitdiffstats
path: root/include/linux/err.h
blob: 87be24350e91c2788fd68a06dce1da3499d3fc0d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_ERR_H
#define _LINUX_ERR_H

#include <linux/compiler.h>
#include <linux/types.h>

#include <asm/errno.h>

/*
 * Kernel pointers have redundant information, so we can use a
 * scheme where we can return either an error code or a normal
 * pointer with the same return value.
 *
 * This should be a per-architecture thing, to allow different
 * error and pointer decisions.
 */
#define MAX_ERRNO	4095

#ifndef __ASSEMBLY__

#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)

static inline void * __must_check ERR_PTR(long error)
{
	return (void *) error;
}

static inline long __must_check PTR_ERR(__force const void *ptr)
{
	return (long) ptr;
}

static inline bool __must_check IS_ERR(__force const void *ptr)
{
	return IS_ERR_VALUE((unsigned long)ptr);
}

static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
{
	return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr);
}

/**
 * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
 * @ptr: The pointer to cast.
 *
 * Explicitly cast an error-valued pointer to another pointer type in such a
 * way as to make it clear that's what's going on.
 */
static inline void * __must_check ERR_CAST(__force const void *ptr)
{
	/* cast away the const */
	return (void *) ptr;
}

static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
{
	if (IS_ERR(ptr))
		return PTR_ERR(ptr);
	else
		return 0;
}

/* Deprecated */
#define PTR_RET(p) PTR_ERR_OR_ZERO(p)

#endif

#endif /* _LINUX_ERR_H */
.git/commit/include/linux/virtio.h?id=016c98c6fe0c914d12e2e242b2bccde6d6dea54b'>virtio: unify config_changed handlingMichael S. Tsirkin2014-10-151-0/+2 * virtio: virtio_break_device() to mark all virtqueues broken.Rusty Russell2014-04-281-0/+2 * virtio_ring: add new function virtqueue_is_broken()Heinz Graalfs2013-10-291-0/+2 * virtio_ring: let virtqueue_{kick()/notify()} return a boolHeinz Graalfs2013-10-291-2/+2 * Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-nextLinus Torvalds2013-07-101-0/+4 |\ | * virtio: support unlocked queue pollMichael S. Tsirkin2013-07-091-0/+4 * | virtio: remove virtqueue_add_buf().Rusty Russell2013-05-201-7/+0Star |/ * Merge tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kerne...Linus Torvalds2013-05-021-0/+20 |\ | * virtio_ring: virtqueue_add_outbuf / virtqueue_add_inbuf.Rusty Russell2013-03-201-0/+10 | * virtio_ring: virtqueue_add_sgs, to add multiple sgs.Rusty Russell2013-03-201-0/+7 | * virtio: Introduce vringh wrappers in virtio_configSjur Brændeland2013-03-201-0/+3 * | virtio: remove obsolete virtqueue_get_queue_index()Rusty Russell2013-03-221-6/+0Star |/ * virtio: Add module driver macro for virtio drivers.Sjur Brændeland2013-02-131-0/+9 * virtio: make config_ops constStephen Hemminger2013-02-111-1/+1 * virtio: add drv_to_virtio to make code clearlyWanlong Gao2012-12-181-0/+5 * virtio: use dev_to_virtio wrapper in virtioWanlong Gao2012-12-181-1/+5 * virtio: move queue_index and num_free fields into core struct virtqueue.Rusty Russell2012-12-181-1/+13 * virtio-ring: move queue_index to vring_virtqueueJason Wang2012-09-281-0/+2 * [SCSI] virtio-scsi: Add vdrv->scan for post VIRTIO_CONFIG_S_DRIVER_OK LUN sca...Nicholas Bellinger2012-07-201-0/+1 * virtio: drop thaw PM operationAmit Shah2012-03-311-1/+0Star * virtio: pci: add PM notification handlers for restore, freeze, thaw, poweroffAmit Shah2012-01-121-0/+5 * virtio: support unlocked queue kickRusty Russell2012-01-121-0/+4 * virtio: rename virtqueue_add_buf_gfp to virtqueue_add_bufRusty Russell2012-01-121-15/+6Star * virtio: document functions better.Rusty Russell2012-01-121-47/+0Star * virtio.h: correct comment for struct virtio_driverWang Sheng-Hui2011-11-021-2/+2