Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1622491pxk; Tue, 1 Sep 2020 03:35:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3ycKOMzcVzlu/QfKQxkwi7NHIKgigoYj6hlfvN+w8c+Adf4w4makmbC02SdG2sXwyDIqf X-Received: by 2002:aa7:db02:: with SMTP id t2mr26378eds.95.1598956525136; Tue, 01 Sep 2020 03:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598956525; cv=none; d=google.com; s=arc-20160816; b=bW07QRyg7neKD4JhK4MsJMMXB5oDwnYwdm9bM0GMNVH5QEBKNWy3z2ODseDXBL7f+V LtkGRGPKGbSqgTLqW5aLG2uD7Es8zQSTfKDOTWw0Q28V2Y6wR5WtPi4zmBYJxMNVVXaZ Muqm7GjA+Ppl96damLqnWdWw+556jVa15N9bM7DHmOn7qISWly7dGQVGURe0gplfwbAA h8jeLbhdassDyOOl990ZDAgwQXl9/Rq4+/2WwOUmOw5UjpIfL6IpO5f+KCkBjlSrHp9T ph1qKRJ1MevbcWAPBo8oTUb8H2T8TPlK0u0mfK/Q4RwSXyE/y3wwaAjb2oInS6AFg8mP rW2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3DJ+d2WStvH8MmLIdA1RYSAm185lH76y+05xPKfqXKk=; b=KpUfi3lANWIbh6PulXq0CAd5xc1aMdSWRng0SwyCSwLCfCdt0/6m5A5x8wNi4dS8pP 4OYahqdcbdkDgSmCdDmACC+/CSybVuJ+GJq7hmJEQ5YSynjqMxyc8ZWQ4gBDlCX2X6cm 7VYenetefwEAzCZ28iC1DuQaowtiD8WSbwK6YVhEWEKJkatFWFusJeWONuXY+7ZV/tR0 13YGg1XCCjIiL+EZbdtocx6UqFAhz4XQ3QjXRqWPV0zSrTVaryeTi5CSERjbiB+SElBZ WJquGYpjuHxQlT/7qeKFV3WkNgHWmQhQb25f5nQ/ZLgEwYC6RDHACIDPOAM4Thtk09Ot T+Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si333672edv.400.2020.09.01.03.35.02; Tue, 01 Sep 2020 03:35:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725949AbgIAKdr (ORCPT + 99 others); Tue, 1 Sep 2020 06:33:47 -0400 Received: from foss.arm.com ([217.140.110.172]:40168 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgIAKdj (ORCPT ); Tue, 1 Sep 2020 06:33:39 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A3851113E; Tue, 1 Sep 2020 03:33:38 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 005BD3F71F; Tue, 1 Sep 2020 03:33:37 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Jens Wiklander Cc: Sudeep Holla , op-tee@lists.trustedfirmware.org Subject: [PATCH 2/2] tee: avoid explicit sysfs_create/delete_group by initialising dev->groups Date: Tue, 1 Sep 2020 11:33:35 +0100 Message-Id: <20200901103335.685-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200901103335.685-1-sudeep.holla@arm.com> References: <20200901103335.685-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the dev->groups is initialised, the sysfs group is created as part of device_add call. There is no need to call sysfs_create/delete_group explicitly. Signed-off-by: Sudeep Holla --- drivers/tee/tee_core.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index b4a8b362d78f..f77d64fafead 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -962,9 +962,7 @@ static struct attribute *tee_dev_attrs[] = { NULL }; -static const struct attribute_group tee_dev_group = { - .attrs = tee_dev_attrs, -}; +ATTRIBUTE_GROUPS(tee_dev); /** * tee_device_register() - Registers a TEE device @@ -984,6 +982,8 @@ int tee_device_register(struct tee_device *teedev) return -EINVAL; } + teedev->dev.groups = tee_dev_groups; + rc = cdev_device_add(&teedev->cdev, &teedev->dev); if (rc) { dev_err(&teedev->dev, @@ -993,19 +993,8 @@ int tee_device_register(struct tee_device *teedev) return rc; } - rc = sysfs_create_group(&teedev->dev.kobj, &tee_dev_group); - if (rc) { - dev_err(&teedev->dev, - "failed to create sysfs attributes, err=%d\n", rc); - goto err_sysfs_create_group; - } - teedev->flags |= TEE_DEVICE_FLAG_REGISTERED; return 0; - -err_sysfs_create_group: - cdev_device_del(&teedev->cdev, &teedev->dev); - return rc; } EXPORT_SYMBOL_GPL(tee_device_register); @@ -1048,10 +1037,8 @@ void tee_device_unregister(struct tee_device *teedev) if (!teedev) return; - if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { - sysfs_remove_group(&teedev->dev.kobj, &tee_dev_group); + if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) cdev_device_del(&teedev->cdev, &teedev->dev); - } tee_device_put(teedev); wait_for_completion(&teedev->c_no_users); -- 2.17.1