Commit 1c385f1f authored by Sjur Brændeland's avatar Sjur Brændeland Committed by David S. Miller

caif-hsi: Replace platform device with ops structure.

Remove use of struct platform_device, and replace it with
struct cfhsi_ops. Updated variable names in the same
spirit:
cfhsi_get_dev to cfhsi_get_ops,
cfhsi->dev to cfhsi->ops and,
cfhsi->dev.drv to cfhsi->ops->cb_ops.
Signed-off-by: default avatarSjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c4125400
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -184,7 +183,7 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi) ...@@ -184,7 +183,7 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi)
__func__); __func__);
do { do {
ret = cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev, ret = cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops,
&fifo_occupancy); &fifo_occupancy);
if (ret) { if (ret) {
netdev_warn(cfhsi->ndev, netdev_warn(cfhsi->ndev,
...@@ -197,8 +196,8 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi) ...@@ -197,8 +196,8 @@ static int cfhsi_flush_fifo(struct cfhsi *cfhsi)
fifo_occupancy = min(sizeof(buffer), fifo_occupancy); fifo_occupancy = min(sizeof(buffer), fifo_occupancy);
set_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits); set_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits);
ret = cfhsi->dev->cfhsi_rx(buffer, fifo_occupancy, ret = cfhsi->ops->cfhsi_rx(buffer, fifo_occupancy,
cfhsi->dev); cfhsi->ops);
if (ret) { if (ret) {
clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits); clear_bit(CFHSI_FLUSH_FIFO, &cfhsi->bits);
netdev_warn(cfhsi->ndev, netdev_warn(cfhsi->ndev,
...@@ -371,7 +370,7 @@ static void cfhsi_start_tx(struct cfhsi *cfhsi) ...@@ -371,7 +370,7 @@ static void cfhsi_start_tx(struct cfhsi *cfhsi)
} }
/* Set up new transfer. */ /* Set up new transfer. */
res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev); res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops);
if (WARN_ON(res < 0)) if (WARN_ON(res < 0))
netdev_err(cfhsi->ndev, "%s: TX error %d.\n", netdev_err(cfhsi->ndev, "%s: TX error %d.\n",
__func__, res); __func__, res);
...@@ -410,11 +409,11 @@ static void cfhsi_tx_done(struct cfhsi *cfhsi) ...@@ -410,11 +409,11 @@ static void cfhsi_tx_done(struct cfhsi *cfhsi)
return; return;
} }
static void cfhsi_tx_done_cb(struct cfhsi_drv *drv) static void cfhsi_tx_done_cb(struct cfhsi_cb_ops *cb_ops)
{ {
struct cfhsi *cfhsi; struct cfhsi *cfhsi;
cfhsi = container_of(drv, struct cfhsi, drv); cfhsi = container_of(cb_ops, struct cfhsi, cb_ops);
netdev_dbg(cfhsi->ndev, "%s.\n", netdev_dbg(cfhsi->ndev, "%s.\n",
__func__); __func__);
...@@ -476,8 +475,8 @@ static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi) ...@@ -476,8 +475,8 @@ static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
skb->dev = cfhsi->ndev; skb->dev = cfhsi->ndev;
/* /*
* We are called from a arch specific platform device. * We are in a callback handler and
* Unfortunately we don't know what context we're * unfortunately we don't know what context we're
* running in. * running in.
*/ */
if (in_interrupt()) if (in_interrupt())
...@@ -607,7 +606,7 @@ static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi) ...@@ -607,7 +606,7 @@ static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
skb->dev = cfhsi->ndev; skb->dev = cfhsi->ndev;
/* /*
* We're called from a platform device, * We're called in callback from HSI
* and don't know the context we're running in. * and don't know the context we're running in.
*/ */
if (in_interrupt()) if (in_interrupt())
...@@ -711,8 +710,8 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi) ...@@ -711,8 +710,8 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
netdev_dbg(cfhsi->ndev, "%s: Start RX.\n", netdev_dbg(cfhsi->ndev, "%s: Start RX.\n",
__func__); __func__);
res = cfhsi->dev->cfhsi_rx(rx_ptr, rx_len, res = cfhsi->ops->cfhsi_rx(rx_ptr, rx_len,
cfhsi->dev); cfhsi->ops);
if (WARN_ON(res < 0)) { if (WARN_ON(res < 0)) {
netdev_err(cfhsi->ndev, "%s: RX error %d.\n", netdev_err(cfhsi->ndev, "%s: RX error %d.\n",
__func__, res); __func__, res);
...@@ -765,11 +764,11 @@ static void cfhsi_rx_slowpath(unsigned long arg) ...@@ -765,11 +764,11 @@ static void cfhsi_rx_slowpath(unsigned long arg)
cfhsi_rx_done(cfhsi); cfhsi_rx_done(cfhsi);
} }
static void cfhsi_rx_done_cb(struct cfhsi_drv *drv) static void cfhsi_rx_done_cb(struct cfhsi_cb_ops *cb_ops)
{ {
struct cfhsi *cfhsi; struct cfhsi *cfhsi;
cfhsi = container_of(drv, struct cfhsi, drv); cfhsi = container_of(cb_ops, struct cfhsi, cb_ops);
netdev_dbg(cfhsi->ndev, "%s.\n", netdev_dbg(cfhsi->ndev, "%s.\n",
__func__); __func__);
...@@ -803,7 +802,7 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -803,7 +802,7 @@ static void cfhsi_wake_up(struct work_struct *work)
} }
/* Activate wake line. */ /* Activate wake line. */
cfhsi->dev->cfhsi_wake_up(cfhsi->dev); cfhsi->ops->cfhsi_wake_up(cfhsi->ops);
netdev_dbg(cfhsi->ndev, "%s: Start waiting.\n", netdev_dbg(cfhsi->ndev, "%s: Start waiting.\n",
__func__); __func__);
...@@ -819,7 +818,7 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -819,7 +818,7 @@ static void cfhsi_wake_up(struct work_struct *work)
__func__, ret); __func__, ret);
clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
cfhsi->dev->cfhsi_wake_down(cfhsi->dev); cfhsi->ops->cfhsi_wake_down(cfhsi->ops);
return; return;
} else if (!ret) { } else if (!ret) {
bool ca_wake = false; bool ca_wake = false;
...@@ -830,14 +829,14 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -830,14 +829,14 @@ static void cfhsi_wake_up(struct work_struct *work)
__func__); __func__);
/* Check FIFO to check if modem has sent something. */ /* Check FIFO to check if modem has sent something. */
WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev, WARN_ON(cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops,
&fifo_occupancy)); &fifo_occupancy));
netdev_dbg(cfhsi->ndev, "%s: Bytes in FIFO: %u.\n", netdev_dbg(cfhsi->ndev, "%s: Bytes in FIFO: %u.\n",
__func__, (unsigned) fifo_occupancy); __func__, (unsigned) fifo_occupancy);
/* Check if we misssed the interrupt. */ /* Check if we misssed the interrupt. */
WARN_ON(cfhsi->dev->cfhsi_get_peer_wake(cfhsi->dev, WARN_ON(cfhsi->ops->cfhsi_get_peer_wake(cfhsi->ops,
&ca_wake)); &ca_wake));
if (ca_wake) { if (ca_wake) {
...@@ -852,7 +851,7 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -852,7 +851,7 @@ static void cfhsi_wake_up(struct work_struct *work)
} }
clear_bit(CFHSI_WAKE_UP, &cfhsi->bits); clear_bit(CFHSI_WAKE_UP, &cfhsi->bits);
cfhsi->dev->cfhsi_wake_down(cfhsi->dev); cfhsi->ops->cfhsi_wake_down(cfhsi->ops);
return; return;
} }
wake_ack: wake_ack:
...@@ -865,7 +864,7 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -865,7 +864,7 @@ static void cfhsi_wake_up(struct work_struct *work)
/* Resume read operation. */ /* Resume read operation. */
netdev_dbg(cfhsi->ndev, "%s: Start RX.\n", __func__); netdev_dbg(cfhsi->ndev, "%s: Start RX.\n", __func__);
res = cfhsi->dev->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, cfhsi->dev); res = cfhsi->ops->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, cfhsi->ops);
if (WARN_ON(res < 0)) if (WARN_ON(res < 0))
netdev_err(cfhsi->ndev, "%s: RX err %d.\n", __func__, res); netdev_err(cfhsi->ndev, "%s: RX err %d.\n", __func__, res);
...@@ -896,7 +895,7 @@ static void cfhsi_wake_up(struct work_struct *work) ...@@ -896,7 +895,7 @@ static void cfhsi_wake_up(struct work_struct *work)
if (likely(len > 0)) { if (likely(len > 0)) {
/* Set up new transfer. */ /* Set up new transfer. */
res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev); res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops);
if (WARN_ON(res < 0)) { if (WARN_ON(res < 0)) {
netdev_err(cfhsi->ndev, "%s: TX error %d.\n", netdev_err(cfhsi->ndev, "%s: TX error %d.\n",
__func__, res); __func__, res);
...@@ -923,7 +922,7 @@ static void cfhsi_wake_down(struct work_struct *work) ...@@ -923,7 +922,7 @@ static void cfhsi_wake_down(struct work_struct *work)
return; return;
/* Deactivate wake line. */ /* Deactivate wake line. */
cfhsi->dev->cfhsi_wake_down(cfhsi->dev); cfhsi->ops->cfhsi_wake_down(cfhsi->ops);
/* Wait for acknowledge. */ /* Wait for acknowledge. */
ret = CFHSI_WAKE_TOUT; ret = CFHSI_WAKE_TOUT;
...@@ -942,7 +941,7 @@ static void cfhsi_wake_down(struct work_struct *work) ...@@ -942,7 +941,7 @@ static void cfhsi_wake_down(struct work_struct *work)
netdev_err(cfhsi->ndev, "%s: Timeout.\n", __func__); netdev_err(cfhsi->ndev, "%s: Timeout.\n", __func__);
/* Check if we misssed the interrupt. */ /* Check if we misssed the interrupt. */
WARN_ON(cfhsi->dev->cfhsi_get_peer_wake(cfhsi->dev, WARN_ON(cfhsi->ops->cfhsi_get_peer_wake(cfhsi->ops,
&ca_wake)); &ca_wake));
if (!ca_wake) if (!ca_wake)
netdev_err(cfhsi->ndev, "%s: CA Wake missed !.\n", netdev_err(cfhsi->ndev, "%s: CA Wake missed !.\n",
...@@ -951,7 +950,7 @@ static void cfhsi_wake_down(struct work_struct *work) ...@@ -951,7 +950,7 @@ static void cfhsi_wake_down(struct work_struct *work)
/* Check FIFO occupancy. */ /* Check FIFO occupancy. */
while (retry) { while (retry) {
WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev, WARN_ON(cfhsi->ops->cfhsi_fifo_occupancy(cfhsi->ops,
&fifo_occupancy)); &fifo_occupancy));
if (!fifo_occupancy) if (!fifo_occupancy)
...@@ -969,8 +968,7 @@ static void cfhsi_wake_down(struct work_struct *work) ...@@ -969,8 +968,7 @@ static void cfhsi_wake_down(struct work_struct *work)
clear_bit(CFHSI_AWAKE, &cfhsi->bits); clear_bit(CFHSI_AWAKE, &cfhsi->bits);
/* Cancel pending RX requests. */ /* Cancel pending RX requests. */
cfhsi->dev->cfhsi_rx_cancel(cfhsi->dev); cfhsi->ops->cfhsi_rx_cancel(cfhsi->ops);
} }
static void cfhsi_out_of_sync(struct work_struct *work) static void cfhsi_out_of_sync(struct work_struct *work)
...@@ -984,11 +982,11 @@ static void cfhsi_out_of_sync(struct work_struct *work) ...@@ -984,11 +982,11 @@ static void cfhsi_out_of_sync(struct work_struct *work)
rtnl_unlock(); rtnl_unlock();
} }
static void cfhsi_wake_up_cb(struct cfhsi_drv *drv) static void cfhsi_wake_up_cb(struct cfhsi_cb_ops *cb_ops)
{ {
struct cfhsi *cfhsi = NULL; struct cfhsi *cfhsi = NULL;
cfhsi = container_of(drv, struct cfhsi, drv); cfhsi = container_of(cb_ops, struct cfhsi, cb_ops);
netdev_dbg(cfhsi->ndev, "%s.\n", netdev_dbg(cfhsi->ndev, "%s.\n",
__func__); __func__);
...@@ -1003,11 +1001,11 @@ static void cfhsi_wake_up_cb(struct cfhsi_drv *drv) ...@@ -1003,11 +1001,11 @@ static void cfhsi_wake_up_cb(struct cfhsi_drv *drv)
queue_work(cfhsi->wq, &cfhsi->wake_up_work); queue_work(cfhsi->wq, &cfhsi->wake_up_work);
} }
static void cfhsi_wake_down_cb(struct cfhsi_drv *drv) static void cfhsi_wake_down_cb(struct cfhsi_cb_ops *cb_ops)
{ {
struct cfhsi *cfhsi = NULL; struct cfhsi *cfhsi = NULL;
cfhsi = container_of(drv, struct cfhsi, drv); cfhsi = container_of(cb_ops, struct cfhsi, cb_ops);
netdev_dbg(cfhsi->ndev, "%s.\n", netdev_dbg(cfhsi->ndev, "%s.\n",
__func__); __func__);
...@@ -1110,7 +1108,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1110,7 +1108,7 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
WARN_ON(!len); WARN_ON(!len);
/* Set up new transfer. */ /* Set up new transfer. */
res = cfhsi->dev->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->dev); res = cfhsi->ops->cfhsi_tx(cfhsi->tx_buf, len, cfhsi->ops);
if (WARN_ON(res < 0)) { if (WARN_ON(res < 0)) {
netdev_err(cfhsi->ndev, "%s: TX error %d.\n", netdev_err(cfhsi->ndev, "%s: TX error %d.\n",
__func__, res); __func__, res);
...@@ -1125,19 +1123,19 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1125,19 +1123,19 @@ static int cfhsi_xmit(struct sk_buff *skb, struct net_device *dev)
return 0; return 0;
} }
static const struct net_device_ops cfhsi_ops; static const struct net_device_ops cfhsi_netdevops;
static void cfhsi_setup(struct net_device *dev) static void cfhsi_setup(struct net_device *dev)
{ {
int i; int i;
struct cfhsi *cfhsi = netdev_priv(dev); struct cfhsi *cfhsi = netdev_priv(dev);
dev->features = 0; dev->features = 0;
dev->netdev_ops = &cfhsi_ops;
dev->type = ARPHRD_CAIF; dev->type = ARPHRD_CAIF;
dev->flags = IFF_POINTOPOINT | IFF_NOARP; dev->flags = IFF_POINTOPOINT | IFF_NOARP;
dev->mtu = CFHSI_MAX_CAIF_FRAME_SZ; dev->mtu = CFHSI_MAX_CAIF_FRAME_SZ;
dev->tx_queue_len = 0; dev->tx_queue_len = 0;
dev->destructor = free_netdev; dev->destructor = free_netdev;
dev->netdev_ops = &cfhsi_netdevops;
for (i = 0; i < CFHSI_PRIO_LAST; ++i) for (i = 0; i < CFHSI_PRIO_LAST; ++i)
skb_queue_head_init(&cfhsi->qhead[i]); skb_queue_head_init(&cfhsi->qhead[i]);
cfhsi->cfdev.link_select = CAIF_LINK_HIGH_BANDW; cfhsi->cfdev.link_select = CAIF_LINK_HIGH_BANDW;
...@@ -1213,10 +1211,10 @@ static int cfhsi_open(struct net_device *ndev) ...@@ -1213,10 +1211,10 @@ static int cfhsi_open(struct net_device *ndev)
spin_lock_init(&cfhsi->lock); spin_lock_init(&cfhsi->lock);
/* Set up the driver. */ /* Set up the driver. */
cfhsi->drv.tx_done_cb = cfhsi_tx_done_cb; cfhsi->cb_ops.tx_done_cb = cfhsi_tx_done_cb;
cfhsi->drv.rx_done_cb = cfhsi_rx_done_cb; cfhsi->cb_ops.rx_done_cb = cfhsi_rx_done_cb;
cfhsi->drv.wake_up_cb = cfhsi_wake_up_cb; cfhsi->cb_ops.wake_up_cb = cfhsi_wake_up_cb;
cfhsi->drv.wake_down_cb = cfhsi_wake_down_cb; cfhsi->cb_ops.wake_down_cb = cfhsi_wake_down_cb;
/* Initialize the work queues. */ /* Initialize the work queues. */
INIT_WORK(&cfhsi->wake_up_work, cfhsi_wake_up); INIT_WORK(&cfhsi->wake_up_work, cfhsi_wake_up);
...@@ -1230,7 +1228,7 @@ static int cfhsi_open(struct net_device *ndev) ...@@ -1230,7 +1228,7 @@ static int cfhsi_open(struct net_device *ndev)
clear_bit(CFHSI_AWAKE, &cfhsi->bits); clear_bit(CFHSI_AWAKE, &cfhsi->bits);
/* Create work thread. */ /* Create work thread. */
cfhsi->wq = create_singlethread_workqueue(cfhsi->pdev->name); cfhsi->wq = create_singlethread_workqueue(cfhsi->ndev->name);
if (!cfhsi->wq) { if (!cfhsi->wq) {
netdev_err(cfhsi->ndev, "%s: Failed to create work queue.\n", netdev_err(cfhsi->ndev, "%s: Failed to create work queue.\n",
__func__); __func__);
...@@ -1257,7 +1255,7 @@ static int cfhsi_open(struct net_device *ndev) ...@@ -1257,7 +1255,7 @@ static int cfhsi_open(struct net_device *ndev)
cfhsi->aggregation_timer.function = cfhsi_aggregation_tout; cfhsi->aggregation_timer.function = cfhsi_aggregation_tout;
/* Activate HSI interface. */ /* Activate HSI interface. */
res = cfhsi->dev->cfhsi_up(cfhsi->dev); res = cfhsi->ops->cfhsi_up(cfhsi->ops);
if (res) { if (res) {
netdev_err(cfhsi->ndev, netdev_err(cfhsi->ndev,
"%s: can't activate HSI interface: %d.\n", "%s: can't activate HSI interface: %d.\n",
...@@ -1275,7 +1273,7 @@ static int cfhsi_open(struct net_device *ndev) ...@@ -1275,7 +1273,7 @@ static int cfhsi_open(struct net_device *ndev)
return res; return res;
err_net_reg: err_net_reg:
cfhsi->dev->cfhsi_down(cfhsi->dev); cfhsi->ops->cfhsi_down(cfhsi->ops);
err_activate: err_activate:
destroy_workqueue(cfhsi->wq); destroy_workqueue(cfhsi->wq);
err_create_wq: err_create_wq:
...@@ -1305,7 +1303,7 @@ static int cfhsi_close(struct net_device *ndev) ...@@ -1305,7 +1303,7 @@ static int cfhsi_close(struct net_device *ndev)
del_timer_sync(&cfhsi->aggregation_timer); del_timer_sync(&cfhsi->aggregation_timer);
/* Cancel pending RX request (if any) */ /* Cancel pending RX request (if any) */
cfhsi->dev->cfhsi_rx_cancel(cfhsi->dev); cfhsi->ops->cfhsi_rx_cancel(cfhsi->ops);
/* Destroy workqueue */ /* Destroy workqueue */
destroy_workqueue(cfhsi->wq); destroy_workqueue(cfhsi->wq);
...@@ -1318,7 +1316,7 @@ static int cfhsi_close(struct net_device *ndev) ...@@ -1318,7 +1316,7 @@ static int cfhsi_close(struct net_device *ndev)
cfhsi_abort_tx(cfhsi); cfhsi_abort_tx(cfhsi);
/* Deactivate interface */ /* Deactivate interface */
cfhsi->dev->cfhsi_down(cfhsi->dev); cfhsi->ops->cfhsi_down(cfhsi->ops);
/* Free buffers. */ /* Free buffers. */
kfree(tx_buf); kfree(tx_buf);
...@@ -1335,7 +1333,7 @@ static void cfhsi_uninit(struct net_device *dev) ...@@ -1335,7 +1333,7 @@ static void cfhsi_uninit(struct net_device *dev)
list_del(&cfhsi->list); list_del(&cfhsi->list);
} }
static const struct net_device_ops cfhsi_ops = { static const struct net_device_ops cfhsi_netdevops = {
.ndo_uninit = cfhsi_uninit, .ndo_uninit = cfhsi_uninit,
.ndo_open = cfhsi_open, .ndo_open = cfhsi_open,
.ndo_stop = cfhsi_close, .ndo_stop = cfhsi_close,
...@@ -1419,7 +1417,7 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev, ...@@ -1419,7 +1417,7 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[]) struct nlattr *tb[], struct nlattr *data[])
{ {
struct cfhsi *cfhsi = NULL; struct cfhsi *cfhsi = NULL;
struct platform_device *(*get_dev)(void); struct cfhsi_ops *(*get_ops)(void);
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -1427,36 +1425,31 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev, ...@@ -1427,36 +1425,31 @@ static int caif_hsi_newlink(struct net *src_net, struct net_device *dev,
cfhsi_netlink_parms(data, cfhsi); cfhsi_netlink_parms(data, cfhsi);
dev_net_set(cfhsi->ndev, src_net); dev_net_set(cfhsi->ndev, src_net);
get_dev = symbol_get(cfhsi_get_device); get_ops = symbol_get(cfhsi_get_ops);
if (!get_dev) { if (!get_ops) {
pr_err("%s: failed to get the cfhsi device symbol\n", __func__); pr_err("%s: failed to get the cfhsi_ops\n", __func__);
return -ENODEV; return -ENODEV;
} }
/* Assign the HSI device. */ /* Assign the HSI device. */
cfhsi->pdev = (*get_dev)(); cfhsi->ops = (*get_ops)();
if (!cfhsi->pdev) { if (!cfhsi->ops) {
pr_err("%s: failed to get the cfhsi device\n", __func__); pr_err("%s: failed to get the cfhsi_ops\n", __func__);
goto err; goto err;
} }
/* Assign the HSI device. */
cfhsi->dev = cfhsi->pdev->dev.platform_data;
/* Assign the driver to this HSI device. */ /* Assign the driver to this HSI device. */
cfhsi->dev->drv = &cfhsi->drv; cfhsi->ops->cb_ops = &cfhsi->cb_ops;
if (register_netdevice(dev)) { if (register_netdevice(dev)) {
pr_warn("%s: device rtml registration failed\n", __func__); pr_warn("%s: caif_hsi device registration failed\n", __func__);
goto err; goto err;
} }
/* Add CAIF HSI device to list. */ /* Add CAIF HSI device to list. */
list_add_tail(&cfhsi->list, &cfhsi_list); list_add_tail(&cfhsi->list, &cfhsi_list);
return 0; return 0;
err: err:
symbol_put(cfhsi_get_device); symbol_put(cfhsi_get_ops);
return -ENODEV; return -ENODEV;
} }
......
...@@ -93,25 +93,25 @@ struct cfhsi_desc { ...@@ -93,25 +93,25 @@ struct cfhsi_desc {
#endif #endif
/* Structure implemented by the CAIF HSI driver. */ /* Structure implemented by the CAIF HSI driver. */
struct cfhsi_drv { struct cfhsi_cb_ops {
void (*tx_done_cb) (struct cfhsi_drv *drv); void (*tx_done_cb) (struct cfhsi_cb_ops *drv);
void (*rx_done_cb) (struct cfhsi_drv *drv); void (*rx_done_cb) (struct cfhsi_cb_ops *drv);
void (*wake_up_cb) (struct cfhsi_drv *drv); void (*wake_up_cb) (struct cfhsi_cb_ops *drv);
void (*wake_down_cb) (struct cfhsi_drv *drv); void (*wake_down_cb) (struct cfhsi_cb_ops *drv);
}; };
/* Structure implemented by HSI device. */ /* Structure implemented by HSI device. */
struct cfhsi_dev { struct cfhsi_ops {
int (*cfhsi_up) (struct cfhsi_dev *dev); int (*cfhsi_up) (struct cfhsi_ops *dev);
int (*cfhsi_down) (struct cfhsi_dev *dev); int (*cfhsi_down) (struct cfhsi_ops *dev);
int (*cfhsi_tx) (u8 *ptr, int len, struct cfhsi_dev *dev); int (*cfhsi_tx) (u8 *ptr, int len, struct cfhsi_ops *dev);
int (*cfhsi_rx) (u8 *ptr, int len, struct cfhsi_dev *dev); int (*cfhsi_rx) (u8 *ptr, int len, struct cfhsi_ops *dev);
int (*cfhsi_wake_up) (struct cfhsi_dev *dev); int (*cfhsi_wake_up) (struct cfhsi_ops *dev);
int (*cfhsi_wake_down) (struct cfhsi_dev *dev); int (*cfhsi_wake_down) (struct cfhsi_ops *dev);
int (*cfhsi_get_peer_wake) (struct cfhsi_dev *dev, bool *status); int (*cfhsi_get_peer_wake) (struct cfhsi_ops *dev, bool *status);
int (*cfhsi_fifo_occupancy)(struct cfhsi_dev *dev, size_t *occupancy); int (*cfhsi_fifo_occupancy) (struct cfhsi_ops *dev, size_t *occupancy);
int (*cfhsi_rx_cancel)(struct cfhsi_dev *dev); int (*cfhsi_rx_cancel)(struct cfhsi_ops *dev);
struct cfhsi_drv *drv; struct cfhsi_cb_ops *cb_ops;
}; };
/* Structure holds status of received CAIF frames processing */ /* Structure holds status of received CAIF frames processing */
...@@ -138,8 +138,8 @@ struct cfhsi { ...@@ -138,8 +138,8 @@ struct cfhsi {
struct net_device *ndev; struct net_device *ndev;
struct platform_device *pdev; struct platform_device *pdev;
struct sk_buff_head qhead[CFHSI_PRIO_LAST]; struct sk_buff_head qhead[CFHSI_PRIO_LAST];
struct cfhsi_drv drv; struct cfhsi_cb_ops cb_ops;
struct cfhsi_dev *dev; struct cfhsi_ops *ops;
int tx_state; int tx_state;
struct cfhsi_rx_state rx_state; struct cfhsi_rx_state rx_state;
unsigned long inactivity_timeout; unsigned long inactivity_timeout;
...@@ -190,6 +190,6 @@ enum ifla_caif_hsi { ...@@ -190,6 +190,6 @@ enum ifla_caif_hsi {
__IFLA_CAIF_HSI_MAX __IFLA_CAIF_HSI_MAX
}; };
extern struct platform_device *cfhsi_get_device(void); extern struct cfhsi_ops *cfhsi_get_ops(void);
#endif /* CAIF_HSI_H_ */ #endif /* CAIF_HSI_H_ */
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