* [PATCH] ALSA: hda - add explicit include of err.h
@ 2014-09-23 7:04 David Henningsson
2014-09-23 7:04 ` [PATCH] hda-emu: add include/linux/err.h David Henningsson
2014-09-23 7:46 ` [PATCH] ALSA: hda - add explicit include of err.h Takashi Iwai
0 siblings, 2 replies; 3+ messages in thread
From: David Henningsson @ 2014-09-23 7:04 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: David Henningsson
Since every caller of snd_hda_jack_detect_enable_callback needs to
use the macros from err.h, it makes sense to include it directly
from hda_jack.h.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
sound/pci/hda/hda_jack.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index b41e0a3..13cb375 100644
--- a/sound/pci/hda/hda_jack.h
+++ b/sound/pci/hda/hda_jack.h
@@ -12,6 +12,8 @@
#ifndef __SOUND_HDA_JACK_H
#define __SOUND_HDA_JACK_H
+#include <linux/err.h>
+
struct auto_pin_cfg;
struct hda_jack_tbl;
struct hda_jack_callback;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] hda-emu: add include/linux/err.h
2014-09-23 7:04 [PATCH] ALSA: hda - add explicit include of err.h David Henningsson
@ 2014-09-23 7:04 ` David Henningsson
2014-09-23 7:46 ` [PATCH] ALSA: hda - add explicit include of err.h Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: David Henningsson @ 2014-09-23 7:04 UTC (permalink / raw)
To: tiwai, alsa-devel; +Cc: David Henningsson
We recently started using it on the kernel side.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
include/linux/err.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100644 include/linux/err.h
diff --git a/include/linux/err.h b/include/linux/err.h
new file mode 100644
index 0000000..627729d
--- /dev/null
+++ b/include/linux/err.h
@@ -0,0 +1,64 @@
+#ifndef _LINUX_ERR_H
+#define _LINUX_ERR_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
+
+#define __must_check
+#define __force
+#define unlikely(x) x
+
+#define IS_ERR_VALUE(x) unlikely((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 !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 /* _LINUX_ERR_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: hda - add explicit include of err.h
2014-09-23 7:04 [PATCH] ALSA: hda - add explicit include of err.h David Henningsson
2014-09-23 7:04 ` [PATCH] hda-emu: add include/linux/err.h David Henningsson
@ 2014-09-23 7:46 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2014-09-23 7:46 UTC (permalink / raw)
To: David Henningsson; +Cc: alsa-devel
At Tue, 23 Sep 2014 09:04:49 +0200,
David Henningsson wrote:
>
> Since every caller of snd_hda_jack_detect_enable_callback needs to
> use the macros from err.h, it makes sense to include it directly
> from hda_jack.h.
>
> Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Thanks, applied (both).
Takashi
> ---
> sound/pci/hda/hda_jack.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
> index b41e0a3..13cb375 100644
> --- a/sound/pci/hda/hda_jack.h
> +++ b/sound/pci/hda/hda_jack.h
> @@ -12,6 +12,8 @@
> #ifndef __SOUND_HDA_JACK_H
> #define __SOUND_HDA_JACK_H
>
> +#include <linux/err.h>
> +
> struct auto_pin_cfg;
> struct hda_jack_tbl;
> struct hda_jack_callback;
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-23 7:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-23 7:04 [PATCH] ALSA: hda - add explicit include of err.h David Henningsson
2014-09-23 7:04 ` [PATCH] hda-emu: add include/linux/err.h David Henningsson
2014-09-23 7:46 ` [PATCH] ALSA: hda - add explicit include of err.h Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).