diff options
author | Joe Hershberger | 2018-09-26 16:48:59 -0500 |
---|---|---|
committer | Joe Hershberger | 2018-10-10 12:28:59 -0500 |
commit | 9cbe5972c3c00e974482181cd4062d9229a9b7d5 (patch) | |
tree | 8ca670695d6931a755c059d66b0e66f662183f82 /drivers | |
parent | 3f02c98bd1000fc26ee2700fd5a75112cdeaca6c (diff) |
net: sandbox: Add a priv ptr for tests to use
Tests need to be able to pass their "unit test state" to the handlers
where asserts are evaluated. Add a function that allows the tests to set
this private data on the sandbox eth device.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sandbox.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index 9c0e0d009ea..e26e72ecc10 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -206,6 +206,26 @@ void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler) priv->tx_handler = sb_default_handler; } +/* + * Set priv ptr + * + * priv - priv void ptr to store in the device + */ +void sandbox_eth_set_priv(int index, void *priv) +{ + struct udevice *dev; + struct eth_sandbox_priv *dev_priv; + int ret; + + ret = uclass_get_device(UCLASS_ETH, index, &dev); + if (ret) + return; + + dev_priv = dev_get_priv(dev); + + dev_priv->priv = priv; +} + static int sb_eth_start(struct udevice *dev) { struct eth_sandbox_priv *priv = dev_get_priv(dev); |