Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / linux / ascii85.h
blob83ad775ad0aac10f22ba5183c58a355a6dd86f5d
1 /*
2 * SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2008 Intel Corporation
5 * Copyright (c) 2018 The Linux Foundation. All rights reserved.
6 */
8 #ifndef _ASCII85_H_
9 #define _ASCII85_H_
11 #include <linux/math.h>
12 #include <linux/types.h>
14 #define ASCII85_BUFSZ 6
16 static inline long
17 ascii85_encode_len(long len)
19 return DIV_ROUND_UP(len, 4);
22 static inline const char *
23 ascii85_encode(u32 in, char *out)
25 int i;
27 if (in == 0)
28 return "z";
30 out[5] = '\0';
31 for (i = 5; i--; ) {
32 out[i] = '!' + in % 85;
33 in /= 85;
36 return out;
39 #endif