Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1217055rdg; Fri, 11 Aug 2023 13:50:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHETgiyIahS8KGSsmJhul9cVZXFgHrEFknx5Quv0HT5PzYtEAniPyg6amhv5IqG86+ho07p X-Received: by 2002:aa7:d445:0:b0:524:9564:4ff1 with SMTP id q5-20020aa7d445000000b0052495644ff1mr915687edr.7.1691787008356; Fri, 11 Aug 2023 13:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691787008; cv=none; d=google.com; s=arc-20160816; b=I8COSvq1wb8WX8SPD6VAgQJt9DO5snTxPwwkRvsoPXeMrmTZjYTM1i319IU0kGHjvI aBlFIMSLS69fj84i5zAUCndfxhb3UceQuWsft5VuFD3CpqZIye34tEq9RndH+vrxQrAE 1jPYuLztxFc5jxjI0a9balG8/Huy7GGke7GCmwdwFeWuXaJmrrgfC+UwsO8QIIYjslEx /NoCtVroQqvMjfNL2xB8melEaR7RW8P/X5OyTcgUQHdKJDSySm8yTJcISpfSFHFJrucQ 5oW1V/Io4YPNZg+Hml5dXUpk18SfvN+IWxeP1ymV9Ng94ROpyVDANMeT39QaPIrBzypd OPzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZltoKjQjRno7TdOJ9HnSY4q66ka1zzjtK5y7xKhN97Y=; fh=VF6KpZgFQOT2pYmYGJnMeiF2OsZKzjtZkJexEhnGsLk=; b=PezIdKnF0howMXBHxyGJalmeZ3be5dLG9q/Pe0bvYPX7NlXqYrhAOGU2YiiGsdo/1i +HSBY/0JXvwwGkw2tPUblWWqBD9ca3TlF/cJkvQDi/AgPrE+7OkFHr65OnrBg2yuA25N ltxMGLmt29ykWDZSlNCA/qkNpGwxEwCzoeipp9ddYmQPcG+g7WWRDXt9Pqnf7W3K/fgb qn7VQ9QYQ5SO+lB+mZWj7nkYdGNnHEiR+oiWR7ZcAtFeyia279R3zJA48liHVF+kdlXU +gklLwupu9wfG49Yckrr0eeFcl13H8yguZmG6e4OH39fRz9LV7GH9pPcbvPZS2z4oAeY D5vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MAD98GDr; 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 x5-20020aa7d385000000b005231f4ead5dsi2308686edq.537.2023.08.11.13.49.44; Fri, 11 Aug 2023 13:50:08 -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=MAD98GDr; 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 S236564AbjHKTkQ (ORCPT + 99 others); Fri, 11 Aug 2023 15:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbjHKTkP (ORCPT ); Fri, 11 Aug 2023 15:40:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2520430E6 for ; Fri, 11 Aug 2023 12:40:15 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B76FB6103F for ; Fri, 11 Aug 2023 19:40:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE4CFC433C7; Fri, 11 Aug 2023 19:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691782814; bh=W/sCTIlzhkPgtcy2Dt4RkaCyTpwyn9jYHCdoz8xGBbA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MAD98GDrATySo70mVck09vWKE7GpPiXNyqXE3ZmGHWTD0sO5upnB0CPu06sXzbBwW 4xmsEybRFtiatRPr7yLs1QHf1ubqGbExAcBHJk3AOyddyAxi0jRTsunHWpe+miXSzg tvgZ+IMTZ2tgXgEIYbIC9iKLFBAZz3qg0rBj3fRg= Date: Fri, 11 Aug 2023 21:40:11 +0200 From: Greg KH To: Ivan Orlov Cc: tomas.winkler@intel.com, arnd@arndb.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mei: make mei_class a static const structure Message-ID: <2023081112-wistful-coping-f775@gregkh> References: <20230810194652.27004-1-ivan.orlov0322@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230810194652.27004-1-ivan.orlov0322@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 On Thu, Aug 10, 2023 at 11:46:52PM +0400, Ivan Orlov wrote: > Now that the driver core allows for struct class to be in read-only > memory, move the mei_class structure to be declared at build time > placing it into read-only memory, instead of having to be dynamically > allocated at boot time. > > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Ivan Orlov > --- > drivers/misc/mei/main.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c > index 51876da3fd65..902789d3106b 100644 > --- a/drivers/misc/mei/main.c > +++ b/drivers/misc/mei/main.c > @@ -27,7 +27,9 @@ > #include "mei_dev.h" > #include "client.h" > > -static struct class *mei_class; > +static const struct class mei_class = { > + .name = "mei", > +}; > static dev_t mei_devt; Extra line after the new structure? > #define MEI_MAX_DEVS MINORMASK > static DEFINE_MUTEX(mei_minor_lock); > @@ -1115,7 +1117,7 @@ void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state) > > dev->dev_state = state; > > - clsdev = class_find_device_by_devt(mei_class, dev->cdev.dev); > + clsdev = class_find_device_by_devt(&mei_class, dev->cdev.dev); > if (clsdev) { > sysfs_notify(&clsdev->kobj, NULL, "dev_state"); > put_device(clsdev); > @@ -1232,7 +1234,7 @@ int mei_register(struct mei_device *dev, struct device *parent) > goto err_dev_add; > } > > - clsdev = device_create_with_groups(mei_class, parent, devno, > + clsdev = device_create_with_groups(&mei_class, parent, devno, > dev, mei_groups, > "mei%d", dev->minor); > > @@ -1264,7 +1266,7 @@ void mei_deregister(struct mei_device *dev) > > mei_dbgfs_deregister(dev); > > - device_destroy(mei_class, devno); > + device_destroy(&mei_class, devno); > > mei_minor_free(dev); > } > @@ -1274,10 +1276,9 @@ static int __init mei_init(void) > { > int ret; > > - mei_class = class_create("mei"); > - if (IS_ERR(mei_class)) { > + ret = class_register(&mei_class); > + if (ret) { > pr_err("couldn't create class\n"); This message doesn't make sense anymore. No need for it either, just remove it and do a simple: return err; here instead. thanks, greg k-h