Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp314684pxf; Wed, 24 Mar 2021 05:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvy+AFmT6PU54jlxe6cQ+8vTxAoW835KzeUuU0gm4HbT9q8A9Jrm0SnVB7JIeBaVPtAqb/ X-Received: by 2002:a17:906:bfcc:: with SMTP id us12mr3620777ejb.266.1616590691194; Wed, 24 Mar 2021 05:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616590691; cv=none; d=google.com; s=arc-20160816; b=VBXEixAjQVYpnxmAIYGUcl1NwumW9h690qj7Zy0H8XFh3a/l2aW1OPUQg0JRfzoLv4 k59LZM4/o1G9E/sU9wQA5zLktUIEGH0cpjQpEGx3iF9miBq19djJ5s7XMhrU/ozi2XRo +qp9NJu/zflLSKWXSdsuiMW0kR5af66RJ4YWY/cbhdjvZt1mrmXtKmaiuDfitPnsWhFJ WP2ID0uO2jkrOcBpXLNNdhOYCQRBHJr4Br6lrUAL2VgqUkqwmTUW4FL+eaP+JEIzzk+T P+e3hwWh5UeKNnJ9kpSHzN3WQJ9LNkUOrbIR+uG+ukQY2ulN+ba2AQ65WqJYtF4cQRJ5 i+Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=frWPEUlqs06JkDdBYmeAt9wV6HnzyvV5zsDKfCcKu+M=; b=N+wShG6fzbKawfeshtMq8h4+tA8xvMcMPPt0zDEkyQcEu/lUDZFcz5eXPT/Obe/olh G5O/qhdr1ysl3tHU7pgBqcwJexg85auTa46DNlBFT727Oz2cQlgBNCC56wPZns8fsF9C AFEetf5OVhf3yu8hOcjnY2d8IqCc/OpG7re6kOC40LgrCbgYZ3Y1vEKQKqeTHOqKOode +8WKxFX8PFtgYL3kSeqPqr6ovyIZGB4T7mDCOYz1kRsuuzy18SxkEfcoovSkcl72wasp MOCEV7OmxwOBZdRpVLz4bbkjdbeeRXwfKFztuGDlINTsMgbxpnzGI3CtkGlBXrs5cHW/ anOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=GmpYQYHQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si1775524edc.544.2021.03.24.05.57.49; Wed, 24 Mar 2021 05:58:11 -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; dkim=pass header.i=@deviqon.com header.s=google header.b=GmpYQYHQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234912AbhCXM4n (ORCPT + 99 others); Wed, 24 Mar 2021 08:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234525AbhCXM4F (ORCPT ); Wed, 24 Mar 2021 08:56:05 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D198C0613DF for ; Wed, 24 Mar 2021 05:56:04 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id hq27so32680061ejc.9 for ; Wed, 24 Mar 2021 05:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=frWPEUlqs06JkDdBYmeAt9wV6HnzyvV5zsDKfCcKu+M=; b=GmpYQYHQItWYbKynRGeuKnH14x7wgEAUOeru1GAukTiYyBVZyNuC62e9vPztxuB3b+ o9qG1cfC4xJt5eKWXvGYooq4t61JA5rELbrYnZC5EImztn7SNINNZaLjhtNqYTZPU1lG 7HDtCpP+MNoS8NfsghQJc1E42HJqvPOPjK1ajPTu6/XtqpQfNdX/CeS3ANPpsNm/o9ED xDwA7eSuWn46kA6P5NmMwaateIOfXhnoptqZyvF9gYKJhhCg+kP0Prb/bLGnSsfNc52a i/ddBMFrew2LvfV46CLC6Wa9q+r3n1hZeM5EfvzjgzxZzvQ0xEdou4zZQsUFhFSTfULD oSFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=frWPEUlqs06JkDdBYmeAt9wV6HnzyvV5zsDKfCcKu+M=; b=MIjDNm/4f3RmphxsXRoPbCb3NySPoLZi9xFFaQxDTXew4UnuFWH5/WgIv3BrGSHQx/ XMIK6w1Fcmj9aJ9Mssrh90dPwiKrALOFuVyM2/6d99/T0+Ud+xnN2pv3QN5rwzksg5xo Zk7nisMSC37c6tHGZLKDZvtpQZu5LtsGdbLJRldGoBwQxAr9VR6KlffIIAskk5/pTRmW LwpyqnuAV6/ZpxbUTA2DYXrfWMfwjix3ghLabZve3fPxwFGYrag+zGFxS+dpmx6+LS/X AQcBtpIMBeFTQKVygcwzDD73xiZbYlpcJLjf0tj+twB7KPHCgWv5N4RksQf+1hQRDzG/ TP4g== X-Gm-Message-State: AOAM532T+iJG5VCimO53ZqA4PoQZl7Qhm9HyeRhwq/I7xI2MXa6GPiFy m/xpBCwBQMcucfs07k5jKgyaqg== X-Received: by 2002:a17:907:a042:: with SMTP id gz2mr3506188ejc.174.1616590563362; Wed, 24 Mar 2021 05:56:03 -0700 (PDT) Received: from localhost.localdomain ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id fi11sm880282ejb.73.2021.03.24.05.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 05:56:03 -0700 (PDT) From: Alexandru Ardelean To: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: coproscefalo@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, jic23@kernel.org, linux@deviqon.com, Alexandru Ardelean Subject: [PATCH 03/10] platform/x86: toshiba_acpi: bind registration of miscdev object to parent Date: Wed, 24 Mar 2021 14:55:41 +0200 Message-Id: <20210324125548.45983-4-aardelean@deviqon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210324125548.45983-1-aardelean@deviqon.com> References: <20210324125548.45983-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change moves the registration of the Toshiba ACPI miscdev to be handled by the devm_add_action_or_reset() hook. This way, the miscdev will be unregistered when the reference count of the parent device object goes to zero. This also changes the order of cleanup in toshiba_acpi_remove(), where the miscdev was deregistered first. Now it will be deregistered right before the toshiba_acpi_dev object is free'd. Signed-off-by: Alexandru Ardelean --- drivers/platform/x86/toshiba_acpi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index c5284601bc2a..53ef565378ef 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -2963,8 +2963,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); - misc_deregister(&dev->miscdev); - remove_toshiba_proc_entries(dev); if (dev->accelerometer_supported && dev->indio_dev) { @@ -3014,6 +3012,13 @@ static void toshiba_acpi_singleton_clear(void *data) toshiba_acpi = NULL; } +static void toshiba_acpi_misc_deregister(void *data) +{ + struct miscdevice *miscdev = data; + + misc_deregister(miscdev); +} + static int toshiba_acpi_add(struct acpi_device *acpi_dev) { struct device *parent = &acpi_dev->dev; @@ -3056,6 +3061,11 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) return ret; } + ret = devm_add_action_or_reset(parent, toshiba_acpi_misc_deregister, + &dev->miscdev); + if (ret) + return ret; + acpi_dev->driver_data = dev; dev_set_drvdata(&acpi_dev->dev, dev); -- 2.30.2