<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 2019/02/08 19:48, Petr Vorel wrote:
<blockquote cite="mid:20190208114833.GA26843@dell5510" type="cite">
<pre wrap="">Hi Xiao,
</pre>
<blockquote type="cite">
<pre wrap="">The maximum major number is set to 511 since kernel commit 133d55c,
so register_blkdev() with a major number grater than the maximum(511)
will get failure instead of pass as expected.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">1) Update tests for the newer behavior of register_blkdev().
2) Add more major numbers(i.e. 511 and 512) to test.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Note:
It is possible that specified major numbers have been used
by system, so we skip them if register_blkdev() returns EBUSY.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Signed-off-by: Xiao Yang <a class="moz-txt-link-rfc2396E" href="mailto:yangx.jy@cn.fujitsu.com"><yangx.jy@cn.fujitsu.com></a>
Reviewed-by: Petr Vorel <a class="moz-txt-link-rfc2396E" href="mailto:pvorel@suse.cz"><pvorel@suse.cz></a>
</pre>
</blockquote>
<pre wrap="">
Acked-by: Petr Vorel <a class="moz-txt-link-rfc2396E" href="mailto:pvorel@suse.cz"><pvorel@suse.cz></a>
Thanks for your updates.
</pre>
<blockquote type="cite">
<pre wrap="">---
.../block/block_dev_kernel/ltp_block_dev.c | 64 +++++++++++-----------
1 file changed, 32 insertions(+), 32 deletions(-)
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c
</pre>
</blockquote>
<pre wrap="">...
</pre>
<blockquote type="cite">
<pre wrap="">@@ -225,18 +221,22 @@ static int tc04(void)
static int tc05(void)
</pre>
</blockquote>
<pre wrap="">...
</pre>
<blockquote type="cite">
<pre wrap="">- major = register_blkdev(UINT_MAX, BLK_DEV_NAME);
- prk_debug("major = %i\n", major);
+ for (i = 0; i < sizeof(test_major) / sizeof(unsigned int); i++) {
+ major = register_blkdev(test_major[i], BLK_DEV_NAME);
+ prk_debug("major = %i\n", major);
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">- if (major == 0) {
- unregister_blkdev(UINT_MAX, BLK_DEV_NAME);
- } else {
- prk_debug("reg blkdev with major %d failed with error %i\n",
- UINT_MAX, major);
- pass = 0;
+ if (major == 0) {
</pre>
</blockquote>
<pre wrap="">In v1 this was major >= 0.
It looks to me as well that major == 0 is correct.
</pre>
</blockquote>
Hi Petr,<br>
<br>
Thanks for your ack. <span class="moz-smiley-s1"><span> :-) </span></span><br>
<br>
According to the comment of register_blkdev() at block/genhd.c in
kernel, i think register_blkdev() only<br>
returns zero or a negative error if a positive major number(i.e.
nonzero) is passed to register_blkdev().<br>
---------------------------------------------------------------------------------------------------------------------------------<br>
<pre><code></code><pre><span class="cm"> * - if a major device number was requested in range [1..BLKDEV_MAJOR_MAX-1]</span>
<span class="cm"> * then the function returns zero on success, or a negative error code</span>
<span class="cm"> * - if any unused major number was requested with @major = 0 parameter</span>
<span class="cm"> * then the return value is the allocated major number in range</span>
<span class="cm"> * [1..BLKDEV_MAJOR_MAX-1] or a negative error code otherwise</span></pre></pre>
---------------------------------------------------------------------------------------------------------------------------------<br>
<br>
So i perfer to use major == 0. <span class="moz-smiley-s1"><span>
:-) </span></span><br>
<br>
Best Regards,<br>
Xiao Yang<br>
<blockquote cite="mid:20190208114833.GA26843@dell5510" type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">+ unregister_blkdev(test_major[i], BLK_DEV_NAME);
+ pass = 0;
+ } else {
+ prk_debug("register_blkdev() with major %u got error %i\n",
+ test_major[i], major);
+ }
}
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap=""> prk_info("Test Case Result: %s\n", result_str(pass));
</pre>
</blockquote>
<pre wrap="">
Kind regards,
Petr
.
</pre>
</blockquote>
<br>
</body>
</html>