mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
zram: propagate error to user
When we initialized zcomp with single, we couldn't change max_comp_streams without zram reset but current interface doesn't show any error to user and even it changes max_comp_streams's value without any effect so it would make user very confusing. This patch prevents max_comp_streams's change when zcomp was initialized as single zcomp and emit the error to user(ex, echo). [[email protected]: don't return with the lock held, per Sergey] [[email protected]: fix coccinelle warnings] Signed-off-by: Minchan Kim <[email protected]> Cc: Nitin Gupta <[email protected]> Cc: Jerome Marchand <[email protected]> Acked-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Fengguang Wu <[email protected]> Cc: Stephen Rothwell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
fcfa8d95ca
commit
60a726e333
4 changed files with 25 additions and 15 deletions
|
|
@ -153,7 +153,7 @@ static void zcomp_strm_multi_release(struct zcomp *comp, struct zcomp_strm *zstr
|
|||
}
|
||||
|
||||
/* change max_strm limit */
|
||||
static int zcomp_strm_multi_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
static bool zcomp_strm_multi_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
{
|
||||
struct zcomp_strm_multi *zs = comp->stream;
|
||||
struct zcomp_strm *zstrm;
|
||||
|
|
@ -172,7 +172,7 @@ static int zcomp_strm_multi_set_max_streams(struct zcomp *comp, int num_strm)
|
|||
zs->avail_strm--;
|
||||
}
|
||||
spin_unlock(&zs->strm_lock);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void zcomp_strm_multi_destroy(struct zcomp *comp)
|
||||
|
|
@ -232,10 +232,10 @@ static void zcomp_strm_single_release(struct zcomp *comp,
|
|||
mutex_unlock(&zs->strm_lock);
|
||||
}
|
||||
|
||||
static int zcomp_strm_single_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
static bool zcomp_strm_single_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
{
|
||||
/* zcomp_strm_single support only max_comp_streams == 1 */
|
||||
return -ENOTSUPP;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void zcomp_strm_single_destroy(struct zcomp *comp)
|
||||
|
|
@ -284,7 +284,7 @@ ssize_t zcomp_available_show(const char *comp, char *buf)
|
|||
return sz;
|
||||
}
|
||||
|
||||
int zcomp_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
bool zcomp_set_max_streams(struct zcomp *comp, int num_strm)
|
||||
{
|
||||
return comp->set_max_streams(comp, num_strm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct zcomp {
|
|||
|
||||
struct zcomp_strm *(*strm_find)(struct zcomp *comp);
|
||||
void (*strm_release)(struct zcomp *comp, struct zcomp_strm *zstrm);
|
||||
int (*set_max_streams)(struct zcomp *comp, int num_strm);
|
||||
bool (*set_max_streams)(struct zcomp *comp, int num_strm);
|
||||
void (*destroy)(struct zcomp *comp);
|
||||
};
|
||||
|
||||
|
|
@ -64,5 +64,5 @@ int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
|
|||
int zcomp_decompress(struct zcomp *comp, const unsigned char *src,
|
||||
size_t src_len, unsigned char *dst);
|
||||
|
||||
int zcomp_set_max_streams(struct zcomp *comp, int num_strm);
|
||||
bool zcomp_set_max_streams(struct zcomp *comp, int num_strm);
|
||||
#endif /* _ZCOMP_H_ */
|
||||
|
|
|
|||
|
|
@ -127,19 +127,28 @@ static ssize_t max_comp_streams_store(struct device *dev,
|
|||
{
|
||||
int num;
|
||||
struct zram *zram = dev_to_zram(dev);
|
||||
int ret;
|
||||
|
||||
if (kstrtoint(buf, 0, &num))
|
||||
return -EINVAL;
|
||||
ret = kstrtoint(buf, 0, &num);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (num < 1)
|
||||
return -EINVAL;
|
||||
|
||||
down_write(&zram->init_lock);
|
||||
if (init_done(zram)) {
|
||||
if (zcomp_set_max_streams(zram->comp, num))
|
||||
if (!zcomp_set_max_streams(zram->comp, num)) {
|
||||
pr_info("Cannot change max compression streams\n");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
zram->max_comp_streams = num;
|
||||
ret = len;
|
||||
out:
|
||||
up_write(&zram->init_lock);
|
||||
return len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t comp_algorithm_show(struct device *dev,
|
||||
|
|
|
|||
Loading…
Reference in a new issue