From patchwork Thu Oct 5 13:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 148786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp354601vqb; Thu, 5 Oct 2023 07:57:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPWZgOeuzJC3pTFnSddm/aQi6xkvGkOKUxMFyojJxBQGt9I+Ac6cgpVT4oNyihqALa4JfP X-Received: by 2002:a05:6a20:12cb:b0:136:faec:a7dc with SMTP id v11-20020a056a2012cb00b00136faeca7dcmr6632164pzg.11.1696517859218; Thu, 05 Oct 2023 07:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517859; cv=none; d=google.com; s=arc-20160816; b=Ce/lsKYuFQd/X7os951IYtIBPPV2JqfEz7TXlBrxaZCUKcQe0dI7wk+VKibBweUSSH 6HvTzxKR8l+t+gP4tOkhYzunDUubcHLzVJI/F2b3Rhq/BAxWAXCfAiBl0+/qX/N7jbQc SaqSwQ/oix3MxO76bz+nH/jS/cjxNvllbzeXdkUTp+Qx88V4VAK+vNLeGu9XH62lG2gG Ce9mP6D29Ikr3e7p9K37eW+G9NoFrEa9ErOE1EWPFviAYPQt7szI3z0gheUnURdFV1wK OGdoE/ouXlygcOJpkbSCxzlRi9eJTIp9cESlQM7BcevyxFZSwc5i8YAMcIoR2VxSOj+D iPjQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5T2VJxkx0zu6+A6DKe2uNRtMY20r2ziNamWIHV5mXgA=; fh=VMSb39Wx1sS7GGXngfRAlD94ndSef23EVKPtqLdbQUY=; b=XBvDuGFeCfFO2Vbcy20r9xa78hJAB5zPsR5SH4k9E0V6c0SQaPYa0VDWdoyAFajVuf 3A+Zi2YLPIPk1Gdw0XRIOip7o5hYRFbi0+uo4qf8voC9nSOpw1rCAJO/gJ2Y0P/1ejjC aQeNZvZIB+K5GVRufsmjE6cUKggZY5vZ8POkwud9s3cMsGvKgh+uKR4PwNz+/lRpKUY6 TTHqjEi7weIAfS/5NAy9BJw819p6YZp690ZfL/WsxgSV81aoLecy/29M7qv9HfSFphyS a7qPnR9V7vAHRM5YRQ7Y/qemSehPutdYCAEcBvrfCgxxl9rlat5bKrysfNlen17TovN3 cJQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ptJJPyqo; 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 kv7-20020a17090328c700b001b8c4168e20si1603866plb.58.2023.10.05.07.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:57:39 -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=ptJJPyqo; 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 5968382F08F6; Thu, 5 Oct 2023 07:57:38 -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 S237489AbjJEOjU (ORCPT + 18 others); Thu, 5 Oct 2023 10:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236116AbjJEOgk (ORCPT ); Thu, 5 Oct 2023 10:36:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF52336A9 for ; Thu, 5 Oct 2023 06:59:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F81C43140; Thu, 5 Oct 2023 13:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696514323; bh=DBqd7AkU7DoctJZB0I+61/B9KY1iQe4pE42vmDX0AyY=; h=From:To:Cc:Subject:Date:From; b=ptJJPyqoL9jyG92VOx03xz1lMgofmxd2qO7NZ8CcbYm5yNHCMf8nWXbX/MjZZ1/p0 7dYNC3pAj83a8hqUQHTLGOLoB+ip6enJbnbZM79ZLo1YtvXMZm2jG5NBCQ1qJfejBe F7TPvYBuxM+c6NXSTgjSJ1oJnleIeZ4gWTTe+nTM= 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 1/3] staging: greybus: raw: make raw_class constant Date: Thu, 5 Oct 2023 15:58:34 +0200 Message-ID: <2023100533-broadband-hunk-9e91@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 81 X-Developer-Signature: v=1; a=openpgp-sha256; l=2583; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=DBqd7AkU7DoctJZB0I+61/B9KY1iQe4pE42vmDX0AyY=; b=owGbwMvMwCRo6H6F97bub03G02pJDKlyBzlZa/er/6s6eWmpSMDJU2W7Z85/pXy59zTHbqslV bfNsqU9O2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiNswM87Ofh/TaBruIr7LQ 6cre27FAw1iyimF+Wvd11YCnUT+1bhxWe2Ouuybf7cl+AA== 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 07:57:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778927910415737965 X-GMAIL-MSGID: 1778927910415737965 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/raw.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c index 8bca8cb12cc6..a00978c8e1d2 100644 --- a/drivers/staging/greybus/raw.c +++ b/drivers/staging/greybus/raw.c @@ -32,7 +32,10 @@ struct raw_data { u8 data[]; }; -static struct class *raw_class; +static const struct class raw_class = { + .name = "gb_raw", +}; + static int raw_major; static const struct file_operations raw_fops; static DEFINE_IDA(minors); @@ -195,7 +198,7 @@ static int gb_raw_probe(struct gb_bundle *bundle, if (retval) goto error_connection_disable; - raw->device = device_create(raw_class, &connection->bundle->dev, + raw->device = device_create(&raw_class, &connection->bundle->dev, raw->dev, raw, "gb!raw%d", minor); if (IS_ERR(raw->device)) { retval = PTR_ERR(raw->device); @@ -229,7 +232,7 @@ static void gb_raw_disconnect(struct gb_bundle *bundle) struct raw_data *temp; // FIXME - handle removing a connection when the char device node is open. - device_destroy(raw_class, raw->dev); + device_destroy(&raw_class, raw->dev); cdev_del(&raw->cdev); gb_connection_disable(connection); ida_simple_remove(&minors, MINOR(raw->dev)); @@ -340,11 +343,9 @@ static int raw_init(void) dev_t dev; int retval; - raw_class = class_create("gb_raw"); - if (IS_ERR(raw_class)) { - retval = PTR_ERR(raw_class); + retval = class_register(&raw_class); + if (retval) goto error_class; - } retval = alloc_chrdev_region(&dev, 0, NUM_MINORS, "gb_raw"); if (retval < 0) @@ -361,7 +362,7 @@ static int raw_init(void) error_gb: unregister_chrdev_region(dev, NUM_MINORS); error_chrdev: - class_destroy(raw_class); + class_unregister(&raw_class); error_class: return retval; } @@ -371,7 +372,7 @@ static void __exit raw_exit(void) { greybus_deregister(&gb_raw_driver); unregister_chrdev_region(MKDEV(raw_major, 0), NUM_MINORS); - class_destroy(raw_class); + class_unregister(&raw_class); ida_destroy(&minors); } module_exit(raw_exit);