aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/cxl/mock_pmem.c
blob: f7315e6f52c0fd36170ee2bd20dd019d59148ead (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2021 Intel Corporation. All rights reserved. */
#include <cxl.h>
#include "test/mock.h"
#include <core/core.h>

int match_nvdimm_bridge(struct device *dev, const void *data)
{
	int index, rc = 0;
	struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
	const struct cxl_nvdimm *cxl_nvd = data;

	if (ops) {
		if (dev->type == &cxl_nvdimm_bridge_type &&
		    (ops->is_mock_dev(dev->parent->parent) ==
		     ops->is_mock_dev(cxl_nvd->dev.parent->parent)))
			rc = 1;
	} else
		rc = dev->type == &cxl_nvdimm_bridge_type;

	put_cxl_mock_ops(index);

	return rc;
}