@@ -1028,9 +1028,33 @@ static ssize_t comp_algorithm_store(struct device *dev,
size_t len)
{
struct zram *zram = dev_to_zram(dev);
+ char *args, *param, *val;
+ char *alg = NULL;
int ret;
- ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, buf);
+ args = skip_spaces(buf);
+ while (*args) {
+ args = next_arg(args, ¶m, &val);
+
+ /*
+ * We need to support 'param' without value, which is an
+ * old format for this attr (algorithm name only).
+ */
+ if (!val || !*val) {
+ alg = param;
+ continue;
+ }
+
+ if (!strcmp(param, "algo")) {
+ alg = val;
+ continue;
+ }
+ }
+
+ if (!alg)
+ return -EINVAL;
+
+ ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, alg);
return ret ? ret : len;
}
Previously comp_algorithm device attr would accept only algorithm name param, however in order to enabled comp configuration we need to extend comp_algorithm_store() with param=value support. Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> --- drivers/block/zram/zram_drv.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)