From patchwork Thu Oct 5 13:58:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 148827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp395760vqb; Thu, 5 Oct 2023 08:58:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtMxyNd5btnCVGsV4tMOSIkrfleC6oGxhXoctyg47KzXNyE6XD1u6EWuiMTTpCVJv0sDWn X-Received: by 2002:a05:6a00:2314:b0:68f:cb69:8e7f with SMTP id h20-20020a056a00231400b0068fcb698e7fmr6557895pfh.7.1696521492617; Thu, 05 Oct 2023 08:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521492; cv=none; d=google.com; s=arc-20160816; b=kVdMtmG4t2PgPtITNPqfIaJSULDKlhmNuFW48iE5KfyCUYSahYypgMTUbgUBBdQNZM 5YFkunVtbxOgR2d5hpsAjGFBh/fo0pZRwOsrMFr450U5w5mV0xFalYJaEunIMuRyhx3r mwBxk/1lm69nDVkLl5HVrNjYxqtb9+oJ+7/ocXQyjgvfG8PctNSioZgDA6b0usV+z+MU 3DADFSFp39iUFKxLyq3Oxm1FMuG+GPkz1nJaFCUoA/6ZhAp7eoz/evgvcHzhtq+pLZsN v3luhJ/OGJno5R9Ub5u9hsnnSkuFTMdXTWr1smQ/ezDnDBXk0s970ZzGp5C6siD/AIAu hd0g== 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=Jt+utU9Y1fhpRrFPF6LkO3dyqk2Wgb+42TZXysnKL50=; fh=VMSb39Wx1sS7GGXngfRAlD94ndSef23EVKPtqLdbQUY=; b=Ag7Xk6ZQprWLuyu+DIX0FH6tjdpFZwlv+UJONL61rZgAczANs2Uopov4DOW2/jWtXh g0GkHE+92nUmpaVBX0dL1WyvkkAdjIhJSTxy2MCyMw+ohD4uRFNQAP7eB49F37rDQ8ry +KhRJG1cqxFyOW+35sxPM7HzPBNkdNmtEDfJyd/E3+03yznhjBXN5HWL+uvVWZ1QF/f3 l66R/FcEg/HQCjuv7iXCmnB0ySA2oBRg3/YQHwx49tLIh1mWREjWIr7rISAiIwm+uYaL WHZOaILfoInyIE8KAAaQ0C/aE3VG7eDrVmMt52rUST3WYpBC8yfb/aMbAVc2gLvG2W2m ejgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V2p1hDhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a62-20020a639041000000b005859e22461csi1650815pge.817.2023.10.05.08.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V2p1hDhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id EAD03869EAF4; Thu, 5 Oct 2023 08:58:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236948AbjJEP5d (ORCPT + 19 others); Thu, 5 Oct 2023 11:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236752AbjJEP4g (ORCPT ); Thu, 5 Oct 2023 11:56:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EACF369F for ; Thu, 5 Oct 2023 06:59:36 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52EEC43142; Thu, 5 Oct 2023 13:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696514320; bh=5pLx0oV6bg6h2ZrtEPu2Hn5oOoMFTmfUpUEMcaBhv+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2p1hDhNf/h8zw4v3DVF9FkdwMg8Zai0AvvpOf6zl6cAvMGLEnG2C3kJ1Pcg4cMh0 CVJoBGxwyXXULQuaiuFNr+sUtJqK7otsLII7covBEu3tWQX9exB8NpY4ytvpsYtevU eSJx+a+hcirGFtWg83gRzJW3vt+blGerh6PCca2o= 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 2/3] staging: greybus: authentication: make cap_class constant Date: Thu, 5 Oct 2023 15:58:35 +0200 Message-ID: <2023100534-showoff-alright-6c95@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=2480; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=5pLx0oV6bg6h2ZrtEPu2Hn5oOoMFTmfUpUEMcaBhv+g=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlyB7n2RddOaQudZy9QdP3BpG3GR5a513/qfyJ7xPTZn /hH+y+c7YhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJsOswLDj9Q1bJ/+TVPYLz o54GWQb1CJRvAYo21XEwR0Ssn8TzJK45Zn4p45FAL1EA 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 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:58:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778931720919513043 X-GMAIL-MSGID: 1778931720919513043 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/authentication.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c index 7e01790a4659..b67315641d18 100644 --- a/drivers/staging/greybus/authentication.c +++ b/drivers/staging/greybus/authentication.c @@ -36,7 +36,10 @@ struct gb_cap { dev_t dev_num; }; -static struct class *cap_class; +static const struct class cap_class = { + .name = "gb_authenticate", +}; + static dev_t cap_dev_num; static DEFINE_IDA(cap_minors_map); static LIST_HEAD(cap_list); @@ -336,7 +339,7 @@ int gb_cap_connection_init(struct gb_connection *connection) goto err_remove_ida; /* Add a soft link to the previously added char-dev within the bundle */ - cap->class_device = device_create(cap_class, cap->parent, cap->dev_num, + cap->class_device = device_create(&cap_class, cap->parent, cap->dev_num, NULL, "gb-authenticate-%d", minor); if (IS_ERR(cap->class_device)) { ret = PTR_ERR(cap->class_device); @@ -370,7 +373,7 @@ void gb_cap_connection_exit(struct gb_connection *connection) cap = gb_connection_get_data(connection); - device_destroy(cap_class, cap->dev_num); + device_destroy(&cap_class, cap->dev_num); cdev_del(&cap->cdev); ida_simple_remove(&cap_minors_map, MINOR(cap->dev_num)); @@ -402,9 +405,9 @@ int cap_init(void) { int ret; - cap_class = class_create("gb_authenticate"); - if (IS_ERR(cap_class)) - return PTR_ERR(cap_class); + ret = class_register(&cap_class); + if (ret) + return ret; ret = alloc_chrdev_region(&cap_dev_num, 0, NUM_MINORS, "gb_authenticate"); @@ -414,13 +417,13 @@ int cap_init(void) return 0; err_remove_class: - class_destroy(cap_class); + class_unregister(&cap_class); return ret; } void cap_exit(void) { unregister_chrdev_region(cap_dev_num, NUM_MINORS); - class_destroy(cap_class); + class_unregister(&cap_class); ida_destroy(&cap_minors_map); }