Skip to content

Commit

Permalink
s390: remove cu3088 layer for lcs and ctcm
Browse files Browse the repository at this point in the history
The cu3088-driver used as common base for lcs- and ctcm-devices
makes it difficult to assign the appropriate driver to an lcs-device
or a ctcm-device. This patch eliminates the cu3088-driver and thus
the root device "cu3088". Path /sys/devices/cu3088 is replaced with
the pathes /sys/devices/lcs and /sys/devices/ctcm.

Patch is based on a proposal from Cornelia Huck.

Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ursula Braun authored and David S. Miller committed Nov 14, 2009
1 parent 1e1815b commit 0ca8cc6
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 242 deletions.
6 changes: 3 additions & 3 deletions drivers/s390/net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#

ctcm-y += ctcm_main.o ctcm_fsms.o ctcm_mpc.o ctcm_sysfs.o ctcm_dbug.o
obj-$(CONFIG_CTCM) += ctcm.o fsm.o cu3088.o
obj-$(CONFIG_CTCM) += ctcm.o fsm.o
obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o
obj-$(CONFIG_SMSGIUCV) += smsgiucv.o
obj-$(CONFIG_LCS) += lcs.o cu3088.o
obj-$(CONFIG_CLAW) += claw.o cu3088.o
obj-$(CONFIG_LCS) += lcs.o
obj-$(CONFIG_CLAW) += claw.o
qeth-y += qeth_core_sys.o qeth_core_main.o qeth_core_mpc.o
obj-$(CONFIG_QETH) += qeth.o
qeth_l2-y += qeth_l2_main.o
Expand Down
82 changes: 72 additions & 10 deletions drivers/s390/net/claw.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
#include <linux/timer.h>
#include <linux/types.h>

#include "cu3088.h"
#include "claw.h"

/*
Expand Down Expand Up @@ -258,6 +257,9 @@ static int claw_pm_prepare(struct ccwgroup_device *gdev)
return -EPERM;
}

/* the root device for claw group devices */
static struct device *claw_root_dev;

/* ccwgroup table */

static struct ccwgroup_driver claw_group_driver = {
Expand All @@ -272,6 +274,47 @@ static struct ccwgroup_driver claw_group_driver = {
.prepare = claw_pm_prepare,
};

static struct ccw_device_id claw_ids[] = {
{CCW_DEVICE(0x3088, 0x61), .driver_info = claw_channel_type_claw},
{},
};
MODULE_DEVICE_TABLE(ccw, claw_ids);

static struct ccw_driver claw_ccw_driver = {
.owner = THIS_MODULE,
.name = "claw",
.ids = claw_ids,
.probe = ccwgroup_probe_ccwdev,
.remove = ccwgroup_remove_ccwdev,
};

static ssize_t
claw_driver_group_store(struct device_driver *ddrv, const char *buf,
size_t count)
{
int err;
err = ccwgroup_create_from_string(claw_root_dev,
claw_group_driver.driver_id,
&claw_ccw_driver, 3, buf);
return err ? err : count;
}

static DRIVER_ATTR(group, 0200, NULL, claw_driver_group_store);

static struct attribute *claw_group_attrs[] = {
&driver_attr_group.attr,
NULL,
};

static struct attribute_group claw_group_attr_group = {
.attrs = claw_group_attrs,
};

static struct attribute_group *claw_group_attr_groups[] = {
&claw_group_attr_group,
NULL,
};

/*
* Key functions
*/
Expand Down Expand Up @@ -3326,7 +3369,11 @@ claw_remove_files(struct device *dev)
static void __exit
claw_cleanup(void)
{
unregister_cu3088_discipline(&claw_group_driver);
driver_remove_file(&claw_group_driver.driver,
&driver_attr_group);
ccwgroup_driver_unregister(&claw_group_driver);
ccw_driver_unregister(&claw_ccw_driver);
root_device_unregister(claw_root_dev);
claw_unregister_debug_facility();
pr_info("Driver unloaded\n");

Expand All @@ -3348,16 +3395,31 @@ claw_init(void)
if (ret) {
pr_err("Registering with the S/390 debug feature"
" failed with error code %d\n", ret);
return ret;
goto out_err;
}
CLAW_DBF_TEXT(2, setup, "init_mod");
ret = register_cu3088_discipline(&claw_group_driver);
if (ret) {
CLAW_DBF_TEXT(2, setup, "init_bad");
claw_unregister_debug_facility();
pr_err("Registering with the cu3088 device driver failed "
"with error code %d\n", ret);
}
claw_root_dev = root_device_register("qeth");
ret = IS_ERR(claw_root_dev) ? PTR_ERR(claw_root_dev) : 0;
if (ret)
goto register_err;
ret = ccw_driver_register(&claw_ccw_driver);
if (ret)
goto ccw_err;
claw_group_driver.driver.groups = claw_group_attr_groups;
ret = ccwgroup_driver_register(&claw_group_driver);
if (ret)
goto ccwgroup_err;
return 0;

ccwgroup_err:
ccw_driver_unregister(&claw_ccw_driver);
ccw_err:
root_device_unregister(claw_root_dev);
register_err:
CLAW_DBF_TEXT(2, setup, "init_bad");
claw_unregister_debug_facility();
out_err:
pr_err("Initializing the claw device driver failed\n");
return ret;
}

Expand Down
12 changes: 12 additions & 0 deletions drivers/s390/net/claw.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ static inline int claw_dbf_passes(debug_info_t *dbf_grp, int level)
} \
} while (0)

