Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1231035lqe; Mon, 8 Apr 2024 02:47:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9xePEfA+UxLJucDEgWnh/vVyBKUVYWUKWJnVMWvpHcRyS5QiJnP5Q6HSkCh0gRGaUGqwpt0Fxn5aRPhbHMFgm3c7gXo2LVZTWIeZQdA== X-Google-Smtp-Source: AGHT+IHODHs5dQEnWRdlE3Z5OlBttwalLmqoc0NtUTRlZpVrV8kfsh2c2HPi/NEKi4wrdW6E1qXu X-Received: by 2002:a05:6359:4295:b0:186:2ac7:316c with SMTP id kp21-20020a056359429500b001862ac7316cmr1341959rwb.20.1712569677399; Mon, 08 Apr 2024 02:47:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712569677; cv=pass; d=google.com; s=arc-20160816; b=zgWzA+8qv9FyXgeKfd4u98Ry2/mTELKLVhpKvLwM2/nsCP3IOqmHb1J7X40s/iGXMV MvCo2zAiEFhxJ0Q+B4dt5sN24dgOb8TDV1hk4uZWLbwKeJJJnfPft6QOU5X1E1iwdtzL d7kkYJ95PviBBidAVDde/gdNQsGuStRZqJERu2DCXK8j4i0URh+QTpYE2OqhJjci8jnW kI8QZlrRGKhE6kx5DrbJGhYuZvS7eWXU7kkLaridbqy6nyj54yPXZpJqN0R5ZUPbUuHu OhkUp+jk14YCqD14X12T28EIxShXMnXdPqJx96yqcVDB1tT9qsiE6yjMkdKvT17+bgKi owug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=kMu0qywOf6N+bMTkQig0P3MtzCX/DPq2/hkZzawKvUQ=; fh=Wkmc5VrIdMRuGmiTpaGnPIT0gfQqVqcXR217+J+xQBM=; b=FEZ5LcBOEX+WTdAd98pa3HYGrXDX2d0jNOM2etGK5vPIsBCfDj1CpHpSO1oJcH7Y8C 8qSYNEcbRwFL0xW31EdkIsOLl+EZ+7TcPEDzf0M9VAWY7wQPO4taUtJi18O069cRcC+0 MehCz5K/k5h7KtQN5cjJasM4Cvot6+4bq3WUsUqhkayteuvs3HR8QPds8Uzw1DZP6byR nPgNB7U+gsonM5wV3btToXb9wTWQbBWhBWEGGrfenzogNm3SQLYzNp9HXQ22/DCA9b/n PnK+01e2H9cvm9nTupsIetTt1phwxg6BF5bpN7n7/F5V29g9oGPlpSQPxHYgLRocge64 gEAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-135177-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d4-20020a63f244000000b005e46e6ba6cdsi6039954pgk.391.2024.04.08.02.47.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 02:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135177-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-135177-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 056A2284262 for ; Mon, 8 Apr 2024 09:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 778BE4D10A; Mon, 8 Apr 2024 09:47:46 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6CDBFBF3; Mon, 8 Apr 2024 09:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712569665; cv=none; b=XF4K0ub4MEZlmxN28Oth/JosD355/EX9evX+wwlZWutdZiea4tPFcruvD/N3o8XYB5sQ7k3P9sJ0iYH4vSbUh+UIgYQsfhvqiBTxKP3okP3XZ6dPi44VGcr8LyBv0gZH4QmD8iPr4UiwJ2HmR8ceM8qsSnWKUfkE+rqwIwtwDDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712569665; c=relaxed/simple; bh=97P4hwOBL8anWqyksdeGLp7M7kyP6hFX6f9Mnke7txQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=O4tksS2DUy5itqhvLbh6DCDDBVwiODB0oOBBjf2PSIfIoqKliqQ/qSqDMStAAUrozVvGIlwcKcJACI5lrJ5L4aC9aSqVByw6EGT49DdvBb0JTUzaSYt6AUHtP9KIAKJ4jOwRFVZ3ZOFu1sCHViN95YTeYd3rHz+PlH2giln4x6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55A9FC433C7; Mon, 8 Apr 2024 09:47:44 +0000 (UTC) Message-ID: Date: Mon, 8 Apr 2024 11:47:42 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] media: dvbdev: make dvb_class constant Content-Language: en-US, nl To: "Ricardo B. Marliere" , Mauro Carvalho Chehab , Sean Young Cc: Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240305-class_cleanup-media-v1-0-53e1538973cd@marliere.net> <20240305-class_cleanup-media-v1-1-53e1538973cd@marliere.net> From: Hans Verkuil Autocrypt: addr=hverkuil@xs4all.nl; keydata= xsFNBFQ84W0BEAC7EF1iL4s3tY8cRTVkJT/297h0Hz0ypA+ByVM4CdU9sN6ua/YoFlr9k0K4 BFUlg7JzJoUuRbKxkYb8mmqOe722j7N3HO8+ofnio5cAP5W0WwDpM0kM84BeHU0aPSTsWiGR yw55SOK2JBSq7hueotWLfJLobMWhQii0Zd83hGT9SIt9uHaHjgwmtTH7MSTIiaY6N14nw2Ud C6Uykc1va0Wqqc2ov5ihgk/2k2SKa02ookQI3e79laOrbZl5BOXNKR9LguuOZdX4XYR3Zi6/ BsJ7pVCK9xkiVf8svlEl94IHb+sa1KrlgGv3fn5xgzDw8Z222TfFceDL/2EzUyTdWc4GaPMC E/c1B4UOle6ZHg02+I8tZicjzj5+yffv1lB5A1btG+AmoZrgf0X2O1B96fqgHx8w9PIpVERN YsmkfxvhfP3MO3oHh8UY1OLKdlKamMneCLk2up1Zlli347KMjHAVjBAiy8qOguKF9k7HOjif JCLYTkggrRiEiE1xg4tblBNj8WGyKH+u/hwwwBqCd/Px2HvhAsJQ7DwuuB3vBAp845BJYUU3 06kRihFqbO0vEt4QmcQDcbWINeZ2zX5TK7QQ91ldHdqJn6MhXulPKcM8tCkdD8YNXXKyKqNl UVqXnarz8m2JCbHgjEkUlAJCNd6m3pfESLZwSW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IIQn1TOkuXrciTVfZY1cZD0aVxwlxXBnUNZZNslldvXFtndxR0SFat sflovhDxKyhFwXOP0Rv8H378/+14TaykknRBIKEc0+lcr+EMOSUR5eg4aURb8Gc3Uc7fgQ6q UssTXzHPyj1hAyDpfu8DzAwlh4kKFTodxSsKAjI45SLjadSc94/5Gy8645Y1KgBzBPTH7Q== In-Reply-To: <20240305-class_cleanup-media-v1-1-53e1538973cd@marliere.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 05/03/2024 14:26, Ricardo B. Marliere wrote: > Since commit 43a7206b0963 ("driver core: class: make class_register() take > a const *"), the driver core allows for struct class to be in read-only > memory, so move the dvb_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: Greg Kroah-Hartman > Suggested-by: Greg Kroah-Hartman > Signed-off-by: Ricardo B. Marliere > --- > drivers/media/dvb-core/dvbdev.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c > index 733d0bc4b4cc..dcbf68b00240 100644 > --- a/drivers/media/dvb-core/dvbdev.c > +++ b/drivers/media/dvb-core/dvbdev.c > @@ -78,7 +78,13 @@ static const u8 minor_type[] = { > #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS * 64) > #endif > > -static struct class *dvb_class; > +static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env); > +static char *dvb_devnode(const struct device *dev, umode_t *mode); Forward references are typically something you want to avoid. Looking at the code, I think it makes sense to just move those two functions to just before this dvb_class. > +static const struct class dvb_class = { > + .name = "dvb", > + .dev_uevent = dvb_uevent, > + .devnode = dvb_devnode, > +}; > > static struct dvb_device *dvb_minors[MAX_DVB_MINORS]; > static DECLARE_RWSEM(minor_rwsem); Also move the dvb_class (+ the two functions) to after this line. I think that's a more suitable place for this. > @@ -561,7 +567,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, > return ret; > } > > - clsdev = device_create(dvb_class, adap->device, > + clsdev = device_create(&dvb_class, adap->device, > MKDEV(DVB_MAJOR, minor), > dvbdev, "dvb%d.%s%d", adap->num, dnames[type], id); > if (IS_ERR(clsdev)) { > @@ -600,7 +606,7 @@ void dvb_remove_device(struct dvb_device *dvbdev) > > dvb_media_device_free(dvbdev); > > - device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); > + device_destroy(&dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); > > list_del(&dvbdev->list_head); > } > @@ -1096,13 +1102,10 @@ static int __init init_dvbdev(void) > goto error; > } > > - dvb_class = class_create("dvb"); > - if (IS_ERR(dvb_class)) { > - retval = PTR_ERR(dvb_class); > + retval = class_register(&dvb_class); > + if (retval != 0) This can just be 'if (retval)'. > goto error; > - } > - dvb_class->dev_uevent = dvb_uevent; > - dvb_class->devnode = dvb_devnode; > + > return 0; > > error: > @@ -1115,7 +1118,7 @@ static void __exit exit_dvbdev(void) > { > struct dvbdevfops_node *node, *next; > > - class_destroy(dvb_class); > + class_unregister(&dvb_class); > cdev_del(&dvb_device_cdev); > unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); > > Regards, Hans