Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wan: make LAPB callbacks const

This is compile tested only.
Suggested by dumpster diving in PAX.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

stephen hemminger and committed by
David S. Miller
d97a077a 026359bc

+28 -28
+8 -8
drivers/net/wan/hdlc_x25.c
··· 134 134 135 135 static int x25_open(struct net_device *dev) 136 136 { 137 - struct lapb_register_struct cb; 138 137 int result; 139 - 140 - cb.connect_confirmation = x25_connected; 141 - cb.connect_indication = x25_connected; 142 - cb.disconnect_confirmation = x25_disconnected; 143 - cb.disconnect_indication = x25_disconnected; 144 - cb.data_indication = x25_data_indication; 145 - cb.data_transmit = x25_data_transmit; 138 + static const struct lapb_register_struct cb = { 139 + .connect_confirmation = x25_connected, 140 + .connect_indication = x25_connected, 141 + .disconnect_confirmation = x25_disconnected, 142 + .disconnect_indication = x25_disconnected, 143 + .data_indication = x25_data_indication, 144 + .data_transmit = x25_data_transmit, 145 + }; 146 146 147 147 result = lapb_register(dev, &cb); 148 148 if (result != LAPB_OK)
+1 -2
drivers/net/wan/lapbether.c
··· 259 259 } 260 260 261 261 262 - static struct lapb_register_struct lapbeth_callbacks = { 262 + static const struct lapb_register_struct lapbeth_callbacks = { 263 263 .connect_confirmation = lapbeth_connected, 264 264 .connect_indication = lapbeth_connected, 265 265 .disconnect_confirmation = lapbeth_disconnected, 266 266 .disconnect_indication = lapbeth_disconnected, 267 267 .data_indication = lapbeth_data_indication, 268 268 .data_transmit = lapbeth_data_transmit, 269 - 270 269 }; 271 270 272 271 /*
+1 -2
drivers/net/wan/x25_asy.c
··· 434 434 netif_rx(skb); 435 435 } 436 436 437 - static struct lapb_register_struct x25_asy_callbacks = { 437 + static const struct lapb_register_struct x25_asy_callbacks = { 438 438 .connect_confirmation = x25_asy_connected, 439 439 .connect_indication = x25_asy_connected, 440 440 .disconnect_confirmation = x25_asy_disconnected, 441 441 .disconnect_indication = x25_asy_disconnected, 442 442 .data_indication = x25_asy_data_indication, 443 443 .data_transmit = x25_asy_data_transmit, 444 - 445 444 }; 446 445 447 446
+2 -1
include/linux/lapb.h
··· 44 44 unsigned int mode; 45 45 }; 46 46 47 - extern int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks); 47 + extern int lapb_register(struct net_device *dev, 48 + const struct lapb_register_struct *callbacks); 48 49 extern int lapb_unregister(struct net_device *dev); 49 50 extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms); 50 51 extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms);
+1 -1
include/net/lapb.h
··· 95 95 struct sk_buff_head write_queue; 96 96 struct sk_buff_head ack_queue; 97 97 unsigned char window; 98 - struct lapb_register_struct callbacks; 98 + const struct lapb_register_struct *callbacks; 99 99 100 100 /* FRMR control information */ 101 101 struct lapb_frame frmr_data;
+15 -14
net/lapb/lapb_iface.c
··· 139 139 return lapb; 140 140 } 141 141 142 - int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks) 142 + int lapb_register(struct net_device *dev, 143 + const struct lapb_register_struct *callbacks) 143 144 { 144 145 struct lapb_cb *lapb; 145 146 int rc = LAPB_BADTOKEN; ··· 159 158 goto out; 160 159 161 160 lapb->dev = dev; 162 - lapb->callbacks = *callbacks; 161 + lapb->callbacks = callbacks; 163 162 164 163 __lapb_insert_cb(lapb); 165 164 ··· 381 380 382 381 void lapb_connect_confirmation(struct lapb_cb *lapb, int reason) 383 382 { 384 - if (lapb->callbacks.connect_confirmation) 385 - lapb->callbacks.connect_confirmation(lapb->dev, reason); 383 + if (lapb->callbacks->connect_confirmation) 384 + lapb->callbacks->connect_confirmation(lapb->dev, reason); 386 385 } 387 386 388 387 void lapb_connect_indication(struct lapb_cb *lapb, int reason) 389 388 { 390 - if (lapb->callbacks.connect_indication) 391 - lapb->callbacks.connect_indication(lapb->dev, reason); 389 + if (lapb->callbacks->connect_indication) 390 + lapb->callbacks->connect_indication(lapb->dev, reason); 392 391 } 393 392 394 393 void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason) 395 394 { 396 - if (lapb->callbacks.disconnect_confirmation) 397 - lapb->callbacks.disconnect_confirmation(lapb->dev, reason); 395 + if (lapb->callbacks->disconnect_confirmation) 396 + lapb->callbacks->disconnect_confirmation(lapb->dev, reason); 398 397 } 399 398 400 399 void lapb_disconnect_indication(struct lapb_cb *lapb, int reason) 401 400 { 402 - if (lapb->callbacks.disconnect_indication) 403 - lapb->callbacks.disconnect_indication(lapb->dev, reason); 401 + if (lapb->callbacks->disconnect_indication) 402 + lapb->callbacks->disconnect_indication(lapb->dev, reason); 404 403 } 405 404 406 405 int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb) 407 406 { 408 - if (lapb->callbacks.data_indication) 409 - return lapb->callbacks.data_indication(lapb->dev, skb); 407 + if (lapb->callbacks->data_indication) 408 + return lapb->callbacks->data_indication(lapb->dev, skb); 410 409 411 410 kfree_skb(skb); 412 411 return NET_RX_SUCCESS; /* For now; must be != NET_RX_DROP */ ··· 416 415 { 417 416 int used = 0; 418 417 419 - if (lapb->callbacks.data_transmit) { 420 - lapb->callbacks.data_transmit(lapb->dev, skb); 418 + if (lapb->callbacks->data_transmit) { 419 + lapb->callbacks->data_transmit(lapb->dev, skb); 421 420 used = 1; 422 421 } 423 422