From patchwork Tue Feb 6 02:25:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 10202155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DCFD6056F for ; Tue, 6 Feb 2018 02:31:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 203D4289D2 for ; Tue, 6 Feb 2018 02:31:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14B37289E5; Tue, 6 Feb 2018 02:31:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B36AB289D7 for ; Tue, 6 Feb 2018 02:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbeBFCbS (ORCPT ); Mon, 5 Feb 2018 21:31:18 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:44320 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbeBFCbO (ORCPT ); Mon, 5 Feb 2018 21:31:14 -0500 X-Greylist: delayed 358 seconds by postgrey-1.27 at vger.kernel.org; Mon, 05 Feb 2018 21:31:14 EST Received: from 67-148-5-85.dia.static.qwest.net ([67.148.5.85] helo=[127.0.1.1]) by outgoing-stata.csail.mit.edu with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1eiswr-000R0s-6q; Mon, 05 Feb 2018 21:25:29 -0500 Subject: [PATCH 2/2] block, char_dev: Use correct format specifier for unsigned ints From: "Srivatsa S. Bhat" To: gregkh@linuxfoundation.org, logang@deltatee.com Cc: axboe@kernel.dk, jlayton@poochiereds.net, bfields@fieldses.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, srivatsa@csail.mit.edu Date: Mon, 05 Feb 2018 18:25:27 -0800 Message-ID: <151788391701.28069.13145257664735983272.stgit@srivatsa-ubuntu> In-Reply-To: <151788389652.28069.6065922071875812126.stgit@srivatsa-ubuntu> References: <151788389652.28069.6065922071875812126.stgit@srivatsa-ubuntu> User-Agent: StGit/0.18 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srivatsa S. Bhat register_blkdev() and __register_chrdev_region() treat the major number as an unsigned int. So print it the same way to avoid absurd error statements such as: "... major requested (-1) is greater than the maximum (511) ..." (and also fix off-by-one bugs in the error prints). While at it, also update the comment describing register_blkdev(). Signed-off-by: Srivatsa S. Bhat Reviewed-by: Logan Gunthorpe --- block/genhd.c | 19 +++++++++++-------- fs/char_dev.c | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 88a53c1..21a18e5 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -308,19 +308,22 @@ void blkdev_show(struct seq_file *seqf, off_t offset) /** * register_blkdev - register a new block device * - * @major: the requested major device number [1..255]. If @major = 0, try to - * allocate any unused major number. + * @major: the requested major device number [1..BLKDEV_MAJOR_MAX-1]. If + * @major = 0, try to allocate any unused major number. * @name: the name of the new block device as a zero terminated string * * The @name must be unique within the system. * * The return value depends on the @major input parameter: * - * - if a major device number was requested in range [1..255] then the - * function returns zero on success, or a negative error code + * - if a major device number was requested in range [1..BLKDEV_MAJOR_MAX-1] + * then the function returns zero on success, or a negative error code * - if any unused major number was requested with @major = 0 parameter * then the return value is the allocated major number in range - * [1..255] or a negative error code otherwise + * [1..BLKDEV_MAJOR_MAX-1] or a negative error code otherwise + * + * See Documentation/admin-guide/devices.txt for the list of allocated + * major numbers. */ int register_blkdev(unsigned int major, const char *name) { @@ -347,8 +350,8 @@ int register_blkdev(unsigned int major, const char *name) } if (major >= BLKDEV_MAJOR_MAX) { - pr_err("register_blkdev: major requested (%d) is greater than the maximum (%d) for %s\n", - major, BLKDEV_MAJOR_MAX, name); + pr_err("register_blkdev: major requested (%u) is greater than the maximum (%u) for %s\n", + major, BLKDEV_MAJOR_MAX-1, name); ret = -EINVAL; goto out; @@ -375,7 +378,7 @@ int register_blkdev(unsigned int major, const char *name) ret = -EBUSY; if (ret < 0) { - printk("register_blkdev: cannot get major %d for %s\n", + printk("register_blkdev: cannot get major %u for %s\n", major, name); kfree(p); } diff --git a/fs/char_dev.c b/fs/char_dev.c index 33c9385..a279c58 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, } if (major >= CHRDEV_MAJOR_MAX) { - pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n", - name, major, CHRDEV_MAJOR_MAX); + pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n", + name, major, CHRDEV_MAJOR_MAX-1); ret = -EINVAL; goto out; }