diff options
author | Samuel Ortiz <samuel@sortiz.org> | 2006-09-27 23:06:44 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-28 21:02:48 -0400 |
commit | 1b0fee7d68f234be6b270cda51d9fcb71bebd780 (patch) | |
tree | 11e734d80ebaf2f0a053f912bfc59068c33ef4aa /net/irda/irlan | |
parent | 778e6398d32590eaf2333706318cbcd04dbe50b7 (diff) |
[IrDA]: Memory allocations cleanups
This patch replaces the bunch of arbitrary 64 and 128 bytes alloc_skb() calls
with more accurate allocation sizes.
Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/irda/irlan')
-rw-r--r-- | net/irda/irlan/irlan_common.c | 46 | ||||
-rw-r--r-- | net/irda/irlan/irlan_provider.c | 12 |
2 files changed, 46 insertions, 12 deletions
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c index 7dd0a2fe1d20..9b962f247714 100644 --- a/net/irda/irlan/irlan_common.c +++ b/net/irda/irlan/irlan_common.c | |||
@@ -636,7 +636,8 @@ void irlan_get_provider_info(struct irlan_cb *self) | |||
636 | IRDA_ASSERT(self != NULL, return;); | 636 | IRDA_ASSERT(self != NULL, return;); |
637 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 637 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
638 | 638 | ||
639 | skb = alloc_skb(64, GFP_ATOMIC); | 639 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER, |
640 | GFP_ATOMIC); | ||
640 | if (!skb) | 641 | if (!skb) |
641 | return; | 642 | return; |
642 | 643 | ||
@@ -668,7 +669,10 @@ void irlan_open_data_channel(struct irlan_cb *self) | |||
668 | IRDA_ASSERT(self != NULL, return;); | 669 | IRDA_ASSERT(self != NULL, return;); |
669 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 670 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
670 | 671 | ||
671 | skb = alloc_skb(64, GFP_ATOMIC); | 672 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
673 | IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") + | ||
674 | IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"), | ||
675 | GFP_ATOMIC); | ||
672 | if (!skb) | 676 | if (!skb) |
673 | return; | 677 | return; |
674 | 678 | ||
@@ -704,7 +708,9 @@ void irlan_close_data_channel(struct irlan_cb *self) | |||
704 | if (self->client.tsap_ctrl == NULL) | 708 | if (self->client.tsap_ctrl == NULL) |
705 | return; | 709 | return; |
706 | 710 | ||
707 | skb = alloc_skb(64, GFP_ATOMIC); | 711 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
712 | IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN"), | ||
713 | GFP_ATOMIC); | ||
708 | if (!skb) | 714 | if (!skb) |
709 | return; | 715 | return; |
710 | 716 | ||
@@ -715,7 +721,7 @@ void irlan_close_data_channel(struct irlan_cb *self) | |||
715 | 721 | ||
716 | /* Build frame */ | 722 | /* Build frame */ |
717 | frame[0] = CMD_CLOSE_DATA_CHAN; | 723 | frame[0] = CMD_CLOSE_DATA_CHAN; |
718 | frame[1] = 0x01; /* Two parameters */ | 724 | frame[1] = 0x01; /* One parameter */ |
719 | 725 | ||
720 | irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); | 726 | irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); |
721 | 727 | ||
@@ -739,7 +745,11 @@ static void irlan_open_unicast_addr(struct irlan_cb *self) | |||
739 | IRDA_ASSERT(self != NULL, return;); | 745 | IRDA_ASSERT(self != NULL, return;); |
740 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 746 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
741 | 747 | ||
742 | skb = alloc_skb(128, GFP_ATOMIC); | 748 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
749 | IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + | ||
750 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + | ||
751 | IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"), | ||
752 | GFP_ATOMIC); | ||
743 | if (!skb) | 753 | if (!skb) |
744 | return; | 754 | return; |
745 | 755 | ||
@@ -777,7 +787,12 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status) | |||
777 | IRDA_ASSERT(self != NULL, return;); | 787 | IRDA_ASSERT(self != NULL, return;); |
778 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 788 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
779 | 789 | ||
780 | skb = alloc_skb(128, GFP_ATOMIC); | 790 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
791 | IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + | ||
792 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") + | ||
793 | /* We may waste one byte here...*/ | ||
794 | IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"), | ||
795 | GFP_ATOMIC); | ||
781 | if (!skb) | 796 | if (!skb) |
782 | return; | 797 | return; |
783 | 798 | ||
@@ -816,7 +831,12 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status) | |||
816 | IRDA_ASSERT(self != NULL, return;); | 831 | IRDA_ASSERT(self != NULL, return;); |
817 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 832 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
818 | 833 | ||
819 | skb = alloc_skb(128, GFP_ATOMIC); | 834 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
835 | IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + | ||
836 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") + | ||
837 | /* We may waste one byte here...*/ | ||
838 | IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "NONE"), | ||
839 | GFP_ATOMIC); | ||
820 | if (!skb) | 840 | if (!skb) |
821 | return; | 841 | return; |
822 | 842 | ||
@@ -856,7 +876,12 @@ static void irlan_get_unicast_addr(struct irlan_cb *self) | |||
856 | IRDA_ASSERT(self != NULL, return;); | 876 | IRDA_ASSERT(self != NULL, return;); |
857 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 877 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
858 | 878 | ||
859 | skb = alloc_skb(128, GFP_ATOMIC); | 879 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
880 | IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + | ||
881 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + | ||
882 | IRLAN_STRING_PARAMETER_LEN("FILTER_OPERATION", | ||
883 | "DYNAMIC"), | ||
884 | GFP_ATOMIC); | ||
860 | if (!skb) | 885 | if (!skb) |
861 | return; | 886 | return; |
862 | 887 | ||
@@ -891,7 +916,10 @@ void irlan_get_media_char(struct irlan_cb *self) | |||
891 | IRDA_ASSERT(self != NULL, return;); | 916 | IRDA_ASSERT(self != NULL, return;); |
892 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 917 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
893 | 918 | ||
894 | skb = alloc_skb(64, GFP_ATOMIC); | 919 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
920 | IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"), | ||
921 | GFP_ATOMIC); | ||
922 | |||
895 | if (!skb) | 923 | if (!skb) |
896 | return; | 924 | return; |
897 | 925 | ||
diff --git a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c index 9c0df86044d7..58efde919667 100644 --- a/net/irda/irlan/irlan_provider.c +++ b/net/irda/irlan/irlan_provider.c | |||
@@ -296,7 +296,14 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command, | |||
296 | IRDA_ASSERT(self != NULL, return;); | 296 | IRDA_ASSERT(self != NULL, return;); |
297 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 297 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
298 | 298 | ||
299 | skb = alloc_skb(128, GFP_ATOMIC); | 299 | skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + |
300 | /* Bigger param length comes from CMD_GET_MEDIA_CHAR */ | ||
301 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + | ||
302 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BORADCAST") + | ||
303 | IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") + | ||
304 | IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "HOSTED"), | ||
305 | GFP_ATOMIC); | ||
306 | |||
300 | if (!skb) | 307 | if (!skb) |
301 | return; | 308 | return; |
302 | 309 | ||
@@ -354,8 +361,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command, | |||
354 | } else | 361 | } else |
355 | skb->data[1] = 0x02; /* 2 parameters */ | 362 | skb->data[1] = 0x02; /* 2 parameters */ |
356 | irlan_insert_byte_param(skb, "DATA_CHAN", self->stsap_sel_data); | 363 | irlan_insert_byte_param(skb, "DATA_CHAN", self->stsap_sel_data); |
357 | irlan_insert_array_param(skb, "RECONNECT_KEY", "LINUX RULES!", | 364 | irlan_insert_string_param(skb, "RECONNECT_KEY", "LINUX RULES!"); |
358 | 12); | ||
359 | break; | 365 | break; |
360 | case CMD_FILTER_OPERATION: | 366 | case CMD_FILTER_OPERATION: |
361 | irlan_filter_request(self, skb); | 367 | irlan_filter_request(self, skb); |