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: [PATCHv2 09/10] zram: return zram device_id value from zram_add()
Date: Thu, 16 Apr 2015 20:55:55 +0900 [thread overview]
Message-ID: <1429185356-11096-10-git-send-email-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <1429185356-11096-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 | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f26251a..2c2e7cc 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1154,6 +1154,10 @@ 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;
@@ -1241,7 +1245,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);
@@ -1299,7 +1303,7 @@ static int __init zram_init(void)
for (dev_id = 0; dev_id < num_devices; dev_id++) {
ret = zram_add(dev_id);
- if (ret != 0)
+ if (ret < 0)
goto out_error;
}
--
2.4.0.rc2
next prev parent reply other threads:[~2015-04-16 11:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 11:55 [PATCHv2 00/10] cleaned up on-demand device creation Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 01/10] zram: enable compaction support in zram Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 02/10] zram: cosmetic ZRAM_ATTR_RO code formatting tweak Sergey Senozhatsky
2015-04-23 2:16 ` Minchan Kim
2015-04-16 11:55 ` [PATCHv2 03/10] zram: use idr instead of `zram_devices' array Sergey Senozhatsky
2015-04-23 2:23 ` Minchan Kim
2015-04-23 4:30 ` Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 04/10] zram: factor out device reset from reset_store() Sergey Senozhatsky
2015-04-23 2:29 ` Minchan Kim
2015-04-23 4:26 ` Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 05/10] zram: reorganize code layout Sergey Senozhatsky
2015-04-23 2:32 ` Minchan Kim
2015-04-16 11:55 ` [PATCHv2 06/10] zram: remove max_num_devices limitation Sergey Senozhatsky
2015-04-23 2:36 ` Minchan Kim
2015-04-23 4:24 ` Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 07/10] zram: report every added and removed device Sergey Senozhatsky
2015-04-23 2:38 ` Minchan Kim
2015-04-23 4:23 ` Sergey Senozhatsky
2015-04-16 11:55 ` [PATCHv2 08/10] zram: trivial: correct flag operations comment Sergey Senozhatsky
2015-04-23 2:40 ` Minchan Kim
2015-04-16 11:55 ` Sergey Senozhatsky [this message]
2015-04-23 2:41 ` [PATCHv2 09/10] zram: return zram device_id value from zram_add() Minchan Kim
2015-04-16 11:55 ` [PATCHv2 10/10] zram: add dynamic device add/remove functionality Sergey Senozhatsky
2015-04-23 3:06 ` Minchan Kim
2015-04-23 3:12 ` Minchan Kim
2015-04-23 4:23 ` Sergey Senozhatsky
2015-04-23 6:20 ` Minchan Kim
2015-04-16 23:23 ` [PATCHv2 00/10] cleaned up on-demand device creation Minchan Kim
2015-04-17 0:27 ` Sergey Senozhatsky
2015-04-17 0:39 ` Sergey Senozhatsky
2015-04-17 1:00 ` Sergey Senozhatsky
2015-04-17 1:32 ` 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=1429185356-11096-10-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®