Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1622082pxk; Tue, 1 Sep 2020 03:34:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoLf67HdAr+eEjKp7lgDMV6sQZJAF5K6xuoOtrype9VKFniRpfZSMxeTPbBf+v6GaY5MoQ X-Received: by 2002:a17:906:841a:: with SMTP id n26mr840752ejx.213.1598956479808; Tue, 01 Sep 2020 03:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598956479; cv=none; d=google.com; s=arc-20160816; b=prFG9foYvHA88K9PUMIE2tv2ekM+LtLs7qYo3hoYsmoYrZs1oHh8CAOGd5sPjaE5P5 nQSN4bt/9qRCAXyfFMix4v9fJ6molh9ZEQVRJaebQDJzvccNVvL+cmSeb2WCNCKWFuOO Vvzx0/fSmmvgvCoXLganJOmQb6ge5HMnSq9KJb7IdSgUzCqPmfJjq0WzP0CGqz2PD1iL XTWsE8ONkH3LLGGm5/E078ley8ItBMeH1yyFIZvY4svTOMWEzArIMwaWp9wk6SKjJdti DRc4GCIIjvYvqmnVFpAhX+7Xa0qEgOLqsQMBkGvwyxWmQWRIKR9kpqakVfm1w8FpEloQ vBMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=o5AglhmEhvbAsE8QQxpQggRVHNhRXIPdXjt/2YLoNk0=; b=leHx/PswV33ChFI+TUb/Y7fW/Eo4pgn/Lnj6A9drrp+uAQSIX1q/RZnrYi6/DJ6Twe kLkpae0Y4k5pkS1EmNPBEElekXWcqLM/gUJzHK2RgQgOgMDwDdwAr67JYbk0lXfA1uk3 aXeB2RepeFNdglkyNS2VKy/v8SHIb6zwZ27rCjBdp3dfZFcwkJmIOFf4R/EiISNwx47Z pUjrPdhGslJ8mL4/JGMp7vBQiygcu3Pct1JGvZuCPpC/Rzyzyai9GDHXp1o4AyM+m4n+ pcf/xuci8CPhFZ6utR3vB6WQZiVU4E1thLuyjAgbZbeu9dzhHsljY475DHLcqGlwedXa EmKA== 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 ld12si426877ejb.329.2020.09.01.03.34.15; Tue, 01 Sep 2020 03:34:39 -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 S1726140AbgIAKdk (ORCPT + 99 others); Tue, 1 Sep 2020 06:33:40 -0400 Received: from foss.arm.com ([217.140.110.172]:40158 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbgIAKdi (ORCPT ); Tue, 1 Sep 2020 06:33:38 -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 C0CE01063; Tue, 1 Sep 2020 03:33:37 -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 1BE643F71F; 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 1/2] tee: replace cdev_add + device_add with cdev_device_add Date: Tue, 1 Sep 2020 11:33:34 +0100 Message-Id: <20200901103335.685-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 233ed09d7fda ("chardev: add helper function to register char devs with a struct device") added a helper function 'cdev_device_add'. Make use of cdev_device_add in tee_device_register to replace cdev_add and device_add. Since cdev_device_add takes care of setting the kobj->parent, drop explicit initialisation in tee_device_alloc. 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 64637e09a095..b4a8b362d78f 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -917,7 +917,6 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc, cdev_init(&teedev->cdev, &tee_fops); teedev->cdev.owner = teedesc->owner; - teedev->cdev.kobj.parent = &teedev->dev.kobj; dev_set_drvdata(&teedev->dev, driver_data); device_initialize(&teedev->dev); @@ -985,24 +984,15 @@ int tee_device_register(struct tee_device *teedev) return -EINVAL; } - rc = cdev_add(&teedev->cdev, teedev->dev.devt, 1); + rc = cdev_device_add(&teedev->cdev, &teedev->dev); if (rc) { dev_err(&teedev->dev, - "unable to cdev_add() %s, major %d, minor %d, err=%d\n", + "unable to cdev_device_add() %s, major %d, minor %d, err=%d\n", teedev->name, MAJOR(teedev->dev.devt), MINOR(teedev->dev.devt), rc); return rc; } - rc = device_add(&teedev->dev); - if (rc) { - dev_err(&teedev->dev, - "unable to device_add() %s, major %d, minor %d, err=%d\n", - teedev->name, MAJOR(teedev->dev.devt), - MINOR(teedev->dev.devt), rc); - goto err_device_add; - } - rc = sysfs_create_group(&teedev->dev.kobj, &tee_dev_group); if (rc) { dev_err(&teedev->dev, @@ -1014,9 +1004,7 @@ int tee_device_register(struct tee_device *teedev) return 0; err_sysfs_create_group: - device_del(&teedev->dev); -err_device_add: - cdev_del(&teedev->cdev); + cdev_device_del(&teedev->cdev, &teedev->dev); return rc; } EXPORT_SYMBOL_GPL(tee_device_register); @@ -1062,8 +1050,7 @@ void tee_device_unregister(struct tee_device *teedev) if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { sysfs_remove_group(&teedev->dev.kobj, &tee_dev_group); - cdev_del(&teedev->cdev); - device_del(&teedev->dev); + cdev_device_del(&teedev->cdev, &teedev->dev); } tee_device_put(teedev); -- 2.17.1