Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8200904rwd; Tue, 20 Jun 2023 11:33:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QuKlAEPtIsIH+xQ/bruAwk3AtKJ9Pbz9bqax8Xz3qJ89QI+CT6pOHyZYkttTm4zfL6Uz6 X-Received: by 2002:a05:6808:6cc:b0:398:f48:eaf with SMTP id m12-20020a05680806cc00b003980f480eafmr15934156oih.26.1687286020253; Tue, 20 Jun 2023 11:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687286020; cv=none; d=google.com; s=arc-20160816; b=ak6qdw03BHqOpdpgJCm18SYRMJSnafQ2hgN6cUm785hbaOFLhFJ/R/y4Om/AxX3RtJ RFWLC6qVWcvmHILfub0WBLlQ8WeN6Jg8ouhQrGzr+eHojQ6pJ/dD5wSHAtknOzUNI4SL rHkFFSIrPxVeQaKEsDlImstvEkUTOYZfVM9D0Cy0mztYJc/ndYZpFh8P1Cw8sgR8BuLz mpDJeMm3n0lJxglbCd8fbeBQwz60fEYJH5PRoHgBnX8nl3DdUR8c4UUspvuVllcRFvIj T09xDNDlA+SFDCAsbhF6V7fkqcuI9I8uw1Q6jiUatvUJKD6aS72TDYpW891/B7jRiqzk 4Qrg== ARC-Message-Signature: i=1; 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=J57ueJ1HoAuMos4hQYcsllyGWp6gyJ+pPBJhrZ7Ce7I=; b=HghnOMden1d2Ss5XioZ+FsUMg5H742fFTQo6m/NjYi2tRUmGuK2zeJ1aKEBvQbwRF9 0eDKgHdyBjRN1vc8TSNz/LZIpQGYRe5aqHkO1jAxfI72U2OjskG37gBZLS556fiV+yVg V6qnYO4DxkH9W9wK8YcQU2lR42eFgRkl0Lj+bk9Hl/mxpMaZUdMQVvI+S0yDHdTCaASq LfA1aJbA+EjlGscl+50Ht2x5HJL5AxrhEj4RqcYU0INvAIYLQwHIgDKVz8eDMQOJ3cpp gxHV2AVO+NcSsqvJh5CpdaD/QwGLfrdDATe7euUUx2fojr0l+8srRou7xAXMM9c5wLGg f7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1OHtgxwI; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a17090a71c700b0025e404ffb21si2536204pjs.18.2023.06.20.11.33.28; Tue, 20 Jun 2023 11:33:40 -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=@linuxfoundation.org header.s=korg header.b=1OHtgxwI; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbjFTSCG (ORCPT + 99 others); Tue, 20 Jun 2023 14:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbjFTSBx (ORCPT ); Tue, 20 Jun 2023 14:01:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 018961A8; Tue, 20 Jun 2023 11:01:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B22E61359; Tue, 20 Jun 2023 18:01:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DA5AC433C8; Tue, 20 Jun 2023 18:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687284110; bh=mLWzIkB9n6b+IgFjY2oTg9W4Iuvar0Rst5HENnLsKCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1OHtgxwIb4ubKzxNV8Ad7uLkzco2kcDk0cCN7fqyXOg71+MYBgDqy5RrSz68BqwJm tMhqCal5n1WhBt1r8en07b9aNXQe/G8x0fXr+rghqJrinhPT2VaDHyJZRjfFyHhiMV InokhMPviNjv72pi4kAXnOUgCB7kdCmlHSwz7umQ= From: Greg Kroah-Hartman To: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ivan Orlov , FUJITA Tomonori , Jens Axboe , linux-scsi@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH 4/4] bsg: make bsg_class a static const structure Date: Tue, 20 Jun 2023 20:01:33 +0200 Message-ID: <20230620180129.645646-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620180129.645646-5-gregkh@linuxfoundation.org> References: <20230620180129.645646-5-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2239; i=gregkh@linuxfoundation.org; h=from:subject; bh=fnHpjCymBCx207w0QsVqcrjVrGR4TQ1EajvXa247ZDU=; b=owGbwMvMwCRo6H6F97bub03G02pJDCkTX1aZuMV9Uo01aZ9zpf7GpkNn1hzxWFobOfWfZH5jQ NSR0rWpHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRaBaG+bnKJ2VNc/cumjQl +2+I3YePdV8fT2JYcEh+u2jVrB7NfE/9AzG1PW7xTmbbAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 From: Ivan Orlov Now that the driver core allows for struct class to be in read-only memory, move the bsg_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: FUJITA Tomonori Cc: Jens Axboe Cc: linux-scsi@vger.kernel.org Cc: linux-block@vger.kernel.org Suggested-by: Greg Kroah-Hartman Signed-off-by: Ivan Orlov Signed-off-by: Greg Kroah-Hartman --- block/bsg.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/block/bsg.c b/block/bsg.c index 7eca43f33d7f..e04fb075d604 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -39,7 +39,7 @@ static inline struct bsg_device *to_bsg_device(struct inode *inode) #define BSG_MAX_DEVS 32768 static DEFINE_IDA(bsg_minor_ida); -static struct class *bsg_class; +static const struct class bsg_class; static int bsg_major; static unsigned int bsg_timeout(struct bsg_device *bd, struct sg_io_v4 *hdr) @@ -206,7 +206,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, return ERR_PTR(ret); } bd->device.devt = MKDEV(bsg_major, ret); - bd->device.class = bsg_class; + bd->device.class = &bsg_class; bd->device.parent = parent; bd->device.release = bsg_device_release; dev_set_name(&bd->device, "%s", name); @@ -240,15 +240,19 @@ static char *bsg_devnode(const struct device *dev, umode_t *mode) return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev)); } +static const struct class bsg_class = { + .name = "bsg", + .devnode = bsg_devnode, +}; + static int __init bsg_init(void) { dev_t devid; int ret; - bsg_class = class_create("bsg"); - if (IS_ERR(bsg_class)) - return PTR_ERR(bsg_class); - bsg_class->devnode = bsg_devnode; + ret = class_register(&bsg_class); + if (ret) + return ret; ret = alloc_chrdev_region(&devid, 0, BSG_MAX_DEVS, "bsg"); if (ret) @@ -260,7 +264,7 @@ static int __init bsg_init(void) return 0; destroy_bsg_class: - class_destroy(bsg_class); + class_unregister(&bsg_class); return ret; } -- 2.41.0