Commit 0b81c6c6 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: don't check drvdata in sysfs code

Given the way how the sysfs attributes are registered / unregistered,
the show/store helpers will never be called with a NULL drvdata.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b80c08ac
...@@ -20,8 +20,6 @@ static ssize_t qeth_dev_state_show(struct device *dev, ...@@ -20,8 +20,6 @@ static ssize_t qeth_dev_state_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
switch (card->state) { switch (card->state) {
case CARD_STATE_DOWN: case CARD_STATE_DOWN:
...@@ -45,8 +43,6 @@ static ssize_t qeth_dev_chpid_show(struct device *dev, ...@@ -45,8 +43,6 @@ static ssize_t qeth_dev_chpid_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%02X\n", card->info.chpid); return sprintf(buf, "%02X\n", card->info.chpid);
} }
...@@ -57,8 +53,7 @@ static ssize_t qeth_dev_if_name_show(struct device *dev, ...@@ -57,8 +53,7 @@ static ssize_t qeth_dev_if_name_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card)); return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card));
} }
...@@ -68,8 +63,6 @@ static ssize_t qeth_dev_card_type_show(struct device *dev, ...@@ -68,8 +63,6 @@ static ssize_t qeth_dev_card_type_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%s\n", qeth_get_cardname_short(card)); return sprintf(buf, "%s\n", qeth_get_cardname_short(card));
} }
...@@ -94,8 +87,6 @@ static ssize_t qeth_dev_inbuf_size_show(struct device *dev, ...@@ -94,8 +87,6 @@ static ssize_t qeth_dev_inbuf_size_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%s\n", qeth_get_bufsize_str(card)); return sprintf(buf, "%s\n", qeth_get_bufsize_str(card));
} }
...@@ -106,8 +97,6 @@ static ssize_t qeth_dev_portno_show(struct device *dev, ...@@ -106,8 +97,6 @@ static ssize_t qeth_dev_portno_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->dev->dev_port); return sprintf(buf, "%i\n", card->dev->dev_port);
} }
...@@ -120,9 +109,6 @@ static ssize_t qeth_dev_portno_store(struct device *dev, ...@@ -120,9 +109,6 @@ static ssize_t qeth_dev_portno_store(struct device *dev,
unsigned int portno, limit; unsigned int portno, limit;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -171,9 +157,6 @@ static ssize_t qeth_dev_prioqing_show(struct device *dev, ...@@ -171,9 +157,6 @@ static ssize_t qeth_dev_prioqing_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
switch (card->qdio.do_prio_queueing) { switch (card->qdio.do_prio_queueing) {
case QETH_PRIO_Q_ING_PREC: case QETH_PRIO_Q_ING_PREC:
return sprintf(buf, "%s\n", "by precedence"); return sprintf(buf, "%s\n", "by precedence");
...@@ -195,9 +178,6 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev, ...@@ -195,9 +178,6 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev,
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
if (IS_IQD(card)) if (IS_IQD(card))
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -262,9 +242,6 @@ static ssize_t qeth_dev_bufcnt_show(struct device *dev, ...@@ -262,9 +242,6 @@ static ssize_t qeth_dev_bufcnt_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count); return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count);
} }
...@@ -276,9 +253,6 @@ static ssize_t qeth_dev_bufcnt_store(struct device *dev, ...@@ -276,9 +253,6 @@ static ssize_t qeth_dev_bufcnt_store(struct device *dev,
int cnt, old_cnt; int cnt, old_cnt;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -307,9 +281,6 @@ static ssize_t qeth_dev_recover_store(struct device *dev, ...@@ -307,9 +281,6 @@ static ssize_t qeth_dev_recover_store(struct device *dev,
char *tmp; char *tmp;
int i; int i;
if (!card)
return -EINVAL;
if (!qeth_card_hw_is_reachable(card)) if (!qeth_card_hw_is_reachable(card))
return -EPERM; return -EPERM;
...@@ -325,11 +296,6 @@ static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store); ...@@ -325,11 +296,6 @@ static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store);
static ssize_t qeth_dev_performance_stats_show(struct device *dev, static ssize_t qeth_dev_performance_stats_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "1\n"); return sprintf(buf, "1\n");
} }
...@@ -342,9 +308,6 @@ static ssize_t qeth_dev_performance_stats_store(struct device *dev, ...@@ -342,9 +308,6 @@ static ssize_t qeth_dev_performance_stats_store(struct device *dev,
bool reset; bool reset;
int rc; int rc;
if (!card)
return -EINVAL;
rc = kstrtobool(buf, &reset); rc = kstrtobool(buf, &reset);
if (rc) if (rc)
return rc; return rc;
...@@ -370,9 +333,6 @@ static ssize_t qeth_dev_layer2_show(struct device *dev, ...@@ -370,9 +333,6 @@ static ssize_t qeth_dev_layer2_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->options.layer); return sprintf(buf, "%i\n", card->options.layer);
} }
...@@ -385,9 +345,6 @@ static ssize_t qeth_dev_layer2_store(struct device *dev, ...@@ -385,9 +345,6 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
int i, rc = 0; int i, rc = 0;
enum qeth_discipline_id newdis; enum qeth_discipline_id newdis;
if (!card)
return -EINVAL;
mutex_lock(&card->discipline_mutex); mutex_lock(&card->discipline_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -453,9 +410,6 @@ static ssize_t qeth_dev_isolation_show(struct device *dev, ...@@ -453,9 +410,6 @@ static ssize_t qeth_dev_isolation_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
switch (card->options.isolation) { switch (card->options.isolation) {
case ISOLATION_MODE_NONE: case ISOLATION_MODE_NONE:
return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_NONE); return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_NONE);
...@@ -475,9 +429,6 @@ static ssize_t qeth_dev_isolation_store(struct device *dev, ...@@ -475,9 +429,6 @@ static ssize_t qeth_dev_isolation_store(struct device *dev,
enum qeth_ipa_isolation_modes isolation; enum qeth_ipa_isolation_modes isolation;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (!IS_OSD(card) && !IS_OSX(card)) { if (!IS_OSD(card) && !IS_OSX(card)) {
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
...@@ -522,9 +473,6 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev, ...@@ -522,9 +473,6 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev,
struct qeth_switch_info sw_info; struct qeth_switch_info sw_info;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
if (!qeth_card_hw_is_reachable(card)) if (!qeth_card_hw_is_reachable(card))
return sprintf(buf, "n/a\n"); return sprintf(buf, "n/a\n");
...@@ -555,8 +503,6 @@ static ssize_t qeth_hw_trap_show(struct device *dev, ...@@ -555,8 +503,6 @@ static ssize_t qeth_hw_trap_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
if (card->info.hwtrap) if (card->info.hwtrap)
return snprintf(buf, 5, "arm\n"); return snprintf(buf, 5, "arm\n");
else else
...@@ -570,9 +516,6 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -570,9 +516,6 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
int rc = 0; int rc = 0;
int state = 0; int state = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (qeth_card_hw_is_reachable(card)) if (qeth_card_hw_is_reachable(card))
state = 1; state = 1;
...@@ -607,24 +550,12 @@ static ssize_t qeth_hw_trap_store(struct device *dev, ...@@ -607,24 +550,12 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
static DEVICE_ATTR(hw_trap, 0644, qeth_hw_trap_show, static DEVICE_ATTR(hw_trap, 0644, qeth_hw_trap_show,
qeth_hw_trap_store); qeth_hw_trap_store);
static ssize_t qeth_dev_blkt_show(char *buf, struct qeth_card *card, int value)
{
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", value);
}
static ssize_t qeth_dev_blkt_store(struct qeth_card *card, static ssize_t qeth_dev_blkt_store(struct qeth_card *card,
const char *buf, size_t count, int *value, int max_value) const char *buf, size_t count, int *value, int max_value)
{ {
char *tmp; char *tmp;
int i, rc = 0; int i, rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -645,7 +576,7 @@ static ssize_t qeth_dev_blkt_total_show(struct device *dev, ...@@ -645,7 +576,7 @@ static ssize_t qeth_dev_blkt_total_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
return qeth_dev_blkt_show(buf, card, card->info.blkt.time_total); return sprintf(buf, "%i\n", card->info.blkt.time_total);
} }
static ssize_t qeth_dev_blkt_total_store(struct device *dev, static ssize_t qeth_dev_blkt_total_store(struct device *dev,
...@@ -657,8 +588,6 @@ static ssize_t qeth_dev_blkt_total_store(struct device *dev, ...@@ -657,8 +588,6 @@ static ssize_t qeth_dev_blkt_total_store(struct device *dev,
&card->info.blkt.time_total, 5000); &card->info.blkt.time_total, 5000);
} }
static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show, static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show,
qeth_dev_blkt_total_store); qeth_dev_blkt_total_store);
...@@ -667,7 +596,7 @@ static ssize_t qeth_dev_blkt_inter_show(struct device *dev, ...@@ -667,7 +596,7 @@ static ssize_t qeth_dev_blkt_inter_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
return qeth_dev_blkt_show(buf, card, card->info.blkt.inter_packet); return sprintf(buf, "%i\n", card->info.blkt.inter_packet);
} }
static ssize_t qeth_dev_blkt_inter_store(struct device *dev, static ssize_t qeth_dev_blkt_inter_store(struct device *dev,
...@@ -687,8 +616,7 @@ static ssize_t qeth_dev_blkt_inter_jumbo_show(struct device *dev, ...@@ -687,8 +616,7 @@ static ssize_t qeth_dev_blkt_inter_jumbo_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
return qeth_dev_blkt_show(buf, card, return sprintf(buf, "%i\n", card->info.blkt.inter_packet_jumbo);
card->info.blkt.inter_packet_jumbo);
} }
static ssize_t qeth_dev_blkt_inter_jumbo_store(struct device *dev, static ssize_t qeth_dev_blkt_inter_jumbo_store(struct device *dev,
......
...@@ -18,9 +18,6 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev, ...@@ -18,9 +18,6 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev,
int rc = 0; int rc = 0;
char *word; char *word;
if (!card)
return -EINVAL;
if (qeth_l2_vnicc_is_in_use(card)) if (qeth_l2_vnicc_is_in_use(card))
return sprintf(buf, "n/a (VNIC characteristics)\n"); return sprintf(buf, "n/a (VNIC characteristics)\n");
...@@ -79,8 +76,6 @@ static ssize_t qeth_bridge_port_role_store(struct device *dev, ...@@ -79,8 +76,6 @@ static ssize_t qeth_bridge_port_role_store(struct device *dev,
int rc = 0; int rc = 0;
enum qeth_sbp_roles role; enum qeth_sbp_roles role;
if (!card)
return -EINVAL;
if (sysfs_streq(buf, "primary")) if (sysfs_streq(buf, "primary"))
role = QETH_SBP_ROLE_PRIMARY; role = QETH_SBP_ROLE_PRIMARY;
else if (sysfs_streq(buf, "secondary")) else if (sysfs_streq(buf, "secondary"))
...@@ -132,9 +127,6 @@ static ssize_t qeth_bridgeport_hostnotification_show(struct device *dev, ...@@ -132,9 +127,6 @@ static ssize_t qeth_bridgeport_hostnotification_show(struct device *dev,
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
int enabled; int enabled;
if (!card)
return -EINVAL;
if (qeth_l2_vnicc_is_in_use(card)) if (qeth_l2_vnicc_is_in_use(card))
return sprintf(buf, "n/a (VNIC characteristics)\n"); return sprintf(buf, "n/a (VNIC characteristics)\n");
...@@ -150,9 +142,6 @@ static ssize_t qeth_bridgeport_hostnotification_store(struct device *dev, ...@@ -150,9 +142,6 @@ static ssize_t qeth_bridgeport_hostnotification_store(struct device *dev,
bool enable; bool enable;
int rc; int rc;
if (!card)
return -EINVAL;
rc = kstrtobool(buf, &enable); rc = kstrtobool(buf, &enable);
if (rc) if (rc)
return rc; return rc;
...@@ -183,9 +172,6 @@ static ssize_t qeth_bridgeport_reflect_show(struct device *dev, ...@@ -183,9 +172,6 @@ static ssize_t qeth_bridgeport_reflect_show(struct device *dev,
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
char *state; char *state;
if (!card)
return -EINVAL;
if (qeth_l2_vnicc_is_in_use(card)) if (qeth_l2_vnicc_is_in_use(card))
return sprintf(buf, "n/a (VNIC characteristics)\n"); return sprintf(buf, "n/a (VNIC characteristics)\n");
...@@ -207,9 +193,6 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev, ...@@ -207,9 +193,6 @@ static ssize_t qeth_bridgeport_reflect_store(struct device *dev,
int enable, primary; int enable, primary;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
if (sysfs_streq(buf, "none")) { if (sysfs_streq(buf, "none")) {
enable = 0; enable = 0;
primary = 0; primary = 0;
...@@ -315,9 +298,6 @@ static ssize_t qeth_vnicc_timeout_show(struct device *dev, ...@@ -315,9 +298,6 @@ static ssize_t qeth_vnicc_timeout_show(struct device *dev,
u32 timeout; u32 timeout;
int rc; int rc;
if (!card)
return -EINVAL;
rc = qeth_l2_vnicc_get_timeout(card, &timeout); rc = qeth_l2_vnicc_get_timeout(card, &timeout);
if (rc == -EBUSY) if (rc == -EBUSY)
return sprintf(buf, "n/a (BridgePort)\n"); return sprintf(buf, "n/a (BridgePort)\n");
...@@ -335,9 +315,6 @@ static ssize_t qeth_vnicc_timeout_store(struct device *dev, ...@@ -335,9 +315,6 @@ static ssize_t qeth_vnicc_timeout_store(struct device *dev,
u32 timeout; u32 timeout;
int rc; int rc;
if (!card)
return -EINVAL;
rc = kstrtou32(buf, 10, &timeout); rc = kstrtou32(buf, 10, &timeout);
if (rc) if (rc)
return rc; return rc;
...@@ -357,9 +334,6 @@ static ssize_t qeth_vnicc_char_show(struct device *dev, ...@@ -357,9 +334,6 @@ static ssize_t qeth_vnicc_char_show(struct device *dev,
u32 vnicc; u32 vnicc;
int rc; int rc;
if (!card)
return -EINVAL;
vnicc = qeth_l2_vnicc_sysfs_attr_to_char(attr->attr.name); vnicc = qeth_l2_vnicc_sysfs_attr_to_char(attr->attr.name);
rc = qeth_l2_vnicc_get_state(card, vnicc, &state); rc = qeth_l2_vnicc_get_state(card, vnicc, &state);
...@@ -380,9 +354,6 @@ static ssize_t qeth_vnicc_char_store(struct device *dev, ...@@ -380,9 +354,6 @@ static ssize_t qeth_vnicc_char_store(struct device *dev,
u32 vnicc; u32 vnicc;
int rc; int rc;
if (!card)
return -EINVAL;
if (kstrtobool(buf, &state)) if (kstrtobool(buf, &state))
return -EINVAL; return -EINVAL;
......
...@@ -60,9 +60,6 @@ static ssize_t qeth_l3_dev_route4_show(struct device *dev, ...@@ -60,9 +60,6 @@ static ssize_t qeth_l3_dev_route4_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_route_show(card, &card->options.route4, buf); return qeth_l3_dev_route_show(card, &card->options.route4, buf);
} }
...@@ -109,9 +106,6 @@ static ssize_t qeth_l3_dev_route4_store(struct device *dev, ...@@ -109,9 +106,6 @@ static ssize_t qeth_l3_dev_route4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_route_store(card, &card->options.route4, return qeth_l3_dev_route_store(card, &card->options.route4,
QETH_PROT_IPV4, buf, count); QETH_PROT_IPV4, buf, count);
} }
...@@ -124,9 +118,6 @@ static ssize_t qeth_l3_dev_route6_show(struct device *dev, ...@@ -124,9 +118,6 @@ static ssize_t qeth_l3_dev_route6_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_route_show(card, &card->options.route6, buf); return qeth_l3_dev_route_show(card, &card->options.route6, buf);
} }
...@@ -135,9 +126,6 @@ static ssize_t qeth_l3_dev_route6_store(struct device *dev, ...@@ -135,9 +126,6 @@ static ssize_t qeth_l3_dev_route6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_route_store(card, &card->options.route6, return qeth_l3_dev_route_store(card, &card->options.route6,
QETH_PROT_IPV6, buf, count); QETH_PROT_IPV6, buf, count);
} }
...@@ -150,9 +138,6 @@ static ssize_t qeth_l3_dev_fake_broadcast_show(struct device *dev, ...@@ -150,9 +138,6 @@ static ssize_t qeth_l3_dev_fake_broadcast_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0); return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0);
} }
...@@ -163,9 +148,6 @@ static ssize_t qeth_l3_dev_fake_broadcast_store(struct device *dev, ...@@ -163,9 +148,6 @@ static ssize_t qeth_l3_dev_fake_broadcast_store(struct device *dev,
char *tmp; char *tmp;
int i, rc = 0; int i, rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -190,9 +172,6 @@ static ssize_t qeth_l3_dev_sniffer_show(struct device *dev, ...@@ -190,9 +172,6 @@ static ssize_t qeth_l3_dev_sniffer_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0); return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0);
} }
...@@ -203,9 +182,6 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev, ...@@ -203,9 +182,6 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
int rc = 0; int rc = 0;
unsigned long i; unsigned long i;
if (!card)
return -EINVAL;
if (!IS_IQD(card)) if (!IS_IQD(card))
return -EPERM; return -EPERM;
if (card->options.cq == QETH_CQ_ENABLED) if (card->options.cq == QETH_CQ_ENABLED)
...@@ -248,16 +224,12 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev, ...@@ -248,16 +224,12 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
static DEVICE_ATTR(sniffer, 0644, qeth_l3_dev_sniffer_show, static DEVICE_ATTR(sniffer, 0644, qeth_l3_dev_sniffer_show,
qeth_l3_dev_sniffer_store); qeth_l3_dev_sniffer_store);
static ssize_t qeth_l3_dev_hsuid_show(struct device *dev, static ssize_t qeth_l3_dev_hsuid_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
char tmp_hsuid[9]; char tmp_hsuid[9];
if (!card)
return -EINVAL;
if (!IS_IQD(card)) if (!IS_IQD(card))
return -EPERM; return -EPERM;
...@@ -273,9 +245,6 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev, ...@@ -273,9 +245,6 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
char *tmp; char *tmp;
int rc; int rc;
if (!card)
return -EINVAL;
if (!IS_IQD(card)) if (!IS_IQD(card))
return -EPERM; return -EPERM;
if (card->state != CARD_STATE_DOWN) if (card->state != CARD_STATE_DOWN)
...@@ -336,9 +305,6 @@ static ssize_t qeth_l3_dev_ipato_enable_show(struct device *dev, ...@@ -336,9 +305,6 @@ static ssize_t qeth_l3_dev_ipato_enable_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->ipato.enabled? 1:0); return sprintf(buf, "%i\n", card->ipato.enabled? 1:0);
} }
...@@ -349,9 +315,6 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -349,9 +315,6 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
bool enable; bool enable;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (card->state != CARD_STATE_DOWN) { if (card->state != CARD_STATE_DOWN) {
rc = -EPERM; rc = -EPERM;
...@@ -385,9 +348,6 @@ static ssize_t qeth_l3_dev_ipato_invert4_show(struct device *dev, ...@@ -385,9 +348,6 @@ static ssize_t qeth_l3_dev_ipato_invert4_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->ipato.invert4? 1:0); return sprintf(buf, "%i\n", card->ipato.invert4? 1:0);
} }
...@@ -399,9 +359,6 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev, ...@@ -399,9 +359,6 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
bool invert; bool invert;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (sysfs_streq(buf, "toggle")) { if (sysfs_streq(buf, "toggle")) {
invert = !card->ipato.invert4; invert = !card->ipato.invert4;
...@@ -460,9 +417,6 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev, ...@@ -460,9 +417,6 @@ static ssize_t qeth_l3_dev_ipato_add4_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV4); return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV4);
} }
...@@ -528,9 +482,6 @@ static ssize_t qeth_l3_dev_ipato_add4_store(struct device *dev, ...@@ -528,9 +482,6 @@ static ssize_t qeth_l3_dev_ipato_add4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -558,9 +509,6 @@ static ssize_t qeth_l3_dev_ipato_del4_store(struct device *dev, ...@@ -558,9 +509,6 @@ static ssize_t qeth_l3_dev_ipato_del4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -572,9 +520,6 @@ static ssize_t qeth_l3_dev_ipato_invert6_show(struct device *dev, ...@@ -572,9 +520,6 @@ static ssize_t qeth_l3_dev_ipato_invert6_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return sprintf(buf, "%i\n", card->ipato.invert6? 1:0); return sprintf(buf, "%i\n", card->ipato.invert6? 1:0);
} }
...@@ -585,9 +530,6 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev, ...@@ -585,9 +530,6 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
bool invert; bool invert;
int rc = 0; int rc = 0;
if (!card)
return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (sysfs_streq(buf, "toggle")) { if (sysfs_streq(buf, "toggle")) {
invert = !card->ipato.invert6; invert = !card->ipato.invert6;
...@@ -617,9 +559,6 @@ static ssize_t qeth_l3_dev_ipato_add6_show(struct device *dev, ...@@ -617,9 +559,6 @@ static ssize_t qeth_l3_dev_ipato_add6_show(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV6); return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV6);
} }
...@@ -628,9 +567,6 @@ static ssize_t qeth_l3_dev_ipato_add6_store(struct device *dev, ...@@ -628,9 +567,6 @@ static ssize_t qeth_l3_dev_ipato_add6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV6);
} }
...@@ -643,9 +579,6 @@ static ssize_t qeth_l3_dev_ipato_del6_store(struct device *dev, ...@@ -643,9 +579,6 @@ static ssize_t qeth_l3_dev_ipato_del6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV6);
} }
...@@ -679,9 +612,6 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf, ...@@ -679,9 +612,6 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
int entry_len; /* length of 1 entry string, differs between v4 and v6 */ int entry_len; /* length of 1 entry string, differs between v4 and v6 */
int i; int i;
if (!card)
return -EINVAL;
entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; entry_len = (proto == QETH_PROT_IPV4)? 12 : 40;
entry_len += 2; /* \n + terminator */ entry_len += 2; /* \n + terminator */
mutex_lock(&card->ip_lock); mutex_lock(&card->ip_lock);
...@@ -741,9 +671,6 @@ static ssize_t qeth_l3_dev_vipa_add4_store(struct device *dev, ...@@ -741,9 +671,6 @@ static ssize_t qeth_l3_dev_vipa_add4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -771,9 +698,6 @@ static ssize_t qeth_l3_dev_vipa_del4_store(struct device *dev, ...@@ -771,9 +698,6 @@ static ssize_t qeth_l3_dev_vipa_del4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -793,9 +717,6 @@ static ssize_t qeth_l3_dev_vipa_add6_store(struct device *dev, ...@@ -793,9 +717,6 @@ static ssize_t qeth_l3_dev_vipa_add6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV6);
} }
...@@ -808,9 +729,6 @@ static ssize_t qeth_l3_dev_vipa_del6_store(struct device *dev, ...@@ -808,9 +729,6 @@ static ssize_t qeth_l3_dev_vipa_del6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV6);
} }
...@@ -884,9 +802,6 @@ static ssize_t qeth_l3_dev_rxip_add4_store(struct device *dev, ...@@ -884,9 +802,6 @@ static ssize_t qeth_l3_dev_rxip_add4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -914,9 +829,6 @@ static ssize_t qeth_l3_dev_rxip_del4_store(struct device *dev, ...@@ -914,9 +829,6 @@ static ssize_t qeth_l3_dev_rxip_del4_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV4); return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV4);
} }
...@@ -936,9 +848,6 @@ static ssize_t qeth_l3_dev_rxip_add6_store(struct device *dev, ...@@ -936,9 +848,6 @@ static ssize_t qeth_l3_dev_rxip_add6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV6);
} }
...@@ -951,9 +860,6 @@ static ssize_t qeth_l3_dev_rxip_del6_store(struct device *dev, ...@@ -951,9 +860,6 @@ static ssize_t qeth_l3_dev_rxip_del6_store(struct device *dev,
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
if (!card)
return -EINVAL;
return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV6); return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV6);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment