dsa.c (ed96f35cecb0a7d1d95bbba8b9f212e60d0f7480) | dsa.c (d0004a020bb50263de0e3e775c7b7c7a003e0e0c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * net/dsa/dsa.c - Hardware switch handling 4 * Copyright (c) 2008-2009 Marvell Semiconductor 5 * Copyright (c) 2013 Florian Fainelli <florian@openwrt.org> 6 */ 7 8#include <linux/device.h> --- 266 unchanged lines hidden (view full) --- 275 return 0; 276 277 gro_cells_receive(&p->gcells, skb); 278 279 return 0; 280} 281 282#ifdef CONFIG_PM_SLEEP | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * net/dsa/dsa.c - Hardware switch handling 4 * Copyright (c) 2008-2009 Marvell Semiconductor 5 * Copyright (c) 2013 Florian Fainelli <florian@openwrt.org> 6 */ 7 8#include <linux/device.h> --- 266 unchanged lines hidden (view full) --- 275 return 0; 276 277 gro_cells_receive(&p->gcells, skb); 278 279 return 0; 280} 281 282#ifdef CONFIG_PM_SLEEP |
283static bool dsa_is_port_initialized(struct dsa_switch *ds, int p) | 283static bool dsa_port_is_initialized(const struct dsa_port *dp) |
284{ | 284{ |
285 const struct dsa_port *dp = dsa_to_port(ds, p); 286 | |
287 return dp->type == DSA_PORT_TYPE_USER && dp->slave; 288} 289 290int dsa_switch_suspend(struct dsa_switch *ds) 291{ | 285 return dp->type == DSA_PORT_TYPE_USER && dp->slave; 286} 287 288int dsa_switch_suspend(struct dsa_switch *ds) 289{ |
292 int i, ret = 0; | 290 struct dsa_port *dp; 291 int ret = 0; |
293 294 /* Suspend slave network devices */ | 292 293 /* Suspend slave network devices */ |
295 for (i = 0; i < ds->num_ports; i++) { 296 if (!dsa_is_port_initialized(ds, i)) | 294 dsa_switch_for_each_port(dp, ds) { 295 if (!dsa_port_is_initialized(dp)) |
297 continue; 298 | 296 continue; 297 |
299 ret = dsa_slave_suspend(dsa_to_port(ds, i)->slave); | 298 ret = dsa_slave_suspend(dp->slave); |
300 if (ret) 301 return ret; 302 } 303 304 if (ds->ops->suspend) 305 ret = ds->ops->suspend(ds); 306 307 return ret; 308} 309EXPORT_SYMBOL_GPL(dsa_switch_suspend); 310 311int dsa_switch_resume(struct dsa_switch *ds) 312{ | 299 if (ret) 300 return ret; 301 } 302 303 if (ds->ops->suspend) 304 ret = ds->ops->suspend(ds); 305 306 return ret; 307} 308EXPORT_SYMBOL_GPL(dsa_switch_suspend); 309 310int dsa_switch_resume(struct dsa_switch *ds) 311{ |
313 int i, ret = 0; | 312 struct dsa_port *dp; 313 int ret = 0; |
314 315 if (ds->ops->resume) 316 ret = ds->ops->resume(ds); 317 318 if (ret) 319 return ret; 320 321 /* Resume slave network devices */ | 314 315 if (ds->ops->resume) 316 ret = ds->ops->resume(ds); 317 318 if (ret) 319 return ret; 320 321 /* Resume slave network devices */ |
322 for (i = 0; i < ds->num_ports; i++) { 323 if (!dsa_is_port_initialized(ds, i)) | 322 dsa_switch_for_each_port(dp, ds) { 323 if (!dsa_port_is_initialized(dp)) |
324 continue; 325 | 324 continue; 325 |
326 ret = dsa_slave_resume(dsa_to_port(ds, i)->slave); | 326 ret = dsa_slave_resume(dp->slave); |
327 if (ret) 328 return ret; 329 } 330 331 return 0; 332} 333EXPORT_SYMBOL_GPL(dsa_switch_resume); 334#endif --- 175 unchanged lines hidden --- | 327 if (ret) 328 return ret; 329 } 330 331 return 0; 332} 333EXPORT_SYMBOL_GPL(dsa_switch_resume); 334#endif --- 175 unchanged lines hidden --- |