1 // SPDX-License-Identifier: GPL-2.0
3 * Device driver for s390 storage class memory.
5 * Copyright IBM Corp. 2012
6 * Author(s): Sebastian Ott <sebott@linux.vnet.ibm.com>
9 #define KMSG_COMPONENT "scm_block"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
13 #include <linux/slab.h>
17 static void scm_notify(struct scm_device
*scmdev
, enum scm_event event
)
19 struct scm_blk_dev
*bdev
= dev_get_drvdata(&scmdev
->dev
);
23 pr_info("%lx: The capabilities of the SCM increment changed\n",
24 (unsigned long) scmdev
->address
);
25 SCM_LOG(2, "State changed");
26 SCM_LOG_STATE(2, scmdev
);
29 SCM_LOG(2, "Increment available");
30 SCM_LOG_STATE(2, scmdev
);
31 scm_blk_set_available(bdev
);
36 static int scm_probe(struct scm_device
*scmdev
)
38 struct scm_blk_dev
*bdev
;
42 SCM_LOG_STATE(2, scmdev
);
44 if (scmdev
->attrs
.oper_state
!= OP_STATE_GOOD
)
47 bdev
= kzalloc(sizeof(*bdev
), GFP_KERNEL
);
51 dev_set_drvdata(&scmdev
->dev
, bdev
);
52 ret
= scm_blk_dev_setup(bdev
, scmdev
);
54 dev_set_drvdata(&scmdev
->dev
, NULL
);
63 static int scm_remove(struct scm_device
*scmdev
)
65 struct scm_blk_dev
*bdev
= dev_get_drvdata(&scmdev
->dev
);
67 scm_blk_dev_cleanup(bdev
);
68 dev_set_drvdata(&scmdev
->dev
, NULL
);
74 static struct scm_driver scm_drv
= {
82 .handler
= scm_blk_irq
,
85 int __init
scm_drv_init(void)
87 return scm_driver_register(&scm_drv
);
90 void scm_drv_cleanup(void)
92 scm_driver_unregister(&scm_drv
);