tools/testing/nvdimm/test/iomap.c

Source file repositories/reference/linux-study-clean/tools/testing/nvdimm/test/iomap.c

File Facts

System
Linux kernel
Corpus path
tools/testing/nvdimm/test/iomap.c
Extension
.c
Size
10083 bytes
Lines
401
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (nfit_res) {
			struct nfit_test_request *req;
			struct resource *res = NULL;

			if (dev) {
				devres_release(dev, nfit_devres_release, match,
						&start);
				return true;
			}

			spin_lock(&nfit_res->lock);
			list_for_each_entry(req, &nfit_res->requests, list)
				if (req->res.start == start) {
					res = &req->res;
					list_del(&req->list);
					break;
				}
			spin_unlock(&nfit_res->lock);

			WARN(!res || resource_size(res) != n,
					"%s: start: %llx n: %llx mismatch: %pr\n",
						__func__, start, n, res);
			if (res)
				kfree(req);
			return true;
		}
	}
	return false;
}

static struct resource *nfit_test_request_region(struct device *dev,
		struct resource *parent, resource_size_t start,
		resource_size_t n, const char *name, int flags)
{
	struct nfit_test_resource *nfit_res;

	if (parent == &iomem_resource) {
		nfit_res = get_nfit_res(start);
		if (nfit_res) {
			struct nfit_test_request *req;
			struct resource *res = NULL;

			if (start + n > nfit_res->res.start
					+ resource_size(&nfit_res->res)) {
				pr_debug("%s: start: %llx n: %llx overflow: %pr\n",
						__func__, start, n,
						&nfit_res->res);
				return NULL;
			}

			spin_lock(&nfit_res->lock);
			list_for_each_entry(req, &nfit_res->requests, list)
				if (start == req->res.start) {
					res = &req->res;
					break;
				}
			spin_unlock(&nfit_res->lock);

			if (res) {
				WARN(1, "%pr already busy\n", res);
				return NULL;
			}

			req = kzalloc(sizeof(*req), GFP_KERNEL);
			if (!req)
				return NULL;
			INIT_LIST_HEAD(&req->list);
			res = &req->res;

			res->start = start;
			res->end = start + n - 1;
			res->name = name;
			res->flags = resource_type(parent);
			res->flags |= IORESOURCE_BUSY | flags;
			spin_lock(&nfit_res->lock);
			list_add(&req->list, &nfit_res->requests);
			spin_unlock(&nfit_res->lock);

			if (dev) {
				struct resource **d;

				d = devres_alloc(nfit_devres_release,
						sizeof(struct resource *),
						GFP_KERNEL);
				if (!d)
					return NULL;
				*d = res;
				devres_add(dev, d);
			}

Annotation

Implementation Notes