drivers/nvdimm/nd.h

Source file repositories/reference/linux-study-clean/drivers/nvdimm/nd.h

File Facts

System
Linux kernel
Corpus path
drivers/nvdimm/nd.h
Extension
.h
Size
18582 bytes
Lines
692
Domain
Driver Families
Bucket
drivers/nvdimm
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nvdimm_drvdata {
	struct device *dev;
	int nslabel_size;
	struct nd_cmd_get_config_size nsarea;
	void *data;
	bool cxl;
	int ns_current, ns_next;
	struct resource dpa;
	struct kref kref;
};

static inline const u8 *nsl_ref_name(struct nvdimm_drvdata *ndd,
				     struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return nd_label->cxl.name;
	return nd_label->efi.name;
}

static inline u8 *nsl_get_name(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label, u8 *name)
{
	if (ndd->cxl)
		return memcpy(name, nd_label->cxl.name, NSLABEL_NAME_LEN);
	return memcpy(name, nd_label->efi.name, NSLABEL_NAME_LEN);
}

static inline u8 *nsl_set_name(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label, u8 *name)
{
	if (!name)
		return NULL;
	if (ndd->cxl)
		return memcpy(nd_label->cxl.name, name, NSLABEL_NAME_LEN);
	return memcpy(nd_label->efi.name, name, NSLABEL_NAME_LEN);
}

static inline u32 nsl_get_slot(struct nvdimm_drvdata *ndd,
			       struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le32_to_cpu(nd_label->cxl.slot);
	return __le32_to_cpu(nd_label->efi.slot);
}

static inline void nsl_set_slot(struct nvdimm_drvdata *ndd,
				struct nd_namespace_label *nd_label, u32 slot)
{
	if (ndd->cxl)
		nd_label->cxl.slot = __cpu_to_le32(slot);
	else
		nd_label->efi.slot = __cpu_to_le32(slot);
}

static inline u64 nsl_get_checksum(struct nvdimm_drvdata *ndd,
				   struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le64_to_cpu(nd_label->cxl.checksum);
	return __le64_to_cpu(nd_label->efi.checksum);
}

static inline void nsl_set_checksum(struct nvdimm_drvdata *ndd,
				    struct nd_namespace_label *nd_label,
				    u64 checksum)
{
	if (ndd->cxl)
		nd_label->cxl.checksum = __cpu_to_le64(checksum);
	else
		nd_label->efi.checksum = __cpu_to_le64(checksum);
}

static inline u32 nsl_get_flags(struct nvdimm_drvdata *ndd,
				struct nd_namespace_label *nd_label)
{
	if (ndd->cxl)
		return __le32_to_cpu(nd_label->cxl.flags);
	return __le32_to_cpu(nd_label->efi.flags);
}

static inline void nsl_set_flags(struct nvdimm_drvdata *ndd,
				 struct nd_namespace_label *nd_label, u32 flags)
{
	if (ndd->cxl)
		nd_label->cxl.flags = __cpu_to_le32(flags);
	else
		nd_label->efi.flags = __cpu_to_le32(flags);
}

static inline u64 nsl_get_dpa(struct nvdimm_drvdata *ndd,

Annotation

Implementation Notes