From patchwork Thu Jan 12 22:34:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bostic X-Patchwork-Id: 9514345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 838D960476 for ; Thu, 12 Jan 2017 22:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89FC22870A for ; Thu, 12 Jan 2017 22:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EA3C28719; Thu, 12 Jan 2017 22:34:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 262AE2870A for ; Thu, 12 Jan 2017 22:34:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRnx9-0001r0-S6; Thu, 12 Jan 2017 22:34:39 +0000 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRnx6-0001gz-Bm for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2017 22:34:38 +0000 Received: by mail-ot0-x244.google.com with SMTP id 73so489434otj.1 for ; Thu, 12 Jan 2017 14:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6cSzcXkCJd1ouU1HMJbnL/8wl0r1Zf+/iUFJGQ1x/Uo=; b=rjDNsdibLoarn1edYex7Uf7YVcqGGf0fgtAVOzTycy1x/e5bTt36buiS10IF7XJwMi Cdrvtb2sBy7d92oB92h4C0bUaTYO/A22VJQuIwYCFvMS33EXvjmBAZJOhi7B88Xf/gNI cO3G64yxu67xC7rNbrR/8Vy7x0IK1RoXIxo9FEbuwF1aocrs21EpzwcGZCFrUKmdQRGr nOsglAvpul9UXuZFA2rjq9bgclC73vfTW9+v8ugy9HdoEzCLYl9fUclF1AZGfk8eVbIi Tv7UY/pmf8RkYpw/xpbXcCT/lH5+wJvyrVCB03d5J45DZmbVSguWD9nLlFT6cq+kdwLL HwWQ== 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; bh=6cSzcXkCJd1ouU1HMJbnL/8wl0r1Zf+/iUFJGQ1x/Uo=; b=lwlL43Ep4oLBrZBr0EvrUaTLiI1QNgZgJ6Vojoa5Wofzq1UKn3BtrrokBrCxaADplq 5Vc4ucnth86d0Gx9cLJhA16iGVY7ERWsameBBQZ0w85tEbQGetAu2p2BbKnGzadGw+DP KOG1h4HDLWUw0gDJHZs9OkKwvZtU/WKh/a2sj3oN6ts8BUteCa8mEo+2BZJFv7dmsld5 lcLR8F3l6zQ5ow30lYVNcvXSE1yzyfUGJzPuvRWkiLuOrQdqmcLFk+d6dJYzFsvLk8Cr FD3pFKE6+W6dzYGug0vCYHL4qngs/U/LQ9faIe39HqjKCs6quttcE3RP4vLg1CTfg4O4 QYgA== X-Gm-Message-State: AIkVDXK4inzRBJu5SZWDU1fStgZxO4bYc1eunykoowMaeVAetBBd/iALZQ3qQN7w04Tabg== X-Received: by 10.157.29.251 with SMTP id w56mr7107943otw.13.1484260455292; Thu, 12 Jan 2017 14:34:15 -0800 (PST) Received: from Christophers-MacBook-Pro.local.com (45-20-192-79.lightspeed.austtx.sbcglobal.net. [45.20.192.79]) by smtp.gmail.com with ESMTPSA id f7sm4913158otb.34.2017.01.12.14.34.14 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 12 Jan 2017 14:34:14 -0800 (PST) From: christopher.lee.bostic@gmail.com To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, mturquette@baylibre.com, geert+renesas@glider.be, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, joel@jms.id.au, jk@ozlabs.org, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: [PATCH v2 13/18] drivers/fsi: Remove all scanned devices during master unregister Date: Thu, 12 Jan 2017 16:34:09 -0600 Message-Id: <1484260449-80182-1-git-send-email-christopher.lee.bostic@gmail.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170112_143436_549201_9F150A73 X-CRM114-Status: UNSURE ( 8.29 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Bostic MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Bostic Master will remove all previously scanned devices during an unregister operation. This will be necessary should any master attempt to register more than once. Signed-off-by: Chris Bostic --- V2 - Remove list heads and explicit master device list management int the fsi master and fsi slave structs. Instead utilize the device_for_each_child method already available. --- drivers/fsi/fsi-core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index af7965f..28b82d1 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -428,12 +428,26 @@ int fsi_master_register(struct fsi_master *master) } EXPORT_SYMBOL_GPL(fsi_master_register); +static int fsi_slave_device_remove(struct device *dev, void *data) +{ + put_device(dev); + return 0; +} + +static int fsi_master_slave_remove(struct device *dev, void *data) +{ + device_for_each_child(dev, NULL, fsi_slave_device_remove); + device_unregister(dev); + return 0; +} + void fsi_master_unregister(struct fsi_master *master) { if (!master || !master->dev) return; ida_simple_remove(&master_ida, master->idx); + device_for_each_child(master->dev, NULL, fsi_master_slave_remove); put_device(master->dev); } EXPORT_SYMBOL_GPL(fsi_master_unregister);