From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH 1/2] zram: return zram device_id value from zram_add()
Date: Wed, 4 Mar 2015 23:16:40 +0900 [thread overview]
Message-ID: <1425478601-19141-2-git-send-email-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <1425478601-19141-1-git-send-email-sergey.senozhatsky@gmail.com>
zram_add requires valid device_id to be provided, that can be a
bit inconvenient. Change zram_add() to return negative value upon
new device creation failure, and device_id (>= 0) value otherwise.
This prepares zram_add to perform automatic device_id assignment. New
device_id will be returned back to user-space (so user can reference
that device as /dev/zramX).
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/block/zram/zram_drv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 087b043..0978307 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1066,6 +1066,8 @@ static struct attribute_group zram_disk_attr_group = {
.attrs = zram_disk_attrs,
};
+/* allocate and initialize new zram device. the function returns
+ * '>= 0' device_id upon success, and negative value otherwise. */
static int zram_add(int device_id)
{
struct zram *zram;
@@ -1151,7 +1153,7 @@ static int zram_add(int device_id)
zram->max_comp_streams = 1;
pr_info("Added device: %s\n", zram->disk->disk_name);
- return 0;
+ return device_id;
out_free_disk:
del_gendisk(zram->disk);
@@ -1322,7 +1324,7 @@ static int __init zram_init(void)
mutex_lock(&zram_index_mutex);
ret = zram_add(dev_id);
mutex_unlock(&zram_index_mutex);
- if (ret != 0)
+ if (ret < 0)
goto out_error;
}
--
2.3.1.167.g7f4ba4b
next prev parent reply other threads:[~2015-03-04 14:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 14:16 [PATCH 0/2] make automatic device_id generation possible Sergey Senozhatsky
2015-03-04 14:16 ` Sergey Senozhatsky [this message]
2015-03-04 14:16 ` [PATCH 2/2] zram: introduce automatic device_id generation Sergey Senozhatsky
2015-03-04 22:13 ` Andrew Morton
2015-03-05 0:09 ` Sergey Senozhatsky
2015-03-05 0:20 ` [PATCH 0/2] make automatic device_id generation possible Minchan Kim
2015-03-05 0:58 ` Sergey Senozhatsky
2015-03-05 1:17 ` Minchan Kim
2015-03-05 1:36 ` Sergey Senozhatsky
2015-03-05 1:20 ` Sergey Senozhatsky
2015-03-05 1:33 ` Minchan Kim
2015-03-05 1:47 ` Sergey Senozhatsky
2015-03-05 2:04 ` Minchan Kim
2015-03-05 2:27 ` Sergey Senozhatsky
2015-03-05 2:35 ` Minchan Kim
2015-03-05 12:10 ` Karel Zak
2015-03-05 12:31 ` Sergey Senozhatsky
2015-03-05 12:02 ` Karel Zak
2015-03-05 12:26 ` Sergey Senozhatsky
2015-03-05 12:03 ` Sergey Senozhatsky
2015-03-06 3:31 ` Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425478601-19141-2-git-send-email-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=sergey.senozhatsky.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®