Skip to content

Commit 803521b

Browse files
mzaslonktorvalds
authored andcommitted
lib/zlib: add zlib_deflate_dfltcc_enabled() function
Add a new function to zlib.h checking if s390 Deflate-Conversion facility is installed and enabled. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mikhail Zaslonko <[email protected]> Cc: Chris Mason <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David Sterba <[email protected]> Cc: Eduard Shishkin <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ilya Leoshkevich <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c65e681 commit 803521b

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

include/linux/zlib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
191191
exceed those passed here.
192192
*/
193193

194+
extern int zlib_deflate_dfltcc_enabled (void);
195+
/*
196+
Returns 1 if Deflate-Conversion facility is installed and enabled,
197+
otherwise 0.
198+
*/
199+
194200
/*
195201
extern int deflateInit (z_streamp strm, int level);
196202

lib/zlib_deflate/deflate.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define DEFLATE_RESET_HOOK(strm) do {} while (0)
6060
#define DEFLATE_HOOK(strm, flush, bstate) 0
6161
#define DEFLATE_NEED_CHECKSUM(strm) 1
62+
#define DEFLATE_DFLTCC_ENABLED() 0
6263
#endif
6364

6465
/* ===========================================================================
@@ -1138,3 +1139,8 @@ int zlib_deflate_workspacesize(int windowBits, int memLevel)
11381139
+ zlib_deflate_head_memsize(memLevel)
11391140
+ zlib_deflate_overlay_memsize(memLevel);
11401141
}
1142+
1143+
int zlib_deflate_dfltcc_enabled(void)
1144+
{
1145+
return DEFLATE_DFLTCC_ENABLED();
1146+
}

lib/zlib_deflate/deflate_syms.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/zlib.h>
1313

1414
EXPORT_SYMBOL(zlib_deflate_workspacesize);
15+
EXPORT_SYMBOL(zlib_deflate_dfltcc_enabled);
1516
EXPORT_SYMBOL(zlib_deflate);
1617
EXPORT_SYMBOL(zlib_deflateInit2);
1718
EXPORT_SYMBOL(zlib_deflateEnd);

lib/zlib_dfltcc/dfltcc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#define DFLTCC_H
44

55
#include "../zlib_deflate/defutil.h"
6+
#include <asm/facility.h>
7+
#include <asm/setup.h>
68

79
/*
810
* Tuning parameters.
@@ -14,6 +16,8 @@
1416
#define DFLTCC_DHT_MIN_SAMPLE_SIZE 4096
1517
#define DFLTCC_RIBM 0
1618

19+
#define DFLTCC_FACILITY 151
20+
1721
/*
1822
* Parameter Block for Query Available Functions.
1923
*/
@@ -113,6 +117,11 @@ typedef enum {
113117
} dfltcc_inflate_action;
114118
dfltcc_inflate_action dfltcc_inflate(z_streamp strm,
115119
int flush, int *ret);
120+
static inline int is_dfltcc_enabled(void)
121+
{
122+
return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
123+
test_facility(DFLTCC_FACILITY));
124+
}
116125

117126
#define DEFLATE_RESET_HOOK(strm) \
118127
dfltcc_reset((strm), sizeof(deflate_state))
@@ -121,6 +130,8 @@ dfltcc_inflate_action dfltcc_inflate(z_streamp strm,
121130

122131
#define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm)))
123132

133+
#define DEFLATE_DFLTCC_ENABLED() is_dfltcc_enabled()
134+
124135
#define INFLATE_RESET_HOOK(strm) \
125136
dfltcc_reset((strm), sizeof(struct inflate_state))
126137

lib/zlib_dfltcc/dfltcc_util.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#define DFLTCC_UTIL_H
44

55
#include <linux/zutil.h>
6-
#include <asm/facility.h>
7-
#include <asm/setup.h>
86

97
/*
108
* C wrapper for the DEFLATE CONVERSION CALL instruction.
@@ -24,7 +22,6 @@ typedef enum {
2422
#define HBT_CIRCULAR (1 << 7)
2523
#define HB_BITS 15
2624
#define HB_SIZE (1 << HB_BITS)
27-
#define DFLTCC_FACILITY 151
2825

2926
static inline dfltcc_cc dfltcc(
3027
int fn,
@@ -101,12 +98,6 @@ static inline int dfltcc_are_params_ok(
10198
(strategy == Z_DEFAULT_STRATEGY);
10299
}
103100

104-
static inline int is_dfltcc_enabled(void)
105-
{
106-
return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
107-
test_facility(DFLTCC_FACILITY));
108-
}
109-
110101
char *oesc_msg(char *buf, int oesc);
111102

112103
#endif /* DFLTCC_UTIL_H */

0 commit comments

Comments
 (0)