Skip to content

Commit de5d35a

Browse files
umakrishnmartinkpetersen
authored andcommitted
scsi: cxlflash: Abstract hardware dependent assignments
As a staging cleanup to support transport specific builds of the cxlflash module, relocate device dependent assignments to header files. This will avoid littering the core driver with conditional compilation logic. Signed-off-by: Uma Krishnan <[email protected]> Acked-by: Matthew R. Ochs <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 5e12397 commit de5d35a

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

drivers/scsi/cxlflash/main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3708,11 +3708,8 @@ static int cxlflash_probe(struct pci_dev *pdev,
37083708
cfg->init_state = INIT_STATE_NONE;
37093709
cfg->dev = pdev;
37103710
cfg->cxl_fops = cxlflash_cxl_fops;
3711-
3712-
if (ddv->flags & CXLFLASH_OCXL_DEV)
3713-
cfg->ops = &cxlflash_ocxl_ops;
3714-
else
3715-
cfg->ops = &cxlflash_cxl_ops;
3711+
cfg->ops = cxlflash_assign_ops(ddv);
3712+
WARN_ON_ONCE(!cfg->ops);
37163713

37173714
/*
37183715
* Promoted LUNs move to the top of the LUN table. The rest stay on

drivers/scsi/cxlflash/main.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <scsi/scsi.h>
2121
#include <scsi/scsi_device.h>
2222

23+
#include "backend.h"
24+
2325
#define CXLFLASH_NAME "cxlflash"
2426
#define CXLFLASH_ADAPTER_NAME "IBM POWER CXL Flash Adapter"
2527
#define CXLFLASH_MAX_ADAPTERS 32
@@ -100,6 +102,19 @@ struct dev_dependent_vals {
100102
#define CXLFLASH_OCXL_DEV 0x0000000000000004ULL
101103
};
102104

105+
static inline const struct cxlflash_backend_ops *
106+
cxlflash_assign_ops(struct dev_dependent_vals *ddv)
107+
{
108+
const struct cxlflash_backend_ops *ops = NULL;
109+
110+
if (ddv->flags & CXLFLASH_OCXL_DEV)
111+
ops = &cxlflash_ocxl_ops;
112+
if (!(ddv->flags & CXLFLASH_OCXL_DEV))
113+
ops = &cxlflash_cxl_ops;
114+
115+
return ops;
116+
}
117+
103118
struct asyc_intr_info {
104119
u64 status;
105120
char *desc;

0 commit comments

Comments
 (0)