|
@@ -370,9 +370,8 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
{
|
|
|
struct qeth_card *card = dev_get_drvdata(dev);
|
|
|
- struct qeth_ipaddr *addr;
|
|
|
- int i, rc = 0;
|
|
|
bool enable;
|
|
|
+ int rc = 0;
|
|
|
|
|
|
if (!card)
|
|
|
return -EINVAL;
|
|
@@ -391,20 +390,12 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- if (card->ipato.enabled == enable)
|
|
|
- goto out;
|
|
|
- card->ipato.enabled = enable;
|
|
|
-
|
|
|
- spin_lock_bh(&card->ip_lock);
|
|
|
- hash_for_each(card->ip_htable, i, addr, hnode) {
|
|
|
- if (addr->type != QETH_IP_TYPE_NORMAL)
|
|
|
- continue;
|
|
|
- if (!enable)
|
|
|
- addr->set_flags &= ~QETH_IPA_SETIP_TAKEOVER_FLAG;
|
|
|
- else if (qeth_l3_is_addr_covered_by_ipato(card, addr))
|
|
|
- addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
|
|
|
+ if (card->ipato.enabled != enable) {
|
|
|
+ card->ipato.enabled = enable;
|
|
|
+ spin_lock_bh(&card->ip_lock);
|
|
|
+ qeth_l3_update_ipato(card);
|
|
|
+ spin_unlock_bh(&card->ip_lock);
|
|
|
}
|
|
|
- spin_unlock_bh(&card->ip_lock);
|
|
|
out:
|
|
|
mutex_unlock(&card->conf_mutex);
|
|
|
return rc ? rc : count;
|
|
@@ -430,20 +421,27 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
|
|
|
const char *buf, size_t count)
|
|
|
{
|
|
|
struct qeth_card *card = dev_get_drvdata(dev);
|
|
|
+ bool invert;
|
|
|
int rc = 0;
|
|
|
|
|
|
if (!card)
|
|
|
return -EINVAL;
|
|
|
|
|
|
mutex_lock(&card->conf_mutex);
|
|
|
- if (sysfs_streq(buf, "toggle"))
|
|
|
- card->ipato.invert4 = (card->ipato.invert4)? 0 : 1;
|
|
|
- else if (sysfs_streq(buf, "1"))
|
|
|
- card->ipato.invert4 = 1;
|
|
|
- else if (sysfs_streq(buf, "0"))
|
|
|
- card->ipato.invert4 = 0;
|
|
|
- else
|
|
|
+ if (sysfs_streq(buf, "toggle")) {
|
|
|
+ invert = !card->ipato.invert4;
|
|
|
+ } else if (kstrtobool(buf, &invert)) {
|
|
|
rc = -EINVAL;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (card->ipato.invert4 != invert) {
|
|
|
+ card->ipato.invert4 = invert;
|
|
|
+ spin_lock_bh(&card->ip_lock);
|
|
|
+ qeth_l3_update_ipato(card);
|
|
|
+ spin_unlock_bh(&card->ip_lock);
|
|
|
+ }
|
|
|
+out:
|
|
|
mutex_unlock(&card->conf_mutex);
|
|
|
return rc ? rc : count;
|
|
|
}
|
|
@@ -609,20 +607,27 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
|
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
|
{
|
|
|
struct qeth_card *card = dev_get_drvdata(dev);
|
|
|
+ bool invert;
|
|
|
int rc = 0;
|
|
|
|
|
|
if (!card)
|
|
|
return -EINVAL;
|
|
|
|
|
|
mutex_lock(&card->conf_mutex);
|
|
|
- if (sysfs_streq(buf, "toggle"))
|
|
|
- card->ipato.invert6 = (card->ipato.invert6)? 0 : 1;
|
|
|
- else if (sysfs_streq(buf, "1"))
|
|
|
- card->ipato.invert6 = 1;
|
|
|
- else if (sysfs_streq(buf, "0"))
|
|
|
- card->ipato.invert6 = 0;
|
|
|
- else
|
|
|
+ if (sysfs_streq(buf, "toggle")) {
|
|
|
+ invert = !card->ipato.invert6;
|
|
|
+ } else if (kstrtobool(buf, &invert)) {
|
|
|
rc = -EINVAL;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (card->ipato.invert6 != invert) {
|
|
|
+ card->ipato.invert6 = invert;
|
|
|
+ spin_lock_bh(&card->ip_lock);
|
|
|
+ qeth_l3_update_ipato(card);
|
|
|
+ spin_unlock_bh(&card->ip_lock);
|
|
|
+ }
|
|
|
+out:
|
|
|
mutex_unlock(&card->conf_mutex);
|
|
|
return rc ? rc : count;
|
|
|
}
|