From patchwork Fri Mar 8 12:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Heimes X-Patchwork-Id: 1909681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Trlpm5Pzrz1yWx for ; Fri, 8 Mar 2024 23:29:20 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1riZLa-0003nq-R7; Fri, 08 Mar 2024 12:29:10 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1riZL2-0003Qj-ND for kernel-team@lists.ubuntu.com; Fri, 08 Mar 2024 12:28:39 +0000 Received: from T570.fritz.box (dslb-084-057-174-001.084.057.pools.vodafone-ip.de [84.57.174.1]) (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 smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 624C73F2C1 for ; Fri, 8 Mar 2024 12:28:36 +0000 (UTC) From: frank.heimes@canonical.com To: kernel-team@lists.ubuntu.com Subject: [SRU][J][F][PATCH 5/8] hvcs: Use driver groups to manage driver attributes Date: Fri, 8 Mar 2024 13:28:17 +0100 Message-Id: <20240308122820.316586-6-frank.heimes@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240308122820.316586-1-frank.heimes@canonical.com> References: <20240308122820.316586-1-frank.heimes@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Brian King BugLink: https://bugs.launchpad.net/bugs/2056373 Rather than manually creating attributes for the hvcs driver, let the driver core do this for us. This also fixes some hotplug remove issues and ensures that cleanup of these attributes is done in the right order. Signed-off-by: Brian King Link: https://lore.kernel.org/r/20230203155802.404324-3-brking@linux.vnet.ibm.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 503a90dd619d52dcac2cc68bd742aa914c7cd47a) Signed-off-by: Frank Heimes --- drivers/tty/hvc/hvcs.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 8fc8816c7c0c..5c0fd72dd0f1 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -492,6 +492,13 @@ static ssize_t rescan_store(struct device_driver *ddp, const char * buf, static DRIVER_ATTR_RW(rescan); +static struct attribute *hvcs_attrs[] = { + &driver_attr_rescan.attr, + NULL, +}; + +ATTRIBUTE_GROUPS(hvcs); + static void hvcs_kick(void) { hvcs_kicked = 1; @@ -851,6 +858,7 @@ static struct vio_driver hvcs_vio_driver = { .remove = hvcs_remove, .name = hvcs_driver_name, .driver = { + .groups = hvcs_groups, .dev_groups = hvcs_dev_groups, }, }; @@ -1529,13 +1537,6 @@ static int __init hvcs_module_init(void) pr_info("HVCS: Driver registered.\n"); - /* This needs to be done AFTER the vio_register_driver() call or else - * the kobjects won't be initialized properly. - */ - rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan); - if (rc) - pr_warn("HVCS: Failed to create rescan file (err %d)\n", rc); - return 0; } @@ -1560,8 +1561,6 @@ static void __exit hvcs_module_exit(void) hvcs_pi_buff = NULL; spin_unlock(&hvcs_pi_lock); - driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan); - tty_unregister_driver(hvcs_tty_driver); hvcs_free_index_list();