/**
* Enum for classifying detected devices.
*/
enum claw_channel_types {
/* Device is not a channel */
claw_channel_type_none,

/* Device is a CLAW channel device */
claw_channel_type_claw
};


/*******************************************************
* Define Control Blocks *
* *
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/net/ctcm_fsms.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include <asm/idals.h>

#include "fsm.h"
#include "cu3088.h"

#include "ctcm_dbug.h"
#include "ctcm_main.h"
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/net/ctcm_fsms.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <asm/idals.h>

#include "fsm.h"
#include "cu3088.h"
#include "ctcm_main.h"

/*
Expand Down
104 changes: 84 additions & 20 deletions drivers/s390/net/ctcm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@

#include <asm/idals.h>

#include "cu3088.h"
#include "ctcm_fsms.h"
#include "ctcm_main.h"

/* Some common global variables */

/**
* The root device for ctcm group devices
*/
static struct device *ctcm_root_dev;

/*
* Linked list of all detected channels.
*/
Expand Down Expand Up @@ -246,7 +250,7 @@ static void channel_remove(struct channel *ch)
*
* returns Pointer to a channel or NULL if no matching channel available.
*/
static struct channel *channel_get(enum channel_types type,
static struct channel *channel_get(enum ctcm_channel_types type,
char *id, int direction)
{
struct channel *ch = channels;
Expand Down Expand Up @@ -1342,7 +1346,7 @@ static int ctcm_probe_device(struct ccwgroup_device *cgdev)
*
* returns 0 on success, !0 on error.
*/
static int add_channel(struct ccw_device *cdev, enum channel_types type,
static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type,
struct ctcm_priv *priv)
{
struct channel **c = &channels;
Expand Down Expand Up @@ -1501,13 +1505,13 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type,
/*
* Return type of a detected device.
*/
static enum channel_types get_channel_type(struct ccw_device_id *id)
static enum ctcm_channel_types get_channel_type(struct ccw_device_id *id)
{
enum channel_types type;
type = (enum channel_types)id->driver_info;
enum ctcm_channel_types type;
type = (enum ctcm_channel_types)id->driver_info;

if (type == channel_type_ficon)
type = channel_type_escon;
if (type == ctcm_channel_type_ficon)
type = ctcm_channel_type_escon;

return type;
}
Expand All @@ -1525,7 +1529,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
char read_id[CTCM_ID_SIZE];
char write_id[CTCM_ID_SIZE];
int direction;
enum channel_types type;
enum ctcm_channel_types type;
struct ctcm_priv *priv;
struct net_device *dev;
struct ccw_device *cdev0;
Expand Down Expand Up @@ -1749,6 +1753,22 @@ static int ctcm_pm_resume(struct ccwgroup_device *gdev)
return rc;
}

static struct ccw_device_id ctcm_ids[] = {
{CCW_DEVICE(0x3088, 0x08), .driver_info = ctcm_channel_type_parallel},
{CCW_DEVICE(0x3088, 0x1e), .driver_info = ctcm_channel_type_ficon},
{CCW_DEVICE(0x3088, 0x1f), .driver_info = ctcm_channel_type_escon},
{},
};
MODULE_DEVICE_TABLE(ccw, ctcm_ids);

static struct ccw_driver ctcm_ccw_driver = {
.owner = THIS_MODULE,
.name = "ctcm",
.ids = ctcm_ids,
.probe = ccwgroup_probe_ccwdev,
.remove = ccwgroup_remove_ccwdev,
};

static struct ccwgroup_driver ctcm_group_driver = {
.owner = THIS_MODULE,
.name = CTC_DRIVER_NAME,
Expand All @@ -1763,6 +1783,33 @@ static struct ccwgroup_driver ctcm_group_driver = {
.restore = ctcm_pm_resume,
};

static ssize_t
ctcm_driver_group_store(struct device_driver *ddrv, const char *buf,
size_t count)
{
int err;

err = ccwgroup_create_from_string(ctcm_root_dev,
ctcm_group_driver.driver_id,
&ctcm_ccw_driver, 2, buf);
return err ? err : count;
}

static DRIVER_ATTR(group, 0200, NULL, ctcm_driver_group_store);

static struct attribute *ctcm_group_attrs[] = {
&driver_attr_group.attr,
NULL,
};

static struct attribute_group ctcm_group_attr_group = {
.attrs = ctcm_group_attrs,
};

static struct attribute_group *ctcm_group_attr_groups[] = {
&ctcm_group_attr_group,
NULL,
};

/*
* Module related routines
Expand All @@ -1776,7 +1823,10 @@ static struct ccwgroup_driver ctcm_group_driver = {
*/
static void __exit ctcm_exit(void)
{
unregister_cu3088_discipline(&ctcm_group_driver);
driver_remove_file(&ctcm_group_driver.driver, &driver_attr_group);
ccwgroup_driver_unregister(&ctcm_group_driver);
ccw_driver_unregister(&ctcm_ccw_driver);
root_device_unregister(ctcm_root_dev);
ctcm_unregister_dbf_views();
pr_info("CTCM driver unloaded\n");
}
Expand All @@ -1802,17 +1852,31 @@ static int __init ctcm_init(void)
channels = NULL;

ret = ctcm_register_dbf_views();
if (ret) {
return ret;
}
ret = register_cu3088_discipline(&ctcm_group_driver);
if (ret) {
ctcm_unregister_dbf_views();
pr_err("%s / register_cu3088_discipline failed, ret = %d\n",
__func__, ret);
return ret;
}
if (ret)
goto out_err;
ctcm_root_dev = root_device_register("ctcm");
ret = IS_ERR(ctcm_root_dev) ? PTR_ERR(ctcm_root_dev) : 0;
if (ret)
goto register_err;
ret = ccw_driver_register(&ctcm_ccw_driver);
if (ret)
goto ccw_err;
ctcm_group_driver.driver.groups = ctcm_group_attr_groups;
ret = ccwgroup_driver_register(&ctcm_group_driver);
if (ret)
goto ccwgroup_err;
print_banner();
return 0;

ccwgroup_err:
ccw_driver_unregister(&ctcm_ccw_driver);
ccw_err:
root_device_unregister(ctcm_root_dev);
register_err:
ctcm_unregister_dbf_views();
out_err:
pr_err("%s / Initializing the ctcm device driver failed, ret = %d\n",
__func__, ret);
return ret;
}

Expand Down
20 changes: 18 additions & 2 deletions drivers/s390/net/ctcm_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <linux/netdevice.h>

#include "fsm.h"
#include "cu3088.h"
#include "ctcm_dbug.h"
#include "ctcm_mpc.h"

Expand Down Expand Up @@ -66,6 +65,23 @@
ctcmpc_dumpit(buf, len); \
} while (0)

/**
* Enum for classifying detected devices
*/
enum ctcm_channel_types {
/* Device is not a channel */
ctcm_channel_type_none,

/* Device is a CTC/A */
ctcm_channel_type_parallel,

/* Device is a FICON channel */
ctcm_channel_type_ficon,

/* Device is a ESCON channel */
ctcm_channel_type_escon
};

/*
* CCW commands, used in this driver.
*/
Expand Down Expand Up @@ -121,7 +137,7 @@ struct channel {
* Type of this channel.
* CTC/A or Escon for valid channels.
*/
enum channel_types type;
enum ctcm_channel_types type;
/*
* Misc. flags. See CHANNEL_FLAGS_... below
*/
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/net/ctcm_mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
#include <linux/moduleparam.h>
#include <asm/idals.h>

#include "cu3088.h"
#include "ctcm_mpc.h"
#include "ctcm_main.h"
#include "ctcm_fsms.h"
Expand Down
Loading

0 comments on commit 0ca8cc6

Please sign in to comment.