@@ -460,25 +460,22 @@ static ssize_t qeth_l3_dev_ipato_add_store(const char *buf, size_t count,
460
460
int mask_bits ;
461
461
int rc = 0 ;
462
462
463
- mutex_lock (& card -> conf_mutex );
464
463
rc = qeth_l3_parse_ipatoe (buf , proto , addr , & mask_bits );
465
464
if (rc )
466
- goto out ;
465
+ return rc ;
467
466
468
467
ipatoe = kzalloc (sizeof (struct qeth_ipato_entry ), GFP_KERNEL );
469
- if (!ipatoe ) {
470
- rc = - ENOMEM ;
471
- goto out ;
472
- }
468
+ if (!ipatoe )
469
+ return - ENOMEM ;
470
+
473
471
ipatoe -> proto = proto ;
474
472
memcpy (ipatoe -> addr , addr , (proto == QETH_PROT_IPV4 )? 4 :16 );
475
473
ipatoe -> mask_bits = mask_bits ;
476
474
477
475
rc = qeth_l3_add_ipato_entry (card , ipatoe );
478
476
if (rc )
479
477
kfree (ipatoe );
480
- out :
481
- mutex_unlock (& card -> conf_mutex );
478
+
482
479
return rc ? rc : count ;
483
480
}
484
481
@@ -501,11 +498,9 @@ static ssize_t qeth_l3_dev_ipato_del_store(const char *buf, size_t count,
501
498
int mask_bits ;
502
499
int rc = 0 ;
503
500
504
- mutex_lock (& card -> conf_mutex );
505
501
rc = qeth_l3_parse_ipatoe (buf , proto , addr , & mask_bits );
506
502
if (!rc )
507
503
rc = qeth_l3_del_ipato_entry (card , proto , addr , mask_bits );
508
- mutex_unlock (& card -> conf_mutex );
509
504
return rc ? rc : count ;
510
505
}
511
506
@@ -650,63 +645,34 @@ static ssize_t qeth_l3_dev_vipa_add4_show(struct device *dev,
650
645
QETH_IP_TYPE_VIPA );
651
646
}
652
647
653
- static int qeth_l3_parse_vipae (const char * buf , enum qeth_prot_versions proto ,
654
- u8 * addr )
655
- {
656
- if (qeth_l3_string_to_ipaddr (buf , proto , addr )) {
657
- return - EINVAL ;
658
- }
659
- return 0 ;
660
- }
661
-
662
- static ssize_t qeth_l3_dev_vipa_add_store (const char * buf , size_t count ,
663
- struct qeth_card * card , enum qeth_prot_versions proto )
648
+ static ssize_t qeth_l3_vipa_store (struct device * dev , const char * buf , bool add ,
649
+ size_t count , enum qeth_prot_versions proto )
664
650
{
651
+ struct qeth_card * card = dev_get_drvdata (dev );
665
652
u8 addr [16 ] = {0 , };
666
653
int rc ;
667
654
668
- mutex_lock (& card -> conf_mutex );
669
- rc = qeth_l3_parse_vipae (buf , proto , addr );
655
+ rc = qeth_l3_string_to_ipaddr (buf , proto , addr );
670
656
if (!rc )
671
- rc = qeth_l3_modify_rxip_vipa (card , true , addr ,
657
+ rc = qeth_l3_modify_rxip_vipa (card , add , addr ,
672
658
QETH_IP_TYPE_VIPA , proto );
673
- mutex_unlock (& card -> conf_mutex );
674
659
return rc ? rc : count ;
675
660
}
676
661
677
662
static ssize_t qeth_l3_dev_vipa_add4_store (struct device * dev ,
678
663
struct device_attribute * attr , const char * buf , size_t count )
679
664
{
680
- struct qeth_card * card = dev_get_drvdata (dev );
681
-
682
- return qeth_l3_dev_vipa_add_store (buf , count , card , QETH_PROT_IPV4 );
665
+ return qeth_l3_vipa_store (dev , buf , true, count , QETH_PROT_IPV4 );
683
666
}
684
667
685
668
static QETH_DEVICE_ATTR (vipa_add4 , add4 , 0644 ,
686
669
qeth_l3_dev_vipa_add4_show ,
687
670
qeth_l3_dev_vipa_add4_store ) ;
688
671
689
- static ssize_t qeth_l3_dev_vipa_del_store (const char * buf , size_t count ,
690
- struct qeth_card * card , enum qeth_prot_versions proto )
691
- {
692
- u8 addr [16 ];
693
- int rc ;
694
-
695
- mutex_lock (& card -> conf_mutex );
696
- rc = qeth_l3_parse_vipae (buf , proto , addr );
697
- if (!rc )
698
- rc = qeth_l3_modify_rxip_vipa (card , false, addr ,
699
- QETH_IP_TYPE_VIPA , proto );
700
- mutex_unlock (& card -> conf_mutex );
701
- return rc ? rc : count ;
702
- }
703
-
704
672
static ssize_t qeth_l3_dev_vipa_del4_store (struct device * dev ,
705
673
struct device_attribute * attr , const char * buf , size_t count )
706
674
{
707
- struct qeth_card * card = dev_get_drvdata (dev );
708
-
709
- return qeth_l3_dev_vipa_del_store (buf , count , card , QETH_PROT_IPV4 );
675
+ return qeth_l3_vipa_store (dev , buf , true, count , QETH_PROT_IPV4 );
710
676
}
711
677
712
678
static QETH_DEVICE_ATTR (vipa_del4 , del4 , 0200 , NULL,
@@ -723,9 +689,7 @@ static ssize_t qeth_l3_dev_vipa_add6_show(struct device *dev,
723
689
static ssize_t qeth_l3_dev_vipa_add6_store (struct device * dev ,
724
690
struct device_attribute * attr , const char * buf , size_t count )
725
691
{
726
- struct qeth_card * card = dev_get_drvdata (dev );
727
-
728
- return qeth_l3_dev_vipa_add_store (buf , count , card , QETH_PROT_IPV6 );
692
+ return qeth_l3_vipa_store (dev , buf , true, count , QETH_PROT_IPV6 );
729
693
}
730
694
731
695
static QETH_DEVICE_ATTR (vipa_add6 , add6 , 0644 ,
@@ -735,9 +699,7 @@ static QETH_DEVICE_ATTR(vipa_add6, add6, 0644,
735
699
static ssize_t qeth_l3_dev_vipa_del6_store (struct device * dev ,
736
700
struct device_attribute * attr , const char * buf , size_t count )
737
701
{
738
- struct qeth_card * card = dev_get_drvdata (dev );
739
-
740
- return qeth_l3_dev_vipa_del_store (buf , count , card , QETH_PROT_IPV6 );
702
+ return qeth_l3_vipa_store (dev , buf , false, count , QETH_PROT_IPV6 );
741
703
}
742
704
743
705
static QETH_DEVICE_ATTR (vipa_del6 , del6 , 0200 , NULL,
@@ -790,54 +752,34 @@ static int qeth_l3_parse_rxipe(const char *buf, enum qeth_prot_versions proto,
790
752
return 0 ;
791
753
}
792
754
793
- static ssize_t qeth_l3_dev_rxip_add_store ( const char * buf , size_t count ,
794
- struct qeth_card * card , enum qeth_prot_versions proto )
755
+ static ssize_t qeth_l3_rxip_store ( struct device * dev , const char * buf , bool add ,
756
+ size_t count , enum qeth_prot_versions proto )
795
757
{
758
+ struct qeth_card * card = dev_get_drvdata (dev );
796
759
u8 addr [16 ] = {0 , };
797
760
int rc ;
798
761
799
- mutex_lock (& card -> conf_mutex );
800
762
rc = qeth_l3_parse_rxipe (buf , proto , addr );
801
763
if (!rc )
802
- rc = qeth_l3_modify_rxip_vipa (card , true , addr ,
764
+ rc = qeth_l3_modify_rxip_vipa (card , add , addr ,
803
765
QETH_IP_TYPE_RXIP , proto );
804
- mutex_unlock (& card -> conf_mutex );
805
766
return rc ? rc : count ;
806
767
}
807
768
808
769
static ssize_t qeth_l3_dev_rxip_add4_store (struct device * dev ,
809
770
struct device_attribute * attr , const char * buf , size_t count )
810
771
{
811
- struct qeth_card * card = dev_get_drvdata (dev );
812
-
813
- return qeth_l3_dev_rxip_add_store (buf , count , card , QETH_PROT_IPV4 );
772
+ return qeth_l3_rxip_store (dev , buf , true, count , QETH_PROT_IPV4 );
814
773
}
815
774
816
775
static QETH_DEVICE_ATTR (rxip_add4 , add4 , 0644 ,
817
776
qeth_l3_dev_rxip_add4_show ,
818
777
qeth_l3_dev_rxip_add4_store ) ;
819
778
820
- static ssize_t qeth_l3_dev_rxip_del_store (const char * buf , size_t count ,
821
- struct qeth_card * card , enum qeth_prot_versions proto )
822
- {
823
- u8 addr [16 ];
824
- int rc ;
825
-
826
- mutex_lock (& card -> conf_mutex );
827
- rc = qeth_l3_parse_rxipe (buf , proto , addr );
828
- if (!rc )
829
- rc = qeth_l3_modify_rxip_vipa (card , false, addr ,
830
- QETH_IP_TYPE_RXIP , proto );
831
- mutex_unlock (& card -> conf_mutex );
832
- return rc ? rc : count ;
833
- }
834
-
835
779
static ssize_t qeth_l3_dev_rxip_del4_store (struct device * dev ,
836
780
struct device_attribute * attr , const char * buf , size_t count )
837
781
{
838
- struct qeth_card * card = dev_get_drvdata (dev );
839
-
840
- return qeth_l3_dev_rxip_del_store (buf , count , card , QETH_PROT_IPV4 );
782
+ return qeth_l3_rxip_store (dev , buf , false, count , QETH_PROT_IPV4 );
841
783
}
842
784
843
785
static QETH_DEVICE_ATTR (rxip_del4 , del4 , 0200 , NULL,
@@ -854,9 +796,7 @@ static ssize_t qeth_l3_dev_rxip_add6_show(struct device *dev,
854
796
static ssize_t qeth_l3_dev_rxip_add6_store (struct device * dev ,
855
797
struct device_attribute * attr , const char * buf , size_t count )
856
798
{
857
- struct qeth_card * card = dev_get_drvdata (dev );
858
-
859
- return qeth_l3_dev_rxip_add_store (buf , count , card , QETH_PROT_IPV6 );
799
+ return qeth_l3_rxip_store (dev , buf , true, count , QETH_PROT_IPV6 );
860
800
}
861
801
862
802
static QETH_DEVICE_ATTR (rxip_add6 , add6 , 0644 ,
@@ -866,9 +806,7 @@ static QETH_DEVICE_ATTR(rxip_add6, add6, 0644,
866
806
static ssize_t qeth_l3_dev_rxip_del6_store (struct device * dev ,
867
807
struct device_attribute * attr , const char * buf , size_t count )
868
808
{
869
- struct qeth_card * card = dev_get_drvdata (dev );
870
-
871
- return qeth_l3_dev_rxip_del_store (buf , count , card , QETH_PROT_IPV6 );
809
+ return qeth_l3_rxip_store (dev , buf , false, count , QETH_PROT_IPV6 );
872
810
}
873
811
874
812
static QETH_DEVICE_ATTR (rxip_del6 , del6 , 0200 , NULL,
0 commit comments