| .. | .. |
|---|
| 112 | 112 | */ |
|---|
| 113 | 113 | #define PRINTK_HEADER " iucv: " /* for debugging */ |
|---|
| 114 | 114 | |
|---|
| 115 | | -/* dummy device to make sure netiucv_pm functions are called */ |
|---|
| 116 | | -static struct device *netiucv_dev; |
|---|
| 117 | | - |
|---|
| 118 | | -static int netiucv_pm_prepare(struct device *); |
|---|
| 119 | | -static void netiucv_pm_complete(struct device *); |
|---|
| 120 | | -static int netiucv_pm_freeze(struct device *); |
|---|
| 121 | | -static int netiucv_pm_restore_thaw(struct device *); |
|---|
| 122 | | - |
|---|
| 123 | | -static const struct dev_pm_ops netiucv_pm_ops = { |
|---|
| 124 | | - .prepare = netiucv_pm_prepare, |
|---|
| 125 | | - .complete = netiucv_pm_complete, |
|---|
| 126 | | - .freeze = netiucv_pm_freeze, |
|---|
| 127 | | - .thaw = netiucv_pm_restore_thaw, |
|---|
| 128 | | - .restore = netiucv_pm_restore_thaw, |
|---|
| 129 | | -}; |
|---|
| 130 | | - |
|---|
| 131 | 115 | static struct device_driver netiucv_driver = { |
|---|
| 132 | 116 | .owner = THIS_MODULE, |
|---|
| 133 | 117 | .name = "netiucv", |
|---|
| 134 | 118 | .bus = &iucv_bus, |
|---|
| 135 | | - .pm = &netiucv_pm_ops, |
|---|
| 136 | 119 | }; |
|---|
| 137 | 120 | |
|---|
| 138 | 121 | static int netiucv_callback_connreq(struct iucv_path *, u8 *, u8 *); |
|---|
| .. | .. |
|---|
| 213 | 196 | fsm_instance *fsm; |
|---|
| 214 | 197 | struct iucv_connection *conn; |
|---|
| 215 | 198 | struct device *dev; |
|---|
| 216 | | - int pm_state; |
|---|
| 217 | 199 | }; |
|---|
| 218 | 200 | |
|---|
| 219 | 201 | /** |
|---|
| .. | .. |
|---|
| 1275 | 1257 | return 0; |
|---|
| 1276 | 1258 | } |
|---|
| 1277 | 1259 | |
|---|
| 1278 | | -static int netiucv_pm_prepare(struct device *dev) |
|---|
| 1279 | | -{ |
|---|
| 1280 | | - IUCV_DBF_TEXT(trace, 3, __func__); |
|---|
| 1281 | | - return 0; |
|---|
| 1282 | | -} |
|---|
| 1283 | | - |
|---|
| 1284 | | -static void netiucv_pm_complete(struct device *dev) |
|---|
| 1285 | | -{ |
|---|
| 1286 | | - IUCV_DBF_TEXT(trace, 3, __func__); |
|---|
| 1287 | | - return; |
|---|
| 1288 | | -} |
|---|
| 1289 | | - |
|---|
| 1290 | | -/** |
|---|
| 1291 | | - * netiucv_pm_freeze() - Freeze PM callback |
|---|
| 1292 | | - * @dev: netiucv device |
|---|
| 1293 | | - * |
|---|
| 1294 | | - * close open netiucv interfaces |
|---|
| 1295 | | - */ |
|---|
| 1296 | | -static int netiucv_pm_freeze(struct device *dev) |
|---|
| 1297 | | -{ |
|---|
| 1298 | | - struct netiucv_priv *priv = dev_get_drvdata(dev); |
|---|
| 1299 | | - struct net_device *ndev = NULL; |
|---|
| 1300 | | - int rc = 0; |
|---|
| 1301 | | - |
|---|
| 1302 | | - IUCV_DBF_TEXT(trace, 3, __func__); |
|---|
| 1303 | | - if (priv && priv->conn) |
|---|
| 1304 | | - ndev = priv->conn->netdev; |
|---|
| 1305 | | - if (!ndev) |
|---|
| 1306 | | - goto out; |
|---|
| 1307 | | - netif_device_detach(ndev); |
|---|
| 1308 | | - priv->pm_state = fsm_getstate(priv->fsm); |
|---|
| 1309 | | - rc = netiucv_close(ndev); |
|---|
| 1310 | | -out: |
|---|
| 1311 | | - return rc; |
|---|
| 1312 | | -} |
|---|
| 1313 | | - |
|---|
| 1314 | | -/** |
|---|
| 1315 | | - * netiucv_pm_restore_thaw() - Thaw and restore PM callback |
|---|
| 1316 | | - * @dev: netiucv device |
|---|
| 1317 | | - * |
|---|
| 1318 | | - * re-open netiucv interfaces closed during freeze |
|---|
| 1319 | | - */ |
|---|
| 1320 | | -static int netiucv_pm_restore_thaw(struct device *dev) |
|---|
| 1321 | | -{ |
|---|
| 1322 | | - struct netiucv_priv *priv = dev_get_drvdata(dev); |
|---|
| 1323 | | - struct net_device *ndev = NULL; |
|---|
| 1324 | | - int rc = 0; |
|---|
| 1325 | | - |
|---|
| 1326 | | - IUCV_DBF_TEXT(trace, 3, __func__); |
|---|
| 1327 | | - if (priv && priv->conn) |
|---|
| 1328 | | - ndev = priv->conn->netdev; |
|---|
| 1329 | | - if (!ndev) |
|---|
| 1330 | | - goto out; |
|---|
| 1331 | | - switch (priv->pm_state) { |
|---|
| 1332 | | - case DEV_STATE_RUNNING: |
|---|
| 1333 | | - case DEV_STATE_STARTWAIT: |
|---|
| 1334 | | - rc = netiucv_open(ndev); |
|---|
| 1335 | | - break; |
|---|
| 1336 | | - default: |
|---|
| 1337 | | - break; |
|---|
| 1338 | | - } |
|---|
| 1339 | | - netif_device_attach(ndev); |
|---|
| 1340 | | -out: |
|---|
| 1341 | | - return rc; |
|---|
| 1342 | | -} |
|---|
| 1343 | | - |
|---|
| 1344 | 1260 | /** |
|---|
| 1345 | 1261 | * Start transmission of a packet. |
|---|
| 1346 | 1262 | * Called from generic network device layer. |
|---|
| 1347 | | - * |
|---|
| 1348 | | - * @param skb Pointer to buffer containing the packet. |
|---|
| 1349 | | - * @param dev Pointer to interface struct. |
|---|
| 1350 | | - * |
|---|
| 1351 | | - * @return 0 if packet consumed, !0 if packet rejected. |
|---|
| 1352 | | - * Note: If we return !0, then the packet is free'd by |
|---|
| 1353 | | - * the generic network layer. |
|---|
| 1354 | 1263 | */ |
|---|
| 1355 | | -static int netiucv_tx(struct sk_buff *skb, struct net_device *dev) |
|---|
| 1264 | +static netdev_tx_t netiucv_tx(struct sk_buff *skb, struct net_device *dev) |
|---|
| 1356 | 1265 | { |
|---|
| 1357 | 1266 | struct netiucv_priv *privptr = netdev_priv(dev); |
|---|
| 1358 | 1267 | int rc; |
|---|
| .. | .. |
|---|
| 2156 | 2065 | netiucv_unregister_device(dev); |
|---|
| 2157 | 2066 | } |
|---|
| 2158 | 2067 | |
|---|
| 2159 | | - device_unregister(netiucv_dev); |
|---|
| 2160 | 2068 | driver_unregister(&netiucv_driver); |
|---|
| 2161 | 2069 | iucv_unregister(&netiucv_handler, 1); |
|---|
| 2162 | 2070 | iucv_unregister_dbf_views(); |
|---|
| .. | .. |
|---|
| 2182 | 2090 | IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", rc); |
|---|
| 2183 | 2091 | goto out_iucv; |
|---|
| 2184 | 2092 | } |
|---|
| 2185 | | - /* establish dummy device */ |
|---|
| 2186 | | - netiucv_dev = kzalloc(sizeof(struct device), GFP_KERNEL); |
|---|
| 2187 | | - if (!netiucv_dev) { |
|---|
| 2188 | | - rc = -ENOMEM; |
|---|
| 2189 | | - goto out_driver; |
|---|
| 2190 | | - } |
|---|
| 2191 | | - dev_set_name(netiucv_dev, "netiucv"); |
|---|
| 2192 | | - netiucv_dev->bus = &iucv_bus; |
|---|
| 2193 | | - netiucv_dev->parent = iucv_root; |
|---|
| 2194 | | - netiucv_dev->release = (void (*)(struct device *))kfree; |
|---|
| 2195 | | - netiucv_dev->driver = &netiucv_driver; |
|---|
| 2196 | | - rc = device_register(netiucv_dev); |
|---|
| 2197 | | - if (rc) { |
|---|
| 2198 | | - put_device(netiucv_dev); |
|---|
| 2199 | | - goto out_driver; |
|---|
| 2200 | | - } |
|---|
| 2093 | + |
|---|
| 2201 | 2094 | netiucv_banner(); |
|---|
| 2202 | 2095 | return rc; |
|---|
| 2203 | 2096 | |
|---|
| 2204 | | -out_driver: |
|---|
| 2205 | | - driver_unregister(&netiucv_driver); |
|---|
| 2206 | 2097 | out_iucv: |
|---|
| 2207 | 2098 | iucv_unregister(&netiucv_handler, 1); |
|---|
| 2208 | 2099 | out_dbf: |
|---|