Commit d97a077a authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

wan: make LAPB callbacks const

This is compile tested only.
Suggested by dumpster diving in PAX.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 026359bc
...@@ -134,15 +134,15 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -134,15 +134,15 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
static int x25_open(struct net_device *dev) static int x25_open(struct net_device *dev)
{ {
struct lapb_register_struct cb;
int result; int result;
static const struct lapb_register_struct cb = {
cb.connect_confirmation = x25_connected; .connect_confirmation = x25_connected,
cb.connect_indication = x25_connected; .connect_indication = x25_connected,
cb.disconnect_confirmation = x25_disconnected; .disconnect_confirmation = x25_disconnected,
cb.disconnect_indication = x25_disconnected; .disconnect_indication = x25_disconnected,
cb.data_indication = x25_data_indication; .data_indication = x25_data_indication,
cb.data_transmit = x25_data_transmit; .data_transmit = x25_data_transmit,
};
result = lapb_register(dev, &cb); result = lapb_register(dev, &cb);
if (result != LAPB_OK) if (result != LAPB_OK)
......
...@@ -259,14 +259,13 @@ static int lapbeth_set_mac_address(struct net_device *dev, void *addr) ...@@ -259,14 +259,13 @@ static int lapbeth_set_mac_address(struct net_device *dev, void *addr)
} }
static struct lapb_register_struct lapbeth_callbacks = { static const struct lapb_register_struct lapbeth_callbacks = {
.connect_confirmation = lapbeth_connected, .connect_confirmation = lapbeth_connected,
.connect_indication = lapbeth_connected, .connect_indication = lapbeth_connected,
.disconnect_confirmation = lapbeth_disconnected, .disconnect_confirmation = lapbeth_disconnected,
.disconnect_indication = lapbeth_disconnected, .disconnect_indication = lapbeth_disconnected,
.data_indication = lapbeth_data_indication, .data_indication = lapbeth_data_indication,
.data_transmit = lapbeth_data_transmit, .data_transmit = lapbeth_data_transmit,
}; };
/* /*
......
...@@ -434,14 +434,13 @@ static void x25_asy_disconnected(struct net_device *dev, int reason) ...@@ -434,14 +434,13 @@ static void x25_asy_disconnected(struct net_device *dev, int reason)
netif_rx(skb); netif_rx(skb);
} }
static struct lapb_register_struct x25_asy_callbacks = { static const struct lapb_register_struct x25_asy_callbacks = {
.connect_confirmation = x25_asy_connected, .connect_confirmation = x25_asy_connected,
.connect_indication = x25_asy_connected, .connect_indication = x25_asy_connected,
.disconnect_confirmation = x25_asy_disconnected, .disconnect_confirmation = x25_asy_disconnected,
.disconnect_indication = x25_asy_disconnected, .disconnect_indication = x25_asy_disconnected,
.data_indication = x25_asy_data_indication, .data_indication = x25_asy_data_indication,
.data_transmit = x25_asy_data_transmit, .data_transmit = x25_asy_data_transmit,
}; };
......
...@@ -44,7 +44,8 @@ struct lapb_parms_struct { ...@@ -44,7 +44,8 @@ struct lapb_parms_struct {
unsigned int mode; unsigned int mode;
}; };
extern int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks); extern int lapb_register(struct net_device *dev,
const struct lapb_register_struct *callbacks);
extern int lapb_unregister(struct net_device *dev); extern int lapb_unregister(struct net_device *dev);
extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms); extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms);
extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms); extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms);
......
...@@ -95,7 +95,7 @@ struct lapb_cb { ...@@ -95,7 +95,7 @@ struct lapb_cb {
struct sk_buff_head write_queue; struct sk_buff_head write_queue;
struct sk_buff_head ack_queue; struct sk_buff_head ack_queue;
unsigned char window; unsigned char window;
struct lapb_register_struct callbacks; const struct lapb_register_struct *callbacks;
/* FRMR control information */ /* FRMR control information */
struct lapb_frame frmr_data; struct lapb_frame frmr_data;
......
...@@ -139,7 +139,8 @@ static struct lapb_cb *lapb_create_cb(void) ...@@ -139,7 +139,8 @@ static struct lapb_cb *lapb_create_cb(void)
return lapb; return lapb;
} }
int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks) int lapb_register(struct net_device *dev,
const struct lapb_register_struct *callbacks)
{ {
struct lapb_cb *lapb; struct lapb_cb *lapb;
int rc = LAPB_BADTOKEN; int rc = LAPB_BADTOKEN;
...@@ -158,7 +159,7 @@ int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks ...@@ -158,7 +159,7 @@ int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks
goto out; goto out;
lapb->dev = dev; lapb->dev = dev;
lapb->callbacks = *callbacks; lapb->callbacks = callbacks;
__lapb_insert_cb(lapb); __lapb_insert_cb(lapb);
...@@ -380,32 +381,32 @@ int lapb_data_received(struct net_device *dev, struct sk_buff *skb) ...@@ -380,32 +381,32 @@ int lapb_data_received(struct net_device *dev, struct sk_buff *skb)
void lapb_connect_confirmation(struct lapb_cb *lapb, int reason) void lapb_connect_confirmation(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.connect_confirmation) if (lapb->callbacks->connect_confirmation)
lapb->callbacks.connect_confirmation(lapb->dev, reason); lapb->callbacks->connect_confirmation(lapb->dev, reason);
} }
void lapb_connect_indication(struct lapb_cb *lapb, int reason) void lapb_connect_indication(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.connect_indication) if (lapb->callbacks->connect_indication)
lapb->callbacks.connect_indication(lapb->dev, reason); lapb->callbacks->connect_indication(lapb->dev, reason);
} }
void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason) void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.disconnect_confirmation) if (lapb->callbacks->disconnect_confirmation)
lapb->callbacks.disconnect_confirmation(lapb->dev, reason); lapb->callbacks->disconnect_confirmation(lapb->dev, reason);
} }
void lapb_disconnect_indication(struct lapb_cb *lapb, int reason) void lapb_disconnect_indication(struct lapb_cb *lapb, int reason)
{ {
if (lapb->callbacks.disconnect_indication) if (lapb->callbacks->disconnect_indication)
lapb->callbacks.disconnect_indication(lapb->dev, reason); lapb->callbacks->disconnect_indication(lapb->dev, reason);
} }
int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb) int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb)
{ {
if (lapb->callbacks.data_indication) if (lapb->callbacks->data_indication)
return lapb->callbacks.data_indication(lapb->dev, skb); return lapb->callbacks->data_indication(lapb->dev, skb);
kfree_skb(skb); kfree_skb(skb);
return NET_RX_SUCCESS; /* For now; must be != NET_RX_DROP */ return NET_RX_SUCCESS; /* For now; must be != NET_RX_DROP */
...@@ -415,8 +416,8 @@ int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb) ...@@ -415,8 +416,8 @@ int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb)
{ {
int used = 0; int used = 0;
if (lapb->callbacks.data_transmit) { if (lapb->callbacks->data_transmit) {
lapb->callbacks.data_transmit(lapb->dev, skb); lapb->callbacks->data_transmit(lapb->dev, skb);
used = 1; used = 1;
} }
......
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