]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
s390/cio: introduce io_subchannel_type
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Mon, 15 May 2017 13:49:07 +0000 (15:49 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 12 Jun 2017 14:26:01 +0000 (16:26 +0200)
The sysfs attributes implemented by the vfio_ccw driver are also implemented by
the io_subchannel driver. Move these into a device_type which is set by the
css bus.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/css.c
drivers/s390/cio/device.c
drivers/s390/cio/vfio_ccw_drv.c

index e2aa944eb566dbce3cfaf0b7df830e3cf42f3155..d3e504c3c362655f4eec5903893d8bc8f8e5af2c 100644 (file)
@@ -296,6 +296,51 @@ static const struct attribute_group *default_subch_attr_groups[] = {
        NULL,
 };
 
+static ssize_t chpids_show(struct device *dev,
+                          struct device_attribute *attr,
+                          char *buf)
+{
+       struct subchannel *sch = to_subchannel(dev);
+       struct chsc_ssd_info *ssd = &sch->ssd_info;
+       ssize_t ret = 0;
+       int mask;
+       int chp;
+
+       for (chp = 0; chp < 8; chp++) {
+               mask = 0x80 >> chp;
+               if (ssd->path_mask & mask)
+                       ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id);
+               else
+                       ret += sprintf(buf + ret, "00 ");
+       }
+       ret += sprintf(buf + ret, "\n");
+       return ret;
+}
+static DEVICE_ATTR(chpids, 0444, chpids_show, NULL);
+
+static ssize_t pimpampom_show(struct device *dev,
+                             struct device_attribute *attr,
+                             char *buf)
+{
+       struct subchannel *sch = to_subchannel(dev);
+       struct pmcw *pmcw = &sch->schib.pmcw;
+
+       return sprintf(buf, "%02x %02x %02x\n",
+                      pmcw->pim, pmcw->pam, pmcw->pom);
+}
+static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL);
+
+static struct attribute *io_subchannel_type_attrs[] = {
+       &dev_attr_chpids.attr,
+       &dev_attr_pimpampom.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(io_subchannel_type);
+
+static const struct device_type io_subchannel_type = {
+       .groups = io_subchannel_type_groups,
+};
+
 int css_register_subchannel(struct subchannel *sch)
 {
        int ret;
@@ -304,6 +349,10 @@ int css_register_subchannel(struct subchannel *sch)
        sch->dev.parent = &channel_subsystems[0]->device;
        sch->dev.bus = &css_bus_type;
        sch->dev.groups = default_subch_attr_groups;
+
+       if (sch->st == SUBCHANNEL_TYPE_IO)
+               sch->dev.type = &io_subchannel_type;
+
        /*
         * We don't want to generate uevents for I/O subchannels that don't
         * have a working ccw device behind them since they will be
index b8006ea9099cd910d75531a9dcbe95d5b62f409d..7be01a58b44f78ee01bfbda5c068a710434a65a1 100644 (file)
@@ -208,44 +208,6 @@ int __init io_subchannel_init(void)
 
 /************************ device handling **************************/
 
-/*
- * A ccw_device has some interfaces in sysfs in addition to the
- * standard ones.
- * The following entries are designed to export the information which
- * resided in 2.4 in /proc/subchannels. Subchannel and device number
- * are obvious, so they don't have an entry :)
- * TODO: Split chpids and pimpampom up? Where is "in use" in the tree?
- */
-static ssize_t
-chpids_show (struct device * dev, struct device_attribute *attr, char * buf)
-{
-       struct subchannel *sch = to_subchannel(dev);
-       struct chsc_ssd_info *ssd = &sch->ssd_info;
-       ssize_t ret = 0;
-       int chp;
-       int mask;
-
-       for (chp = 0; chp < 8; chp++) {
-               mask = 0x80 >> chp;
-               if (ssd->path_mask & mask)
-                       ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id);
-               else
-                       ret += sprintf(buf + ret, "00 ");
-       }
-       ret += sprintf (buf+ret, "\n");
-       return min((ssize_t)PAGE_SIZE, ret);
-}
-
-static ssize_t
-pimpampom_show (struct device * dev, struct device_attribute *attr, char * buf)
-{
-       struct subchannel *sch = to_subchannel(dev);
-       struct pmcw *pmcw = &sch->schib.pmcw;
-
-       return sprintf (buf, "%02x %02x %02x\n",
-                       pmcw->pim, pmcw->pam, pmcw->pom);
-}
-
 static ssize_t
 devtype_show (struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -636,8 +598,6 @@ static ssize_t vpm_show(struct device *dev, struct device_attribute *attr,
        return sprintf(buf, "%02x\n", sch->vpm);
 }
 
-static DEVICE_ATTR(chpids, 0444, chpids_show, NULL);
-static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL);
 static DEVICE_ATTR(devtype, 0444, devtype_show, NULL);
 static DEVICE_ATTR(cutype, 0444, cutype_show, NULL);
 static DEVICE_ATTR(modalias, 0444, modalias_show, NULL);
@@ -647,8 +607,6 @@ static DEVICE_ATTR(logging, 0200, NULL, initiate_logging);
 static DEVICE_ATTR(vpm, 0444, vpm_show, NULL);
 
 static struct attribute *io_subchannel_attrs[] = {
-       &dev_attr_chpids.attr,
-       &dev_attr_pimpampom.attr,
        &dev_attr_logging.attr,
        &dev_attr_vpm.attr,
        NULL,
index e90dd43d2a556c390b92fcc188f6470404910faf..a25367ebaa89595971f859e56f4142434e12e4e7 100644 (file)
@@ -89,54 +89,6 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
                private->state = VFIO_CCW_STATE_IDLE;
 }
 
-/*
- * Sysfs interfaces
- */
-static ssize_t chpids_show(struct device *dev,
-                          struct device_attribute *attr,
-                          char *buf)
-{
-       struct subchannel *sch = to_subchannel(dev);
-       struct chsc_ssd_info *ssd = &sch->ssd_info;
-       ssize_t ret = 0;
-       int chp;
-       int mask;
-
-       for (chp = 0; chp < 8; chp++) {
-               mask = 0x80 >> chp;
-               if (ssd->path_mask & mask)
-                       ret += sprintf(buf + ret, "%02x ", ssd->chpid[chp].id);
-               else
-                       ret += sprintf(buf + ret, "00 ");
-       }
-       ret += sprintf(buf+ret, "\n");
-       return ret;
-}
-
-static ssize_t pimpampom_show(struct device *dev,
-                             struct device_attribute *attr,
-                             char *buf)
-{
-       struct subchannel *sch = to_subchannel(dev);
-       struct pmcw *pmcw = &sch->schib.pmcw;
-
-       return sprintf(buf, "%02x %02x %02x\n",
-                      pmcw->pim, pmcw->pam, pmcw->pom);
-}
-
-static DEVICE_ATTR(chpids, 0444, chpids_show, NULL);
-static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL);
-
-static struct attribute *vfio_subchannel_attrs[] = {
-       &dev_attr_chpids.attr,
-       &dev_attr_pimpampom.attr,
-       NULL,
-};
-
-static struct attribute_group vfio_subchannel_attr_group = {
-       .attrs = vfio_subchannel_attrs,
-};
-
 /*
  * Css driver callbacks
  */
@@ -174,13 +126,9 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
        if (ret)
                goto out_free;
 
-       ret = sysfs_create_group(&sch->dev.kobj, &vfio_subchannel_attr_group);
-       if (ret)
-               goto out_disable;
-
        ret = vfio_ccw_mdev_reg(sch);
        if (ret)
-               goto out_rm_group;
+               goto out_disable;
 
        INIT_WORK(&private->io_work, vfio_ccw_sch_io_todo);
        atomic_set(&private->avail, 1);
@@ -188,8 +136,6 @@ static int vfio_ccw_sch_probe(struct subchannel *sch)
 
        return 0;
 
-out_rm_group:
-       sysfs_remove_group(&sch->dev.kobj, &vfio_subchannel_attr_group);
 out_disable:
        cio_disable_subchannel(sch);
 out_free:
@@ -206,8 +152,6 @@ static int vfio_ccw_sch_remove(struct subchannel *sch)
 
        vfio_ccw_mdev_unreg(sch);
 
-       sysfs_remove_group(&sch->dev.kobj, &vfio_subchannel_attr_group);
-
        dev_set_drvdata(&sch->dev, NULL);
 
        kfree(private);