Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1412655rwb; Tue, 4 Oct 2022 22:08:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qLy4ycix3Vfw/ScFvs4I73NJ1hthPj34258fPVB9cWouYbQ4a5nM/eKtm1fvt197SALrE X-Received: by 2002:a17:906:794b:b0:787:bb35:84cd with SMTP id l11-20020a170906794b00b00787bb3584cdmr21453865ejo.428.1664946482469; Tue, 04 Oct 2022 22:08:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664946482; cv=pass; d=google.com; s=arc-20160816; b=P2ztSJv4bLhsyyAYMS6/8bLAeFpHvV6ga9FmM/XdCjzD0egPPL6NkYsE8FQxeSvtRX 5zlh4JL60MSCj7qHoYYbf9xzfleASwOCSerc2N0wlgGCcU1NvHRNBf6j1O0jkA+GsWEk 1AOZUkC5Vk71meTlCvcdnF3epYEyiBMWvC/0EUtRIFk3iH42X9mJ4626I75ej60fGSlQ s2181obQPjQAA6HFzAtFuSxlgGfEnk/ph17QvwrUU7EZ+LVqbr2m+6dx6phB+YZ2p5X9 irQINiBj48SiER+CEP4YDyOyr/RpDxiHqruQx3SJhEvnbTTOPh0SAHURIpfHbzav3KHg DEWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8xmtiNGAmNE7dW/7iM5AgEgNvt4lKAO45mgCCIQCeNE=; b=q9r9BNUmFYthrJYOWGn2KD0luk7vPwEy8+n2xKTRMNHOEpA0xZZf8AtHmWeY/8iedw o+ErFbEmofqYCDuRd0mmLHmMu7Ri3qt0t8vu6xrtbSvSNdNhokFiNYB2QxkXRR3mwJMg bP8foNZRmmpc8cB6FbGL1SxUNReWFGNy9ZBM65/KF1BXhSazO5hA31FQrQeVyifxoq/H q8qUCI612aa/LIb0XMag45OT3kLo2+foil3zBbKjxjAHd+CuePHh5DfDgv8onk8jbUNy VHGBSYkS+TRb2xrXrL0usxrSRdKQybSVtzWgSTAmNgGfoMoC04RuWBzpQCfUZMPG6/y7 MX5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ONHjW9Zw; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr2-20020a1709073f8200b00787796077a0si13521186ejc.429.2022.10.04.22.07.37; Tue, 04 Oct 2022 22:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ONHjW9Zw; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbiJEFFd (ORCPT + 99 others); Wed, 5 Oct 2022 01:05:33 -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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.29.0