Commit 98cc43ab authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

s390/cio: clarify cssid usage

Currently the cssid in various structures is used as the id of
the respective channel subsystem. Sometimes however we call the
index in the channel_subsystems array cssid. In some places the
id is even used as the index.

Provide a new define MAX_CSS_IDX and use it where appropriate.
In addition to that provide a dummy function to find a channel
subsystem by its id and a macro to iterate over the channel
subsystems.
Signed-off-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 57c52ae7
...@@ -444,6 +444,7 @@ int chp_update_desc(struct channel_path *chp) ...@@ -444,6 +444,7 @@ int chp_update_desc(struct channel_path *chp)
*/ */
int chp_new(struct chp_id chpid) int chp_new(struct chp_id chpid)
{ {
struct channel_subsystem *css = css_by_id(chpid.cssid);
struct channel_path *chp; struct channel_path *chp;
int ret; int ret;
...@@ -456,7 +457,7 @@ int chp_new(struct chp_id chpid) ...@@ -456,7 +457,7 @@ int chp_new(struct chp_id chpid)
/* fill in status, etc. */ /* fill in status, etc. */
chp->chpid = chpid; chp->chpid = chpid;
chp->state = 1; chp->state = 1;
chp->dev.parent = &channel_subsystems[chpid.cssid]->device; chp->dev.parent = &css->device;
chp->dev.groups = chp_attr_groups; chp->dev.groups = chp_attr_groups;
chp->dev.release = chp_release; chp->dev.release = chp_release;
mutex_init(&chp->lock); mutex_init(&chp->lock);
...@@ -479,17 +480,17 @@ int chp_new(struct chp_id chpid) ...@@ -479,17 +480,17 @@ int chp_new(struct chp_id chpid)
put_device(&chp->dev); put_device(&chp->dev);
goto out; goto out;
} }
mutex_lock(&channel_subsystems[chpid.cssid]->mutex); mutex_lock(&css->mutex);
if (channel_subsystems[chpid.cssid]->cm_enabled) { if (css->cm_enabled) {
ret = chp_add_cmg_attr(chp); ret = chp_add_cmg_attr(chp);
if (ret) { if (ret) {
device_unregister(&chp->dev); device_unregister(&chp->dev);
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); mutex_unlock(&css->mutex);
goto out; goto out;
} }
} }
channel_subsystems[chpid.cssid]->chps[chpid.id] = chp; css->chps[chpid.id] = chp;
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); mutex_unlock(&css->mutex);
goto out; goto out;
out_free: out_free:
kfree(chp); kfree(chp);
......
...@@ -54,7 +54,7 @@ struct channel_path { ...@@ -54,7 +54,7 @@ struct channel_path {
/* Return channel_path struct for given chpid. */ /* Return channel_path struct for given chpid. */
static inline struct channel_path *chpid_to_chp(struct chp_id chpid) static inline struct channel_path *chpid_to_chp(struct chp_id chpid)
{ {
return channel_subsystems[chpid.cssid]->chps[chpid.id]; return css_by_id(chpid.cssid)->chps[chpid.id];
} }
int chp_get_status(struct chp_id chpid); int chp_get_status(struct chp_id chpid);
......
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
int css_init_done = 0; int css_init_done = 0;
int max_ssid; int max_ssid;
struct channel_subsystem *channel_subsystems[__MAX_CSSID + 1]; #define MAX_CSS_IDX 0
struct channel_subsystem *channel_subsystems[MAX_CSS_IDX + 1];
static struct bus_type css_bus_type; static struct bus_type css_bus_type;
int int
...@@ -805,13 +806,11 @@ static int css_reboot_event(struct notifier_block *this, ...@@ -805,13 +806,11 @@ static int css_reboot_event(struct notifier_block *this,
unsigned long event, unsigned long event,
void *ptr) void *ptr)
{ {
int ret, i;
ret = NOTIFY_DONE;
for (i = 0; i <= __MAX_CSSID; i++) {
struct channel_subsystem *css; struct channel_subsystem *css;
int ret;
css = channel_subsystems[i]; ret = NOTIFY_DONE;
for_each_css(css) {
mutex_lock(&css->mutex); mutex_lock(&css->mutex);
if (css->cm_enabled) if (css->cm_enabled)
if (chsc_secm(css, 0)) if (chsc_secm(css, 0))
...@@ -835,16 +834,14 @@ static struct notifier_block css_reboot_notifier = { ...@@ -835,16 +834,14 @@ static struct notifier_block css_reboot_notifier = {
static int css_power_event(struct notifier_block *this, unsigned long event, static int css_power_event(struct notifier_block *this, unsigned long event,
void *ptr) void *ptr)
{ {
int ret, i; struct channel_subsystem *css;
int ret;
switch (event) { switch (event) {
case PM_HIBERNATION_PREPARE: case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE: case PM_SUSPEND_PREPARE:
ret = NOTIFY_DONE; ret = NOTIFY_DONE;
for (i = 0; i <= __MAX_CSSID; i++) { for_each_css(css) {
struct channel_subsystem *css;
css = channel_subsystems[i];
mutex_lock(&css->mutex); mutex_lock(&css->mutex);
if (!css->cm_enabled) { if (!css->cm_enabled) {
mutex_unlock(&css->mutex); mutex_unlock(&css->mutex);
...@@ -858,10 +855,7 @@ static int css_power_event(struct notifier_block *this, unsigned long event, ...@@ -858,10 +855,7 @@ static int css_power_event(struct notifier_block *this, unsigned long event,
case PM_POST_HIBERNATION: case PM_POST_HIBERNATION:
case PM_POST_SUSPEND: case PM_POST_SUSPEND:
ret = NOTIFY_DONE; ret = NOTIFY_DONE;
for (i = 0; i <= __MAX_CSSID; i++) { for_each_css(css) {
struct channel_subsystem *css;
css = channel_subsystems[i];
mutex_lock(&css->mutex); mutex_lock(&css->mutex);
if (!css->cm_enabled) { if (!css->cm_enabled) {
mutex_unlock(&css->mutex); mutex_unlock(&css->mutex);
...@@ -916,7 +910,7 @@ static int __init css_bus_init(void) ...@@ -916,7 +910,7 @@ static int __init css_bus_init(void)
goto out; goto out;
/* Setup css structure. */ /* Setup css structure. */
for (i = 0; i <= __MAX_CSSID; i++) { for (i = 0; i <= MAX_CSS_IDX; i++) {
struct channel_subsystem *css; struct channel_subsystem *css;
css = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL); css = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL);
...@@ -993,10 +987,8 @@ static int __init css_bus_init(void) ...@@ -993,10 +987,8 @@ static int __init css_bus_init(void)
static void __init css_bus_cleanup(void) static void __init css_bus_cleanup(void)
{ {
struct channel_subsystem *css; struct channel_subsystem *css;
int i;
for (i = 0; i <= __MAX_CSSID; i++) { for_each_css(css) {
css = channel_subsystems[i];
device_unregister(&css->pseudo_subchannel->dev); device_unregister(&css->pseudo_subchannel->dev);
css->pseudo_subchannel = NULL; css->pseudo_subchannel = NULL;
if (css_chsc_characteristics.secm) if (css_chsc_characteristics.secm)
......
...@@ -130,6 +130,16 @@ struct channel_subsystem { ...@@ -130,6 +130,16 @@ struct channel_subsystem {
extern struct channel_subsystem *channel_subsystems[]; extern struct channel_subsystem *channel_subsystems[];
/* Dummy helper which needs to change once we support more than one css. */
static inline struct channel_subsystem *css_by_id(u8 cssid)
{
return channel_subsystems[0];
}
/* Dummy iterator which needs to change once we support more than one css. */
#define for_each_css(css) \
for ((css) = channel_subsystems[0]; (css); (css) = NULL)
/* Helper functions to build lists for the slow path. */ /* Helper functions to build lists for the slow path. */
void css_schedule_eval(struct subchannel_id schid); void css_schedule_eval(struct subchannel_id schid);
void css_schedule_eval_all(void); void css_schedule_eval_all(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment