Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp334197lqs; Tue, 5 Mar 2024 03:37:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWB72H6HOcxXhjtoVSvk/yECcD9pEp8i6+RqDQA33ldsdTs3Pyz2l5tFDzliNcLmJODhusQFOs27bfOWQ3P1e4jTAXoWo8JECOv0/ZO1Q== X-Google-Smtp-Source: AGHT+IHHBBfftv/LvZbFIuPpe63u4y9mUrzFQr9NhEn917bo2etp/hI3N7wZ1TMX78ahkEK+874p X-Received: by 2002:a17:906:48f:b0:a45:84e2:bde5 with SMTP id f15-20020a170906048f00b00a4584e2bde5mr2358982eja.3.1709638631051; Tue, 05 Mar 2024 03:37:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709638631; cv=pass; d=google.com; s=arc-20160816; b=zjNz0Yl8GQ+3vghtRmQitS61757kfwZHvgQk0p6NlZKdQVX8Z0dD6/KPNgsWOBKWh1 kIQSqRPU0jyjQvqq7i9bSz6HuxMaxaOufkcMUdBSS0a6PAPnzOO7noXqokXLU/Tj09is 82RgA6XTdRazfx4/2784R6b8xjnNrq86GmXmBJCYn4gzugEdgiYwT3n4YeKmYcNxcDP6 VE7eLQC/0OARtL3Cee7+JGpoPzLV7DUWawiSLnJMrUzeVozoqFpqO3I6UBzq/0MdMrOU nmlS2snti1LTghjbqmPTp8Wiao8X6fxlOH+ormlE130nZb+rgbkNMNRs1c4scLnDLXEG UGVw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:dkim-signature:from; bh=DrnOmqUduKVY9054SARMGgmju4czNVg1PR7unBKC3kc=; fh=Bq/OYmqxgvvb/fF/bj4g8doOEOFdBVI7L41cBvs4j04=; b=rAGhixnG2dQ1hslAMjeuQIETFq+S0QhYClxubfc3je8t1Qxb/WSRnW47pkNVa/jnlU F0C2j+J8xmRQDzvzoEL7Olld6VZ0voVOlx+8otf+zyp+aJX870R7Ah2/cqWGyhENXsLv /PVsEWYrhrLmilxU5JE2M7Owi7ESEi+5BonjqUuciuiI7Si7MXXqv60DRVkWJRTETnhp l+qrAFT6INH34JjTcc3nNYOcThueTOfqkGF/z/XDEMDaHZaaJHXwjLXs07sfY3dMdmXp 9RhixlqtXHAQqucwJ6t8LrdQWYONvMlwWLHUAY/cuC8Ua7xZT1hcl0RpO/HA2vr1RAP8 ie/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marliere.net header.s=2024 header.b="YTaQZ8h/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=marliere.net dmarc=pass fromdomain=marliere.net); spf=pass (google.com: domain of linux-kernel+bounces-92262-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=marliere.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x8-20020a170906710800b00a4451887e60si4652039ejj.1029.2024.03.05.03.37.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92262-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@marliere.net header.s=2024 header.b="YTaQZ8h/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=marliere.net dmarc=pass fromdomain=marliere.net); spf=pass (google.com: domain of linux-kernel+bounces-92262-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=marliere.net 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 am.mirrors.kernel.org (Postfix) with ESMTPS id BE82A1F281C7 for ; Tue, 5 Mar 2024 11:28:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4B655B67A; Tue, 5 Mar 2024 11:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="YTaQZ8h/" Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0026B56758; Tue, 5 Mar 2024 11:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709637935; cv=none; b=lBt6S1cs+FrTrsnZD8EFcTSTSRtNJvVoPXwR2PFdTktj6iVBXNJQNY8RQoPak0gR2ivN/myLz+PopxPTazow9UfK4T3zz31jkz5x/Bbq7NR99lxhqhcnRkmVked3NG86cx8Z55cuEiLsEf7Z/H8TKCgNj89Y7d+C8Iw7KFSqiiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709637935; c=relaxed/simple; bh=WGIFWYFh3hQ9VXnIJFPQZwA2uJuy2dcs4lEb7YsAaFs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lWL5zXUIIw/RCP1oWOcA/0QUg32fgfWeTZTOQVCG+cTPTREJfB7KuYIWxHQGIYQTHD5WSivgvQzho9I9Nntq/Isjo/vgIrmNimpHlq+WLfAOhP+u3SAfNSjO8kqIxYT5lscgFeb7a78FBDowg2rhs1ofIuqlt8x6L7okrjvxXsw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b=YTaQZ8h/; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=marliere.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e5eb3dd2f8so2032203b3a.2; Tue, 05 Mar 2024 03:25:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709637933; x=1710242733; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:dkim-signature:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DrnOmqUduKVY9054SARMGgmju4czNVg1PR7unBKC3kc=; b=Ob8gJ5jlMw0+vNnAgvfkAOngZ65ChFVajuyNM3MeugsRJj7xvhhTDXMVGBn8LbZ9D7 3+pkj5orhJ+XWSTqtw+wDpl5wsK9mdhJRAS4qWgQA6sz6/dMzeI3GyBGJMW0QfuIBNTw njNS7BdP0vq/bJAJkeDZIvRjMuZ2xjWVACuLRgZkY4VTB4tbJqf6RNtOoHUDQAl3WJXU 4b4NoCEoEDLA+3C/0OCqHlprGKICDK5zPWmb4a+aIvVwtnmneVHqXZQufUvHdmdF2w/1 nwhstYAyQJRKfb1tChckZjaUPACkWmJLAtvRGhavlXHJln9YFNknudLmjTilBMraU6Xo qG1g== X-Forwarded-Encrypted: i=1; AJvYcCUjas7whmzOqiw2x9Px5JXWZCuMkrTkGGOq6sEs9p+F0Yub/WiT155R5YoUQyVF41QNmELrV+JfFdckwAEPqXi9tl689IJP2GWSWFe0 X-Gm-Message-State: AOJu0YzEpskQQYHkdTrvXvGL7fBEfJSKwfYcvrju5DZyNEzE2wHVbftJ KstgLBqbqDNtUXXFoBn1BwS04d8XnWtA28KJ7VSWDAhYlRuhLnS9hM3QRo4cCLAO3Q== X-Received: by 2002:aa7:88c1:0:b0:6e5:5425:d914 with SMTP id k1-20020aa788c1000000b006e55425d914mr12434691pff.2.1709637933258; Tue, 05 Mar 2024 03:25:33 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id i37-20020a631325000000b005dc36761ad1sm8200256pgl.33.2024.03.05.03.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:25:32 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709637931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrnOmqUduKVY9054SARMGgmju4czNVg1PR7unBKC3kc=; b=YTaQZ8h/Vb/fXGX8im75NlizIO9ffQMZtKZjnokc8kyip/LVx8veYTs1MaW89ALt8V8sEp zx0Xe2Y4fcT8QumoUa3FprwVeP87a+PQPjafBap+us+ZvsYosTaQbKdUJxC7N6Zm5AQZ77 Y8YiL25d1SmM4cBEUOSv7nHFAAJqB/ScDH/2rKcf3ad4otLBBYPr7FAYB+0YjyzHWxTNSr JctXmTCWEIYVs3icGC0H4sXYuWXPdeKtNiGPMbcGpmmO0/UNNTVjrWGTS4qSsfVrlu0e2d wdvaUuT82yjp+Vhl3h+KKd+XySb6Az90DMT/KTcRxe/3/NJY5A0GXErTwoPH2A== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Tue, 05 Mar 2024 08:25:19 -0300 Subject: [PATCH 1/6] s390: zcrypt: make zcrypt_class constant Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240305-class_cleanup-s390-v1-1-c4ff1ec49ffd@marliere.net> References: <20240305-class_cleanup-s390-v1-0-c4ff1ec49ffd@marliere.net> In-Reply-To: <20240305-class_cleanup-s390-v1-0-c4ff1ec49ffd@marliere.net> To: Harald Freudenberger , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, "Ricardo B. Marliere" , Greg Kroah-Hartman X-Developer-Signature: v=1; a=openpgp-sha256; l=4118; i=ricardo@marliere.net; h=from:subject:message-id; bh=WGIFWYFh3hQ9VXnIJFPQZwA2uJuy2dcs4lEb7YsAaFs=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl5wEgURe+g1tpepus6BzVvP0vk980i/IPWroJI /59/F/MGSeJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZecBIAAKCRDJC4p8Y4ZY pogPEACmO8SwFAnU9wgtOI41rvLzi7JyoS05P4lm/jj4lLxAXflnBrnaP8JNAxjMlk0RXAZfm5C vOP/xbV/3LPfLKsB3OKbToIBBtsGPHkpKJPUROzM0YnwZl0fGWjox+y2SqBg8VjKlnTMtEw6tsy A0/Gx6ZtWQgO9Q6v0dC2Jsx+Aq/dxhpXZ3oiACwCHZxAxDl8MwgL8RDIoUjEty+vkEDmteadAZR KflNPnXrhAWy4RobwDHBAqjOXRlzjUNCJi/Fnpt31FcO7N8ffoIR7NyU2/3S5OyaRnDnvjpePHH wZNTqZKe9/SW5pgRF/VRl0v3SZv/yZiOSmwxU65ZD9RUMEfGmuT1Q1LGYLzS26kwbMvkj3hcsqh 4ndSJIGFAceQewVfCd/X14p5lKmgXVqAwd6x+jh2qrrgFUrJ8EkmM74YrBNz2oIU975U47xs1Gx rWjLPcTf165B7R4tyxz6zllhGseEPStyo/egzD59BN8SVzQtdieAN2B7L24niXmWGYVt6nLZBO1 RHQooqtjYrVs83DQv5GNRAzMia6UcaCBkWtLBWARj0bN63esCldbtSQi1nTcMvYjZ4c4CjpXbZ6 Sydfhv8zFnoTW91a4Ab6c8DSIswcR1stpmwUAutB4EHPjPC5k6/OBcxHQ5YMV/K/zSRfTS90/Fc jSWA0BeBaz4/TUQ== X-Developer-Key: i=ricardo@marliere.net; a=openpgp; fpr=030A8E9E424EE3C0655787E1C90B8A7C638658A6 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 zcrypt_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/s390/crypto/zcrypt_api.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index e8742757085b..d0358bb6ccf2 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -116,7 +116,11 @@ EXPORT_SYMBOL(zcrypt_msgtype); struct zcdn_device; -static struct class *zcrypt_class; +static void zcdn_device_release(struct device *dev); +static const struct class zcrypt_class = { + .name = ZCRYPT_NAME, + .dev_release = zcdn_device_release, +}; static dev_t zcrypt_devt; static struct cdev zcrypt_cdev; @@ -139,7 +143,7 @@ static int zcdn_destroy(const char *name); */ static inline struct zcdn_device *find_zcdndev_by_name(const char *name) { - struct device *dev = class_find_device_by_name(zcrypt_class, name); + struct device *dev = class_find_device_by_name(&zcrypt_class, name); return dev ? to_zcdn_dev(dev) : NULL; } @@ -151,7 +155,7 @@ static inline struct zcdn_device *find_zcdndev_by_name(const char *name) */ static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt) { - struct device *dev = class_find_device_by_devt(zcrypt_class, devt); + struct device *dev = class_find_device_by_devt(&zcrypt_class, devt); return dev ? to_zcdn_dev(dev) : NULL; } @@ -405,7 +409,7 @@ static int zcdn_create(const char *name) goto unlockout; } zcdndev->device.release = zcdn_device_release; - zcdndev->device.class = zcrypt_class; + zcdndev->device.class = &zcrypt_class; zcdndev->device.devt = devt; zcdndev->device.groups = zcdn_dev_attr_groups; if (name[0]) @@ -2067,12 +2071,9 @@ static int __init zcdn_init(void) int rc; /* create a new class 'zcrypt' */ - zcrypt_class = class_create(ZCRYPT_NAME); - if (IS_ERR(zcrypt_class)) { - rc = PTR_ERR(zcrypt_class); + rc = class_register(&zcrypt_class); + if (rc) goto out_class_create_failed; - } - zcrypt_class->dev_release = zcdn_device_release; /* alloc device minor range */ rc = alloc_chrdev_region(&zcrypt_devt, @@ -2088,35 +2089,35 @@ static int __init zcdn_init(void) goto out_cdev_add_failed; /* need some class specific sysfs attributes */ - rc = class_create_file(zcrypt_class, &class_attr_zcdn_create); + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_create); if (rc) goto out_class_create_file_1_failed; - rc = class_create_file(zcrypt_class, &class_attr_zcdn_destroy); + rc = class_create_file(&zcrypt_class, &class_attr_zcdn_destroy); if (rc) goto out_class_create_file_2_failed; return 0; out_class_create_file_2_failed: - class_remove_file(zcrypt_class, &class_attr_zcdn_create); + class_remove_file(&zcrypt_class, &class_attr_zcdn_create); out_class_create_file_1_failed: cdev_del(&zcrypt_cdev); out_cdev_add_failed: unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES); out_alloc_chrdev_failed: - class_destroy(zcrypt_class); + class_unregister(&zcrypt_class); out_class_create_failed: return rc; } static void zcdn_exit(void) { - class_remove_file(zcrypt_class, &class_attr_zcdn_create); - class_remove_file(zcrypt_class, &class_attr_zcdn_destroy); + class_remove_file(&zcrypt_class, &class_attr_zcdn_create); + class_remove_file(&zcrypt_class, &class_attr_zcdn_destroy); zcdn_destroy_all(); cdev_del(&zcrypt_cdev); unregister_chrdev_region(zcrypt_devt, ZCRYPT_MAX_MINOR_NODES); - class_destroy(zcrypt_class); + class_unregister(&zcrypt_class); } /* -- 2.43.0