From f30664e2c85c7804f07c636bbe99f35e0b2d4c76 Mon Sep 17 00:00:00 2001 From: Sebastian Ott Date: Tue, 28 Aug 2012 16:50:38 +0200 Subject: s390: add scm block driver Block device driver for Storage Class Memory (SCM). This driver provides a block device interface for each available SCM increment. Signed-off-by: Sebastian Ott Signed-off-by: Martin Schwidefsky --- drivers/s390/block/scm_drv.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 drivers/s390/block/scm_drv.c (limited to 'drivers/s390/block/scm_drv.c') diff --git a/drivers/s390/block/scm_drv.c b/drivers/s390/block/scm_drv.c new file mode 100644 index 000000000000..fce711a63060 --- /dev/null +++ b/drivers/s390/block/scm_drv.c @@ -0,0 +1,90 @@ +/* + * Device driver for s390 storage class memory. + * + * Copyright IBM Corp. 2012 + * Author(s): Sebastian Ott + */ + +#define KMSG_COMPONENT "scm_block" +#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt + +#include +#include +#include +#include +#include "scm_blk.h" + +static void notify(struct scm_device *scmdev) +{ + pr_info("%lu: The capabilities of the SCM increment changed\n", + (unsigned long) scmdev->address); + SCM_LOG(2, "State changed"); + SCM_LOG_STATE(2, scmdev); +} + +static int scm_probe(struct scm_device *scmdev) +{ + struct scm_blk_dev *bdev; + int ret; + + SCM_LOG(2, "probe"); + SCM_LOG_STATE(2, scmdev); + + if (scmdev->attrs.oper_state != OP_STATE_GOOD) + return -EINVAL; + + bdev = kzalloc(sizeof(*bdev), GFP_KERNEL); + if (!bdev) + return -ENOMEM; + + spin_lock_irq(&scmdev->lock); + dev_set_drvdata(&scmdev->dev, bdev); + spin_unlock_irq(&scmdev->lock); + + ret = scm_blk_dev_setup(bdev, scmdev); + if (ret) { + spin_lock_irq(&scmdev->lock); + dev_set_drvdata(&scmdev->dev, NULL); + spin_unlock_irq(&scmdev->lock); + kfree(bdev); + goto out; + } + +out: + return ret; +} + +static int scm_remove(struct scm_device *scmdev) +{ + struct scm_blk_dev *bdev; + + spin_lock_irq(&scmdev->lock); + bdev = dev_get_drvdata(&scmdev->dev); + dev_set_drvdata(&scmdev->dev, NULL); + spin_unlock_irq(&scmdev->lock); + scm_blk_dev_cleanup(bdev); + kfree(bdev); + + return 0; +} + +static struct scm_driver scm_drv = { + .drv = { + .name = "scm_block", + .owner = THIS_MODULE, + }, + .notify = notify, + .probe = scm_probe, + .remove = scm_remove, + .handler = scm_blk_irq, +}; + +int __init scm_drv_init(void) +{ + return scm_driver_register(&scm_drv); +} + +void scm_drv_cleanup(void) +{ + scm_driver_unregister(&scm_drv); +} -- cgit v1.2.3