From patchwork Wed Oct 5 05:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998989 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 1790AC433FE for ; Wed, 5 Oct 2022 05:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbiJEFBJ (ORCPT ); Wed, 5 Oct 2022 01:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiJEFBE (ORCPT ); Wed, 5 Oct 2022 01:01:04 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1EE733C1; Tue, 4 Oct 2022 22:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dFLQLYfurYo3DxshNkpVRZLnN3G0PPT/t5fQij1gXlwAPAw2L8x5yAw4wdoQ4hNgxvGZWu1RYTh0TdJA2MunyjztJBjNQO2MdKBt5gy5UNmfQEDlAtHicy1Y9XgQ7AuCE8PzMdujXrwasd5BPmkqZKNVH3WPYuqJgmhNWb+vnjuoYEjteB5wTf6AXz1N6lDuLUPQ5521eBBykSxylRDCQZzVOz1MzpxlJDGlPG0mFN4jxKje3mjmqg7mEqwQ3URfQ716qLCOFro1Am6EWH1mJ9d8CaWCQFdjnstRtjN7PBTuesPVg2waIDy/kutKO0bBIoTnClePr3ovoHAMp/zeGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=scnW2Xsya/kBm3v46oGlai56SM3aaT0CZqakUx7jxug=; b=TM+OYENpvbptB6MfzTxSYPzBcbPijqN5NZTdxKyTZehreyF7ql0Ird/kfPMFWaNAEd8iPgVvfZOy5VZfLeI8SlizGASg6gkQn+JGz5dR3lk7Pb6fPM3qB7k1SlyBRmtTvaSpH7E7BQAjb8GzRztwIKiNJoJhvFszMj7JvDf3YTtqoa9twySDB9Yf+PnPeklPiPPbFlmvY4cQ6VFsEvHie8tUE/zdZs4cYLDn+3stBwVH1BcZvm/yUgev3e/NTK/CI4UZUKYj628rNeshmaU52iRRHXlnAiDWZDDVHLjQCzaTkLQ3qR3TmIyVhmItooaCI91WpqlgYulfTdzKPvFE9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=scnW2Xsya/kBm3v46oGlai56SM3aaT0CZqakUx7jxug=; b=SrU5ZOdoC+LFehnJGhvPgKNqP8Hfi4/mMqKnHlZ/FI4JVWhXMW2+SVTuAV+BbZvPBqVbqMS5lH5vDyLvuxzyXxEgGkjLVk4AbQOTsVd5eatDMv9ng4WAATWlLuFlAiHeJQS5QQ/rjPuWsIGzO/ockd6JWzdQfaUdUIyisJBpN546VsoyzyYKfWqvKeX96duU/81/lXCNp5HDZHXLPjXPnSvGrkpXcuGStzeJMEo6rVzM1spKhccl7P+/l3oFhByQp6Ra6KnpPlICNKa/Qt7fxaZtY7o+snZy6PJEpdIcRZkIytBS+bNOhfV7vAxBC17ZlmJJsdeKzt5fRFiFeQkkKw== Received: from DS7PR05CA0047.namprd05.prod.outlook.com (2603:10b6:8:2f::26) by SJ0PR12MB5405.namprd12.prod.outlook.com (2603:10b6:a03:3af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Wed, 5 Oct 2022 05:01:00 +0000 Received: from DM6NAM11FT100.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::91) by DS7PR05CA0047.outlook.office365.com (2603:10b6:8:2f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.11 via Frontend Transport; Wed, 5 Oct 2022 05:01:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT100.mail.protection.outlook.com (10.13.172.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:00:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:00:49 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:00:47 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 01/18] block: add and use init disk helper Date: Tue, 4 Oct 2022 22:00:10 -0700 Message-ID: <20221005050027.39591-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT100:EE_|SJ0PR12MB5405:EE_ X-MS-Office365-Filtering-Correlation-Id: 47961f58-4358-45fe-167a-08daa68e9853 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QbIrNtqlfhAbf/gf03oLsqVoqKo753H703gSw1lUPUiXt7oaSI6ree+VIpCOMvdAqE94vQyoxnuUyXSC0s/FqYjkWuToCT19jSTxar1Qvr8Ek6Ij6QFOcqE/Y+u7iQZB1Pu6p+f4ruhKo8EYd5GBEroFyi4KCFQU682x3r3SaEa97yBYXaXnJrEUnJIG5/G+EDd6BSdtN65TDdPoJ8oEvOQ8VnLLFTptkgDm5FUAjEuYlXEpLu2QA23LK6ojILRQNly3zBZdU503+gI7uitx+1519lMJGyebhyvdOKxfVGJjILaEdcHDCCxllTImovuynxaDw68qgz+3rb557CbBNUSnVHFBjPlB9AgmKcLxWFwHJR4d2bmf/FlBRSsBsDptwk5BfV9mCswCiJXGFDwV1GN+hNcdwb2ioi2NxXvTCUl52wRPfMWxZo+yw6BOICSewAm0K3PMo+QZrvvB7MH8900dXeOTeHXs140ngBW4fDu3xh5p0QJnquL8Deb9yv4kOZs6cDEW1deIQ7WzwOb2oxImzqStP+3gX1EJoxE0ARWlT5NiV58Ixmb98I2M1saoWNNNdD1FxBCGfYbb9hf9YcTwA57DT3Rde4zzOYO+OtlGXe918REc1Y/jlB4i29txIz7MlstcYoGc2lwh+PY74BawL9q9QFzk/CtPy/RcIaAeSYqDABSFD2nKSPcNd869j+Z8AJam+RN1LbEfqUa+659mKaPD5S/ixOV88/uUo4UrD+DDl2QUXNblb6VejE+N/WHZg0eao3jBRXRa95asVS+zYITuTknQDXsAvneR3kQ= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(396003)(376002)(346002)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(6666004)(36756003)(426003)(7696005)(478600001)(26005)(7636003)(4326008)(8676002)(47076005)(36860700001)(83380400001)(2616005)(40460700003)(2906002)(356005)(336012)(16526019)(316002)(110136005)(186003)(1076003)(41300700001)(40480700001)(70206006)(82740400003)(8936002)(70586007)(7416002)(5660300002)(54906003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:00:59.5620 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47961f58-4358-45fe-167a-08daa68e9853 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT100.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5405 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- block/genhd.c | 13 +++++++++++++ drivers/block/null_blk/main.c | 12 ++++-------- include/linux/blkdev.h | 5 +++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 514395361d7c..701309a7388e 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1470,3 +1470,16 @@ void inc_diskseq(struct gendisk *disk) { disk->diskseq = atomic64_inc_return(&diskseq); } + +void init_disk(struct gendisk *disk, int major, int first_minor, + int minors, sector_t sectors, void *private_data, + const struct block_device_operations *fops) +{ + disk->major = major; + disk->first_minor = first_minor; + disk->minors = minors; + set_capacity(disk, sectors); + disk->private_data = private_data; + disk->fops = fops; +} +EXPORT_SYMBOL_GPL(init_disk); diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1f154f92f4c2..d31085c94fd3 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1871,18 +1871,14 @@ static int init_driver_queues(struct nullb *nullb) static int null_gendisk_register(struct nullb *nullb) { sector_t size = ((sector_t)nullb->dev->size * SZ_1M) >> SECTOR_SHIFT; + const struct block_device_operations *fops; struct gendisk *disk = nullb->disk; - set_capacity(disk, size); - - disk->major = null_major; - disk->first_minor = nullb->index; - disk->minors = 1; if (queue_is_mq(nullb->q)) - disk->fops = &null_rq_ops; + fops = &null_rq_ops; else - disk->fops = &null_bio_ops; - disk->private_data = nullb; + fops = &null_bio_ops; + init_disk(disk, null_major, nullb->index, 1, size, nullb, fops); strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN); if (nullb->dev->zoned) { diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 49373d002631..cb9db857f890 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -757,6 +757,11 @@ static inline int __must_check add_disk(struct gendisk *disk) { return device_add_disk(NULL, disk, NULL); } + +void init_disk(struct gendisk *disk, int major, int first_minor, + int minors, sector_t sectors, void *private_data, + const struct block_device_operations *fops); + void del_gendisk(struct gendisk *gp); void invalidate_disk(struct gendisk *disk); void set_disk_ro(struct gendisk *disk, bool read_only); From patchwork Wed Oct 5 05:00:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998990 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 A3559C433FE for ; Wed, 5 Oct 2022 05:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbiJEFBb (ORCPT ); Wed, 5 Oct 2022 01:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbiJEFBP (ORCPT ); Wed, 5 Oct 2022 01:01:15 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2043.outbound.protection.outlook.com [40.107.220.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF580733C2; Tue, 4 Oct 2022 22:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BuBsSGHoSij8DAyIFrB4j4Sx2h+gmAl5kD0oBF5Q4j7PXZI+xjFA+4F8CUbxUPPaOlVE3mdJmkTfV6lv8hOEy7W3nvrlyBUuxxlXOCBfPhPCwE0KpH9sbia1DkI/sfl3MzM+duW9J4AAQu//EaBLqXq+Dbg4HMOWNlpp2ntRXS7Svu0olMKNR3qnKPF9zlMXPAIKK9E5SSxeuvkme9MDhjtFSaNgkUdULN8rCXiKCY5r6oThIY3WR5tnhz+LTlUzvxYRUht6OufjzWaYlKPIxCtHrMptPh0ErVVt4hQ9avGCoKA+jqh49xP6g9YxaRRHhCQzPS1JrIN5fwE+Hrncdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9+hWFXD7w1pH08kchvxYLyGqOHFyNMvnAWLDOWycxz0=; b=hL7pelQR37MKFgwRqZOT2/o4jpsNgcg4H6yxbdxTTSpGcP2Rpa/olXjsTy+G7oYpZfsfDq4XiJaBQD3SYZ4PTzEiUMvNflMgZI08tZowzu4plhSBJzq51QVNB66OEAqiGVLF74+iYNHL2l7APbT48CJYgyoMdE2eav+oo/qgRrydrg3BVTw/5mf16/BDQPb+akZ6LHEqsrPAjbg+pFzUOLUdsFlmdmKy2kpCfo7nTkEvpB2SagRaLgTUW6xcHlzQLA+PkTz48UWFHkL0fzRYuWjoSek6jPyTfhHP4K5Pl3LRm78o5NUBI1LwWvXp1TybHgKh2LOrVWduAsPkBQfYVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9+hWFXD7w1pH08kchvxYLyGqOHFyNMvnAWLDOWycxz0=; b=VU1dG5waPGIbBU3D6Q/akGAZOGDRTPH7cqqAP1pZ5ZlnRPK182n6JhMEZMKLYwG9P5HbwlBH2ay/6ofsfGLDiDnd+OCG6vT11IjLrzndNgQTwogU80+hlVYGwk1mzBDQUeiWMIvuVv1JntA7GOWQmPLCpZGERJqXuPj5KhvG25PfKiF4XSIiggUmxycVaHxiLkDX47gBzFETwmfZHbouXEoWTL3Ni8npVNePtrYDW+OzZt/drGo2vo6+uR/4a/3/tr8W42LM8JHzjdiCoKYSjPGHD4cs9i1V9iQM3Kw2XqVLpqBKmgqr5F78n+6GSfIU2x1QIqm8+QEnwHNJQP0mnQ== Received: from MW3PR05CA0026.namprd05.prod.outlook.com (2603:10b6:303:2b::31) by CH0PR12MB5042.namprd12.prod.outlook.com (2603:10b6:610:e1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 5 Oct 2022 05:01:12 +0000 Received: from CO1NAM11FT081.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2b:cafe::3e) by MW3PR05CA0026.outlook.office365.com (2603:10b6:303:2b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.7 via Frontend Transport; Wed, 5 Oct 2022 05:01:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT081.mail.protection.outlook.com (10.13.174.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:01:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:00 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:00:59 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 02/18] nfblock: use init disk helper Date: Tue, 4 Oct 2022 22:00:11 -0700 Message-ID: <20221005050027.39591-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT081:EE_|CH0PR12MB5042:EE_ X-MS-Office365-Filtering-Correlation-Id: b3119055-1693-429f-062a-08daa68e9f08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: isFAiDsqSaF/uc9JuNH1VgxatKxFu6KOEDONYfon/AS7I8aJ2xdrs/PuPyz0hD7R3Dmi4fafffg5WB961guBBgyNhidIGnxmJN119WVBsHhNqkQc9KUCUGdxMhf+9g72G4CNsxf0TYIOQt3ChTsjAfz2QkMgHkeS4cMee7hHbenxYKYfzbBy4pTcb4v0U+pe4Zvv+vrVa8wpkR24NHksoRt5/VxX2DiAfDPvbeIxfUjUzQfj4fwCsKlcLifDm2YA6EMhLt1LUdiLNuovjFZnVrZ1fCh2BAXmBdJn1nSSY7Ag1ILUxBpxZGZMU7VQ43yBNPw6DZaqHMefuRXTFdTrGcCxft4fwjGhRw/JdDy/dtxNu7A0XRcF/S5IK36Dxh4raX5GDeCsS/eWRycE/HR5V1FoqrOSBvDtJs4VLz8rF7EEZB9gE6BydW/H5NPX2cHwT1JnUUwwXClDYlg4gQWGxd0Hr0Ar4fjSmF7BmkOSmFxgL+H2AXdvTgtwdXF+GHFSFcheg0D2P2PT8Sx7+XduYgugXu84QOrS+7lZjydIPqEuKNCSdYaLcnCyzbSuNPp4HxesmElhkyduSw94J0HnSyGB057bWDyC3t08YpdgAU7wdVDpZQiBYq6HBi6vX9NcMAZ0urpmIpFs2sbBSjAwBRE0d5L9MHOcrvBFnQfpsbC9Ykp2pMjF8jO3c/D/dA8vJczyo5yVb4QB/wXlgEVN2mHTKuGCTwx2ioYc6+9LofPuw79o5egr6Y09+exwUVH2up1lOp7n1XfgPwufPBGZMvSV5ItVZJj0vDuTh8fvAxE= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(8676002)(36756003)(5660300002)(2906002)(8936002)(70586007)(70206006)(40460700003)(316002)(7416002)(41300700001)(4326008)(26005)(6666004)(7636003)(40480700001)(356005)(110136005)(36860700001)(1076003)(82310400005)(16526019)(54906003)(7696005)(47076005)(2616005)(426003)(478600001)(83380400001)(336012)(82740400003)(186003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:01:10.9079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3119055-1693-429f-062a-08daa68e9f08 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT081.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5042 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- arch/m68k/emu/nfblock.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/m68k/emu/nfblock.c b/arch/m68k/emu/nfblock.c index a708fbd5a844..81d3d3edace6 100644 --- a/arch/m68k/emu/nfblock.c +++ b/arch/m68k/emu/nfblock.c @@ -121,13 +121,9 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize) if (!dev->disk) goto free_dev; - dev->disk->major = major_num; - dev->disk->first_minor = dev_id * 16; - dev->disk->minors = 16; - dev->disk->fops = &nfhd_ops; - dev->disk->private_data = dev; + init_disk(dev->disk, major_num, dev_id * 16, 16, + (sector_t)blocks * (bsize / 512), dev, &nfhd_ops); sprintf(dev->disk->disk_name, "nfhd%u", dev_id); - set_capacity(dev->disk, (sector_t)blocks * (bsize / 512)); blk_queue_logical_block_size(dev->disk->queue, bsize); err = add_disk(dev->disk); if (err) From patchwork Wed Oct 5 05:00:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998991 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 9BA05C4332F for ; Wed, 5 Oct 2022 05:01:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbiJEFBr (ORCPT ); Wed, 5 Oct 2022 01:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiJEFBg (ORCPT ); Wed, 5 Oct 2022 01:01:36 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2057.outbound.protection.outlook.com [40.107.223.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FDFA7333A; Tue, 4 Oct 2022 22:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=magKLvnrfH01xG5i/5zBxn+ueDau8LLCHXv2JcG4b4I6v4waghdqVWjSW/socP6POStDylPRGM+6mNxPKs8JJ9gcL6CDqWBAvvDRNddLc9+8AkJqd5zzYB6lEO4HswzEQhpQj1kUSbQUOh3YTjMMhD5+1uCrDRMKu8Chr1w2zl5uXyzx2QDILOovWuPyCa3ZzvgLJSRJvCzXZ6Yq36bEiHEG2nBT+ZaiYoniRyizSCdjH/Ys1o1+kE+jGLOJQPzoejUK+tN7Asuwu48lXYqj4gr712ehaHr8I1QehMrzpxKMjcAKJaHCjZeKzkal06BBhWI4pUCt7G68HfED48dGag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sJP0HjxKqbqm2cPL0D23Vy8DyY+XnISaSuaPl2ELDEk=; b=c2moDgH/LQeZV80cZwlCUJJPYixrpyUkV2MalnjYjHhctNlTbLnLl1cHvusZ7Gud66AL7CUjpvIweNoxYK1UutDjEif0kzZhN0tOgpdtQmxjerL5vNzgUR8yliXsyYRsqtvDnAdCahygLiMtUgrr8ov4DVPPI2Jagof70c0sjyVb2InrLPQvKvfQhQEcYTSN29PFSGhI68Pg/UgTHndsBb/gKkbqB10DQBMHNsi3TVPRAdRuRGBHYsqtrDY/gqtBtVjBiqhpw5PlEYs4J19huAKK+3fvGPFtz1XbpOklwjkQ5Z+XyuwUMZhZgWd8znlePleScsOlluDfXYfAIeGcvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJP0HjxKqbqm2cPL0D23Vy8DyY+XnISaSuaPl2ELDEk=; b=lLbaXg1CToKwn0fJQnesE8m9T4zeWar/lzL7WD3lDc7KgX9mCdZGnByUPAi0fnyrVU8GYfzXpYgNODUA4BNS2IXdxyRtZVy3cFUy8/UnTrRra5fubjCGguv46Eq7z7QxemGXMbzDjkD0Z+QKcz2j74DxgkrwPyoHJ2KAbiVeGoFhJlTYSg+1tzsUsotfY08jgMUWGsNvfphyejNjbVlj/dbblmMSluvNKPyzWARtpVt6CGCfV1OKkvId6A1H0uqU3oR/1+2+DnAllwc2Pdh9MxJMaQjYG6KvM0Z6IHtjLV5+exMYxKdbgRhMXPrpmOBsoM5QA9bDwZyXH6FcO/BNbQ== Received: from DM6PR21CA0022.namprd21.prod.outlook.com (2603:10b6:5:174::32) by DM4PR12MB6637.namprd12.prod.outlook.com (2603:10b6:8:bb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31; Wed, 5 Oct 2022 05:01:32 +0000 Received: from DM6NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::af) by DM6PR21CA0022.outlook.office365.com (2603:10b6:5:174::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.8 via Frontend Transport; Wed, 5 Oct 2022 05:01:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT112.mail.protection.outlook.com (10.13.173.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:01:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:12 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:01:11 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 03/18] amiflop: use init disk helper Date: Tue, 4 Oct 2022 22:00:12 -0700 Message-ID: <20221005050027.39591-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT112:EE_|DM4PR12MB6637:EE_ X-MS-Office365-Filtering-Correlation-Id: 015a58a7-467c-41b8-86b2-08daa68eabaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PzprjFkKHROONXcQ/BAh9OJW7TC9NuBrrwffpsNsEvOZWdDtb2drAF/9pqEq0Yz+i6iFjvSYkJDZIT/FNWgECniZ70oNDk6zjhdLsDKCZZ3inLx4dXR+m1C+2qFzSm0IB54Jk39NnF4Vprp8C8BEF7ihDjfR1KbS2hRa4iMP2oFTy0Vdxb9CzKSz5YiyeoJYDTdYGcrI+jXCElnRfcJCFebVBe3ea5zrLLHbqQVnsPPXMaUln+gcyLsc2+Wy0rifJAYRbjMTM+lxyypS9ZqYt8jXEriAQYQuApF7P3LkzuZUxYtoxNrCdD1AlqwzZqyJDGfWaCpOLiBo6ARDz6P453ssLshFn/Mkc2/Qq4L+ruIlZ8isikEULUPbfQTOy0qyEpTRgNsIEXg6QV8y+iVONSFZAJaalj9KmfYoAVPkSnRXzLVk/eesMfzDYdtMisltdw7+Kc9DA2rXEpxUW3xRGFz6YXTdBg2Sf08y/jQCQNUKQqIiW6kQiifKXJals7Jk0mbOPIVic3lY8Qw5Q0eKPPJM8nhUfg9lBX91cb1IbxEANAQ7nCkvkEtH/2LcfvtcbP1dMdqrTDhQ5g20otdGwnf59DhBJUVtPHps+ADVlXEI7rGne690hoAD0M9TaL7MykD2AMroThGT271amts89c0LoXr2FK3vbHwMmEIPvDJm9PxuaXqppd6BlwOxOFPzjRDDI9MQCTr4euapzn2u/JbqMP97aGMst8zmNNbxmTK1u9v6STrnhkN0h8PLfYbch9amgsIlYCgEGH+WJ9h1K7CdKTu9JCV0HIHPHWqycSQ= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(40480700001)(36860700001)(82310400005)(16526019)(41300700001)(2906002)(7696005)(2616005)(110136005)(54906003)(36756003)(40460700003)(26005)(336012)(356005)(316002)(8936002)(8676002)(4326008)(478600001)(83380400001)(7416002)(426003)(47076005)(7636003)(186003)(5660300002)(70586007)(1076003)(82740400003)(70206006)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:01:32.0118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 015a58a7-467c-41b8-86b2-08daa68eabaa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6637 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/amiflop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 4c8b2ba579ee..40f220fd61a7 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1786,18 +1786,14 @@ static int fd_alloc_disk(int drive, int system) if (IS_ERR(disk)) return PTR_ERR(disk); - disk->major = FLOPPY_MAJOR; - disk->first_minor = drive + system; - disk->minors = 1; - disk->fops = &floppy_fops; disk->flags |= GENHD_FL_NO_PART; disk->events = DISK_EVENT_MEDIA_CHANGE; if (system) sprintf(disk->disk_name, "fd%d_msdos", drive); else sprintf(disk->disk_name, "fd%d", drive); - disk->private_data = &unit[drive]; - set_capacity(disk, 880 * 2); + init_disk(disk, FLOPPY_MAJOR, drive + system, 1, 880 * 2, &unit[drive], + &floppy_fops); unit[drive].gendisk[system] = disk; err = add_disk(disk); From patchwork Wed Oct 5 05:00:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998992 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 CF605C433FE for ; Wed, 5 Oct 2022 05:02:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230026AbiJEFCK (ORCPT ); Wed, 5 Oct 2022 01:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiJEFBn (ORCPT ); Wed, 5 Oct 2022 01:01:43 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2041.outbound.protection.outlook.com [40.107.95.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB71733D8; Tue, 4 Oct 2022 22:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgxMm0raoX9bFrZmNITnpS/0ZHZJzUfPa1um5LJOhFcAbrPaG7dhFz4rSL7+ruqGwFOkoBS3r1UAXlQFUyl0PWmv/XOB+HO6qlcnPBf7N2who2Bmad/RFz1UVMOWhY5RBbWjrFWkufvurFBne1XAqZ82or8MMH85NkIA5hNPksDK429dy0W7xbEYfe44/qRYS9b0iMMKIxoEhStQv73PsQafqd9BQpSA+JQFd1rO+IOcpkHOEluMOM0hGnhJ1rHJV5x370owGqTxu4MUPRsI+jV6ZK711L8gjIhN1ZObmp0KgT5tiYP4/E76+fbRTX8JtnI0uL7HWLfpkN+w0jLX9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EDQoyOcWJRzgzApnOsj06MNo4yMyxG1Q+K+A+NPH2CM=; b=I8f0U3boiinhl8g1+ml/PveRkt7by3fVDz728E4d/UsBVBtGrd3ROV2WRptIHmlu+I31360XDOHK3aDf1n1FRYObWzjpf7IUcEQD6rbSnTUwFk9uqadl+Rtr+DqKkFwYVniVazKPk1kWZxUsz7jjhTSeEmSynIvdPPukgKReFnWxEa9SiR46Oy3Zb5QImLmvL8uop4n2lzw4QIucQaaedMJimlx+pistMDnwDwhKQBtuUYABLRBdLEnlWhgM3WiVnexOiBSnxZudeMWXBRsQHQ6XFJCZ95C5w9vQ6K5dbmoCPy/X02yJcGINW52XwliAPRVAm2OrY7vmakLTuQzAPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EDQoyOcWJRzgzApnOsj06MNo4yMyxG1Q+K+A+NPH2CM=; b=g14bBWOrCLD39ttLJwfhcIXcrUJwrklgea3v6ilkSBKuesdP/+ye6x7++UeQL1guPXltmPY7ikU8mipFNgwQdapOpWlKsegWctoidrm3ILXT/0AaBV7jU1SlqXJTe2CU72XGDxTKUXFN93+idMkbxAdV5ml6Fzhb9zAzzL6t+irmtBEI7zAhZoIVNSn+ceOgUziZRH4quV7mDAYpNIAH02XObxIzoLf0kylfJEBejOeAUhkMk7uMCVqg2/PMJmynKA2jdX56HQBUa9NKO6t6THcDMQhFyjAUdgtckooQrPEccto8UfYpce0x4TzUwI5vUiDuvGsCEYDCut3qJpzVKA== Received: from DM6PR21CA0019.namprd21.prod.outlook.com (2603:10b6:5:174::29) by PH7PR12MB5711.namprd12.prod.outlook.com (2603:10b6:510:1e2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Wed, 5 Oct 2022 05:01:37 +0000 Received: from DM6NAM11FT112.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::ef) by DM6PR21CA0019.outlook.office365.com (2603:10b6:5:174::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.9 via Frontend Transport; Wed, 5 Oct 2022 05:01:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT112.mail.protection.outlook.com (10.13.173.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:01:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:24 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:01:23 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 04/18] brd: use init disk helper Date: Tue, 4 Oct 2022 22:00:13 -0700 Message-ID: <20221005050027.39591-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT112:EE_|PH7PR12MB5711:EE_ X-MS-Office365-Filtering-Correlation-Id: 65b42157-e7b5-4bf3-e4fe-08daa68eaeba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jThZbbniUmpMyhmqACf8FDoNh6MpBOSNnmtzYmvgumvibMnyLLi8tr3zndO9EKuZSLiu2wi6ygd4OVUwKM3CIyAImu07q79N7pyBlNN6JQXs8ybMyI+KKqyYXRjRCxi8mjuU/8xUvVWUbVff3uyniW4ia4CyK5qwN673Fw85+skh1lRf56qzEjCVD57xiQ2f129lg6UsACmZmVGVB4k+bHhOrkR95vKkkDvXrOOFveJwarZZiMG5VuH2CSmN3VUS/MwIg/KMc4pXDjJp3kZtQ+GZwaKrQWy84ibAebXC5zMEaAJzM8dMl5Wc2wDyXnIuuokCg6CA+jhROi8SIapgQdDmvTxdPvD1gj+RV2JPzYArZo3HuD5kjLiMRooIXIqidxoRW/86cbA2qNUYgWsHMyTX0XyRPdoYFhScA+EG8a6ErEsLgfmYGnMeaFnrpwk8wydAPyJVx0B+z09PG6XFdc6aIzhzmywTvt7KB865W/I4ut0daEwCaVxPWazzPOo0YsQL73wzrCZArjycNaMMkoImgeCpkD7XmTjKVie7BDDhKN5iIZNNWXxwuUe/ynXU1Aua1ktrjdlgcoZQXaldv9oXiERmRjVUBXb5vfwmb0mA3wswuLksb6NPi7VzXTa3PITomVHzEAJEcuGo6IGlTKYt9Q/6IEtvUvWJ0vkkDXzBUxKa4iLj3AZEhHHtoG6s7ffi7+B7XXpp9jtdh7/8rigEbDPvtNIize293iFCxlftBWxm6C3Ft4+wM4r5VAgarH4C6/kO/CTX1vS52uWt2Htt0RrPTTNYHR7oc4Gz3rQ= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(478600001)(6666004)(336012)(426003)(83380400001)(26005)(8936002)(2616005)(1076003)(47076005)(40460700003)(2906002)(16526019)(7696005)(186003)(82310400005)(7416002)(54906003)(316002)(4326008)(70586007)(110136005)(5660300002)(41300700001)(70206006)(8676002)(7636003)(356005)(82740400003)(36860700001)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:01:37.1522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65b42157-e7b5-4bf3-e4fe-08daa68eaeba X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT112.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5711 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/ataflop.c | 8 ++------ drivers/block/brd.c | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 9deb4df6bdb8..cd70f7b329c4 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1997,15 +1997,11 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type) if (IS_ERR(disk)) return PTR_ERR(disk); - disk->major = FLOPPY_MAJOR; - disk->first_minor = drive + (type << 2); - disk->minors = 1; sprintf(disk->disk_name, "fd%d", drive); - disk->fops = &floppy_fops; disk->flags |= GENHD_FL_NO_PART; disk->events = DISK_EVENT_MEDIA_CHANGE; - disk->private_data = &unit[drive]; - set_capacity(disk, MAX_DISK_SIZE * 2); + init_disk(disk, FLOPPY_MAJOR, drive + (type << 2), 1, + MAX_DISK_SIZE * 2, &unit[drive], &floppy_fops); unit[drive].disk[type] = disk; return 0; diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 20acc4a1fd6d..f60fda36a813 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -392,14 +392,9 @@ static int brd_alloc(int i) if (!disk) goto out_free_dev; - disk->major = RAMDISK_MAJOR; - disk->first_minor = i * max_part; - disk->minors = max_part; - disk->fops = &brd_fops; - disk->private_data = brd; strscpy(disk->disk_name, buf, DISK_NAME_LEN); - set_capacity(disk, rd_size * 2); - + init_disk(disk, RAMDISK_MAJOR, i * max_part, max_part, rd_size * 2, + brd, &brd_fops); /* * This is so fdisk will align partitions on 4k, because of * direct_access API needing 4k alignment, returning a PFN From patchwork Wed Oct 5 05:00:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998993 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 54AB4C433F5 for ; Wed, 5 Oct 2022 05:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbiJEFCN (ORCPT ); Wed, 5 Oct 2022 01:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbiJEFBq (ORCPT ); Wed, 5 Oct 2022 01:01:46 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B40FA733EA; Tue, 4 Oct 2022 22:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZlmVp8xMMiR6xNUPYXVZx0V33pYiLtmHWi+xrxmf82dVV2l+yFandfLGGdWtQg5QXd+liTVDQkUG5FxbzNjGb72pRNi10/0rPUdFj0GJvj//kHrKAZLeN9R6dGWzMCNBLrlfDFmQpsMG4ebtgqfzqyRtgopllqX12kpdFmiMgaU4ZOrqzFLWqm+QdWIi9PToaimxbm5D2D87vFfo3VJBGC1nLSvsdp+oK5jFEJ4WKu0g0oGhwtureqE+dw43BL8WOd2P6z+z5zqMT6irKBBRQ89pGHx0Lr+mMMeAdtQYGkY/v8+5afavTBNxAg8TUXow2/q+Uch4qTGzEIZmSgKfOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZxfbJRt2BKtuidsfyYK1/83azNXpZLxlDE6e54jzQ/o=; b=XfQC6x/xLYCn9zACQVuog5fc2poI/JkXjbvHQyUa68TcjyNCZHjoj2UM3p5qvTWtv8fT30/Jtv9e2p6HO0d2/wYHapTQQ2L6tFJoJzs8Uw/dIhhFDoUzt2Fg7iHFuBavpY1/UilbbFSxZaq5CJ802lE3YSk4o7u9eh7QaLANCmUtYJLrZzZTwFwW+GJV8Z/6neTABsVl6RitirRJ+yUbdHLdYXx4eZFO0BRujddSuwRMIW0tB/sSafTWlQL8f6rjHQ2hZ1ZP9TyFVY51U/czcaytvZy2M86fy4pgiWTh0UxBZVNWaqbzfBX6PfVVFg6FTPkvOWPf6WISO+h6oOMuUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZxfbJRt2BKtuidsfyYK1/83azNXpZLxlDE6e54jzQ/o=; b=d2Rtnn2P5Xuxbb7wtpPYIs2Vvg0ZFXqtpoVdiJj7Qqgnh12wNsdiDsfimtB8IdLRNmxVCe49dXH9zll17+3hextRZwfev72QpxnLuOWBd5YlJvQk+oeM9jzYsvYmn9KP+Lps/hIEzqzco9zEsD9fD63zcXDCx3pr8gdQo86Db7Gt5J8K87iSFSPc7nMARXgG6Zmc1HV8MJQGn7gGfjWbVxSDBkr/xz0VQz1PnxYIfrI9RVkjuEV4YJdtl6RRp+M1YopQVCKlxRkDSMslLwYpBrn13p+yHmcTpH2RTi+I+UuFBsu8DwoAZ+sh1FeaEe2k6YZt6t2Aa+qrqegurFs8lw== Received: from DM6PR03CA0092.namprd03.prod.outlook.com (2603:10b6:5:333::25) by SN7PR12MB7449.namprd12.prod.outlook.com (2603:10b6:806:299::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 05:01:43 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::cd) by DM6PR03CA0092.outlook.office365.com (2603:10b6:5:333::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28 via Frontend Transport; Wed, 5 Oct 2022 05:01:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:01:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:36 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:01:34 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 05/18] drbd: use init disk helper Date: Tue, 4 Oct 2022 22:00:14 -0700 Message-ID: <20221005050027.39591-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT035:EE_|SN7PR12MB7449:EE_ X-MS-Office365-Filtering-Correlation-Id: b18ee13e-dd62-465d-442c-08daa68eb1fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o1RG+PviX+SAr504ahLHHbhYY+N/OAg4Kb3/b51ApVh5WbH5RLNaWdrhF1RtU4WqvFYT5qk/Vo649OoUpZhPvyHl8ty9uRyu7diANc7AIdw8pl/cfBcBqdsISSMH7kwVjChs5ysWEgWGJ4Fok37/kTThJ2wdh7Jbjk0cUazieIWnpHNNCtkifZH6LX2vqhDbHpxQP+/56tPpicoCBNBpwhfS9lQv2r02ofDeTHwquMvQ3yHDbcHc8ijH4H3RVrBed6gq9Rf/cjhVR3yiKYGiUwedlSv5Fjoi6p4dofecCnxlb/8R54909JQHGfzj4VofxcnL5DutScGnvYsRltY8caLu504968wCusjFHjKoQ3iBRn6B4TdMIYhSp5ILjS8nDenxr/vRVqRFYyBo12JkyNQOrMFvnomYQ4zM5lpH4R/fLKHBlpFZLq5gmYkQiEo9e3od8Ohd4pS7ywJkkm9FeH/kf0bi9hXjZzTJBM56aG9vBjXgU8zu1T3yjT2JedVDA0wQXLrwazZQLW+6aa+S58VoL78rv5nSBkEZCCeATvQ3UOHtwHuYHetQALh6tMuN2ndsN0/gQRHen9oFgDIuMXct+JHvCGHJ9FPPEQR+QTgZQNuUs0zTVN989pTqHQGbjHZadBokA5kxqXEEfBk2UCkQbU+7lPB/qMWoZ6XsgqWduLMAbCfKMmjpw8QfnwRAj+/g5WgpRvZvGcwyMbcOedlLdbv/I84ZaZFubtNRcOnJSzB7iqdDasrNxGLfMsnUcrOAZ1lDo3LE9cptq0GVwmylVv7qOsDg3f1BZ3Os7sU= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(36840700001)(46966006)(40470700004)(83380400001)(186003)(16526019)(336012)(426003)(47076005)(356005)(7636003)(82310400005)(36860700001)(82740400003)(41300700001)(8936002)(5660300002)(7416002)(316002)(54906003)(110136005)(40480700001)(8676002)(70586007)(70206006)(4326008)(26005)(7696005)(6666004)(40460700003)(2616005)(1076003)(2906002)(478600001)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:01:42.6007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b18ee13e-dd62-465d-442c-08daa68eb1fa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7449 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/drbd/drbd_main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index f3e4db16fd07..58fae122de16 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2706,13 +2706,9 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig set_disk_ro(disk, true); - disk->major = DRBD_MAJOR; - disk->first_minor = minor; - disk->minors = 1; - disk->fops = &drbd_ops; disk->flags |= GENHD_FL_NO_PART; sprintf(disk->disk_name, "drbd%d", minor); - disk->private_data = device; + init_disk(disk, DRBD_MAJOR, minor, 1, 0, device, &drbd_ops); blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); blk_queue_write_cache(disk->queue, true, true); From patchwork Wed Oct 5 05:00:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998994 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 5A0C7C433FE for ; Wed, 5 Oct 2022 05:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbiJEFCm (ORCPT ); Wed, 5 Oct 2022 01:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbiJEFCL (ORCPT ); Wed, 5 Oct 2022 01:02:11 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBECF7392C; Tue, 4 Oct 2022 22:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lsDtevQ43KutRcnE49bm5lafKJ+XX0jT3godeD2afCo3ftb6yKbJT8hm6GMs9uKVsNquX1HCgCfTYaSWfJtD+IbOsZl/taDUrFcZqlDW13V0YfMhEfLkmM8V4CYUH1IMIcJyRpyHGywanrTKFecLMCHXHGbr8Lc0rA9JEq8MvuMIwZmP58G3UpWv/1zOjRglOqLvWsbP6Pxghh1l1AYDHmnhUS2Vxd+U3Woya+7X49WLRAuYTpB7Q8+JqpjfjC04yeEhunb5cp3ctwqRD/yY1oz0/Zkwu4qQxyGVJa+F16wTrBdoieNyD74i5xbL3ds9VxaU7dgSSXH6lCR6f0dKJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KKmYNl5ebEs54KRb+rCqpu+4URjeGcZf7KmI7PhATIg=; b=G+IrbmKDo63QKDpeNO8w9ki/XJBQhuqhVJbHsy0xLKHaYQY0AgwFpntRpwezDs5DJharXY0m0gskTlBfeHPGAg3D0+yBpqo70FM1qQ/TnaJBjWSEa4AUVixPsUXdNaoNHuBMej5UhajLfb9AEM/267Q3UG7Y+FaZQo8oTQxneKekqQaUHvlGRXkg+8RB4gGv2YA0P36mLBXSa2Bg7vg+UgkRGRXFdcKjICLYBbXwDkLOJdQRnE0D7IgJJXdtZMcUKyzzP/626BRZvzSTN6PyfjO0qdHlztDaAQV8TWLYAIz/52rJUZKzFjpdYdtgsrvVIHHAWg037BtLtOknj+4DQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KKmYNl5ebEs54KRb+rCqpu+4URjeGcZf7KmI7PhATIg=; b=FqkOAGtExIaX78tp1b1ZWsieWiWPeI5lf1Olhhiv5ytdueQBIDuihF0JJAYReOEUBkLor19dEsmKmXXnOeCpO7A7YgZLwjcRJ2nldvqZ09omSwvi1jfuXJKIvh05y17+TcAq0mIdBTMNSO4USXWWva4pAMvvHFfjpnvUGnxwq/FbhluzdqzoCz6gQrgSQa9gio5YC/YgbIgq+pRLzHH7wHMep83C9EbIgqtNZ1HRQuZNgwuPAWTg9FOMtyTv9sG+vs9EDb9R+TpqwSpbPy0SLM/HPMjPgQ5C28rSy+4jcBUYwCIBLBWYGdAmwrWepEUbC9j11XNPLcpJBYsC/zs5Uw== Received: from DS7PR05CA0046.namprd05.prod.outlook.com (2603:10b6:8:2f::14) by MN2PR12MB4319.namprd12.prod.outlook.com (2603:10b6:208:1dc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 05:01:57 +0000 Received: from DM6NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::f8) by DS7PR05CA0046.outlook.office365.com (2603:10b6:8:2f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.9 via Frontend Transport; Wed, 5 Oct 2022 05:01:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT006.mail.protection.outlook.com (10.13.173.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:01:56 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:48 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:01:46 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 06/18] floppy: use init disk helper Date: Tue, 4 Oct 2022 22:00:15 -0700 Message-ID: <20221005050027.39591-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT006:EE_|MN2PR12MB4319:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f24eb98-307e-420c-5950-08daa68eba48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DDcak8M5rCvBx4mrZ3CWnZBWr+fCg//c5NYq8WvMpNAOYNSITgrXZvcs8h/CtPr9uUOCY5lDsn4dJEndkvD0d9XBDCerdxO7P4gjjPEUM8NbHDMyYQoYLDTDdELRMERnXok6hLnCYOJI1PJEZeaNyjt7UTRvIRjXi+H31Duq2qCiNthesyUsE17X0JR7DI1v1UJAnFUvUsx0tmCH6ok0pmejqsl7vBS13AFbn0DZGElV2/c4yf5DkeYa1VNZ6dUIOKoHefX6TpY5+q5Bwj/wGoWShelb+v/uUk7Mp16DGH0MNf1fZ4L+To80FqcsBe7C2361liZvS0TdSfcU2/6/zI0xRENk5GrR/o6H20S9QRLZQHc06VB9FQP6oEzGx5VUGh39KIHUasOTFaLQ3VMAT/r24ZZwAiCN0IOPmwMO19VjaVvF47GUrNyFG6YZhcytgr3kc81A5aQHMIQDOdBDEGmwvn9Tbt5bTDyuFANfsoXoIvK5KVSolJV5SSbH8VTVXq8lqa80GDfa129HnoTnwJWg4C0GA1U4mXZPhRLLNXcUxv6A2INzNl8GjYo9BSuBUvwFhJuOZE5XZTXzoJRP0PYC4iEwOZCDfo8y9/+K5Vbc5TKL2qcoQMETr+aa7JRIx3qLoDzsDVhRltF40B2E9Djjf6YxmWzj7P2oy4wFAYEAQ2zNKrO3FHsWLP29yhn8zFmC8c5sKz1SjP+Rsn9zdQU134YIrxQaGtgArCKMfPNryaVvTFGaq+Le/QIb3dzDVMnOPDAu+6sV/OddSougNnrU+IZYV9Llm4l7mP+arO8= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(82740400003)(478600001)(47076005)(40480700001)(6666004)(7696005)(2616005)(40460700003)(26005)(83380400001)(426003)(336012)(36756003)(1076003)(16526019)(186003)(5660300002)(8936002)(41300700001)(7416002)(2906002)(4326008)(82310400005)(8676002)(7636003)(316002)(36860700001)(356005)(54906003)(110136005)(70586007)(70206006)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:01:56.5342 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f24eb98-307e-420c-5950-08daa68eba48 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4319 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/floppy.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index ccad3d7b3ddd..7304fd87c038 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4516,18 +4516,14 @@ static int floppy_alloc_disk(unsigned int drive, unsigned int type) return PTR_ERR(disk); blk_queue_max_hw_sectors(disk->queue, 64); - disk->major = FLOPPY_MAJOR; - disk->first_minor = TOMINOR(drive) | (type << 2); - disk->minors = 1; - disk->fops = &floppy_fops; disk->flags |= GENHD_FL_NO_PART; disk->events = DISK_EVENT_MEDIA_CHANGE; + init_disk(disk, FLOPPY_MAJOR, TOMINOR(drive) | (type << 2), 1, 0, + (void *)(long)drive, &floppy_fops); if (type) sprintf(disk->disk_name, "fd%d_type%d", drive, type); else sprintf(disk->disk_name, "fd%d", drive); - /* to be cleaned up... */ - disk->private_data = (void *)(long)drive; disk->flags |= GENHD_FL_REMOVABLE; disks[drive][type] = disk; From patchwork Wed Oct 5 05:00:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998995 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 3276DC4332F for ; Wed, 5 Oct 2022 05:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiJEFC5 (ORCPT ); Wed, 5 Oct 2022 01:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiJEFCO (ORCPT ); Wed, 5 Oct 2022 01:02:14 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D870E74343; Tue, 4 Oct 2022 22:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QWknscsmqkIL6xOJmyCVe4D3+VWdptwcux4NNsBMZujugtvQ4+BOIxuohWiu5KqX0M5xYjP1BEfDzaSYAv6qh2C/PJ/u+jM7L3EJDnEVBXyTsQGjmHDvsHb+mkHIgG7q05xVzXW6AK2fg8vkMY+1HI+vdWIoShODynJge+epIQND2fCdKXLSC56qDZ6rXK60ecQSe7ivfnV+8qgTIgaiDsO2e+6QZ6ciOXNSQyiMYfrunG45RTBqcUwqAuYLldU3U/o5RpHt8vlr/1EPgiHUYbn3tWdq12TGWvkspz7dZFSsB8mtb4u2vUogS+4qxwTspvZBf3DPC++RtI2Xv8LQZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tk9MyVy1oXy3uv5w8WYL3X2gFiy9z92JS7cFu9tqVIw=; b=Xa47t8qX9FH+L7bGvmL3BioyM5mzAgXQD7E93N50Paef6bsmmrxA6XPiP/dXyigoMxxtKpmNUac7CIehmya84u8JX8WbMxY6jGBDoPiQP3WUrM648waDy7/6JW7KoMe6B57BmIa70luLhUh5+TcTXBbkY2vN098De9Co87iLB0G1ypsyWMp5lJ5jXUhltEFrsJTt9xirRY9Nz1yzVkMYYkaDvFrK6vTiXFZX31yjzzXFOlNZpxLU3BxEalLJtd00/Dfb4HTVOJsjL/DFIvEml2ONsdHi/o5IKuOERZ1chzeNuOjXWkeHfkZP/sx3UX21vmmmROOH3as2EyGA/GmJJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tk9MyVy1oXy3uv5w8WYL3X2gFiy9z92JS7cFu9tqVIw=; b=Bttd6s4zp3W6yRfKjrX9pMpf4YLh1OXQvQXMcHFS1miDFuwEAmGX6k3ckH9/EeMiX3THwlDz4ZxxntSSELbezLDcORt1FZuPbXYnsCsz+vv2P45i8MzM7y95+4itmjPF+pFnK/zGjTcKnqjsxo+P/fioVmAQqdpXgkKTAP1d+Y3AN6uUFBIU+9AkCEc0IKvNhzWQJ25mNIwttfR85QRrkmDQl5cVtz2fMX6ZkYDRou7ByRCu5ROkg2MGIk9OBUQHoJ6S4Sw02cM+Xsf7tq20Rt6+pKsIti2n5WInHtIKUJo692M1bFHdrlb2qBGXWx6QmZ6lDewXEiOdJgCSepR1CA== Received: from MW4PR04CA0148.namprd04.prod.outlook.com (2603:10b6:303:84::33) by MN0PR12MB6032.namprd12.prod.outlook.com (2603:10b6:208:3cc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 05:02:07 +0000 Received: from CO1NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::e6) by MW4PR04CA0148.outlook.office365.com (2603:10b6:303:84::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.26 via Frontend Transport; Wed, 5 Oct 2022 05:02:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT063.mail.protection.outlook.com (10.13.175.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:02:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:01:59 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:01:58 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 07/18] loop: use init disk helper Date: Tue, 4 Oct 2022 22:00:16 -0700 Message-ID: <20221005050027.39591-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT063:EE_|MN0PR12MB6032:EE_ X-MS-Office365-Filtering-Correlation-Id: 86147461-1e5a-4a9f-5df2-08daa68ebffa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r0bOj+0xd98aOFwD4Ns5R7TDWeqQ6UrlYINarhWNFKq9x7P9d/iPfx/hYslCCqQWV8LPo07JFyuGDa5ij+v71omMzGBvPsAxgm9eKEeR4YeYZYOG6kdMT25dF2hbt8TGAqCbe98IzZcz+7Ej6R1JkI1ZkBZp1+TsZov5odPxyOM0LqHXfbbSlDUTheUvmCtXE9rZwAB+LYzNNWbW0RKYUaCirclo/7ZTPoWgrggoFnSEnpO2GNfyMOqQGJXygjry9XXJn2OU7IgudfqYDsiVpv3OJpDWwuMePEHkCXHDk1eqEtwA/CZdiIIZns0H4kV646N/ugw4QqDdg07mcpUfk+YRZiTj/rxUjWyK4X4nlVwUTWjJG512b0f4LzceKcZkMIeWJuCKcTWllAFEI6+rUKnoBOqgZjlcfyrTK92HDSEcUEVMmuY7Jv7BM0BY20WcYHaudZEtgPwc1S6YgAqQnCDb6/Ufo6CJSyWONtyV3dL2GJIQThGHsui0h4WpCJHdxHe8FSZDIhYhi9/i4y6nStX/YyJJADsDMYDdee3pqLOODpxTCV8SaDdT15G/OG105cuZ2T3N0a5HQA6zV+y/sCDmIbWrPz9n2aM12ShXnQ2JcAQXGUdYZ7qyM6/q8aeyf/ll/SgjCtXeeEsrRF1wMz38fy6+4cv/66dU6dhXeHSLkrAE//zgudQsA2jiCAhtmbElvgDetL/Zi7b1pVL1O+R+Us/RBk2mjvnL34ahf4ldJ+fkL4Atj1A2LRj8Zh2IuYXRNe4XNhCdzInjhOxnWZn9nxmdJpT8n12bspmRYRQ= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(346002)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(356005)(54906003)(7696005)(36860700001)(26005)(40460700003)(7636003)(82740400003)(36756003)(41300700001)(8936002)(40480700001)(6666004)(110136005)(478600001)(4326008)(70206006)(336012)(316002)(2906002)(186003)(70586007)(8676002)(7416002)(82310400005)(426003)(47076005)(5660300002)(83380400001)(16526019)(2616005)(1076003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:02:06.1832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86147461-1e5a-4a9f-5df2-08daa68ebffa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6032 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/loop.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ad92192c7d61..82cdb57ecd18 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2023,15 +2023,12 @@ static int loop_add(int i) spin_lock_init(&lo->lo_work_lock); INIT_WORK(&lo->rootcg_work, loop_rootcg_workfn); INIT_LIST_HEAD(&lo->rootcg_cmd_list); - disk->major = LOOP_MAJOR; - disk->first_minor = i << part_shift; - disk->minors = 1 << part_shift; - disk->fops = &lo_fops; - disk->private_data = lo; disk->queue = lo->lo_queue; disk->events = DISK_EVENT_MEDIA_CHANGE; disk->event_flags = DISK_EVENT_FLAG_UEVENT; sprintf(disk->disk_name, "loop%d", i); + init_disk(disk, LOOP_MAJOR, i << part_shift, 1 << part_shift, 0, lo, + &lo_fops); /* Make this loop device reachable from pathname. */ err = add_disk(disk); if (err) From patchwork Wed Oct 5 05:00:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998996 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 2D412C4332F for ; Wed, 5 Oct 2022 05:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiJEFDR (ORCPT ); Wed, 5 Oct 2022 01:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiJEFCZ (ORCPT ); Wed, 5 Oct 2022 01:02:25 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2080.outbound.protection.outlook.com [40.107.101.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C7F87434D; Tue, 4 Oct 2022 22:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D4mcjGmv1IgKezs1Z72PjAAjz0Za/Yh8ZooZoMcqbfMleh3gaoNEzi95HcChXPjMFqj23JOx3NIO9OC5KFH2MvN4HjmEQPy8rKFG3b73Zu/UZKvgCHYXQGhrmdb/x0JCfbeV2gx9TEJE9lIPKzitNVE6zxnf/KbHqH/McVU8p9RmIop71Z/NCw87E6iQ/1pGLQQUtauxfokVql429u8gnvdHsc8Q4N0cTKNDUwreF/1vOknUP03dWwwImAK6kJ96BxJGhpSLD040fLku1C/1/38XCXTEjZuGY2U9IJexCi82j9MpcOuiUugd03L9H4zvrhe+auyEnPzr4Y3UAdgl3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AC/dVltCh33t7LB/hHRJPz/aQqcKnUc2LKGWQ1WRrwc=; b=N0ID4YwI4t13w7vv8DrKI//xVPK/SGrLHFz9501M/O1CqSNi7ZfcH5/uJWiKzdlZgCQCC8SMUKh22le1HfiCBRRD/ga2O1v2/gpMvJWNAIlKJju1Fcm8dHSGUmLPknDGRGs00JA9gkSSlrqYxGHFVXEWDzMgFpZQkZQdLd2yVtqPmUvDENGrH0i8ovyQlnw6BDWNP/tYMbTsbP7czd6IjYR4ns2tcRzXkpfVkAY4O05rn9E5IGI61lFt3fpJ/EZIczbkMlb28d/2oxzon7BBGqTBGV1n4Pw4AvFz09j9RLo4Lb4xlaW0W3wHKhwtA6jOO3CjQhF0A6v3YlRKCK3h9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AC/dVltCh33t7LB/hHRJPz/aQqcKnUc2LKGWQ1WRrwc=; b=UG+2BTa22OzmhLWSpJ34Dcx9nodADseYqd8akLnnDJTr5BV9ZluWoHxra5JigCcmc8qy7PpmgzN91Yoj7jbfJveWPy/9aRfJm0Mti0V/TrhUNk8srRoJLM/p1Yobfj+cgn2HriX9eA6+HKR26C3gngG/d9ioHDgXDQ2Lty2n68cPbdSoUkJhDyXBiNUJuFOq2J0xK6uzle/7Z864r2aAx2j3uHVqVFn2FbjA28og3BV1hDpkXHtZUQSTUD6HLSyE/ZWG3NLWV+s1P3Xx/ePXl8j80aQ/Xyuo1iuX5dQchJKBfni97UTPBY7OC3cYSwDWtMqO3JDhov92ANDcWhDx6Q== Received: from DM6PR07CA0097.namprd07.prod.outlook.com (2603:10b6:5:337::30) by MN2PR12MB4271.namprd12.prod.outlook.com (2603:10b6:208:1d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:02:17 +0000 Received: from DM6NAM11FT083.eop-nam11.prod.protection.outlook.com (2603:10b6:5:337:cafe::3b) by DM6PR07CA0097.outlook.office365.com (2603:10b6:5:337::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20 via Frontend Transport; Wed, 5 Oct 2022 05:02:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT083.mail.protection.outlook.com (10.13.173.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:02:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:02:11 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:02:10 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 08/18] n64cart: use init disk helper Date: Tue, 4 Oct 2022 22:00:17 -0700 Message-ID: <20221005050027.39591-9-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT083:EE_|MN2PR12MB4271:EE_ X-MS-Office365-Filtering-Correlation-Id: 2aa07d64-048f-491f-a32c-08daa68ec68f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r43Idkm8GFfSaTc7gr6lVrCdxX/uWViJTRKGCAtUMG9WRYbLrTobWmko6Fnkh2rNKQdERSThc2tCRNR5CLiNnhBkPqSjFJ9aMaMJHsGVYy9idWCzBH3tMgjw+9nukIWALps9L2UNoOM/s5xyvkSNLWwM+pzB94Uli9JGbdjTkBkB4CNyJIABDEOn4gxu8ey6QzPUwwK/c0VPGph+8wUPY82PSGC+kVznUxb43kRnFuNFg3TpCA6yLTdaJJT5KxvqNtRkhzwils7QNMBDr0LM/5o+06L05VEq5oP0ceDRfrp9D42v3w8y4P8tJLX7aSk6eJP9L5JX8jf+6pTc2LxHePk7yMgt2J7XlCeb6ZRjc3SfABEFcmq6oTSoyL3WUMr56L9qbXtF7WXJWyPw5KU597j5rkRsSdaNqX+xnngjNTT1hEBwjZNV8VvUTlJ0rpQVLD2UTI/Geb+/GUcG6G1R5PWroJoyzQZSui2CKGt+XRceKHcfsGbP15qhO+wVEkrZFEkvRUiLjH9/ymespdsBNy+pkmaDuD5MhPgklzLQUna2yEw43+FfoogCkgqpy/92pGxnxMedoZcdqco90gmzcdw8SqcITF99mQbU0TuShAgK6jyIM89Q4fM3xnh6D0nhkoRH5BJTfJ4+CS+lNzzKN6ZyBnDXSM1SvvGbiQkpm9iaaTkINIwaemkmv4VirUnOT51R5p0ZWFNmg7mKmsc9IdRuIcVDTl3JTvLN52iJrEGTEn9PPd+TJu67E/hLbq4TBot71r7kaImQdzbYhH1NjgdaUmWpk5E1ZMzQh61FKaY= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(39860400002)(376002)(346002)(451199015)(46966006)(36840700001)(40470700004)(7696005)(26005)(2616005)(478600001)(1076003)(186003)(40480700001)(82310400005)(40460700003)(2906002)(8936002)(5660300002)(7416002)(356005)(7636003)(316002)(110136005)(4326008)(41300700001)(54906003)(70586007)(36756003)(8676002)(16526019)(70206006)(36860700001)(82740400003)(47076005)(336012)(83380400001)(426003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:02:17.1340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2aa07d64-048f-491f-a32c-08daa68ec68f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT083.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4271 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/n64cart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/block/n64cart.c b/drivers/block/n64cart.c index d914156db2d8..28b32fbe6586 100644 --- a/drivers/block/n64cart.c +++ b/drivers/block/n64cart.c @@ -135,14 +135,12 @@ static int __init n64cart_probe(struct platform_device *pdev) if (!disk) goto out; - disk->first_minor = 0; disk->flags = GENHD_FL_NO_PART; disk->fops = &n64cart_fops; - disk->private_data = &pdev->dev; strcpy(disk->disk_name, "n64cart"); - set_capacity(disk, size >> SECTOR_SHIFT); set_disk_ro(disk, 1); + init_disk(disk, 0, 0, 0, size >> 9, &pdev->dev, &n64cart_fops); blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); blk_queue_physical_block_size(disk->queue, 4096); From patchwork Wed Oct 5 05:00:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998997 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 F008EC433FE for ; Wed, 5 Oct 2022 05:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbiJEFDv (ORCPT ); Wed, 5 Oct 2022 01:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiJEFDR (ORCPT ); Wed, 5 Oct 2022 01:03:17 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C7BD74BA3; Tue, 4 Oct 2022 22:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NdCvXFhwBwPUruZ1FeBVgVQfJ1bWLZ7Olp4OSEWp7yHSnUS9OrQwUoPy9XWRAxT2K7IZ1lXZyllXCoJbjTHv9WWvHBehDnTsn7JohiMP4YFMXWf6aVVh3h4vbyM3I/IMLfE/3OMXQ6MpJx3zWS4V0vzvZf+71JfzKdAanOs1O1MpgHfp3YDo2Ce5cFXjB+HzB/8IRPgD9dKXqAGicEltImMytMf1Bbn+790Yjf7ReWaEEeJSkkLA8aOkSiOV8a8hgC9YfU2S1CXAc5ZNxm4t1B1iIGbFbCtv36MC1sXWrudvtDIoNGYmte6jPqpF/bdrrTV6+HfAQbF2bubEqBjgtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NLbJqCQUdN0O3ArWCvxCEMQtaJqsn/oqqbAVsX4p5pQ=; b=C00X05327iufzFi1oFvAou4naqSKQ0u88aTeMwI7NPKwuyTzewO+YreHD/c1eS1W7TDRDxAVm8qt7uxKJfJ6lAMuvq5ZrZHo35K0pcm1bByn3JlRHRxY+PwbjHXA44DKa0UEohuSfBvOwu7yWKjhLGs11yiE3VOGpy0u/kxEBTQJY6CN5bd2I3G5+HjH9HqhEFLd2EqyHDcNQkawnzs/QQNnQFls83xiEOn74ofxtcTLNaPPpkauzCZE/lZKsxbQqACo3sPd3yqLukg1rACXTSvoORRBY7Y7x9p9/SxqiJyD67vVS6jr5MkbwvMwfxAw62+lHGSV+w7dCriFyMZfVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NLbJqCQUdN0O3ArWCvxCEMQtaJqsn/oqqbAVsX4p5pQ=; b=lubrSpBg8JsSB8jZjg1v5IQnqsU/Vzu3lmU65xT+UdByYpJC5LFPVyyP1NTLc4r+GBt/ZsKsc4JXyMgpryOIAo7mTcCpxQglOtmlk/G/QAAAfolvF+RzFkuiEifxVZ56FWSlXgeILmelMx4a9zJkdEJuwAOgf4k1lCRh+umR3vSRkDk2YtmK4Bn2fegrG9LKi5WwpGUve8ATP6mfDcX4JN9lXvBjePTMNBhTDw4ZCJ/LuxkXAHpwC2dE9AfM8ajFP1ZTJ8owPjma78ldziq7CCLqcqrSxHdXPHCXIuPL3LgW/awBso17/AP+Vo1JlLM6dNFh3F7pIZTk63+wBLSitQ== Received: from MW4PR03CA0003.namprd03.prod.outlook.com (2603:10b6:303:8f::8) by CH2PR12MB4246.namprd12.prod.outlook.com (2603:10b6:610:a9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:02:36 +0000 Received: from CO1NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8f:cafe::6c) by MW4PR03CA0003.outlook.office365.com (2603:10b6:303:8f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Wed, 5 Oct 2022 05:02:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT107.mail.protection.outlook.com (10.13.175.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:02:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:02:23 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:02:22 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 09/18] nbd: use init disk helper Date: Tue, 4 Oct 2022 22:00:18 -0700 Message-ID: <20221005050027.39591-10-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT107:EE_|CH2PR12MB4246:EE_ X-MS-Office365-Filtering-Correlation-Id: 01b1848f-a9ad-48c4-ae06-08daa68ed176 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2tnV1e9Ex/BhoGXm5h/c69xf2Uwfo1eUMAelCyvXPD4OGaeGFdoBtIQCcHyIhRy1kGD7GQdsT5aUQ63IVeQEnzPlurWMZOOr55+7Ps5yazUaQQoy/dnjyQ1YZYSMREl/Uc5R/v17y+ujs3IkaMkoh/csosIIJLLIobRLPDihRwyDbUElH5V8BOKVxXrGtY3fFqnZPGV9TYVPJCeBGd6OvPUbwkfbYJ+vBmyKfRkZ4njW3fNFDdlRHGJUq2ogRTNyMDSlFrIrwKpeewShaINc4FVpTeIhW8f58BTa6QCRNMVdgx6k1krpV4hne3s95t9L+Y6Vf+1OKO+zlwM5/XKvdYwu8eTz334t+BKdHuKMaFcGcM1AWbtybnmVb+F7tZZ1OP2PtzkGBwfT4AQ5NIHZQkcYsT2h7km9PM2W24pr/2XlDneHjJfQmeDcfFWMhPZifyAS0jnM1Wrx2AVSr3vPVXCCg5N7LAEX3tozzA/2PyAJVZHQY0bv5qT/3nuR/UMMj3RupkCVidq5f3VBoiuM02iSAkZjMQiwx6NG0S6lOjXolj8BENQWZaaXEs1Y+9A5xQA2ajzY5nEgZfRstJSqjlKXdasR04xELAEqhvi08FgyWg2wa5/QiQXed77oy8k7UTD1KRKlpCVT7mDUTdl+3b/zFzKZ7L0fJfi29VwXPyeQ1eQi5SFUer/k2z2NEa+OpP6A34NI3SWeqzemUqBurrSD6ByMyRtASZYr3FSJr1QSITO3VXht/ResdLeOiqJ9IceVAIedzsL3eRIlzgzk/cGP9u8wPh+tsw32GxWCWVo= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(39860400002)(376002)(136003)(451199015)(46966006)(36840700001)(40470700004)(40480700001)(36860700001)(478600001)(110136005)(54906003)(316002)(8936002)(7636003)(5660300002)(70586007)(70206006)(186003)(82740400003)(356005)(26005)(36756003)(83380400001)(7416002)(8676002)(82310400005)(41300700001)(1076003)(2616005)(7696005)(2906002)(336012)(6666004)(4326008)(47076005)(16526019)(426003)(40460700003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:02:35.5191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01b1848f-a9ad-48c4-ae06-08daa68ed176 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4246 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/nbd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 2a2a1d996a57..b4f2d7e1be89 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1816,12 +1816,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs) */ refcount_set(&nbd->refs, 0); INIT_LIST_HEAD(&nbd->list); - disk->major = NBD_MAJOR; - disk->first_minor = index << part_shift; - disk->minors = 1 << part_shift; - disk->fops = &nbd_fops; - disk->private_data = nbd; sprintf(disk->disk_name, "nbd%d", index); + init_disk(disk, NBD_MAJOR, index << part_shift, 1 << part_shift, 0, + nbd, &nbd_fops); err = add_disk(disk); if (err) goto out_free_work; From patchwork Wed Oct 5 05:00:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998998 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 42F3EC433F5 for ; Wed, 5 Oct 2022 05:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbiJEFEL (ORCPT ); Wed, 5 Oct 2022 01:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiJEFDb (ORCPT ); Wed, 5 Oct 2022 01:03:31 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13679733FA; Tue, 4 Oct 2022 22:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TF/T8JmGQwesIZUX8Y88nLiA8rGWLGfMxDCdtFqt/qJGoXVjAGf2mEtFctd7AWL0adxpZg2FYdXVyzvQ9AXKbXLQUzcK94a40yE40lRbdFlFTpDMgSm/HdayUhaYwnyKCRptnPNQj8/16h9umyuo51DZ/uSC7H8SzAgKO/ubFw3zGPhATd+7B7CqBXnWu8dK8GrcdM1XrJ345aOb5rVYdHxyYQVCiS7rlfhftzPy5G/N3VMbvpBNATcEtsNj41tAOpfPQpdpqlY2+5a0dKlPpyefwXsGDi+v/Q69mPzC//T1R8LoHt7QaYq/ObKsltPxit688p1vAV5+1EwAJ98cKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U2jAh01XV3PtRF2YUGgwcEnvTdTLaLPbUTOFMh8xL9I=; b=QBJcxCb8qDutAHPI1LkNKYPIMzbxW24ELoVPNLjmVr6dlxhCRYaPcoC/UtY3uDrLggxfnxF1nBziI0dkb9E3HO9pdaTxhUdeqqy78sBTlu4KpP839T5x+XPd8m/BH2C+Sg1YDduSajD6WHScf9fC0hnh37WFWc1JXFXITfVqB3RVUGkUfTpr2KysjLDokXGBPFUcpM4dPmbTH8EP5qVoBGVtWpvjzRp8KFDznHY8jKWif+22bwTqpR97YCh6AbLXyEHQ5tIBzHmcWuiCJdJEcofr9xZq0BkVL2WGlX3s+HRxAnFy7Kol1EsT/e+XzE+V5fJt20BoaYB7rjfEHT3UFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U2jAh01XV3PtRF2YUGgwcEnvTdTLaLPbUTOFMh8xL9I=; b=CdYwOQVo02T0OQyUkg/eI5IwWIsEQMOxx3RsS3nrZcazD+fqIon/6F7MdjkXY+qmuEiT3Xsl5fgPZhA1lmhuSLu52pBpfya6jTygzZ1lU4UmsuYTxmCC1xv4KJWSh/0R9I4kqjAn7ZTKIEtve5Uxkx/D4wCt9WhgvNsDVH+94UenwQhQ1OnWPcQMPJSTmIdD/qrCItP2sasR+B+eJHEVfD9lTqdbwHzAKxEC8DKI+eokTFcf4dN+dE2724stgwOJuCNZjmsAnukQTe8aJFqWIk1Fda9Jd6kcvbCZcGlyJXvTrukENgsg9uHalBmtE6AzFbBWovLtT6f76mk/2jKCmw== Received: from MW4PR04CA0292.namprd04.prod.outlook.com (2603:10b6:303:89::27) by CO6PR12MB5442.namprd12.prod.outlook.com (2603:10b6:5:35b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:02:48 +0000 Received: from CO1NAM11FT089.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::f1) by MW4PR04CA0292.outlook.office365.com (2603:10b6:303:89::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.29 via Frontend Transport; Wed, 5 Oct 2022 05:02:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT089.mail.protection.outlook.com (10.13.175.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:02:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:02:36 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:02:34 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 10/18] pcd: use init disk helper Date: Tue, 4 Oct 2022 22:00:19 -0700 Message-ID: <20221005050027.39591-11-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT089:EE_|CO6PR12MB5442:EE_ X-MS-Office365-Filtering-Correlation-Id: 586daa79-3566-4a94-4f0e-08daa68ed8d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXg5ewE4NWTTQOn/ILlBdYZL5NmhkgZ6oOt1VNz1G8E59UDACFlQ90nuphpLA6hZSWSY9jneBr+2SCsEi2mNcuPT2rDt/DOe7KZ/iR0Jaa+giqL31STYnkF1XNnj5v+s1yYlmX2p0r2ETS237Us15o4naUU2/S6XQrDagQCcJZI6931MA+BuZjgCQ6/nqYkA54rpCprub5Kxkd49h7W7367tVMO0VoK6dFYw5KhX5rtuPKpP/oGJ9oCWp4Ur7F1DVC2YDvdYY40juU7SzqN66XUp1InB7w3pZBi/ZS72J08XRsmDBVSG2+jcqLVRFwUCaMZHJbN9DXEpiFUo+ojVlCFThpTI8YLOxJTWoEDBsIJXpAlOspFrs7Fco+8FwWoFmcPg2C63JQF9W8mnPO3QW5QRJErs4Dst20UMuNCbGJwcMyc22uuPxVPQFdVB4LTqba0ZwCPOjDIav6LwSnsvXTIeSajFUfL7bc6uuOdHPKxPZhzwTjOpaRAzu9STkpInPsvyoDuFDblR3ZuatlqaJ/CsfCucuq8YyEdSreU9fjNKWHZYYIINa5sfe1GyUnjC2B0aFB/w8lFT9PFoaK88LAmOVqP7fqQvNY7feRWds/pXRYvycvwzudEOyJRmGHKtsjsMXVQ8PaOIcN/5VyUPtdJ/MHdsdxou06mmWRrYe1/luwXqzMhIeiRjUTMDAKC2mvUZgpEfGQNV33d2M4WZXIj+sgddTU+YDgAJdiD2O0TMmxDxMEzEkyWojMs1GGdiL1Aa9puly5Zi4+nq12An2P7j1iW6LxQr80kOC3zrGlM= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199015)(36840700001)(40470700004)(46966006)(70206006)(6666004)(8676002)(26005)(16526019)(336012)(426003)(70586007)(316002)(7696005)(47076005)(4326008)(54906003)(36756003)(2616005)(8936002)(1076003)(186003)(2906002)(5660300002)(356005)(7636003)(7416002)(82740400003)(40460700003)(41300700001)(36860700001)(40480700001)(83380400001)(82310400005)(478600001)(110136005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:02:47.8612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 586daa79-3566-4a94-4f0e-08daa68ed8d4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT089.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5442 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/paride/pcd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index a5ab40784119..4474fd28a6de 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -923,15 +923,12 @@ static int pcd_init_unit(struct pcd_unit *cd, bool autoprobe, int port, cd->info.speed = 0; cd->info.capacity = 1; cd->info.mask = 0; - disk->major = major; - disk->first_minor = unit; - disk->minors = 1; strcpy(disk->disk_name, cd->name); /* umm... */ - disk->fops = &pcd_bdops; disk->flags |= GENHD_FL_NO_PART; disk->events = DISK_EVENT_MEDIA_CHANGE; disk->event_flags = DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE; + init_disk(disk, major, unit, 1, 0, NULL, &pcd_bdops); if (!pi_init(cd->pi, autoprobe, port, mode, unit, protocol, delay, pcd_buffer, PI_PCD, verbose, cd->name)) { ret = -ENODEV; From patchwork Wed Oct 5 05:00:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998999 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 DF55CC433F5 for ; Wed, 5 Oct 2022 05:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbiJEFEZ (ORCPT ); Wed, 5 Oct 2022 01:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbiJEFDk (ORCPT ); Wed, 5 Oct 2022 01:03:40 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2085.outbound.protection.outlook.com [40.107.102.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E968774BB9; Tue, 4 Oct 2022 22:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OZkon10G9HObOjoHj+/E8j0jCFQTCb11I15ptCW7jqk+H97MQRl2NfuLqJkPDDqdExW+70Zv/P1hSYjJCSDS0tWFQgTfiGL6KaLRP6jl0hINnh6YnJgZTaflm3wjD0pddfyQZyeXeHLrh/4nRZ9N6zVqCTrjMH2a+GQwbA54JDwdy+5REgyUgu2YcG86vDcbMTpCkkK2BvDBDaDLHyWDV32iKo6DSe3W2/D4457SfEQjvsu6ovIuNNskVdYHVWRjnlbOz96zFffX+LlgXpJ7CVHqNflm9DdEi+LDzK1kKUytcC9hp1pEsRWLre/nY0T1IBDHlXZATM4AZY2bnj7Cfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gpi5pI0qiowRU05AtGhtX9GMgKdhyP0p67bdNrYfLTs=; b=VVvqIfYKZR14ZZgXTQf7m5/Zt81DeQ8Zw/iHloXEpw0NyzN/eD2AMsPX/sWXbRHO/xVErM/i3CKxS0+e37zRijK2MbO93OCfrswfyLF5hCOAhvmczi1GyymanKmdHAmO8Enfcel2jnunRkQwFi6j8IFmf+X0alNsMu+yWi/aih4F3SycdPmMl0+Ca8bWcJB2MtSI33lDmiYJxjbmQJAo3/PVTKTnesBsNt8+UxJN0vEScyOiiy/Zn7mMyGVIykrRH60tDk6Art3rSLrDZzpuYhQcpHrGModNLdATPtzaAtESMr48Vp4h+3JyQ7m+XWqUXVn2zSZpkr0z4CXxsb31iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gpi5pI0qiowRU05AtGhtX9GMgKdhyP0p67bdNrYfLTs=; b=GkGhxDyleND/SVZ7qAuPFCKTkBvhjK6oBtCDYnL52reXXTHtUR3wyAn03nSRnN1uFBQHS4ImG30Zyiykj33NyHOxDCFmw7klj1myPCMdrRDdHMzMxgyhFbLCxEn9Wt0RNWtuX2DC5ebkJ32O4JjC6M1vqG6+hqphVwgvJuXGdav21UVlYv06Q7ljR5ezTcezAK4BQMzV0OH4Lcda9TIIH5LQ/3xZK+H4IZcM33pbEs9fmJEE3qkPpiQXjkF7o4F3rOw5guOjlm3bEudrw28MmSs40V1NDMvfLHUCHWzRd/8m1RHUzc9XdHYPRLoDSglJtxo1X0Q2UYmRsitecMgAug== Received: from DM6PR18CA0031.namprd18.prod.outlook.com (2603:10b6:5:15b::44) by DM4PR12MB5071.namprd12.prod.outlook.com (2603:10b6:5:38a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:03:03 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::24) by DM6PR18CA0031.outlook.office365.com (2603:10b6:5:15b::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31 via Frontend Transport; Wed, 5 Oct 2022 05:03:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:03:02 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:02:48 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:02:46 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 11/18] pd: use init disk helper Date: Tue, 4 Oct 2022 22:00:20 -0700 Message-ID: <20221005050027.39591-12-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|DM4PR12MB5071:EE_ X-MS-Office365-Filtering-Correlation-Id: d1b3a64d-d3dd-4c96-200e-08daa68ee1b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xulZF+xkfqutS19v8Q1wkLUOdxZ5qS1T1zBcNnfIpXJCy9dj/y1QRn5tfcqZjASzD0lqTud7k+fdOYtIi/YppOkhyXG/aEbOBAiadrho+VdMfBhf9zfBoMp3Xf0LUkr2R5gykPEpx9oiz3JtMSM95H+vEPoLkwzi+tmySQ70xHPRxHQWtrHErcFHUJ61ywzG3YUieBhfRgz1cnqluA7CZBIqjZqU/Sep6Ry5KNgtg19HMMFWzbf/tM0UvCRgPAq82tuO+sJXmQJfMW9ZziSMbF68ERGnn5Dm/36a+auZd3iK1+OG0+Ym4ipbgPWbkg5lytX1P46m2VYb1m9Udcqtud3aI4MAfbx9ZW7h9KN7BjYR+pcpx7fxeDLhagkk0wghHI7nHP6Hr4bmcrS8i+5e0k0RCdjh3hmqNnScttiwpJJ8ccQ1DQb3UO++/dGg9hN/8oOSFMQOsgUBRB8PLixntcy09ksRUyCwoiYsn3834ZC3qbPLHDKSr3AedY254/eCM65n7PlWEuPVXnCPdLxsCij+ET0QZHlRcouyQ4TTwL59W/KE+7dJaFpD8ahVe42pNfIg8dB2DVGqH+uVxAsjXW0M6CeWlG8qyC+h3AIMtQCVXW6OLQpDruoelSXBZlZ2t+eraOFFuGJ/2PY3aiz3gutyQQUt4zKz9QSrjiJos1Ct7+7KifArfL2jmyTPhNeN2llzbW6qFpvwePcTbvef4bjZj+vNnwU2DURgtO4mouAy7rvZ209TRBd3IM9bVNk7g1bH3KsMyGVkM2Ojs5MsVt1i1bM0AKkcTyhxKxv/3ms= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(36860700001)(47076005)(1076003)(16526019)(336012)(186003)(83380400001)(426003)(356005)(7636003)(40480700001)(82740400003)(70206006)(70586007)(4326008)(8676002)(316002)(54906003)(7416002)(2906002)(41300700001)(5660300002)(8936002)(110136005)(7696005)(6666004)(40460700003)(26005)(478600001)(2616005)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:03:02.6585 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1b3a64d-d3dd-4c96-200e-08daa68ee1b2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5071 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/paride/pd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index f8a75bc90f70..9457ad0cc25f 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -919,12 +919,7 @@ static int pd_probe_drive(struct pd_unit *disk, int autoprobe, int port, disk->gd = p; strcpy(p->disk_name, disk->name); - p->fops = &pd_fops; - p->major = major; - p->first_minor = (disk - pd) << PD_BITS; - p->minors = 1 << PD_BITS; p->events = DISK_EVENT_MEDIA_CHANGE; - p->private_data = disk; blk_queue_max_hw_sectors(p->queue, cluster); blk_queue_bounce_limit(p->queue, BLK_BOUNCE_HIGH); @@ -939,7 +934,8 @@ static int pd_probe_drive(struct pd_unit *disk, int autoprobe, int port, } if (ret) goto put_disk; - set_capacity(disk->gd, disk->capacity); + init_disk(disk, major, (disk - pd) << PD_BITS, 1 << PD_BITS, + disk->capacity, disk, *pd_fops); ret = add_disk(disk->gd); if (ret) goto cleanup_disk; From patchwork Wed Oct 5 05:00:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999000 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 DAE4EC433FE for ; Wed, 5 Oct 2022 05:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbiJEFEt (ORCPT ); Wed, 5 Oct 2022 01:04:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbiJEFDv (ORCPT ); Wed, 5 Oct 2022 01:03:51 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A02CD7434B; Tue, 4 Oct 2022 22:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZlHU/KRovQ1zoOmPusDQihZAywsAe+9saYFzSvkF/vCJJxVd7rTwel7ppyREm39KrRHCr+UHTA+p4XZIyW9cWYjMZb7MEDUVj3/n2OL0MEF0FH37K/n1WPDlVqnQJYmAI2khS6SV4rek/UpLrLDKVSLBLYFP6DV0ERo1csLQOjQ/KXc9b8duezQiiaEKAhExBFKFksGLkjqPv6WRUXok9alMLztDBoXS7gctIv63h4imqZceqGt4GajPcxXPZ3l3GQ0AZEdnHGsZlQYbpaxL1xHbBiKolmLHA9PeKzKCWSZdQnR8ltJ07QRzKmBG5XziTw8A4DtT3GTlTvE1JGzL/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L+7/+g4e2Ke+0bCNjaxTKjA95kp5VH1jRQ/Rn928iYQ=; b=b+2ze7uCANPpfN1u2NE4a5ocgtJhelqDt2xkUxrlz+qp3LNjb3lgK/2j93BdjYnQbEbuPyjBCVjUOAE4pFjQFVNPhSFTQpmnxmcnoiRBaey4v/QTftfX7rbExmBLiNon//lrfL1idPOgPR7vg3FCuhLHC17jm7u0/YagiWjrbtSUHwsfYaT5MOyB3dpm2bx29XtimDzf5xKKQUdDZr0HCuHFO0l0Y130/glzLtu3ja1ulqJnyN7C5ekTWPdGQOQm93wcGjdSndLnFjdtgDmd/PVLNvu6j7/5BV40PfDqYFCf8E/uQxcEO+ogg9OIMk9M7a0mEekO+SQwWBjVaf1PZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L+7/+g4e2Ke+0bCNjaxTKjA95kp5VH1jRQ/Rn928iYQ=; b=anVO3AQWtGnYLJ2kckVLSJZa1aBZLcuKbcqvnyTpj47TDw+6ZvOiFoV+IZOPURNSTuIm9F1nTpHvdeisOUMrIQAASksKAkFDsv9qsp3/AiVOm0oL/XIbncDVLwHVVcRi6H1RPDjjTABrtubak1vEvSmbT5xxW177ljlQfwdmEZgGKyRy4ZB6LdgfY+isfr4mG9LAxco6CHjcV8cbgGNxl3tuk6SWE/rtgAhlrw7+tTUO8gm50ZpiGux8BmkW08MwLzyJrPbQEgTFrHv+15IALu5+7bkG7wvlX3pTCp6dmxqKdhS1OG+iOvaAj4hFMPwZsH5QV9ZpYmUUcMkxVkezfA== Received: from MW4PR03CA0068.namprd03.prod.outlook.com (2603:10b6:303:b6::13) by DS0PR12MB7606.namprd12.prod.outlook.com (2603:10b6:8:13c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.32; Wed, 5 Oct 2022 05:03:14 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::70) by MW4PR03CA0068.outlook.office365.com (2603:10b6:303:b6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Wed, 5 Oct 2022 05:03:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:03:13 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:03:00 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:02:59 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 12/18] pf: use init disk helper Date: Tue, 4 Oct 2022 22:00:21 -0700 Message-ID: <20221005050027.39591-13-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|DS0PR12MB7606:EE_ X-MS-Office365-Filtering-Correlation-Id: dd606bac-2956-44bf-095d-08daa68ee848 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0WCe3bHY3aiqOIyukhVwzls4juzKwxwYnlIXimEhWng6ZsH1oC5DU9nPcISNelNuo5zsbTohyCNcVQVqz82fmoP0I84MiwI07wC707drJbxzuYKqcuxCowS2jma2NNrhAnoBW3ZfTz/zLL4tQqq2PGLWaNWxk6S72vNtfp732ynF/epItK192VcF+CgWuzd89d8scHYU2qMFOQlo/WsDClImgnpDVGSDmZr6qX1dq1oJBRZP6FyIjPTqEg7/joFGO39+doIyZ+qgyXqVTCg+fuwSOd/jPAQ/EJSjO3wYjp9bUbq4TBA4LJjip+iyUeAyn97IkKXqeszEPsu8sZuOFj+VgplEuNVd/7qr7axnxls//CuIL6m1wYy9fzaiAoxSCqMfvMrFa7lMK7MPDPyCYEwqGyXscp2RD1KROBLQ56SZUfEAxafhSMuQjEzLGyy6X2gpa4aVE4qr/RA+PKfT2Pnkohzg+bJHRaDQFNTCxc+EINUaZA0KHBi64qMgAo4E04x0SPDz58gFyb80jSG8I58g7IoOiBQennQsr4sgTDUtw4tKpT5LBBSlMsfVFRcjU+tGI3wvz7UMH6tBb0pCFoZvn6qSueodCMqZXzrcglC0QfWyJq9wVcspGGfuOMJW1EA9lfHzUCVgf6Vi8FKedWiejCyZtOE8pIcBtDGb9tG1PI0ydLwigLe8IdrKY8JQRJvCjqXbfxeENGfsGuuJ+Ws6vec53tT+wO8tN1nzTMtdkVtlmHZ/5v89u1WZGUxKg8KUc1/Hj6Y23r4Y3IvEFTQJaNUMYAEmwo+syfIMMKw= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(396003)(376002)(136003)(451199015)(40470700004)(46966006)(36840700001)(2616005)(336012)(1076003)(16526019)(186003)(47076005)(426003)(83380400001)(7636003)(356005)(36860700001)(82740400003)(7416002)(2906002)(41300700001)(8936002)(40480700001)(82310400005)(4326008)(8676002)(6666004)(478600001)(26005)(40460700003)(7696005)(316002)(70206006)(70586007)(5660300002)(54906003)(110136005)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:03:13.8011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd606bac-2956-44bf-095d-08daa68ee848 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7606 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/paride/pf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index eec1b9fde245..2950642402a8 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -937,15 +937,11 @@ static int __init pf_init_unit(struct pf_unit *pf, bool autoprobe, int port, ret = PTR_ERR(disk); goto out_free_tag_set; } - disk->major = major; - disk->first_minor = pf - units; - disk->minors = 1; strcpy(disk->disk_name, pf->name); - disk->fops = &pf_fops; disk->flags |= GENHD_FL_NO_PART; disk->events = DISK_EVENT_MEDIA_CHANGE; - disk->private_data = pf; + init_disk(disk, major, pf - units, 1, 0, pf, &pf_ops); blk_queue_max_segments(disk->queue, cluster); blk_queue_bounce_limit(disk->queue, BLK_BOUNCE_HIGH); From patchwork Wed Oct 5 05:00:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999001 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 8DE36C433FE for ; Wed, 5 Oct 2022 05:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbiJEFFM (ORCPT ); Wed, 5 Oct 2022 01:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbiJEFEY (ORCPT ); Wed, 5 Oct 2022 01:04:24 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7503474DC5; Tue, 4 Oct 2022 22:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z5Ms8nlAvTEGYjya39uADbHnZjToOYwUgpk/bgkbrcZSFAdg6Ro53ZGzJEwQFMOdg45AnSbjBA5WyBq4k08l7g3qeRTsVyrmi03DgrQBbs6DKbG3COHBcoPkFKS+hNwSB6aWZi3qIx7uzEfhCEgj4t3hY9pveLjT9p13ZzJTajqZy32MMMTv8Q4x0XdWrDEarjuNgaSQZhFrybiLQAHQ+TOEmLzR11hQSVkYAWqi6/0nLyNQtkum4QYOBv09GB60roGPAZ8pRkPVrdKUs4R8os4M48LezUdZG9wK613EN2Dwx1QRt/Ql6oRg0Ff7MwwI/PQWZPimLaketRkd9qaG8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PblZfXDPT84swuLDCHtey8tDUOOapWOEpa2uAMacvhc=; b=I7o9zVTU+rNSbtYndYrdlUfDEkL3FNBgXZJQv34qArFsiHDPgwfJmrWtZpH0uRMyQ8dXzmxtvqRNvUyxspB7DPe/Zq9bjR2asgLfuvzQnPoMT/3FgkzmCmPhiTpANiWEaiPQe7A6v2C6csXKErxl4fthKdZo29yMyWDicdeoIILQi7Wm9tCNizXIsXkRzl4v9xAnanmmAd3vE0qDJwXK4Ytmfyiq6VD/8VECwZdQbFwD8Wf0iH1sJNmgXoqaO7ZRCyfsbvrgsXvlXdM4e/WhFUWOSU+a8/Mn+6fi4KqzjAciQkTpo1PMvihq/TcmWQf/jeOX3RdV6/JVFuimELYRvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PblZfXDPT84swuLDCHtey8tDUOOapWOEpa2uAMacvhc=; b=owsAdzscqAbBXIiv97g/jyOy6s8NAgiKztWSQTEkyZcBa002jvEPEuvwg8MbW/a6oG6DDZ2tvoSoWtkjrY8u8KhsMtm1Yp2BKQa2VVbEG6rN0XxdA+5eMsZuUu00Yi0N/F7NRz/ruwNNVOK0R5FURE+hTIc6ebxLaY9o8lVdT1ziGlYocEret1gelIq7Y+pepL+FMU76scBrMn037A8pnxon/Tx7Hi/j0+hwj25B8x5OTCh03VBYbscRLvLWBpEgH6my4bzfCoCYIr3K+HU03wXS1+lTR9kVY8CiBjy+7O8QantfgSz6bZtWua8ubT2lJBrKbkM331P/vZWm3J9IYA== Received: from MW4PR03CA0241.namprd03.prod.outlook.com (2603:10b6:303:b4::6) by MW3PR12MB4508.namprd12.prod.outlook.com (2603:10b6:303:5b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:03:31 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::5e) by MW4PR03CA0241.outlook.office365.com (2603:10b6:303:b4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Wed, 5 Oct 2022 05:03:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:03:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:03:12 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:03:11 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 13/18] pktcdvd: use init disk helper Date: Tue, 4 Oct 2022 22:00:22 -0700 Message-ID: <20221005050027.39591-14-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT042:EE_|MW3PR12MB4508:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f481e14-9489-4f61-c30c-08daa68ef2a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vatkrtEP4twpK+l8juF6Z87iLJfHuqWi5QQS9OgY6lHdDd/TZFuADk77AK35ctmMrrrIrGciIuZr79vY0k0/uKUgz72stKFIuvxZ0gkAa97ysQyqiDQjo0G+d6hYgATUlJaiBwR6k+obaahKI4VgKWKOzOtMM+BNNUEUcTjo7EsxT0WA9bAf2D8FKTMDSeZr3IIvS+P8o3ktS2QhlrvW3V3gr2IrehM1S1/FmFhtehFJztlm8WwqR3uJwahQ1U/t/wCdv2Xo+OdEc4jeSuYXZ/3DZTT4BiImCeJTzX/cxtfQKJzCi0FvBGIVwyFsAmSzm5Ti0UFqUP8zL+jmq8BuwwRshH9vY7X6gREeqIJ6bvr8LJWuK1q5owodV62H0Yp3+nnKRyB3eXP5Px7COc58Hu5lA3GdQcf180HjpRHKhCEOE1h54cvxNWqFM9lwKOHqC3wCV20l2wzu5LU9wN0AmkCM+kA6HfByzcme80Z3j9xtD8/o2aqoV2KcaB6wwGmACWlbe8wv9J+zun7C2QEWFHiZ3DZLnbgapL54bblmwXIMIzNlB/F1V1mTQqaXs6EWSySZ83yjVXy0b3FkvtHzKG2CATpV57a5+LElCZOLJRJ2vtQsPPL8la+B9x4/QlrvBKlf/qJvviHjVAZ7f97VLAYAwasx835QqRodUlp3Vp8CWChpZmdNgLD+y2AswzNhbf1UIKci8LU+t2D2KFjIqSoQpesT1+BertBfcHYXuI0AKyOnqDXA+kwy8kkna3eO/jpOSQ4e6S5u9gOfGg5/ejf4VjBaufvS2qOT1XAoNBK9k+XA7nKlJYh2FjPIuqoj X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199015)(40470700004)(46966006)(36840700001)(2906002)(478600001)(36860700001)(8936002)(83380400001)(54906003)(110136005)(6666004)(316002)(7696005)(356005)(82740400003)(8676002)(82310400005)(41300700001)(2616005)(47076005)(7636003)(16526019)(36756003)(4326008)(7416002)(70586007)(5660300002)(186003)(1076003)(40480700001)(26005)(70206006)(426003)(40460700003)(336012)(133343001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:03:31.1769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f481e14-9489-4f61-c30c-08daa68ef2a5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4508 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/pktcdvd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 4cea3b08087e..db8f4ca5c09c 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2698,13 +2698,9 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) if (!disk) goto out_mem; pd->disk = disk; - disk->major = pktdev_major; - disk->first_minor = idx; - disk->minors = 1; - disk->fops = &pktcdvd_ops; disk->flags = GENHD_FL_REMOVABLE | GENHD_FL_NO_PART; strcpy(disk->disk_name, pd->name); - disk->private_data = pd; + init_disk(disk, pktdev_major, idx, 1, 0, pd, &pktcdvd_ops); pd->pkt_dev = MKDEV(pktdev_major, idx); ret = pkt_new_dev(pd, dev); From patchwork Wed Oct 5 05:00:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999002 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 598C7C433F5 for ; Wed, 5 Oct 2022 05:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiJEFFc (ORCPT ); Wed, 5 Oct 2022 01:05:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiJEFEz (ORCPT ); Wed, 5 Oct 2022 01:04:55 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2068.outbound.protection.outlook.com [40.107.92.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1223E74B85; Tue, 4 Oct 2022 22:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FMXiWWDN1LMnTqkhoWPuGbVF6+PW77y8SIPc/4B4uQBBn2hlPV6HtupWuyBxOCbuqF5EyVuDyC0Sh07X/6BnUAfyt2l/PU1lcSWVXc6FxGFZGPs2gSG9KbKOGc594NNwIjrNGZe5yzoT3Qy2kWHRj5X8dDArxQPAvi73558y65wqVas7JrEBGX5WG+DQoEgZIZGnW2WT5uDjSC6sd4pjia3f4iZFSm8iOAUkM7PzKo8e0M0HU8/m4QKBsrAP/ImeMqDVha/Bus9crEGDv07mm5Eu1lne6DDOjkC2CNO5Uvfc4bmFN1gVRZ1RDMpXs1kywFeBL+q2VBNXamGW7KK2pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8xmtiNGAmNE7dW/7iM5AgEgNvt4lKAO45mgCCIQCeNE=; b=muO0xGdCYlpbi3067F0zvEvAiql5cQXv/3sda4c7oqZz+XhvSkF3CkmwaDjZmz6uwxh4tlCYs5fMwc7cJGJretyHoS15WKutmBvXP5l8M/sA5kxQUfUWKJ2aCdmCnFMWQ83ruiudt25H1TUpHIpUCLGjoA/bksvKry8C+oXDovZuK4YyO1EaEkwIG/09DDLphNsyI14xK+hiysO0NAtCf6k8gkoDoIoYYd2bj/OhP72+vtIb6VCz3jjGTnjkCS4ldqvjeD+q9XIqHpv/cSOuw5ljobxeioW8cbzd0xtShzycjirAodZz7isldzCNK772mo0Ek88OkoJLx1Y2Vw0/8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8xmtiNGAmNE7dW/7iM5AgEgNvt4lKAO45mgCCIQCeNE=; b=ONHjW9ZwwH8oc9v4qczXnV54KRL6PPcw4rUlKE2AJLvCkKCfRhP/mN4ANFRRMwiZOCePv6QhzsPxBCDFNOIWY7iGNcAccSdysOKMeYll0vbWxoo8ZtVkZR9ci2+LhtSfJJH6LXan+mWx7mQOU7wCoRXhNstMI+2zQK75B4Pg0ZXo1DxNPh6CIytxnvPtwBwKg7/d4nYOzEyPg5kpMV+ewiZXlWzfhSNtMyuDs5Q9UNtC9ob/7pCqeluhFWRTF9+Sjjib4YKVImu91UhI60guORHOEuzDhE8PC0syKga29kCStUnC9Ke8VVKb7HTGXY+pMAaoxatKCp/gm/n/Gc07RQ== Received: from MW4PR03CA0187.namprd03.prod.outlook.com (2603:10b6:303:b8::12) by SA1PR12MB6680.namprd12.prod.outlook.com (2603:10b6:806:253::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 05:03:42 +0000 Received: from CO1NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::ae) by MW4PR03CA0187.outlook.office365.com (2603:10b6:303:b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Wed, 5 Oct 2022 05:03:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT003.mail.protection.outlook.com (10.13.175.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:03:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:03:24 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:03:23 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 14/18] rnbd-clt: use init disk helper Date: Tue, 4 Oct 2022 22:00:23 -0700 Message-ID: <20221005050027.39591-15-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT003:EE_|SA1PR12MB6680:EE_ X-MS-Office365-Filtering-Correlation-Id: b6937243-ded6-465c-f408-08daa68ef911 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G341qt4YpCEEFIv2fWnulqvSlyT9tJB3FcarfTOE9SbAcWv1gEKSMj6yRr4qY4RO3rpcbTtRcRw8GO4wil5qwEHZ8Lzyh/XR2WU1XjNxhlAbZGYTdbbUUSjGWUbaRzWQ7u+HRBd5FsE1ntWYE8ZMep7rUyoyyOlKVEDHrnvqx24o3IdOos+qc18K77eItNUPI1jmds5ZnQBukSVa4uOZ5rv4x/LOZN7Wl8HHehwrDLeWbDzKQQm38QvALDnC0wuPR3E20RzGpLofNYmFbu7aYVVgPKA+E5JQM+xZceZlG6J7oEgUeGlLimAF4iiFEmGjQ2Aw6h4JpZcL8T0oFLJfC7rLfDnQ8npcIih5MVPfujY92uru3LJonMSlpRohn3exKCxnz7nAgBk3A3ir4i+Ztg16lhqGZi/xyhHexV6lZiWovVbyDw6Vl8nttwB+hPNOjoQsxQ2BzFRW8LMWRIspe7hSfclPaKBb4V8bGEj+v5lJwfSVlH5aVhsYyQ8GLivtNl5jp/MwMV4vdLU0IB2eLHzoWvKVgwLdao2VHcwCI7cFmjgSo/V8h7EYjtpxUYsa39nCCnet7YIpuNymBw3IQMBGORQ7tzCbGAEwEJKiAaKFwTtwxEDH8m8+GmS2haxWoFCtDkf4OYdzRXwL23c7ZuAzeELyOJ6gVg2+SPXTE/ZY8T7ukx/q1/+M7IatuEXewjzdyyEFLV2dB7++HS/AivUWlrzExsP7gRZgniZw1HWXkmtoVeCcXYlCkQETsjLDP9uTgMGXkiqaUrGWpZguE0QozwUJFmJl+6d+g5Xz2HQ= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199015)(46966006)(36840700001)(40470700004)(83380400001)(8676002)(2906002)(4326008)(36860700001)(70586007)(70206006)(5660300002)(478600001)(54906003)(110136005)(41300700001)(7416002)(36756003)(82310400005)(8936002)(26005)(7696005)(47076005)(426003)(1076003)(336012)(82740400003)(186003)(16526019)(7636003)(316002)(40460700003)(2616005)(40480700001)(356005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:03:41.9523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6937243-ded6-465c-f408-08daa68ef911 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6680 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/rnbd/rnbd-clt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 78334da74d8b..4f29364a6f4d 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1369,12 +1369,7 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, { int err; - dev->gd->major = rnbd_client_major; - dev->gd->first_minor = idx << RNBD_PART_BITS; - dev->gd->minors = 1 << RNBD_PART_BITS; - dev->gd->fops = &rnbd_client_ops; dev->gd->queue = dev->queue; - dev->gd->private_data = dev; snprintf(dev->gd->disk_name, sizeof(dev->gd->disk_name), "rnbd%d", idx); pr_debug("disk_name=%s, capacity=%llu\n", @@ -1382,7 +1377,9 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, le64_to_cpu(rsp->nsectors) * (le16_to_cpu(rsp->logical_block_size) / SECTOR_SIZE)); - set_capacity(dev->gd, le64_to_cpu(rsp->nsectors)); + init_disk(dev->gd, rnbd_client_major, idx << RNBD_PART_BITS, + 1 << RNBD_PART_BITS, le64_to_cpu(rsp->nsectors), dev, + &rnbd_client_ops); if (dev->access_mode == RNBD_ACCESS_RO) set_disk_ro(dev->gd, true); From patchwork Wed Oct 5 05:00:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999003 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 E1CC2C433FE for ; Wed, 5 Oct 2022 05:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiJEFGF (ORCPT ); Wed, 5 Oct 2022 01:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiJEFFf (ORCPT ); Wed, 5 Oct 2022 01:05:35 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE1174E03; Tue, 4 Oct 2022 22:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mOUjt34p26zOOQaRS/pjhGTvFG5NArjL18PMUilpQqkpfW8Lv2Hv0XhNrekzZ4A449HXnwQdDxYUMDLHnhgjhbE0gjfzrZ2Y2ByeNe4Qvx8yLVoZCwiEUL8Ujn0ZCTIrUIfbQStQsm0z5hUaKeMgWKrQk7Vh0QAorVQ8ta2IwOTE4+1NIAgbsGeMleQc9qs4TKR7LsP0gL0bvwMpjrYtgXesVYBdDWoT5Ezytuacgx9Cnv7u4lMQQ0tGVhyjnTDYbJqAyrc5LOO3kpE8KvmU7dslwD62xRk4wJ7v/9A4dIAjlnaeJZpdeCeb8VrrPNLL++mis+lPi2cHXqTyKVE97Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=spAFhx8+nXp+zmgqn6QXTxIEAJQfg+OdNZF6Az9P92I=; b=Q0rb0G5jrWIluy3/5jsoBnCq9bzmKGqNf9oA/oJ0JulVaf2Uvwat+fGxh0e2jhy2+ktu1q0dlRremomF4bib9B9SSciT6hTY+Wm/2PhqOxgDYhnll5K8pyGV3ivBqLXC/CbsTL2i+FYApUW8uheFjwfupu4wR2WPBoNe+q54YutYvzNXYLOY6PaP84y8LoArqpq9v9I8tngojYvG+UIucZGMD48nymoYEQH1MvNJnYA1GiY9xDh3YT4V11BRd8Ep4mMAbK1ycgJ4aCNusvGRvOzzuEEwfpogeJWUJGZRauykCw+j0GBGC4oT0tsPAbE6XHpuAUAw7DR4nyj1ZwL/jQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=spAFhx8+nXp+zmgqn6QXTxIEAJQfg+OdNZF6Az9P92I=; b=Fk4Ej6wEEUNFktGQkqpFkvRCzLJk6yeDdYt9+duOEl9NO3b0wi2f9skUNlxkv5+OanSqoWJc+u0YHxD/AWPusQcs7KB9T01yj4re3d5gBb7R9po8tVoRyt2glFgHF69MwYD1W91hEjFm2G2TqKaHENPqS1H52nAcogezfA/sgF2upE0oH7fZRJRUqd+R+XutlDf5+FDo3ClN73ynrjzsx0vQJF0PUGAn+KsKCAZEm2FugKeVLh1lavRzXmn4sMGhL/GCM8T4wFDqFsWfopvdFKPSDGMrRZH3NUK4vxZ+qfZ5xjmFP7Y1lrddCPCX9VMV1i9819MQiFQ9XL/3MAvMZg== Received: from BN9P222CA0022.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::27) by BN9PR12MB5178.namprd12.prod.outlook.com (2603:10b6:408:11b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:03:56 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c::4) by BN9P222CA0022.outlook.office365.com (2603:10b6:408:10c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.32 via Frontend Transport; Wed, 5 Oct 2022 05:03:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:03:55 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:03:36 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:03:35 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 15/18] swim: use init disk helper Date: Tue, 4 Oct 2022 22:00:24 -0700 Message-ID: <20221005050027.39591-16-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|BN9PR12MB5178:EE_ X-MS-Office365-Filtering-Correlation-Id: 27bdaf33-8ad9-45c6-8550-08daa68f0153 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TP1PsmvwUIkAlkxp0zEbjTRPeacRaYyqWMF4RiIJzFUZMwv1SfHmXOlGV3ZzfGZFCZIWJVu1YZt/wR3wjwKpAzWAVDjs9H2RK5mP5ROhgfhs6ZisiXZkwxNJ84pdy8A6SUbVOEW0IjwzH8gmwUJeqbUzreTXnANXi+5zS+0YWbOpHCde/QKPkNgqT8/dkvJDa2lqprSfIVhmNKt1VoxSihKhoVr2AbtMh9lqxROX+c/G+vK0gmCL3NyCdjZTX1LdGqGCiIIUQcjK+8SQTVZvfUAlwaL7ZLojTshjnBFXJEivoM7SnCaz7Toik/yMBAT4PE9zt6NXooPCD7H/Nsqw+65C0GbOs1hnK/rZMDYgI9C/yFIlTZr8T1baiTQ2olNuqnnNrNevRNzCbNJxUp9aALalaQ1c39rtn7m7hnzBeAT2LvTxruQisea1WQ3B5Cnuy7LTj7/ub1u6/cxoOUSAo6v2AXV0a0flj6QY1g3UpoFQ9ISe83oouseiGfJ1R3PTFcH4VJX/TzNVGe+aEqz1PjZqODKc/aazovmOQ2b/TVbrMQr0ujxA8VLQMkjl8zTAH2lAJk5ILdHAbxMq1gVGkwSV5mhB3ymAo/gJ1SxezJv0ibddbdl510/D1gNB/OKqAoqAqnuDHTMgLit7AXCd1V28gzDRxcDo5aCO2OMw+h51GxBAFvnwrpYcrSLAgZpeRrfAIchlM8TIGBerhkxVknvEd9cH9hsUsUPM0kxbh4INI7cNyh/YKgtI+lImmT2dpXFxJim4hlgd3OgezxvilL5vr+BP/bDlqan0kvmw+hk= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(376002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(83380400001)(36860700001)(26005)(54906003)(316002)(110136005)(2906002)(7696005)(478600001)(40460700003)(82740400003)(41300700001)(4326008)(7636003)(8676002)(70206006)(70586007)(47076005)(356005)(426003)(1076003)(186003)(40480700001)(2616005)(7416002)(8936002)(16526019)(336012)(5660300002)(82310400005)(6666004)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:03:55.6787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27bdaf33-8ad9-45c6-8550-08daa68f0153 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5178 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/swim.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 42b4b6828690..7fa4b2766367 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -835,15 +835,12 @@ static int swim_floppy_init(struct swim_priv *swd) for (drive = 0; drive < swd->floppy_count; drive++) { swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE; - swd->unit[drive].disk->major = FLOPPY_MAJOR; - swd->unit[drive].disk->first_minor = drive; - swd->unit[drive].disk->minors = 1; sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); - swd->unit[drive].disk->fops = &floppy_fops; swd->unit[drive].disk->flags |= GENHD_FL_NO_PART; swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE; swd->unit[drive].disk->private_data = &swd->unit[drive]; - set_capacity(swd->unit[drive].disk, 2880); + init_disk(swd->unit[drive].disk, FLOPPY_MAJOR, drive, 1, 2880, + &swd->unit[drive], &floopy_dops); err = add_disk(swd->unit[drive].disk); if (err) goto exit_put_disks; From patchwork Wed Oct 5 05:00:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999004 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 DAF92C4332F for ; Wed, 5 Oct 2022 05:06:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbiJEFGH (ORCPT ); Wed, 5 Oct 2022 01:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbiJEFFn (ORCPT ); Wed, 5 Oct 2022 01:05:43 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7511C74CCE; Tue, 4 Oct 2022 22:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CAP5d9ZCw3nkL55O2yQBbFGXC4nQ6ccSeuhSeTEgd7gRGswOmVcki6wy6qtCx09fUs+6SDz78bgb8wIEEioCKIeMZxGLomDUh+aNreGalE9Agm69BNr0uosDK76QkX06dEkqRr8jLPo8x0Gt6aPlsHw5vUsQf/eTTQL+NHVBz49WpcEBhyQw8bvA7zeD+VFjUn2VWh79XQiTyvjQjGjTY3jXWrzoHDOALAdDZZ0odDoUmny7cQzEff6ACwNxpDx24mtW87b2AyutNoW8+UseSpbPSv2idyXX2ilaxOzxNi0a+q/2fBjnkotLMiUCAPHjWXA7cbpC1S+PA3XfFSzUQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rhfj6A9/vtjkP/6TGk0NS4U+K7ntKmNBdm23oSRWgjY=; b=bPaB6JiH7pPAuejeJVVpDX/q/PYbgUwG4OCaZjK1JNDNVnH8Pkb8gosa1WNvx7lZG1+/WtLcm58pkn/Itrx5OUPj1hCcizahb4ImlNpGqxP8CJwFzc+ixfWC+SFtljjBNQYL3ABOGUOisgpRui1lskj2LZnLF+/QDMF/l0t8OVugPbag00z/2MfUfvftc8p3Cvig4xqxQqau4jqKENQJPL0NQkomyYU6J0g9bKJ6XL4lXyLtACfClKh+4UeL5P3IDkenL9FBp5mu4H+rCqfrqkKYkSSc4730YMqvqRH0Iw1obwZEn9TYMBbKuFbgW0iQtAwyU7p5zmRFf3VT3DdGZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rhfj6A9/vtjkP/6TGk0NS4U+K7ntKmNBdm23oSRWgjY=; b=FPGXCq7z7AfCLOPolxaci3uTrq0yTBIuSsyn9eicS8CrDOk8lEQQiu8MesrOtHNpvNMUwvh57r/7c08jtKTCiHN/7kCNf4PglpybP23FOVZjb0yReduyMBbFk7l6OGaLMu6CZCtfnhlc5ug6MJPku1lPFs5Hh3n82AmZMuU8PSoHlibdZZLSpyXaq0C+ouSN0tHmmG8/w5mE9yAaTGzkQbxp1T8KwdboUsON+3DXRE+d9JDwpy1LX85SzRl6pVW43p9PbLBDK6+LwxLuXxXUe/gwPHDCtRnTN+afGxkyZuRH2idOlzGrKE+YLb0ky9X6o3Mu6kSOkDakrX0PvUL7NQ== Received: from MW2PR16CA0016.namprd16.prod.outlook.com (2603:10b6:907::29) by DS0PR12MB7702.namprd12.prod.outlook.com (2603:10b6:8:130::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.32; Wed, 5 Oct 2022 05:04:05 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::1b) by MW2PR16CA0016.outlook.office365.com (2603:10b6:907::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24 via Frontend Transport; Wed, 5 Oct 2022 05:04:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:04:04 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:03:49 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:03:47 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 16/18] swim3: use init disk helper Date: Tue, 4 Oct 2022 22:00:25 -0700 Message-ID: <20221005050027.39591-17-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT085:EE_|DS0PR12MB7702:EE_ X-MS-Office365-Filtering-Correlation-Id: 97ad017d-57dc-424c-cd56-08daa68f0663 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZSmKvNAkH4UcI0t3D7dOAW8edzC3hayVgBXM3yLBJ3T/6mQlKibMmVUUlw1DHjGmDqZWLu0k2u0VPZsz4Xu26ffB477AVipmlMUkafiCiNbpgF8rmtEvwon2D/3PRbAK2M0/ZvfFMgaMmbXkJvCAylQRBQvsKCF//t06MAwepSokksYH22Sm1Zap6CjAgfP2k0bLsEFcoX+oDBluhZdpZTWf3UfgHhisI56qs8b/PQ0jhMDM+UaCCnCON6yFTB/YEXpYffGsdhvkSX7lkH2p8kIFFErrZXlFPPBgfMLYZkZbY5WF2HVabLwLh/EmIyslbdksEmb49QXmwleTrnh3Ng2dpp4noym0WnziLupNbY8zUqU7GpC+qppSsLSfmJKYKhIjq+zkXAPUg+0l0SpSO35b+RcqXFwnmOXCkEwLehiYeR6zr8dxlo2CCRSHrgSOFDbPqL+PLFF87YJN2PCgnzKM+jiHkT+ADD1yYRBq2LJD0fcLswg8ahTwuNYUudERHEQUrx9IltT2dghrnoGA3eJQ4ak/+fwTKVyOzkG44SjM+B84Q2cdYPQ8Q+OgRN0C9qZF3b9T1hXkChnzLCMiPe4LbGAtfWSQh0Hi0NcmLNtFp/OIkYCSYQsaQVfM+LbPvEETGs0KiHioNlJEUqTr+XFKADQE6fK/44C2PwAc+HEN3zWEFBsuycKEMMaUTYWE06dNJ01rmPAIqN7zA5dVRnMrcNO4igLZykfRZB59PrjpshGmJc7zttBC0dk2fwIFLOpz+jlxc2FVgA0w19OtivXE1cSRfeIJB1eqOikPhC0= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(36756003)(4326008)(8676002)(40480700001)(47076005)(426003)(36860700001)(82740400003)(336012)(2906002)(5660300002)(70586007)(8936002)(70206006)(54906003)(41300700001)(7416002)(110136005)(316002)(16526019)(1076003)(186003)(7636003)(356005)(2616005)(26005)(83380400001)(478600001)(6666004)(40460700003)(7696005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:04:04.2990 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97ad017d-57dc-424c-cd56-08daa68f0663 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7702 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/swim3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index da811a7da03f..3c1b92b464d1 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1221,15 +1221,11 @@ static int swim3_attach(struct macio_dev *mdev, if (rc) goto out_cleanup_disk; - disk->major = FLOPPY_MAJOR; - disk->first_minor = floppy_count; - disk->minors = 1; - disk->fops = &floppy_fops; - disk->private_data = fs; disk->events = DISK_EVENT_MEDIA_CHANGE; disk->flags |= GENHD_FL_REMOVABLE | GENHD_FL_NO_PART; sprintf(disk->disk_name, "fd%d", floppy_count); - set_capacity(disk, 2880); + init_disk(swd->unit[drive].disk, FLOPPY_MAJOR, floppy_count, 1, 2880, + &fs, &floopy_dops); rc = add_disk(disk); if (rc) goto out_cleanup_disk; From patchwork Wed Oct 5 05:00:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999006 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 C5D4BC433F5 for ; Wed, 5 Oct 2022 05:06:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbiJEFGv (ORCPT ); Wed, 5 Oct 2022 01:06:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbiJEFGF (ORCPT ); Wed, 5 Oct 2022 01:06:05 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9527753A8; Tue, 4 Oct 2022 22:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQnNarfyEFfJyR9KMhgRcWp3Ap6KKNzyuMWIxUAb1ypLDpxpzFnkxSN4WFzGwFanOB9LVwsrA7DUDHOhQ5ACPiWVZQ47rC/V17CuSzFq4pcHMg6QXsR1OjHlWLtSYcKSnd8qAsL7OqQiFUl8/tGB5P3365Pqk3a5rQYMoYJytkQ8hFNymmKhonYg70t7JLVSR20d1w9Ca65/YUUBgIcdTRyfj8/hjVj/WzdikDthvILZrsT/Mg9N802L5lLNiKenjej6hc7KEzn3YyJpP1fW/2aM2Kbp0VadfUp/ZJ43HD5NH/P6GRFIQ4fsFzsHO9Uwvhjj8vhu7xqHuTBkhd4p5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VUGnMeKXYhsQ4I9OJx4wnJ3fbX8ZcYbAOImg9h0puEU=; b=nUtUJATaPQxIobsWDzq0XfCc6YR3REFQ8jAxjPufvMGFXlbQp+uwII2mhOuRG31pZQ3P27mGQTbIN2EsO+TWeFWbEXatz5d5qs3RiCBnEXcFdfNdJekGpprRF78AcRJwYsW1K4rfl7x0fmUnFT0d5FXG6LnafRDVXrwSl34sbUM8MGhkx52vYSA0p7+hvePoS5DJcTcEDjsbj6j3M4UaECpknmBbW14srEON3C8HS5xXppT/vhQADhl8XCh2APvcUjD0pAOVg77iV/uhsD+9SsTLxfV2qLGJvTQSUQ1ylK2Q54a81wgK7lFejJ1DY4RO71er8rQ7/axEogvuMyS8Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VUGnMeKXYhsQ4I9OJx4wnJ3fbX8ZcYbAOImg9h0puEU=; b=gF7CqEfrTRTmGE536cLpTGvv1cT1SbVVlLhHFGNpJZSM1USYzij5JYUMjQnB2H3JUDxzEjrHtzexjhWkv6QWjlLHjNeGW54mDix6L8AYSxw6W696nwx/7klaXRHEhCw/xEPZKS6Vhb4X9S/hBdUXf00KdUozLU6LVqBpD/oDTvSO36EDGKep/F19J2VcnumdIUcmDOC3NtNMxigGHQH0gnLOHOHRouxPMD70ZISOrgCn28pjhn0pKkoLpND+09skx+/waAqi+Ai/Dm7w3AjTVrAdJ1gL/zGbXOM7iCwTkSd69NDJy8wPbYIclXbEPf1dVFArhj/q0U5I0LOlbD1zgg== Received: from MW4PR03CA0085.namprd03.prod.outlook.com (2603:10b6:303:b6::30) by MW3PR12MB4411.namprd12.prod.outlook.com (2603:10b6:303:5e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:04:21 +0000 Received: from CO1NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::aa) by MW4PR03CA0085.outlook.office365.com (2603:10b6:303:b6::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.29 via Frontend Transport; Wed, 5 Oct 2022 05:04:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT028.mail.protection.outlook.com (10.13.175.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:04:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:04:01 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:03:59 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 17/18] z2ram: use init disk helper Date: Tue, 4 Oct 2022 22:00:26 -0700 Message-ID: <20221005050027.39591-18-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT028:EE_|MW3PR12MB4411:EE_ X-MS-Office365-Filtering-Correlation-Id: 05c2da29-eca7-4174-a926-08daa68f105f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jeWij9BSR+ld5x3cRQK7XJOwVQ+x+XDGyITyRqUSjvo5nps2uSnWQ+3iGIG2W2qQIFYkS3eLmafAVndcWjZKvay17CERvXztVJhPgRtHr+NkIu+OloUyx4q6CEh3MGxKLYRlPiX1mR4vZtwE9tvz88yx3KE0+PQRX9J72EMiNnZFtb0DQERSEFpRa9uOvIODAMCjGZTI8GFxuikZSyCm1IGr/+BzTOhXXImuiKGbVLciZdWetQKEbiQ2h02z4ouLmMm6czEFQoROqCpPGa7FTkAvyBZamMNpXb13zXPZKlJmYdg3ZciLVCCTaMMUPRoCYte9w273S8U8Lf96h5ofR4XbCp6xD1eFuOqfAUY1hC1UGiIEhxCqxCGdbIcATvKgsp+VUZzyhRnQPs7USVe7ZeDunylwfTnoAxmndzrhgmhygbz7w7DMny9TUCYbuVnscP9vh/SJKDaS2L2TdvlRBgos9ipW4aSs7zav8Rmdt3GQmZk8IxqAMX8GVM6jUVI/4jvmI+MLpy9DHm0KnwWs+m2Td61xJx3MQb5sNi4u3JWs2oP0AwUbk9e/dDNDyp1Re3OGsDluZy4EjRwUNDcLBw14kvETyc9xn1Uh7joDEyoAhjB4XtenAbuc/HfisBUSLqkcJdVxSzZ3Tr0r1Jr7oIf4gv0GKOf0D0e3gACKp73pGnz5nDhaPE7tqeGs7IcaH0B1Wd8Gc9pXDoVm5ZSGeiKSsLFj60NyFB+KeU/N7RnsN3W7XzSIMpxIvmw7VNeJXgiCm05sGebiLmp3Ck+hAVXW5xxCGayCLr66OM4lCRY= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199015)(40470700004)(36840700001)(46966006)(478600001)(41300700001)(110136005)(8676002)(54906003)(4326008)(6666004)(40460700003)(70586007)(70206006)(7416002)(36756003)(82740400003)(47076005)(426003)(7636003)(83380400001)(36860700001)(4744005)(7696005)(40480700001)(26005)(8936002)(5660300002)(336012)(316002)(2906002)(356005)(2616005)(186003)(1076003)(16526019)(82310400005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:04:21.0491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05c2da29-eca7-4174-a926-08daa68f105f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4411 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/block/z2ram.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index c1e85f356e4d..74432fbfe42c 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -324,11 +324,8 @@ static int z2ram_register_disk(int minor) if (IS_ERR(disk)) return PTR_ERR(disk); - disk->major = Z2RAM_MAJOR; - disk->first_minor = minor; - disk->minors = 1; disk->flags |= GENHD_FL_NO_PART; - disk->fops = &z2_fops; + init_disk(disk, Z2RAM_MAJOR, minor, 1, 0, NULL, &z2_fops); if (minor) sprintf(disk->disk_name, "z2ram%d", minor); else From patchwork Wed Oct 5 05:00:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999005 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 CB253C433F5 for ; Wed, 5 Oct 2022 05:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbiJEFGi (ORCPT ); Wed, 5 Oct 2022 01:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbiJEFGC (ORCPT ); Wed, 5 Oct 2022 01:06:02 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7D8753B2; Tue, 4 Oct 2022 22:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LCpmbioWARSij48hDHxWLETjLMMmHLguu9p6vy+uK6V5AAtbjUdqGISS4dRk75mtngi3QoVyQrnDHJc47kldN6nDu6DKx2U4uTs0Vinyrc0U4wEbc8xpnjkC8Q+qRcLeE7nYL7jg0pUr9nBs2GSn+HJDxwOEtitSqYUobEMqIDI8zz+ONDXpwr+5PwoNboHoxsQ/4vlwHOjaiyfwHpoMg39aFdxL1uY7zrSjT7H/JIk/fPCfDYOkYAsBx1SAeOzVzDiJ1Gd/Xik4wcPC3NlAJlDYzdZErrCg/o5W0BCwM/ohW0/prXaqrQGJ1cBiTYUDIH7VooRQyWBK/Gl3Teocig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VqJq9X9tqAo2dMwUgS5ahUWpG0s0I2opXSaHSMh2AbQ=; b=M3sP6J/KVHmwTImmF3w5VPNkHq0y+eP62VtSieGymIrypyclSKoFGUSdnCUYtqgCf5VxlXwpf6aSL1Wg/dumvJDfxk76ZyNy2N2IwpgvBU73kFGtv29kVMRgsClaXpP/4UVr0afi6OTvfIi052UFPmuTfc082BnwGxHCktVl0Rnxqp5bnoKhINSHYiKPcJbRFqz3g98vmo0nu2o5EqgBzIZVjKrPiQfziZqu/JHNoQDYE1epuG9b0Qo7b8KiBoKg7YSWq58xjrHg4Iav/JAJHI/L7EICeXQTVxtu8utXkifKq6nE1KM6bYUvbL8doolUStCq7b542aQ445UmRDo2qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=linux-m68k.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VqJq9X9tqAo2dMwUgS5ahUWpG0s0I2opXSaHSMh2AbQ=; b=HU8/1NL9eoXLN+SSVeZsYiH99l8CYhxOVwMgzmPBqtrlUgjshbaVU62ykvsJns3WBpB2CCGd597dmhRtr83E5ykgKhPM2n9EE22fAffwFreIi342IFo9tKshfBKT7dmLP0FOjLtM3TIBuv94kj8d0UEzmZdzKF7odj++eo+bckqTqn4mwEOoJUYqTch4ovnkj+qZzmifCXXt4ydGe5ArQNyStNeh11VOh5ZcSWjxWPsdGz27dSRUSulxHu/qHzhVnGizrh75lYCylqTp3tSprdXz3SSTCojbhI/qyva2M4ytBXj6GsoAJ2+nGIZLKiSF/oqyKACJyhENbFYuXfxlcQ== Received: from BN9PR03CA0317.namprd03.prod.outlook.com (2603:10b6:408:112::22) by CH2PR12MB4053.namprd12.prod.outlook.com (2603:10b6:610:7c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 05:04:25 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::bd) by BN9PR03CA0317.outlook.office365.com (2603:10b6:408:112::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Wed, 5 Oct 2022 05:04:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 05:04:24 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 22:04:13 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 22:04:11 -0700 From: Chaitanya Kulkarni To: , , , , , , CC: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 18/18] ubi: use init disk helper Date: Tue, 4 Oct 2022 22:00:27 -0700 Message-ID: <20221005050027.39591-19-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT033:EE_|CH2PR12MB4053:EE_ X-MS-Office365-Filtering-Correlation-Id: 27d8d60b-e5d1-4050-db8d-08daa68f1276 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bVdH+XWqMGPPWB1/2H3kNLQPismwJd2x3rKmctdDUEn6FYMemnCk8gfzdGSHtQoaKtz4WLpIRHd5Dmuucfu4o5W81SckmwVzL0NFlJD3tvBwVGuwqZKE5NEjg8cWN0fL3/CzgKJfWca4VrI7wqFqKhC67gL2mM55hnahN5c4rvHJCGBWaXh5aFplVqX+fFZ+Py++W1SFyFnMfsYC/wAFGoWeOKVvMX9k3WuHs3nHM66bGBE9HfiZC9Nj/Dvp4IcNpD2qcHrxYwVZtSrRUpvDo2gUBsIzwarOV0nmLl0VYVzB8S7dUgH2qljfOaCKaTrnn5FLlc5QuKzuo57NRDZwpPSvpehxGn3vMS7tzFQXzbmW8UD9drXJ6qxiRuGJU68nWeUTWn8Sv3HwkYMD9g+G9DavHpOUN0cnXTwDy7LTOKuLkVDEUrwriptbflnBGhkf2urbimyFSSna46KTYjtI0qt9yY7L9Eh7YpEZkx2MHhLOnMG/DE9+LiTS4eXsD0i8C99rfpDfCTTFlkno9ewR2C3+fGnzcvi7r/MigpjVL/NamD5Z45+M3f28HsQaMSOxKoCwuPEOdMRIc090HqDdMNmEGBdEL9gB+IDuV7D3fUQiQ0/EBtcvSYcDHuCnKXJhfI9xDd8/DW4m8Ttuye14W5clNvNe5PWjYbG/8UA2iwAWS/p35NnnxPOrJcI3B+68GuKXnULEvX8B/W2eVNxnc5puAJxMSnFya1wuU59h+Xo9lIOdsHPCfOC6oYxG84Wx4jMoXaYts8R+CAbnOkOshGbaxR5nSIStDPkHs7Yj+U4= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(46966006)(40470700004)(36840700001)(82310400005)(36756003)(6666004)(7696005)(478600001)(40460700003)(36860700001)(83380400001)(26005)(2906002)(316002)(54906003)(110136005)(336012)(16526019)(5660300002)(2616005)(40480700001)(8936002)(7416002)(7636003)(4326008)(70586007)(70206006)(8676002)(82740400003)(41300700001)(1076003)(186003)(426003)(356005)(47076005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 05:04:24.4316 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27d8d60b-e5d1-4050-db8d-08daa68f1276 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4053 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add and use the helper to initialize the common fields of struct gendisk such as major, first_minor, minors, disk_name, private_data, and ops. This initialization is spread all over the block drivers. This avoids code repetation of inialization code of gendisk in current block drivers and any future ones. Signed-off-by: Chaitanya Kulkarni --- drivers/mtd/ubi/block.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 4cf67a2a0d04..07c085a5fd52 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -420,9 +420,7 @@ int ubiblock_create(struct ubi_volume_info *vi) goto out_free_tags; } - gd->fops = &ubiblock_ops; - gd->major = ubiblock_major; - gd->minors = 1; + init_disk(gd, ubiblock_major, 1, 0, disk_capacity, dev, &ubiblock_ops); gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL); if (gd->first_minor < 0) { dev_err(disk_to_dev(gd), @@ -431,9 +429,7 @@ int ubiblock_create(struct ubi_volume_info *vi) goto out_cleanup_disk; } gd->flags |= GENHD_FL_NO_PART; - gd->private_data = dev; sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); - set_capacity(gd, disk_capacity); dev->gd = gd; dev->rq = gd->queue;