From patchwork Thu Oct 5 13:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 148838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp397048vqb; Thu, 5 Oct 2023 09:00:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHV32Mi5HCPL8WDRP4cESNAEEyijP7BA08Cbd/27PNgIjEq6nvmnbV4yEKVciQUbTJ8+1J5 X-Received: by 2002:a05:6a00:3916:b0:693:3f7a:eec2 with SMTP id fh22-20020a056a00391600b006933f7aeec2mr6155789pfb.29.1696521610271; Thu, 05 Oct 2023 09:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521610; cv=none; d=google.com; s=arc-20160816; b=L9acDwONYA1Zj6Yg6oftbR5dlhSRXqsSddGxqInM12RDe3NzqNOrhhK4s39BlNHwQb zGl3wgZo3CAMsq3ONtLuSft/SF+n+hD1L/9U7bAwvCvG767bhBxUHsddmKRnjPsZCNBI 37wcfxCOntaaSTT3E/hTjI96lOnubtcgSuA2XJzOrhRU+pWsxYbP8SnmvpdKgQZYcTYd R3eM1F5sowK5P1YpjuYvFRn8EvoGXgTBcOaAx2GVFI4tdYhPUgTqw4t4JQecdyKuj5cL X2prT6/7EYXJVfEECYtz+J8PtsKrSG73pgUYX+030H7qFMD88dsDRxqeI6DwBenCNjWU NuZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:lines:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VUW8khxDb8Ltpqa3m8tWLG07T4qB2IxCRQlI7YHuMV8=; fh=VMSb39Wx1sS7GGXngfRAlD94ndSef23EVKPtqLdbQUY=; b=SCbUpomanIcNhBK2VcOKUF4dnbXk7FsKA/UZiXJ7MV25e9OGWlwfarPoC33xSVzvVO 3bQhsCtfip821VQRIcYBrtFwk3V6PShu6lWniJJbFTS4IQ2JEK0Zc7nRQltuLD1DcHY8 LD7MzPKxjT8ww+T6Fbe8nVruyOuhcJovsuyau4g7Bu35XAnp+OWkrdH/6qm5yvewOfdI KS4Fh6fjdLqSSFfgDPuqpSTBBbKfzsObjw2mowCdPdGlBL44ak3b0Q21HlQ+75xIcFA8 BMA08Nj/Fkxityd0sf2x56wO8dQR07B/f/DoO9IawMuQ8/SXU2DqTMMTUAbJSjX42zlD 20cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lcCQ8V9L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b005859fd484b5si1629825pgd.406.2023.10.05.09.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lcCQ8V9L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5807282F7FB5; Thu, 5 Oct 2023 09:00:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239137AbjJEP70 (ORCPT + 19 others); Thu, 5 Oct 2023 11:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234750AbjJEP46 (ORCPT ); Thu, 5 Oct 2023 11:56:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD9BB291 for ; Thu, 5 Oct 2023 06:59:50 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAB82C116A4; Thu, 5 Oct 2023 13:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696514328; bh=AiYYMA+NHBeWDMz0RJeTj9dCfxc0pBpMecEskqVefGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcCQ8V9LlcSBGrW0NZctP7uRITYQmNVj6qin6uL/yCqmpr4oliqpI5HmUEK+9YF/x J/TP6/3T+4qjBRTj+atu15R+CjHISSwUsjcUUPNBnb8U9FQQVTodnwYUWAX51Wf4YP VtTPy+Vhhh8Bc4Eww4qNELhXKiuN3DY8cBtHYI4I= From: Greg Kroah-Hartman To: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Johan Hovold , Alex Elder Subject: [PATCH 3/3] staging: greybus: fw-management: make fw_mgmt_class constant Date: Thu, 5 Oct 2023 15:58:36 +0200 Message-ID: <2023100534-catty-moodiness-099e@gregkh> X-Mailer: git-send-email 2.42.0 In-Reply-To: <2023100533-broadband-hunk-9e91@gregkh> References: <2023100533-broadband-hunk-9e91@gregkh> MIME-Version: 1.0 Lines: 78 X-Developer-Signature: v=1; a=openpgp-sha256; l=2579; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=AiYYMA+NHBeWDMz0RJeTj9dCfxc0pBpMecEskqVefGY=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlyB7l4gji/rr/28Y2vzu/Z3eHcPA2MupufTGAymJ8U+ P3k+0S2jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIQQvDgo0Xn37b2aF7R1um J+jE5m1cFmVX7jDM09tcn/jyyuPL97RfHCz9mxp/+N9+RQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 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,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:00:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778931844385557096 X-GMAIL-MSGID: 1778931844385557096 Now that the driver core allows for struct class to be in read-only memory, making all 'class' structures to be declared at build time placing them into read-only memory, instead of having to be dynamically allocated at load time. Cc: Johan Hovold Cc: Alex Elder Cc: greybus-dev@lists.linaro.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Johan Hovold --- drivers/staging/greybus/fw-management.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c index cd9141e4b794..93137a3c4907 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -55,7 +55,10 @@ struct fw_mgmt { */ #define NUM_MINORS U8_MAX -static struct class *fw_mgmt_class; +static const struct class fw_mgmt_class = { + .name = "gb_fw_mgmt", +}; + static dev_t fw_mgmt_dev_num; static DEFINE_IDA(fw_mgmt_minors_map); static LIST_HEAD(fw_mgmt_list); @@ -629,7 +632,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection) goto err_remove_ida; /* Add a soft link to the previously added char-dev within the bundle */ - fw_mgmt->class_device = device_create(fw_mgmt_class, fw_mgmt->parent, + fw_mgmt->class_device = device_create(&fw_mgmt_class, fw_mgmt->parent, fw_mgmt->dev_num, NULL, "gb-fw-mgmt-%d", minor); if (IS_ERR(fw_mgmt->class_device)) { @@ -664,7 +667,7 @@ void gb_fw_mgmt_connection_exit(struct gb_connection *connection) fw_mgmt = gb_connection_get_data(connection); - device_destroy(fw_mgmt_class, fw_mgmt->dev_num); + device_destroy(&fw_mgmt_class, fw_mgmt->dev_num); cdev_del(&fw_mgmt->cdev); ida_simple_remove(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num)); @@ -696,9 +699,9 @@ int fw_mgmt_init(void) { int ret; - fw_mgmt_class = class_create("gb_fw_mgmt"); - if (IS_ERR(fw_mgmt_class)) - return PTR_ERR(fw_mgmt_class); + ret = class_register(&fw_mgmt_class); + if (ret) + return ret; ret = alloc_chrdev_region(&fw_mgmt_dev_num, 0, NUM_MINORS, "gb_fw_mgmt"); @@ -708,13 +711,13 @@ int fw_mgmt_init(void) return 0; err_remove_class: - class_destroy(fw_mgmt_class); + class_unregister(&fw_mgmt_class); return ret; } void fw_mgmt_exit(void) { unregister_chrdev_region(fw_mgmt_dev_num, NUM_MINORS); - class_destroy(fw_mgmt_class); + class_unregister(&fw_mgmt_class); ida_destroy(&fw_mgmt_minors_map); }