@@ -370,8 +370,8 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
370370 struct device_attribute * attr , const char * buf , size_t count )
371371{
372372 struct qeth_card * card = dev_get_drvdata (dev );
373- struct qeth_ipaddr * addr ;
374- int i , rc = 0 ;
373+ bool enable ;
374+ int rc = 0 ;
375375
376376 if (!card )
377377 return - EINVAL ;
@@ -384,25 +384,18 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
384384 }
385385
386386 if (sysfs_streq (buf , "toggle" )) {
387- card -> ipato .enabled = (card -> ipato .enabled )? 0 : 1 ;
388- } else if (sysfs_streq (buf , "1" )) {
389- card -> ipato .enabled = 1 ;
390- hash_for_each (card -> ip_htable , i , addr , hnode ) {
391- if ((addr -> type == QETH_IP_TYPE_NORMAL ) &&
392- qeth_l3_is_addr_covered_by_ipato (card , addr ))
393- addr -> set_flags |=
394- QETH_IPA_SETIP_TAKEOVER_FLAG ;
395- }
396- } else if (sysfs_streq (buf , "0" )) {
397- card -> ipato .enabled = 0 ;
398- hash_for_each (card -> ip_htable , i , addr , hnode ) {
399- if (addr -> set_flags &
400- QETH_IPA_SETIP_TAKEOVER_FLAG )
401- addr -> set_flags &=
402- ~QETH_IPA_SETIP_TAKEOVER_FLAG ;
403- }
404- } else
387+ enable = !card -> ipato .enabled ;
388+ } else if (kstrtobool (buf , & enable )) {
405389 rc = - EINVAL ;
390+ goto out ;
391+ }
392+
393+ if (card -> ipato .enabled != enable ) {
394+ card -> ipato .enabled = enable ;
395+ spin_lock_bh (& card -> ip_lock );
396+ qeth_l3_update_ipato (card );
397+ spin_unlock_bh (& card -> ip_lock );
398+ }
406399out :
407400 mutex_unlock (& card -> conf_mutex );
408401 return rc ? rc : count ;
@@ -428,20 +421,27 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
428421 const char * buf , size_t count )
429422{
430423 struct qeth_card * card = dev_get_drvdata (dev );
424+ bool invert ;
431425 int rc = 0 ;
432426
433427 if (!card )
434428 return - EINVAL ;
435429
436430 mutex_lock (& card -> conf_mutex );
437- if (sysfs_streq (buf , "toggle" ))
438- card -> ipato .invert4 = (card -> ipato .invert4 )? 0 : 1 ;
439- else if (sysfs_streq (buf , "1" ))
440- card -> ipato .invert4 = 1 ;
441- else if (sysfs_streq (buf , "0" ))
442- card -> ipato .invert4 = 0 ;
443- else
431+ if (sysfs_streq (buf , "toggle" )) {
432+ invert = !card -> ipato .invert4 ;
433+ } else if (kstrtobool (buf , & invert )) {
444434 rc = - EINVAL ;
435+ goto out ;
436+ }
437+
438+ if (card -> ipato .invert4 != invert ) {
439+ card -> ipato .invert4 = invert ;
440+ spin_lock_bh (& card -> ip_lock );
441+ qeth_l3_update_ipato (card );
442+ spin_unlock_bh (& card -> ip_lock );
443+ }
444+ out :
445445 mutex_unlock (& card -> conf_mutex );
446446 return rc ? rc : count ;
447447}
@@ -607,20 +607,27 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
607607 struct device_attribute * attr , const char * buf , size_t count )
608608{
609609 struct qeth_card * card = dev_get_drvdata (dev );
610+ bool invert ;
610611 int rc = 0 ;
611612
612613 if (!card )
613614 return - EINVAL ;
614615
615616 mutex_lock (& card -> conf_mutex );
616- if (sysfs_streq (buf , "toggle" ))
617- card -> ipato .invert6 = (card -> ipato .invert6 )? 0 : 1 ;
618- else if (sysfs_streq (buf , "1" ))
619- card -> ipato .invert6 = 1 ;
620- else if (sysfs_streq (buf , "0" ))
621- card -> ipato .invert6 = 0 ;
622- else
617+ if (sysfs_streq (buf , "toggle" )) {
618+ invert = !card -> ipato .invert6 ;
619+ } else if (kstrtobool (buf , & invert )) {
623620 rc = - EINVAL ;
621+ goto out ;
622+ }
623+
624+ if (card -> ipato .invert6 != invert ) {
625+ card -> ipato .invert6 = invert ;
626+ spin_lock_bh (& card -> ip_lock );
627+ qeth_l3_update_ipato (card );
628+ spin_unlock_bh (& card -> ip_lock );
629+ }
630+ out :
624631 mutex_unlock (& card -> conf_mutex );
625632 return rc ? rc : count ;
626633}
0 commit comments