| .. | .. | 
|---|
 | 1 | +// SPDX-License-Identifier: GPL-2.0-only  | 
|---|
| 1 | 2 |  /* | 
|---|
| 2 | 3 |   * This file is part of UBIFS. | 
|---|
| 3 | 4 |   * | 
|---|
| 4 | 5 |   * Copyright (C) 2006-2008 Nokia Corporation. | 
|---|
| 5 | 6 |   * Copyright (C) 2006, 2007 University of Szeged, Hungary | 
|---|
| 6 |  | - *  | 
|---|
| 7 |  | - * This program is free software; you can redistribute it and/or modify it  | 
|---|
| 8 |  | - * under the terms of the GNU General Public License version 2 as published by  | 
|---|
| 9 |  | - * the Free Software Foundation.  | 
|---|
| 10 |  | - *  | 
|---|
| 11 |  | - * This program is distributed in the hope that it will be useful, but WITHOUT  | 
|---|
| 12 |  | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  | 
|---|
| 13 |  | - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  | 
|---|
| 14 |  | - * more details.  | 
|---|
| 15 |  | - *  | 
|---|
| 16 |  | - * You should have received a copy of the GNU General Public License along with  | 
|---|
| 17 |  | - * this program; if not, write to the Free Software Foundation, Inc., 51  | 
|---|
| 18 |  | - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA  | 
|---|
| 19 | 7 |   * | 
|---|
| 20 | 8 |   * Authors: Adrian Hunter | 
|---|
| 21 | 9 |   *          Artem Bityutskiy (Битюцкий Артём) | 
|---|
| .. | .. | 
|---|
| 68 | 56 |  static struct ubifs_compressor zlib_compr = { | 
|---|
| 69 | 57 |  	.compr_type = UBIFS_COMPR_ZLIB, | 
|---|
| 70 | 58 |  	.name = "zlib", | 
|---|
 | 59 | +};  | 
|---|
 | 60 | +#endif  | 
|---|
 | 61 | +  | 
|---|
 | 62 | +#ifdef CONFIG_UBIFS_FS_ZSTD  | 
|---|
 | 63 | +static DEFINE_MUTEX(zstd_enc_mutex);  | 
|---|
 | 64 | +static DEFINE_MUTEX(zstd_dec_mutex);  | 
|---|
 | 65 | +  | 
|---|
 | 66 | +static struct ubifs_compressor zstd_compr = {  | 
|---|
 | 67 | +	.compr_type = UBIFS_COMPR_ZSTD,  | 
|---|
 | 68 | +	.comp_mutex = &zstd_enc_mutex,  | 
|---|
 | 69 | +	.decomp_mutex = &zstd_dec_mutex,  | 
|---|
 | 70 | +	.name = "zstd",  | 
|---|
 | 71 | +	.capi_name = "zstd",  | 
|---|
 | 72 | +};  | 
|---|
 | 73 | +#else  | 
|---|
 | 74 | +static struct ubifs_compressor zstd_compr = {  | 
|---|
 | 75 | +	.compr_type = UBIFS_COMPR_ZSTD,  | 
|---|
 | 76 | +	.name = "zstd",  | 
|---|
| 71 | 77 |  }; | 
|---|
| 72 | 78 |  #endif | 
|---|
| 73 | 79 |   | 
|---|
| .. | .. | 
|---|
| 228 | 234 |  	if (err) | 
|---|
| 229 | 235 |  		return err; | 
|---|
| 230 | 236 |   | 
|---|
| 231 |  | -	err = compr_init(&zlib_compr);  | 
|---|
 | 237 | +	err = compr_init(&zstd_compr);  | 
|---|
| 232 | 238 |  	if (err) | 
|---|
| 233 | 239 |  		goto out_lzo; | 
|---|
 | 240 | +  | 
|---|
 | 241 | +	err = compr_init(&zlib_compr);  | 
|---|
 | 242 | +	if (err)  | 
|---|
 | 243 | +		goto out_zstd;  | 
|---|
| 234 | 244 |   | 
|---|
| 235 | 245 |  	ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr; | 
|---|
| 236 | 246 |  	return 0; | 
|---|
| 237 | 247 |   | 
|---|
 | 248 | +out_zstd:  | 
|---|
 | 249 | +	compr_exit(&zstd_compr);  | 
|---|
| 238 | 250 |  out_lzo: | 
|---|
| 239 | 251 |  	compr_exit(&lzo_compr); | 
|---|
| 240 | 252 |  	return err; | 
|---|
| .. | .. | 
|---|
| 247 | 259 |  { | 
|---|
| 248 | 260 |  	compr_exit(&lzo_compr); | 
|---|
| 249 | 261 |  	compr_exit(&zlib_compr); | 
|---|
 | 262 | +	compr_exit(&zstd_compr);  | 
|---|
| 250 | 263 |  } | 
|---|