From patchwork Tue Mar 5 11:34:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13582225 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 E386658208; Tue, 5 Mar 2024 11:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638462; cv=none; b=pWfLScEgCDMyQs+bXBHcggrLfOI7aiQFeg3kJxDytlk6nIXlHu6aJIYnMPfMToezcK5dDKEE1jxBTGfYEzEKjIgSBbGB5ZRnHQKuBAFPRvv+pG8r3T9p/9tSvuTiHhxL7+HdqqrXTzRnkQ7UMa7kVBpzPiekrSmo5lZkDhsL1gI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638462; c=relaxed/simple; bh=fpv0oJ9U8YagK74xk5eqtVNJ2I3xbky4omeorhNvWEo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hpZSy+yBOybvfKeE5VYxlVFz+qsiVm/mr4svigvylmrtUqSQTrI7lczcg9U1i4Fcmkh9R8CTuPtBVuz0tNoZdUOIvIaVHGCBNZ+uSL7cE9oLl4vlhRvyF4/XCAEgpZrTCIOIeVumFqV2C4xGL4KgOYImdEahdQoFDGElZC++j98= 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=j+XUpSrH; arc=none smtp.client-ip=209.85.214.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="j+XUpSrH" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1dc0d11d1b7so45200445ad.2; Tue, 05 Mar 2024 03:34:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709638460; x=1710243260; 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=3HzkmhvWMwRuDdScv54hkeI0UvbzZ4pHSJ+FrUGu5/I=; b=peLeijvVdl6wWkYVlrOwdiwymZT3z/A2rFZZtJuNsJKEr+Drc2HuNqScNeIQuHaV+u p7TnVCK4eLE/r+gP6y+YKY20bF0X5LNymAz0SJtZlhAoBwyd8gOtM2TZPmrNPnzcmy2A ETaTekwzgCMtQq8eWIT+4IDK5dnvC5uyn+QFZnrWy6wEfRcZDHx2yuC9k9OoJAkAjk2M BKadKxGq0oAZWnFlkdSOhK+y6UrTdiC7pqBrwol28LoAtrKhRvHSwUfeyD9V5tV4JkhS M2s+XxzAUNukkXfvESmcLwML+CRSsiF8lD++6W/DXeAPRiScL49JYrPGlvGijF4uVCsW DThQ== X-Forwarded-Encrypted: i=1; AJvYcCW63xHag4zR93zhQjRZQ6PXccpXTIBzxH2e2a4lJO/m3mFNVEAV3WNXT7GsEJTKjmzQJn0I+zZBAxzUu7v/Zmpx3GFhN3N4wZzGOHV/TPISRA7vcdfvBcu2ZmsjiuRr4kL2Mt8w8AtxVTmZT6wptldkLEm9BLDINekU06p82OAz+JkhoDO9LA== X-Gm-Message-State: AOJu0YxdQG3rzgSkwU9KJQYCm/exmOOyFe9hr9+6QccdNiXvufI14sE9 Zym6q8OPHtwufAQhQk0kNAaOlkn8btPQI1kRqOscX8n4pMGHJ/Wq X-Google-Smtp-Source: AGHT+IFTiJmUTFwl87q23IyWlhXuRr/fIfELN2hh99XRxtIMrOfTtlc6yGT90DD2gClkwJviU8MCGg== X-Received: by 2002:a17:902:db02:b0:1dc:d642:aace with SMTP id m2-20020a170902db0200b001dcd642aacemr1934203plx.0.1709638460079; Tue, 05 Mar 2024 03:34:20 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id cp6-20020a170902e78600b001dd2bacf30asm1282755plb.162.2024.03.05.03.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:34:19 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709638458; 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=3HzkmhvWMwRuDdScv54hkeI0UvbzZ4pHSJ+FrUGu5/I=; b=j+XUpSrHky5wTzgY91/qYAlt/Eobb6xpsXkETAUNAQflazQog3Z6gM6eUjxsWP8+1OAJBQ IsjiefgwoZlPnvuY6tOMteS5pwkYa8iDU2t17+vP53hdXq+B7wIOneAI01IM+Ds+S4SmFv VHJf+VLOHCi0NNDTXhgWWH/MqFYSQqpDjlfXq9zJTIxhEDJDqzfxKmpt/Dr5W3MeKv7pE4 DrvXMCHlo2D5BQRBGzEPZeoghyOO814TNr1MS9ICV/TPQ+uJ0zDgqSJWo5rWPWYO8Tjsps rYWVkmZ/7+mH3jIRvUKfvWDW/plNg9wTTRaUXnrR1YmW8F16DGRN0pJa5m5e8g== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Tue, 05 Mar 2024 08:34:10 -0300 Subject: [PATCH RESEND drm-misc 1/4] drm/dp: make drm_dp_aux_dev_class constant Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-class_cleanup-drm-v1-1-94f82740525a@marliere.net> References: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> In-Reply-To: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Hans de Goede , Helge Deller , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=3018; i=ricardo@marliere.net; h=from:subject:message-id; bh=fpv0oJ9U8YagK74xk5eqtVNJ2I3xbky4omeorhNvWEo=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl5wMzRRiMg907Bhn7rGA+MECc/mrwVvpNKldbH JB1VeLskzOJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZecDMwAKCRDJC4p8Y4ZY pvlXEACsfpJwMPU4ihjstqWt7WjHRrjk7T0s+v0WofI6JMO+xEgKiY5q5QAnL47p/YiWh5TpNVL 5X81jJXReN2sLxXFZL+9KZlM+M0dtzAlliyUOJu6qb53BIRZS0GNSc+tw+1P5DDkThI5VlrytgI PPk50hgRgYSrbKWXsANpT0N8+olqGjfwNbwvB4Hkc4XJWTEzBXunz/l1WDZs4GzB+KR88AX0GzR NXhcKcAfe4tyX8ybwg3F3L05PlMl9vPagrqBFKLs4Ua4KSvuBzopWwpAn2gZl3l8FBEKRactEmw nGVsSTHxVJCRPyXGEBxC8wNGhE2HjO5xfaFbF0hhjrKSmXk8oiUBKpqLNzL7QxdfyJaTEbb2ZVO pZvDn3a6XYSxCeBF48Nt8jR4XFyH9mFzL1mOfeAZPgFC4wodaKA+euH/UQj90y0PP8zWrjUETP/ uni7JvVAoxo+Ppj4AiZOrWjq6DQz2PFO9CqX3M2wf24J9t17riKXXLNa9wIC98MDwN0MzeYps6b Xsfsn+uwgsCyHQam83Thn4la2EqGal2ca30xKhZiIvT5lS8g5BND/2Mru5Y3YLxyXUb/JmMO02Z d5LbGtzG+cO0C7dck6HxhKLZhW3gWEmKdlxDoLc9yG9gpdWxuWGalOdXN5G3e49cLtSz+vIdQBG 3AAPTLiufPZHqMw== 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 drm_dp_aux_dev_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/gpu/drm/display/drm_dp_aux_dev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/display/drm_dp_aux_dev.c b/drivers/gpu/drm/display/drm_dp_aux_dev.c index 29555b9f03c8..213abde5b09f 100644 --- a/drivers/gpu/drm/display/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/display/drm_dp_aux_dev.c @@ -54,7 +54,6 @@ struct drm_dp_aux_dev { #define AUX_MAX_OFFSET (1 << 20) static DEFINE_IDR(aux_idr); static DEFINE_MUTEX(aux_idr_mutex); -static struct class *drm_dp_aux_dev_class; static int drm_dev_major = -1; static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_minor(unsigned index) @@ -125,6 +124,11 @@ static struct attribute *drm_dp_aux_attrs[] = { }; ATTRIBUTE_GROUPS(drm_dp_aux); +static const struct class drm_dp_aux_dev_class = { + .name = "drm_dp_aux_dev", + .dev_groups = drm_dp_aux_groups, +}; + static int auxdev_open(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); @@ -293,7 +297,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux) minor = aux_dev->index; if (aux_dev->dev) - device_destroy(drm_dp_aux_dev_class, + device_destroy(&drm_dp_aux_dev_class, MKDEV(drm_dev_major, minor)); DRM_DEBUG("drm_dp_aux_dev: aux [%s] unregistering\n", aux->name); @@ -309,7 +313,7 @@ int drm_dp_aux_register_devnode(struct drm_dp_aux *aux) if (IS_ERR(aux_dev)) return PTR_ERR(aux_dev); - aux_dev->dev = device_create(drm_dp_aux_dev_class, aux->dev, + aux_dev->dev = device_create(&drm_dp_aux_dev_class, aux->dev, MKDEV(drm_dev_major, aux_dev->index), NULL, "drm_dp_aux%d", aux_dev->index); if (IS_ERR(aux_dev->dev)) { @@ -330,11 +334,9 @@ int drm_dp_aux_dev_init(void) { int res; - drm_dp_aux_dev_class = class_create("drm_dp_aux_dev"); - if (IS_ERR(drm_dp_aux_dev_class)) { - return PTR_ERR(drm_dp_aux_dev_class); - } - drm_dp_aux_dev_class->dev_groups = drm_dp_aux_groups; + res = class_register(&drm_dp_aux_dev_class); + if (res) + return res; res = register_chrdev(0, "aux", &auxdev_fops); if (res < 0) @@ -343,12 +345,12 @@ int drm_dp_aux_dev_init(void) return 0; out: - class_destroy(drm_dp_aux_dev_class); + class_unregister(&drm_dp_aux_dev_class); return res; } void drm_dp_aux_dev_exit(void) { unregister_chrdev(drm_dev_major, "aux"); - class_destroy(drm_dp_aux_dev_class); + class_unregister(&drm_dp_aux_dev_class); } From patchwork Tue Mar 5 11:34:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13582226 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 00EB359B54; Tue, 5 Mar 2024 11:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638465; cv=none; b=mYkeTosQAQM1/pzIB19v72AIbXi/51Q8ea69wGk8I2y7kJuk5Zid06yaAB9ZRJCNvDVQPAG00qOYmkn3dYZZZZZFvDArqdWFg4XaCE0M3n2OC/RwJ3uGhcK9eH3pJTFYMS2SIEu4iJB0AhVCZt9+9XPNafoXWoqDUBZzuf7TfpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638465; c=relaxed/simple; bh=TWafS46/cOn388vLX3knlaGbqPHumfrCMMRy3Z1uooE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KvvzZN/le4w6dOdHws2Gu4wdQQWZtUyQFan+sGW/THECf8IOWu3HOL9Es/68g3Ob48qJ2MW2JwFk1uTUQq1tRj+H0Mu3erauX8S+s9rEAdpRnvBhTy2Z16BPKTBz9QULPgvxuWB0fzU93xO2DxJfvbEBztBmFGpBvKMu9Mf5Rxg= 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=XZ4tYvqv; arc=none smtp.client-ip=209.85.216.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="XZ4tYvqv" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-299566373d4so3526407a91.1; Tue, 05 Mar 2024 03:34:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709638463; x=1710243263; 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=/dcQghrlt499tRG4k7pSkJgfZTHsndNjCFgJHR4E/Nw=; b=hPJSsAZrid39pyZJpLvJFXUYYUpOOj4Daj+On9++jipnPBnr2NDnLY6oEiXVfffks8 zOCEokL+XaB6Bsk61L5shNupxbcYc85UUEQrW8ie3Km+eRlZFZuVApNiV235SeBKR/AE 9hjTX1PS6Gixu0R40xFz+eNZXKBh7JvjPBvno+Fj3ZL6n4w0mwbEVbd7dHjSZQd1TmHu JatdbcFxmfbOfkFy7pU323rB5EYlobir7Odi3jn/BrOsKiEnvxROhDTmDyh1nF0dJ0/m gNI5eX2JUr2k93Py055kX8bSxdnQz5EJv7EN07TcJDVjI2aeYB7I6ZtI9q0SSg+yU8sB UvHA== X-Forwarded-Encrypted: i=1; AJvYcCXYRJsARuClPYyfBjrQefeaBXaahOPNLVmws9lF+3clBmz70IGstMJoZCpVUo3p/QQyGje0ZOQaJWx2cls+BKiJ8VZRS0HRBit10c8/0iDxWokvgSDZJJ+5hwOzq5WDLO7diVhzIofh8YZJDGq5O9G4O2W/Xp8KjcbJhHtkpKyLr/z2nbTyzA== X-Gm-Message-State: AOJu0Yw1gdS18JPKBnQh8W5t9OFS7dSYgmNNcJanOA0AF2zElEknfapc gnfLGqvPZT7RhehpSKycu1qFs4YoJ74C5ts1Dn0cDB45+9qv151t X-Google-Smtp-Source: AGHT+IFcyb6MXz9bVUK2zcEKo8hC5CPMTtI/yp9MTxCAoF4zMPOkBO3dIzwpzNBPxsC8I9lzyEVifw== X-Received: by 2002:a17:90a:4813:b0:29a:5c44:2d03 with SMTP id a19-20020a17090a481300b0029a5c442d03mr8091761pjh.27.1709638463275; Tue, 05 Mar 2024 03:34:23 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id il18-20020a17090b165200b0029b6a3e1794sm768448pjb.28.2024.03.05.03.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:34:22 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709638461; 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=/dcQghrlt499tRG4k7pSkJgfZTHsndNjCFgJHR4E/Nw=; b=XZ4tYvqvlEXbwIiTnfnpVNU+/nPGkQx33TMQ2CFokzbx5DbGVJ5SYlfuWzFXV+9KNbGpKd gU1hlJqRrGf86RYCUCpM3dJidFCXucKL6bawyl1EinFYYSY569Vn3P0IcDD6lYRykrtc7b jgb6kTcCMpN22cU6wI2EGuQPknF/B/vHmqHa6yVpPVQQNsUNIM/KSqcDI0eFEjlGXLPMdi eeYRFDX3WxchdPRRR8xvkTpic+8AexW79kaq81UwJ6066xWkjtOo6xqr7ATrXf8t2THUC/ 0OPp5zT/Z1SbJpsA18GVbkp67mkUFjpcwc8lLatmChISqx4dFe0Z2oDFB4xL5A== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Tue, 05 Mar 2024 08:34:11 -0300 Subject: [PATCH RESEND drm-misc 2/4] drm/sysfs: make drm_class constant Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-class_cleanup-drm-v1-2-94f82740525a@marliere.net> References: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> In-Reply-To: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Hans de Goede , Helge Deller , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=4750; i=ricardo@marliere.net; h=from:subject:message-id; bh=TWafS46/cOn388vLX3knlaGbqPHumfrCMMRy3Z1uooE=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl5wMzQiBiCjclrlZHoTJxk8xMwKf6UskNaNTXW 9W/YR9DQ+iJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZecDMwAKCRDJC4p8Y4ZY pv9pEACqUoH8iCZERpLB/OOzKOxqO6vTE6izkQWDbLe9hbraXujYS5JyxW1s0rDffD/x5NU1BNB /njL5VMvSDIGflxGdslrgRzhBb/MedUSM1HcTDZlapNvtu23peHPD2iNsCWER4w9Ak/rnc3xMak DTXA2p1sRJ1eKhgmmSJVmDQb3JBZPAUAuwe7HlxKIHkotWT5ahUd/mXOWM8n847jNJPZN3R4dc0 QcbEA7a7905yz1xrRiMPHIbK5K7ND5BOMERb+YXYdF8OlS7UynJdibJ2SKScThvoD09EBLDe0v5 ASAq8mBNzevgD118DLXHibbdHXm8et/InLSLFnIzxTeM2MRRj43J50YJPo2TSQbjYnio9c8Q6mm 9ohwiOl5HG7fXnZieehZUkVWKwY/2hmyk8x3M9Ypin0CgPPsd/wPpg1ecICY5GPXiK7I9aa8BZv sSoMttQsrvImjcMk+xnuM+KLTOK/I0LdxKMevjjMXki15kXG8FVTUA0p3Uwf47fbu3V0OgbR3JG J1vG6FHo3oVS9Q4lctIwQENlX0lqED+i0ThU2sL/1uremnVo7TU5XU/HYBoIZJ2dQ0V57NnGaw/ b9Cogbxadf93lskA1kIAsmNdofdEhrmj0wSzjvTsgY6aNe8VIzDcwzkLv7tNMwEXlVmFkeynnSJ QPNGH9n3xWVJM5g== 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 drm_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/gpu/drm/drm_internal.h | 2 +- drivers/gpu/drm/drm_privacy_screen.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 44 ++++++++++++++++-------------------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h index 8e4faf0a28e6..a881cd442a9b 100644 --- a/drivers/gpu/drm/drm_internal.h +++ b/drivers/gpu/drm/drm_internal.h @@ -142,7 +142,7 @@ bool drm_master_internal_acquire(struct drm_device *dev); void drm_master_internal_release(struct drm_device *dev); /* drm_sysfs.c */ -extern struct class *drm_class; +extern const struct class drm_class; int drm_sysfs_init(void); void drm_sysfs_destroy(void); diff --git a/drivers/gpu/drm/drm_privacy_screen.c b/drivers/gpu/drm/drm_privacy_screen.c index 6cc39e30781f..2fbd24ba5818 100644 --- a/drivers/gpu/drm/drm_privacy_screen.c +++ b/drivers/gpu/drm/drm_privacy_screen.c @@ -401,7 +401,7 @@ struct drm_privacy_screen *drm_privacy_screen_register( mutex_init(&priv->lock); BLOCKING_INIT_NOTIFIER_HEAD(&priv->notifier_head); - priv->dev.class = drm_class; + priv->dev.class = &drm_class; priv->dev.type = &drm_privacy_screen_type; priv->dev.parent = parent; priv->dev.release = drm_privacy_screen_device_release; diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index a953f69a34b6..90145f9256a2 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -58,7 +58,15 @@ static struct device_type drm_sysfs_device_connector = { .name = "drm_connector", }; -struct class *drm_class; +static char *drm_devnode(const struct device *dev, umode_t *mode) +{ + return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); +} + +const struct class drm_class = { + .name = "drm", + .devnode = drm_devnode, +}; #ifdef CONFIG_ACPI static bool drm_connector_acpi_bus_match(struct device *dev) @@ -93,11 +101,6 @@ static void drm_sysfs_acpi_register(void) { } static void drm_sysfs_acpi_unregister(void) { } #endif -static char *drm_devnode(const struct device *dev, umode_t *mode) -{ - return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); -} - static int typec_connector_bind(struct device *dev, struct device *typec_connector, void *data) { @@ -142,19 +145,16 @@ int drm_sysfs_init(void) { int err; - drm_class = class_create("drm"); - if (IS_ERR(drm_class)) - return PTR_ERR(drm_class); + err = class_register(&drm_class); + if (err) + return err; - err = class_create_file(drm_class, &class_attr_version.attr); + err = class_create_file(&drm_class, &class_attr_version.attr); if (err) { - class_destroy(drm_class); - drm_class = NULL; + class_unregister(&drm_class); return err; } - drm_class->devnode = drm_devnode; - drm_sysfs_acpi_register(); return 0; } @@ -166,12 +166,9 @@ int drm_sysfs_init(void) */ void drm_sysfs_destroy(void) { - if (IS_ERR_OR_NULL(drm_class)) - return; drm_sysfs_acpi_unregister(); - class_remove_file(drm_class, &class_attr_version.attr); - class_destroy(drm_class); - drm_class = NULL; + class_remove_file(&drm_class, &class_attr_version.attr); + class_unregister(&drm_class); } static void drm_sysfs_release(struct device *dev) @@ -372,7 +369,7 @@ int drm_sysfs_connector_add(struct drm_connector *connector) return -ENOMEM; device_initialize(kdev); - kdev->class = drm_class; + kdev->class = &drm_class; kdev->type = &drm_sysfs_device_connector; kdev->parent = dev->primary->kdev; kdev->groups = connector_dev_groups; @@ -550,7 +547,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) minor_str = "card%d"; kdev->devt = MKDEV(DRM_MAJOR, minor->index); - kdev->class = drm_class; + kdev->class = &drm_class; kdev->type = &drm_sysfs_device_minor; } @@ -579,10 +576,7 @@ struct device *drm_sysfs_minor_alloc(struct drm_minor *minor) */ int drm_class_device_register(struct device *dev) { - if (!drm_class || IS_ERR(drm_class)) - return -ENOENT; - - dev->class = drm_class; + dev->class = &drm_class; return device_register(dev); } EXPORT_SYMBOL_GPL(drm_class_device_register); From patchwork Tue Mar 5 11:34:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13582227 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 0AD2659B70; Tue, 5 Mar 2024 11:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638468; cv=none; b=dYYlRkUrUWmRZh5j8j+jGjppLSjta/sfsA+aaAnKm4nJYA2ZeiDyMCJq4j4JFUUx/OdTigiFA0P6mi+nuD930AiJ45wwY+2mLn5pSnDSs3uiVYJWn03YZVhzar04ZcEX/IGCoZnDp3gY02nJxYxweQcPQYqL96qjzLChWKuEDaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638468; c=relaxed/simple; bh=odlS9XGQQRwzN+B0py2AY1reM8pgKOyyB/x+HH+DGwc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZLegU0T0Zg9gH5GVy8iCA5+K+OST/1gY7aH3XUMsKlw91ame60YPpyUZIVuINX4X79lHlTr+1Lc+aCjmNxlB3R7THMjTi1rO0fw4tkMVTsyFM4dwucRK+a1yIwAOcNFq0YsVchHrbmXa+EBX2u7kZkrv5v70IQC//Ja0KkpsLro= 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=BZQuDztV; arc=none smtp.client-ip=209.85.215.170 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="BZQuDztV" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso5038172a12.0; Tue, 05 Mar 2024 03:34:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709638466; x=1710243266; 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=C1DfDZMTMffYiTmyqOzmLOtfTydk4L3JihPgMKHs/SA=; b=r2yKY7Ny1W7s6GEaV7fEqEQvo3ihqPlRSUZFg63Jzg7GrcZeTpNLgDhtRCsBLXOc/g 9BUNdMAXybG548IAChL6Jo2VKGdMKwK30y5x2/pQln9c3rIWpYsKGxwM3bWZ6ef86mfB MpJAtZ+jW7qo/ZOJzmFWr9nrQIWUB6Ro4EbPf1qdazMQTCGvR1ULJY3bYXWMk4SAvRu/ /njTkEVzcn0i9vBs7E9M0SOsEPCq6nTPFn7HviJ7ljPg25GaIZL7NG9mRU48kvWB4ILm q/tavuY22LuukXBzCMsNiITAAxf5hp6RB2sgCRCKKMsguQIg6hPk03X9Dk2rMnd1A1Z7 Vvgw== X-Forwarded-Encrypted: i=1; AJvYcCXFS3h4lVLe7de6gbezFENWNT0wM1NB4XSUJ6iGqGSSsMO7ZHH1DIcE8o3inSsWtFKj2/zbRbT3Yut4OGaCsseGsHT06/07A7Z4FOSnQNCGhVZ+qduZTJcl2Hl9oXHP+Xz+T+fCMvkIU3N0yuStV8zeiT2dkFLS42hab/viRuKMj3wb4CsAHA== X-Gm-Message-State: AOJu0YymMEsoCFEK02R5OdrbGJYEPypCg6cIhjShnFoRG8Z0wK9KJGEi ufOghLfRIsOlSYWSfThGWvCYSHO2GwHVoCdO6NUQsRMF+FAiML+w X-Google-Smtp-Source: AGHT+IHZWXKL+Lk1FfhlYKJcnfb5e8jQKTcN0jHBpaUNr32Y5e7OuV6Xsl+nwlXMjRn/fQRALMcOQw== X-Received: by 2002:a17:90a:ea87:b0:29b:41aa:1673 with SMTP id h7-20020a17090aea8700b0029b41aa1673mr5116953pjz.23.1709638466494; Tue, 05 Mar 2024 03:34:26 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id s12-20020a17090ad48c00b0029aac9c523fsm9293361pju.47.2024.03.05.03.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:34:26 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709638464; 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=C1DfDZMTMffYiTmyqOzmLOtfTydk4L3JihPgMKHs/SA=; b=BZQuDztVgmgzi+Uh2Sd6As8Sivl/LlMh5BhXMEd6lIWOGJryGqMmd+71wdK9N+jv6cdSu4 F4BSAou210tR40UJyLZloxJWaYTbes3MpVIk7dssKXFSks/ezD1EdvAoPbtgvjfMLaX2IH Dv1m4NcbqRygZs2NjqtFMLo9z2FwgT0S9ld1ztiX/uiKpd5Yg/nn1wmBm3/mXCEy5LdTEP xdmrqcdNcuOy8ouXEF4XE/5LmTb8S7dyu50pZF39aMWRkRyzXaVKauS6okL+5SIZXovq13 lRJRlCNsBrZ8SPeWmSxzTAtPAEi1geuJ5D2q8BrsVzLnfrHcWLAZBiqojoX3NQ== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Tue, 05 Mar 2024 08:34:12 -0300 Subject: [PATCH RESEND drm-misc 3/4] drm/fbdev/core: make fb_class constant Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-class_cleanup-drm-v1-3-94f82740525a@marliere.net> References: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> In-Reply-To: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Hans de Goede , Helge Deller , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=4135; i=ricardo@marliere.net; h=from:subject:message-id; bh=odlS9XGQQRwzN+B0py2AY1reM8pgKOyyB/x+HH+DGwc=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl5wMz/VClmII16tlzVnls2AkPKRQDOF8ITXAxS E2AX4MDYLaJAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZecDMwAKCRDJC4p8Y4ZY pi6cD/48CYEbxbcvKs7TOaESq2VHY7ujmAiw6OqMderld8pQkDBzFtKAj9msxKjTqw6CHYhgOZK +mSSI6QSE/tqwMuM8NehJCfvyf4VpXXFRgY5llCm3hOvBXd6SydElVVwgg1ZWxlkyuZUjQ+fHtw gb0wcB5XPSTORMAqMxUADS0a1GJ9TOx1hfQe1KZFnz7Axi0uWdzLKAhs8VoKLaSBIjKCzDIrhPW 2r+mvo0gFhyZ304vStg1xKyg2RdAYWgTXfbBlE2q77AIsVdqZgi5cZ92Uhzpsx0IyVe3+YKqGK5 xUhJQPQlAUPx4sN0r6GvkhT2umuxNf5wFaqznS/CTslhKtKEXbUaHNO6sl4CjXIU6IrcU55QSfv OwdRg+pB7hVLcjNC/IdRO6CbHWhnBc7TJubNFKi3bBN8jsLiWGXV8dTYpw3DBwDxWhyVyjTDixl 8XRBbuC3zHSwSA4U60z28nrjlvvJDJcFy1lcZpn2roUQ6capAKh3j+ELXMX+sYTNRDEmau8heih jdhAwWQ7Mr18+F32vgALXzZTEUVFUrciJ7fmd+rAAAl0bfBuWa7dQ6ZjCzdf0BXefAAVRX8wqnz 3VDKtI0xWBQPQYNPdUOQ9nxrwsThkJB8HA3SEiASF3JsOwd1xqVftYRmVvREWJLO4z09+kpqTHq lmV9bhnUmwWMHWg== 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 fb_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/video/fbdev/core/fb_internal.h | 2 +- drivers/video/fbdev/core/fbcon.c | 4 ++-- drivers/video/fbdev/core/fbmem.c | 17 ++++++++--------- drivers/video/fbdev/core/fbsysfs.c | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/video/fbdev/core/fb_internal.h b/drivers/video/fbdev/core/fb_internal.h index 613832d335fe..f1c0f1386675 100644 --- a/drivers/video/fbdev/core/fb_internal.h +++ b/drivers/video/fbdev/core/fb_internal.h @@ -38,7 +38,7 @@ static inline int fb_show_logo(struct fb_info *info, int rotate) #endif /* CONFIG_LOGO */ /* fbmem.c */ -extern struct class *fb_class; +extern const struct class fb_class; extern struct mutex registration_lock; extern struct fb_info *registered_fb[FB_MAX]; extern int num_registered_fb; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 1183e7a871f8..4d87a6ebdbdf 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -3380,7 +3380,7 @@ void __init fb_console_init(void) int i; console_lock(); - fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, + fbcon_device = device_create(&fb_class, NULL, MKDEV(0, 0), NULL, "fbcon"); if (IS_ERR(fbcon_device)) { @@ -3425,7 +3425,7 @@ void __exit fb_console_exit(void) console_lock(); fbcon_deinit_device(); - device_destroy(fb_class, MKDEV(0, 0)); + device_destroy(&fb_class, MKDEV(0, 0)); do_unregister_con_driver(&fb_con); console_unlock(); diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 48287366e0d4..d868194499fb 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -26,7 +26,9 @@ #define FBPIXMAPSIZE (1024 * 8) -struct class *fb_class; +const struct class fb_class = { + .name = "graphics", +}; DEFINE_MUTEX(registration_lock); struct fb_info *registered_fb[FB_MAX] __read_mostly; @@ -571,11 +573,10 @@ static int __init fbmem_init(void) { int ret; - fb_class = class_create("graphics"); - if (IS_ERR(fb_class)) { - ret = PTR_ERR(fb_class); + ret = class_register(&fb_class); + if (ret) { pr_err("Unable to create fb class; errno = %d\n", ret); - goto err_fb_class; + return ret; } ret = fb_init_procfs(); @@ -593,9 +594,7 @@ static int __init fbmem_init(void) err_fb_cleanup_procfs: fb_cleanup_procfs(); err_class_destroy: - class_destroy(fb_class); -err_fb_class: - fb_class = NULL; + class_unregister(&fb_class); return ret; } @@ -605,7 +604,7 @@ static void __exit fbmem_exit(void) fb_console_exit(); fb_unregister_chrdev(); fb_cleanup_procfs(); - class_destroy(fb_class); + class_unregister(&fb_class); } module_init(fbmem_init); diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c index 1b3c9958ef5c..aac013dfe06a 100644 --- a/drivers/video/fbdev/core/fbsysfs.c +++ b/drivers/video/fbdev/core/fbsysfs.c @@ -476,7 +476,7 @@ int fb_device_create(struct fb_info *fb_info) dev_t devt = MKDEV(FB_MAJOR, node); int ret; - fb_info->dev = device_create(fb_class, fb_info->device, devt, NULL, "fb%d", node); + fb_info->dev = device_create(&fb_class, fb_info->device, devt, NULL, "fb%d", node); if (IS_ERR(fb_info->dev)) { /* Not fatal */ ret = PTR_ERR(fb_info->dev); @@ -497,6 +497,6 @@ void fb_device_destroy(struct fb_info *fb_info) return; fb_cleanup_device(fb_info); - device_destroy(fb_class, devt); + device_destroy(&fb_class, devt); fb_info->dev = NULL; } From patchwork Tue Mar 5 11:34:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13582228 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 810765B1EA; Tue, 5 Mar 2024 11:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638472; cv=none; b=ls7CjeSmhzlI2dgCXOEhESpmoJcioekk1AT2mTyArcZwXqgkL13HfiaNOwJrjybSVQ7UmNecobYvQyxkomLGyamlteDZgvW5nuw2P/Y7pjl8UnPtw5fbHSzywhsf2u23zbryv5DNYfZWfYviSLqwr7mKlB2/fmIhCZdZrwmctNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638472; c=relaxed/simple; bh=TBVpOiYhHL/5knKRvD0InlYh5cmtDcK9l0qZqxgxL78=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dqil5aCongtWgmTtqzVJSgBuu5cByJkV5K3aDrTqa8P0ooxVz1M7KA9Jso9tCmVZBLsQzXrCTZuLpqSM40laBIUOEppNddxp4PEyScoxCx6Gm67YqwufeDhTJ7uNwj8LE45l13HqyigqFK75eC2jE7L3134FfqMXvES6TTRg6EE= 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=ZeOa8Sr0; arc=none smtp.client-ip=209.85.214.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marliere.net header.i=@marliere.net header.b="ZeOa8Sr0" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1dbd32cff0bso46999905ad.0; Tue, 05 Mar 2024 03:34:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709638470; x=1710243270; 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=SGvjvL1l3IEoVUIMcNND+raHtPvpiWRh02eFx2GTgcs=; b=AoCIrG1PMnITXmJmj3VwZhG90wJNJsY0S4rayW3wcLqNPBymg2ITo8TX2W6KF2b6ui o0AoYKrnx4pKidAXmgG9rv1k+5usTRvXr8E6h3CDTsOjbJF7wfLkYjL+ROfm7KZbYP54 mGnSPOgMNWWAZ7fDFXzm161lDpqMf1rdweBoOUFnLsrd15UGrdVyFVn+BCqz5sPonODp idW7vJ03NflOj+s5SF21jkTvUCz2bjM90O+JNPTdjYfVLQwJOpQWUrrB3Aa60BiemIia rnj3yFm1b836HoV4ejX03x0nhqVyQrkW/WNpUDp+2r9g8vrcrkRk9ydI7zjqyjAStIfB BTXA== X-Forwarded-Encrypted: i=1; AJvYcCWGUZApX+LJPVHM+8UG0fksYk+ZQvSMLqo9VPXw94BavRFkqvLwAySnfrGe0uL5TfLMH2kkEDclCt/hgraI6f9fSfeExezBf8/YEKya79ni1iy6l636PzJEyocYX9JuhpSKO4R/x69iQaJ90acPAWliPB+O2XHyRur61EqHBWvmhveYkhYrHA== X-Gm-Message-State: AOJu0YzASSUu1IX+i9FCBJTW9Jn6TGG5z4dVaAQCg6KAoQX/Jj19DS2H B5F9VaW1NLZM6sLf/lxoqHQZJReku/LFelj6sz2BoeLJPsfcjDPwLYZx1aVrT5x8NQ== X-Google-Smtp-Source: AGHT+IEvvXqVgNig+0Ajd3GcxrPcqCzSQEPkm0LQdI67Nas42de+ACS1GOh6k+iqXrCZCfKKLop+HQ== X-Received: by 2002:a17:902:e74b:b0:1da:22d9:e7fd with SMTP id p11-20020a170902e74b00b001da22d9e7fdmr1703170plf.20.1709638469624; Tue, 05 Mar 2024 03:34:29 -0800 (PST) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id d15-20020a170903230f00b001dc3c4e7a12sm10315600plh.14.2024.03.05.03.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:34:29 -0800 (PST) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2024; t=1709638468; 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=SGvjvL1l3IEoVUIMcNND+raHtPvpiWRh02eFx2GTgcs=; b=ZeOa8Sr0g4u6ioHCa+AEJa2P0N6xyD41cZUQ99KQvEzFdKnmd85LBQCyqKPIR5hy9KPSf7 2+tam0hUlZYXqIDf0mcMsitkiEf4w2O2Dsug3zulLjOsnzEaXf10zv9c76IibqBwUbkjxn MWnSweGc9mb7nk902l1B8nIts3HHOF/UOhYGjUTALy8vy8lGwsa28tCcLbBXgfvcuUjmLn d6M6yTQvSWAXtpSrKnFRA/ZhPJRh47SAhJag2AzLaXAhKco444IbXSptaSEjuK0sIydl4h h7PH7a3+TI9JSbm/NNmJU4sIXPFk7ie9bTMFZIZv2WLs3VbdxddhAK4zjQxccQ== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net Date: Tue, 05 Mar 2024 08:34:13 -0300 Subject: [PATCH RESEND drm-misc 4/4] dma-buf: heaps: make dma_heap_class constant Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240305-class_cleanup-drm-v1-4-94f82740525a@marliere.net> References: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> In-Reply-To: <20240305-class_cleanup-drm-v1-0-94f82740525a@marliere.net> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Hans de Goede , Helge Deller , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?utf-8?q?Christian_K=C3=B6nig?= Cc: Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, "Ricardo B. Marliere" X-Developer-Signature: v=1; a=openpgp-sha256; l=2638; i=ricardo@marliere.net; h=from:subject:message-id; bh=TBVpOiYhHL/5knKRvD0InlYh5cmtDcK9l0qZqxgxL78=; b=owEBbQKS/ZANAwAKAckLinxjhlimAcsmYgBl5wMzXXEwr5JfufBuY7fFwRJL8nmL4A2R2R+Df j91UwjdnM+JAjMEAAEKAB0WIQQDCo6eQk7jwGVXh+HJC4p8Y4ZYpgUCZecDMwAKCRDJC4p8Y4ZY pqQCD/9dAq8lWzYs5OjaBNAHM65zzjgz6Bgu/yB5UChhzZHSF5jbEB1KCMPsLUcOAD+H6g5bK69 pAUxqPv2rzp9CWK1LphHF75Ys/ePMnp2Bcf4OyzIE6f91RhLoj6a4vbkFPo3ZEjSx/18f21XIqK 7npqmmzF9bMJZ4uEDe+jODA+DBQYN9hVaJbTKxDS8gCZmfU25oI1BHVDQhreY8re7+ix7JSRyBm wPUj4mXuV+tzsbL9ZckyDvXuWCbO9ahj9PS3uSjE9nNg5frRpySuqZc8r94FQaSLRmTtmqSMmEa SaOKMQjsYWaR7HDt0KtlK2iZTXF+vm7jUvldFW4No5i3FP74h3rBI791dRMszvQXVMxe0YSJp1p S65Q9hxfqClvd7imVlKLKicraIepW+0Q+1p/FN5pf9wbZH4HmFKRlFJwDXpizdmwDpzqrPs2Fcz TS1Ke2yr1f9azqJrtXe2RyDIazXjn8oFYjH/iQ0NVI5qSTQgSiCN7XIsc0P5FF1QaF1J0OycvAg a7Y1NrbrkMUlnY3C/s6vWjrVcIDlj+65mOwFAUPdE9/908I9+Wxr3trDsTEbbyM5D1NEFpIhqvP kIBLJ4SWnDQasUHC1nJXCj2BVKfRDUdfhOGMRhz6653ioDf0gAwIeNI58zjAOjDGasGv4o8TfbK nsoMJNbrypYMCcQ== 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 dma_heap_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 Reviewed-by: T.J. Mercier Acked-by: Sumit Semwal --- drivers/dma-buf/dma-heap.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 84ae708fafe7..bcca6a2bbce8 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -43,10 +43,18 @@ struct dma_heap { struct cdev heap_cdev; }; +static char *dma_heap_devnode(const struct device *dev, umode_t *mode) +{ + return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev)); +} + static LIST_HEAD(heap_list); static DEFINE_MUTEX(heap_list_lock); static dev_t dma_heap_devt; -static struct class *dma_heap_class; +static struct class dma_heap_class = { + .name = DEVNAME, + .devnode = dma_heap_devnode, +}; static DEFINE_XARRAY_ALLOC(dma_heap_minors); static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, @@ -261,7 +269,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) goto err1; } - dev_ret = device_create(dma_heap_class, + dev_ret = device_create(&dma_heap_class, NULL, heap->heap_devt, NULL, @@ -291,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) return heap; err3: - device_destroy(dma_heap_class, heap->heap_devt); + device_destroy(&dma_heap_class, heap->heap_devt); err2: cdev_del(&heap->heap_cdev); err1: @@ -301,11 +309,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) return err_ret; } -static char *dma_heap_devnode(const struct device *dev, umode_t *mode) -{ - return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev)); -} - static int dma_heap_init(void) { int ret; @@ -314,12 +317,11 @@ static int dma_heap_init(void) if (ret) return ret; - dma_heap_class = class_create(DEVNAME); - if (IS_ERR(dma_heap_class)) { + ret = class_register(&dma_heap_class); + if (ret) { unregister_chrdev_region(dma_heap_devt, NUM_HEAP_MINORS); - return PTR_ERR(dma_heap_class); + return ret; } - dma_heap_class->devnode = dma_heap_devnode; return 0; }