From patchwork Fri Mar 23 08:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 10302901 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 E3CDE60385 for ; Fri, 23 Mar 2018 08:12:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C940428A9C for ; Fri, 23 Mar 2018 08:12:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBBA828AEC; Fri, 23 Mar 2018 08:12:32 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4EE7028A9C for ; Fri, 23 Mar 2018 08:12:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4630A22551BB0; Fri, 23 Mar 2018 01:05:59 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=oohall@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D87E22146720 for ; Fri, 23 Mar 2018 01:05:57 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id a11so1086703pff.8 for ; Fri, 23 Mar 2018 01:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=08DEVr3itYiVos2O7WPC8SknnPT1Z7TCM1BNjqCX0ng=; b=vMDJvW+gUiInpw74dMIDqJbdjwytKQED5yE5yss9mS9leuy7fuI0DK516+DlWFdwF0 QJEFRaacAWFanjQMKVB4XHIj68jD0jtLFkWs3DDDzZqPhrmVLWw8V+ND/g7ooLiTM1Tk 2X7QFIhDASWuQ9JYsa9u8JEp6+U8S2AUlNJgFDfVPKBsBrTLqKPUNqX1awaQxXSRQ2bK KgLdtIbyzLghGfc8ffE3s7VJYsttvM96DPW94iyG4d4x1jiDTTgHZ5jOZDWI0P9J+38r sNpRnw4LntMTGbEN5zhg3XYEnw8Qntew5BWVyBalBNDrzejp8IcBoeHL2XGCZ0tMw7Bk 7zQg== 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; bh=08DEVr3itYiVos2O7WPC8SknnPT1Z7TCM1BNjqCX0ng=; b=M/vcZKb8150XaXuf5JO2VPo9ASMpIhKcP5d1udf16ctGKyl5QNq9FA7x54CncN9eVk Q4kAP/mPSyFIzyfcA78phfNjXUWf8Q1i9vuKBB9OLXqrQnJqgNwqQf1eaX05w4M7fYDp b7PTRUkRHYfZQTTgDQDYTbuuocNNP4Ep15+ovfJowmhyQ2AEtCZf8e7nCSb7HTcR4Mvi TDv9OdwaDPaiGth9VwQtOaYx8AGs06sW7izBIDW9eKvhJbuVcf9nfawt3UqmrVQOX4IZ 8HQ89ymheql94eMng2m0QSQVg5oqyunFLrATFhpCgLcCT4EFHcZ5RyZTrPaAsnCON/3Z 3YdQ== X-Gm-Message-State: AElRT7H3stdIJBCmZf5mgaCU0WJ1Bvoqx+kfNA8TkN502wVNTjTyneno QvoL7WveluXIsDgFk+NAkHlNCg== X-Google-Smtp-Source: AG47ELsUcXfRCABYifRiQFLYREoUMkfneYKXg9+cnQgQtMUnzLXZb5p29H2XS1rUP8jejHmXdQFE6A== X-Received: by 10.99.184.1 with SMTP id p1mr17573416pge.96.1521792749776; Fri, 23 Mar 2018 01:12:29 -0700 (PDT) Received: from localhost.localdomain ([203.220.205.233]) by smtp.gmail.com with ESMTPSA id q67sm7474808pfg.39.2018.03.23.01.12.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 01:12:29 -0700 (PDT) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH 4/6] libnvdimm/of: Symlink platform and region devices Date: Fri, 23 Mar 2018 19:12:07 +1100 Message-Id: <20180323081209.31387-4-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180323081209.31387-1-oohall@gmail.com> References: <20180323081209.31387-1-oohall@gmail.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Add a way direct link between the region and the platform device that creates the region. Signed-off-by: Oliver O'Halloran --- drivers/nvdimm/of_nvdimm.c | 11 +++++++++++ drivers/nvdimm/region_devs.c | 13 +++++++++++++ include/linux/libnvdimm.h | 1 + 3 files changed, 25 insertions(+) diff --git a/drivers/nvdimm/of_nvdimm.c b/drivers/nvdimm/of_nvdimm.c index 79c28291f420..28f4ca23a690 100644 --- a/drivers/nvdimm/of_nvdimm.c +++ b/drivers/nvdimm/of_nvdimm.c @@ -37,6 +37,7 @@ static int of_nd_region_probe(struct platform_device *pdev) struct resource temp_res; struct nd_region *region; struct device_node *np; + int rc; np = dev_of_node(&pdev->dev); if (!np) @@ -71,6 +72,15 @@ static int of_nd_region_probe(struct platform_device *pdev) platform_set_drvdata(pdev, region); + /* + * Add a symlink to the ndbus region object. Without this there's no + * simple way to go from the platform device to the region it spawned. + */ + rc = sysfs_create_link(&pdev->dev.kobj, + nd_region_kobj(region), "region"); + if (rc) + pr_warn("Failed to create symlink to region (rc = %d)!\n", rc); + return 0; } @@ -78,6 +88,7 @@ static int of_nd_region_remove(struct platform_device *pdev) { struct nd_region *r = platform_get_drvdata(pdev); + sysfs_delete_link(&pdev->dev.kobj, nd_region_kobj(r), "region"); nd_region_destroy(r); return 0; diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 76f46fd1fae0..af09acc1d93b 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -1054,6 +1054,19 @@ struct nd_region *nvdimm_volatile_region_create(struct nvdimm_bus *nvdimm_bus, } EXPORT_SYMBOL_GPL(nvdimm_volatile_region_create); +struct kobject *nd_region_kobj(struct nd_region *region) +{ + /* + * region init is async so we need to explicitly synchronise + * to prevent handing out a kobj reference before device_add() + * has been run + */ + nd_synchronize(); + + return ®ion->dev.kobj; +} +EXPORT_SYMBOL_GPL(nd_region_kobj); + /** * nvdimm_flush - flush any posted write queues between the cpu and pmem media * @nd_region: blk or interleaved pmem region diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index df21ca176e98..a4b3663bac38 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -172,6 +172,7 @@ struct nvdimm_bus_descriptor *to_nd_desc(struct nvdimm_bus *nvdimm_bus); struct device *to_nvdimm_bus_dev(struct nvdimm_bus *nvdimm_bus); const char *nvdimm_name(struct nvdimm *nvdimm); struct kobject *nvdimm_kobj(struct nvdimm *nvdimm); +struct kobject *nd_region_kobj(struct nd_region *region); unsigned long nvdimm_cmd_mask(struct nvdimm *nvdimm); void *nvdimm_provider_data(struct nvdimm *nvdimm); struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data,