aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorFrank Blaschka <frank.blaschka@de.ibm.com>2009-06-16 04:30:31 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2009-06-16 04:31:13 -0400
commitbbcfcdc8324e75532c4d2592a545a91fcb45f229 (patch)
treecf37e0d0da6e54d324fc65f1363508975132406d /drivers/s390
parentcbb2aec3e7271f4cefcba2942aecc658d5841307 (diff)
[S390] pm: qeth driver power management callbacks
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/net/qeth_core_main.c51
-rw-r--r--drivers/s390/net/qeth_l2_main.c52
-rw-r--r--drivers/s390/net/qeth_l3_main.c52
3 files changed, 152 insertions, 3 deletions
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 74c49d9a8dba..d53621c4acbb 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/net/qeth_core_main.c 2 * drivers/s390/net/qeth_core_main.c
3 * 3 *
4 * Copyright IBM Corp. 2007 4 * Copyright IBM Corp. 2007, 2009
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, 5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
6 * Frank Pavlic <fpavlic@de.ibm.com>, 6 * Frank Pavlic <fpavlic@de.ibm.com>,
7 * Thomas Spatzier <tspat@de.ibm.com>, 7 * Thomas Spatzier <tspat@de.ibm.com>,
@@ -4195,6 +4195,50 @@ static void qeth_core_shutdown(struct ccwgroup_device *gdev)
4195 card->discipline.ccwgdriver->shutdown(gdev); 4195 card->discipline.ccwgdriver->shutdown(gdev);
4196} 4196}
4197 4197
4198static int qeth_core_prepare(struct ccwgroup_device *gdev)
4199{
4200 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
4201 if (card->discipline.ccwgdriver &&
4202 card->discipline.ccwgdriver->prepare)
4203 return card->discipline.ccwgdriver->prepare(gdev);
4204 return 0;
4205}
4206
4207static void qeth_core_complete(struct ccwgroup_device *gdev)
4208{
4209 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
4210 if (card->discipline.ccwgdriver &&
4211 card->discipline.ccwgdriver->complete)
4212 card->discipline.ccwgdriver->complete(gdev);
4213}
4214
4215static int qeth_core_freeze(struct ccwgroup_device *gdev)
4216{
4217 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
4218 if (card->discipline.ccwgdriver &&
4219 card->discipline.ccwgdriver->freeze)
4220 return card->discipline.ccwgdriver->freeze(gdev);
4221 return 0;
4222}
4223
4224static int qeth_core_thaw(struct ccwgroup_device *gdev)
4225{
4226 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
4227 if (card->discipline.ccwgdriver &&
4228 card->discipline.ccwgdriver->thaw)
4229 return card->discipline.ccwgdriver->thaw(gdev);
4230 return 0;
4231}
4232
4233static int qeth_core_restore(struct ccwgroup_device *gdev)
4234{
4235 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
4236 if (card->discipline.ccwgdriver &&
4237 card->discipline.ccwgdriver->restore)
4238 return card->discipline.ccwgdriver->restore(gdev);
4239 return 0;
4240}
4241
4198static struct ccwgroup_driver qeth_core_ccwgroup_driver = { 4242static struct ccwgroup_driver qeth_core_ccwgroup_driver = {
4199 .owner = THIS_MODULE, 4243 .owner = THIS_MODULE,
4200 .name = "qeth", 4244 .name = "qeth",
@@ -4204,6 +4248,11 @@ static struct ccwgroup_driver qeth_core_ccwgroup_driver = {
4204 .set_online = qeth_core_set_online, 4248 .set_online = qeth_core_set_online,
4205 .set_offline = qeth_core_set_offline, 4249 .set_offline = qeth_core_set_offline,
4206 .shutdown = qeth_core_shutdown, 4250 .shutdown = qeth_core_shutdown,
4251 .prepare = qeth_core_prepare,
4252 .complete = qeth_core_complete,
4253 .freeze = qeth_core_freeze,
4254 .thaw = qeth_core_thaw,
4255 .restore = qeth_core_restore,
4207}; 4256};
4208 4257
4209static ssize_t 4258static ssize_t
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index ecd3d06c0d5c..81d7f268418a 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/net/qeth_l2_main.c 2 * drivers/s390/net/qeth_l2_main.c
3 * 3 *
4 * Copyright IBM Corp. 2007 4 * Copyright IBM Corp. 2007, 2009
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, 5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
6 * Frank Pavlic <fpavlic@de.ibm.com>, 6 * Frank Pavlic <fpavlic@de.ibm.com>,
7 * Thomas Spatzier <tspat@de.ibm.com>, 7 * Thomas Spatzier <tspat@de.ibm.com>,
@@ -1141,12 +1141,62 @@ static void qeth_l2_shutdown(struct ccwgroup_device *gdev)
1141 qeth_clear_qdio_buffers(card); 1141 qeth_clear_qdio_buffers(card);
1142} 1142}
1143 1143
1144static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev)
1145{
1146 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
1147
1148 if (card->dev)
1149 netif_device_detach(card->dev);
1150 qeth_set_allowed_threads(card, 0, 1);
1151 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
1152 if (gdev->state == CCWGROUP_OFFLINE)
1153 return 0;
1154 if (card->state == CARD_STATE_UP) {
1155 card->use_hard_stop = 1;
1156 __qeth_l2_set_offline(card->gdev, 1);
1157 } else
1158 __qeth_l2_set_offline(card->gdev, 0);
1159 return 0;
1160}
1161
1162static int qeth_l2_pm_resume(struct ccwgroup_device *gdev)
1163{
1164 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
1165 int rc = 0;
1166
1167 if (gdev->state == CCWGROUP_OFFLINE)
1168 goto out;
1169
1170 if (card->state == CARD_STATE_RECOVER) {
1171 rc = __qeth_l2_set_online(card->gdev, 1);
1172 if (rc) {
1173 if (card->dev) {
1174 rtnl_lock();
1175 dev_close(card->dev);
1176 rtnl_unlock();
1177 }
1178 }
1179 } else
1180 rc = __qeth_l2_set_online(card->gdev, 0);
1181out:
1182 qeth_set_allowed_threads(card, 0xffffffff, 0);
1183 if (card->dev)
1184 netif_device_attach(card->dev);
1185 if (rc)
1186 dev_warn(&card->gdev->dev, "The qeth device driver "
1187 "failed to recover an error on the device\n");
1188 return rc;
1189}
1190
1144struct ccwgroup_driver qeth_l2_ccwgroup_driver = { 1191struct ccwgroup_driver qeth_l2_ccwgroup_driver = {
1145 .probe = qeth_l2_probe_device, 1192 .probe = qeth_l2_probe_device,
1146 .remove = qeth_l2_remove_device, 1193 .remove = qeth_l2_remove_device,
1147 .set_online = qeth_l2_set_online, 1194 .set_online = qeth_l2_set_online,
1148 .set_offline = qeth_l2_set_offline, 1195 .set_offline = qeth_l2_set_offline,
1149 .shutdown = qeth_l2_shutdown, 1196 .shutdown = qeth_l2_shutdown,
1197 .freeze = qeth_l2_pm_suspend,
1198 .thaw = qeth_l2_pm_resume,
1199 .restore = qeth_l2_pm_resume,
1150}; 1200};
1151EXPORT_SYMBOL_GPL(qeth_l2_ccwgroup_driver); 1201EXPORT_SYMBOL_GPL(qeth_l2_ccwgroup_driver);
1152 1202
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 6f2386e9d6e2..54872406864e 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/net/qeth_l3_main.c 2 * drivers/s390/net/qeth_l3_main.c
3 * 3 *
4 * Copyright IBM Corp. 2007 4 * Copyright IBM Corp. 2007, 2009
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, 5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
6 * Frank Pavlic <fpavlic@de.ibm.com>, 6 * Frank Pavlic <fpavlic@de.ibm.com>,
7 * Thomas Spatzier <tspat@de.ibm.com>, 7 * Thomas Spatzier <tspat@de.ibm.com>,
@@ -3283,12 +3283,62 @@ static void qeth_l3_shutdown(struct ccwgroup_device *gdev)
3283 qeth_clear_qdio_buffers(card); 3283 qeth_clear_qdio_buffers(card);
3284} 3284}
3285 3285
3286static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev)
3287{
3288 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3289
3290 if (card->dev)
3291 netif_device_detach(card->dev);
3292 qeth_set_allowed_threads(card, 0, 1);
3293 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0);
3294 if (gdev->state == CCWGROUP_OFFLINE)
3295 return 0;
3296 if (card->state == CARD_STATE_UP) {
3297 card->use_hard_stop = 1;
3298 __qeth_l3_set_offline(card->gdev, 1);
3299 } else
3300 __qeth_l3_set_offline(card->gdev, 0);
3301 return 0;
3302}
3303
3304static int qeth_l3_pm_resume(struct ccwgroup_device *gdev)
3305{
3306 struct qeth_card *card = dev_get_drvdata(&gdev->dev);
3307 int rc = 0;
3308
3309 if (gdev->state == CCWGROUP_OFFLINE)
3310 goto out;
3311
3312 if (card->state == CARD_STATE_RECOVER) {
3313 rc = __qeth_l3_set_online(card->gdev, 1);
3314 if (rc) {
3315 if (card->dev) {
3316 rtnl_lock();
3317 dev_close(card->dev);
3318 rtnl_unlock();
3319 }
3320 }
3321 } else
3322 rc = __qeth_l3_set_online(card->gdev, 0);
3323out:
3324 qeth_set_allowed_threads(card, 0xffffffff, 0);
3325 if (card->dev)
3326 netif_device_attach(card->dev);
3327 if (rc)
3328 dev_warn(&card->gdev->dev, "The qeth device driver "
3329 "failed to recover an error on the device\n");
3330 return rc;
3331}
3332
3286struct ccwgroup_driver qeth_l3_ccwgroup_driver = { 3333struct ccwgroup_driver qeth_l3_ccwgroup_driver = {
3287 .probe = qeth_l3_probe_device, 3334 .probe = qeth_l3_probe_device,
3288 .remove = qeth_l3_remove_device, 3335 .remove = qeth_l3_remove_device,
3289 .set_online = qeth_l3_set_online, 3336 .set_online = qeth_l3_set_online,
3290 .set_offline = qeth_l3_set_offline, 3337 .set_offline = qeth_l3_set_offline,
3291 .shutdown = qeth_l3_shutdown, 3338 .shutdown = qeth_l3_shutdown,
3339 .freeze = qeth_l3_pm_suspend,
3340 .thaw = qeth_l3_pm_resume,
3341 .restore = qeth_l3_pm_resume,
3292}; 3342};
3293EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver); 3343EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver);
3294 3344