From patchwork Mon Oct 30 14:01:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13440622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53402C4167B for ; Mon, 30 Oct 2023 14:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232532AbjJ3OBY (ORCPT ); Mon, 30 Oct 2023 10:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbjJ3OBX (ORCPT ); Mon, 30 Oct 2023 10:01:23 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD5BC1 for ; Mon, 30 Oct 2023 07:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=QWgjEf/fjD16JUEjiIUvMczcLDcjuKwRtJFW/bKIjpc=; b=yji1K7Gg8d69e/2EJqSUY1ymcx pRM0jjJzJnqwX6LwDJThkDH4hBDQqCu2LgeDlc1qf9tSBtuwWJY03NqgGY6VqksX0TjQ4h7JKfgEo l1PpCkkj/adIhQvegGqd4BV1wVCh7f9xVUKLUQmFBSP/9AkoRzjA6aGHZsZvrP/VlS6tKSHWGL8kS 1mxsN/26QCcr9Lf3oY9C9kWJ57Qf9+pzjmlk+rngsId4Vk/A2bzHoKe7Ee6n7QE+TlaRPYs7FVoHw +JSFGJMIOLcDwtBsBxAlQbvI3C073f6JccG3pyr4j9N8DHAt52db4tiaG0OZGkvSzsGvDTaNNRKiC q9kUYcUA==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qxSpN-003RsO-2w; Mon, 30 Oct 2023 14:01:14 +0000 From: Christoph Hellwig To: axboe@kernel.dk, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com Cc: linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, zhongjinghua@huawei.com, yukuai1@huaweicloud.com Subject: [PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value Date: Mon, 30 Oct 2023 15:01:05 +0100 Message-Id: <20231030140106.1393384-1-hch@lst.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org idr_alloc returns an int that is either a negative errno, or the identifier actually allocated. Use signed integer ret variable to catch the return value and only assign it to gd->first_minor to prepare for marking the first_minor field in the gendisk structure as unsigned. Signed-off-by: Christoph Hellwig Reviewed-by: Daniel Golle Acked-by: Richard Weinberger --- drivers/mtd/ubi/block.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 437c5b83ffe513..51d00b518d3197 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -402,13 +402,14 @@ int ubiblock_create(struct ubi_volume_info *vi) gd->fops = &ubiblock_ops; gd->major = ubiblock_major; gd->minors = 1; - gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL); - if (gd->first_minor < 0) { + ret = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL); + if (ret < 0) { dev_err(disk_to_dev(gd), "block: dynamic minor allocation failed"); ret = -ENODEV; goto out_cleanup_disk; } + gd->first_minor = ret; gd->flags |= GENHD_FL_NO_PART; gd->private_data = dev; sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); From patchwork Mon Oct 30 14:01:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13440621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83C58C4332F for ; Mon, 30 Oct 2023 14:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232542AbjJ3OBX (ORCPT ); Mon, 30 Oct 2023 10:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbjJ3OBX (ORCPT ); Mon, 30 Oct 2023 10:01:23 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138B2B7 for ; Mon, 30 Oct 2023 07:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=7Yjc15PJUnJY0o47CDNKLqnyXJ93R9B0HXbm6Hil9Kg=; b=AwMeO+hfZL9/XRZYwws0NCYtbb YGtasjQP1bEFrQ16dbpnotuRB8vaChDpSvbyBkfHP8SFOY7fVXvA/mmIq2+95q93ukz0pluxQAUD+ SmWIKPfY9Bx9yLvTCez+a2Wpoum4YTCiNe4b5K0bM5VXhQkFcgC9srdcE/17kWFfbgF7SD65RtfDV Wk+HRH33F0jUaZrlq1boODdPqi3JhIfTzq8/5axCEObT08GnAPl3DdoEpkAplFOzU5zH7H+wZPdtr xZEeXgT+KL5lnZnxGnF6wpQiETVM7lGhv/acCMsg4ZjVr0Sh9NqgfxFDijvExPiOQLd84oiCTGFlJ sxFftiYw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qxSpQ-003RsW-2R; Mon, 30 Oct 2023 14:01:17 +0000 From: Christoph Hellwig To: axboe@kernel.dk, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com Cc: linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, zhongjinghua@huawei.com, yukuai1@huaweicloud.com Subject: [PATCH 2/2] block: dev_t components are unsigned Date: Mon, 30 Oct 2023 15:01:06 +0100 Message-Id: <20231030140106.1393384-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030140106.1393384-1-hch@lst.de> References: <20231030140106.1393384-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ... thus mark the major, first_minor and minors fields in struct gendisk as such. Signed-off-by: Christoph Hellwig --- block/genhd.c | 4 ++-- include/linux/blkdev.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index cc32a0c704eb84..ceeb30518db696 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -180,7 +180,7 @@ void blkdev_show(struct seq_file *seqf, off_t offset) spin_lock(&major_names_spinlock); for (dp = major_names[major_to_index(offset)]; dp; dp = dp->next) if (dp->major == offset) - seq_printf(seqf, "%3d %s\n", dp->major, dp->name); + seq_printf(seqf, "%3u %s\n", dp->major, dp->name); spin_unlock(&major_names_spinlock); } #endif /* CONFIG_PROC_FS */ @@ -896,7 +896,7 @@ static ssize_t disk_range_show(struct device *dev, { struct gendisk *disk = dev_to_disk(dev); - return sprintf(buf, "%d\n", disk->minors); + return sprintf(buf, "%u\n", disk->minors); } static ssize_t disk_ext_range_show(struct device *dev, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index eef450f259828d..3ecf928d6325b6 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -130,9 +130,9 @@ struct gendisk { * major/first_minor/minors should not be set by any new driver, the * block core will take care of allocating them automatically. */ - int major; - int first_minor; - int minors; + unsigned int major; + unsigned int first_minor; + unsigned int minors; char disk_name[DISK_NAME_LEN]; /* name of major driver */