s390/qeth: stop using struct ccwgroup driver for discipline callbacks

The interface between qeth and its disciplines should not depend on
struct ccwgroup_driver, as a qeth discipline is not a ccwgroup
driver on its own. Instead provide the particular callbacks in struct
qeth_discipline.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
Sebastian Ott 2012-05-15 18:02:21 +02:00 committed by Martin Schwidefsky
parent b7169c515b
commit c041f2d487
5 changed files with 61 additions and 64 deletions

View File

@ -711,7 +711,16 @@ struct qeth_discipline {
qdio_handler_t *input_handler; qdio_handler_t *input_handler;
qdio_handler_t *output_handler; qdio_handler_t *output_handler;
int (*recover)(void *ptr); int (*recover)(void *ptr);
struct ccwgroup_driver *ccwgdriver; int (*setup) (struct ccwgroup_device *);
void (*remove) (struct ccwgroup_device *);
int (*set_online) (struct ccwgroup_device *);
int (*set_offline) (struct ccwgroup_device *);
void (*shutdown)(struct ccwgroup_device *);
int (*prepare) (struct ccwgroup_device *);
void (*complete) (struct ccwgroup_device *);
int (*freeze)(struct ccwgroup_device *);
int (*thaw) (struct ccwgroup_device *);
int (*restore)(struct ccwgroup_device *);
}; };
struct qeth_vlan_vid { struct qeth_vlan_vid {
@ -775,7 +784,7 @@ struct qeth_card {
struct qeth_perf_stats perf_stats; struct qeth_perf_stats perf_stats;
int read_or_write_problem; int read_or_write_problem;
struct qeth_osn_info osn_info; struct qeth_osn_info osn_info;
struct qeth_discipline discipline; struct qeth_discipline *discipline;
atomic_t force_alloc_skb; atomic_t force_alloc_skb;
struct service_level qeth_service_level; struct service_level qeth_service_level;
struct qdio_ssqd_desc ssqd; struct qdio_ssqd_desc ssqd;
@ -841,8 +850,8 @@ static inline int qeth_is_diagass_supported(struct qeth_card *card,
return card->info.diagass_support & (__u32)cmd; return card->info.diagass_support & (__u32)cmd;
} }
extern struct ccwgroup_driver qeth_l2_ccwgroup_driver; extern struct qeth_discipline qeth_l2_discipline;
extern struct ccwgroup_driver qeth_l3_ccwgroup_driver; extern struct qeth_discipline qeth_l3_discipline;
extern const struct attribute_group *qeth_generic_attr_groups[]; extern const struct attribute_group *qeth_generic_attr_groups[];
extern const struct attribute_group *qeth_osn_attr_groups[]; extern const struct attribute_group *qeth_osn_attr_groups[];

View File

@ -1365,7 +1365,7 @@ static void qeth_start_kernel_thread(struct work_struct *work)
card->write.state != CH_STATE_UP) card->write.state != CH_STATE_UP)
return; return;
if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) { if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) {
ts = kthread_run(card->discipline.recover, (void *)card, ts = kthread_run(card->discipline->recover, (void *)card,
"qeth_recover"); "qeth_recover");
if (IS_ERR(ts)) { if (IS_ERR(ts)) {
qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
@ -4629,7 +4629,7 @@ static int qeth_qdio_establish(struct qeth_card *card)
goto out_free_in_sbals; goto out_free_in_sbals;
} }
for (i = 0; i < card->qdio.no_in_queues; ++i) for (i = 0; i < card->qdio.no_in_queues; ++i)
queue_start_poll[i] = card->discipline.start_poll; queue_start_poll[i] = card->discipline->start_poll;
qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll); qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll);
@ -4653,8 +4653,8 @@ static int qeth_qdio_establish(struct qeth_card *card)
init_data.qib_param_field = qib_param_field; init_data.qib_param_field = qib_param_field;
init_data.no_input_qs = card->qdio.no_in_queues; init_data.no_input_qs = card->qdio.no_in_queues;
init_data.no_output_qs = card->qdio.no_out_queues; init_data.no_output_qs = card->qdio.no_out_queues;
init_data.input_handler = card->discipline.input_handler; init_data.input_handler = card->discipline->input_handler;
init_data.output_handler = card->discipline.output_handler; init_data.output_handler = card->discipline->output_handler;
init_data.queue_start_poll_array = queue_start_poll; init_data.queue_start_poll_array = queue_start_poll;
init_data.int_parm = (unsigned long) card; init_data.int_parm = (unsigned long) card;
init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; init_data.input_sbal_addr_array = (void **) in_sbal_ptrs;
@ -5039,17 +5039,15 @@ int qeth_core_load_discipline(struct qeth_card *card,
mutex_lock(&qeth_mod_mutex); mutex_lock(&qeth_mod_mutex);
switch (discipline) { switch (discipline) {
case QETH_DISCIPLINE_LAYER3: case QETH_DISCIPLINE_LAYER3:
card->discipline.ccwgdriver = try_then_request_module( card->discipline = try_then_request_module(
symbol_get(qeth_l3_ccwgroup_driver), symbol_get(qeth_l3_discipline), "qeth_l3");
"qeth_l3");
break; break;
case QETH_DISCIPLINE_LAYER2: case QETH_DISCIPLINE_LAYER2:
card->discipline.ccwgdriver = try_then_request_module( card->discipline = try_then_request_module(
symbol_get(qeth_l2_ccwgroup_driver), symbol_get(qeth_l2_discipline), "qeth_l2");
"qeth_l2");
break; break;
} }
if (!card->discipline.ccwgdriver) { if (!card->discipline) {
dev_err(&card->gdev->dev, "There is no kernel module to " dev_err(&card->gdev->dev, "There is no kernel module to "
"support discipline %d\n", discipline); "support discipline %d\n", discipline);
rc = -EINVAL; rc = -EINVAL;
@ -5061,10 +5059,10 @@ int qeth_core_load_discipline(struct qeth_card *card,
void qeth_core_free_discipline(struct qeth_card *card) void qeth_core_free_discipline(struct qeth_card *card)
{ {
if (card->options.layer2) if (card->options.layer2)
symbol_put(qeth_l2_ccwgroup_driver); symbol_put(qeth_l2_discipline);
else else
symbol_put(qeth_l3_ccwgroup_driver); symbol_put(qeth_l3_discipline);
card->discipline.ccwgdriver = NULL; card->discipline = NULL;
} }
static const struct device_type qeth_generic_devtype = { static const struct device_type qeth_generic_devtype = {
@ -5140,7 +5138,7 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev)
rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2); rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2);
if (rc) if (rc)
goto err_dbf; goto err_dbf;
rc = card->discipline.ccwgdriver->probe(card->gdev); rc = card->discipline->setup(card->gdev);
if (rc) if (rc)
goto err_disc; goto err_disc;
case QETH_CARD_TYPE_OSD: case QETH_CARD_TYPE_OSD:
@ -5174,8 +5172,8 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)
QETH_DBF_TEXT(SETUP, 2, "removedv"); QETH_DBF_TEXT(SETUP, 2, "removedv");
if (card->discipline.ccwgdriver) { if (card->discipline) {
card->discipline.ccwgdriver->remove(gdev); card->discipline->remove(gdev);
qeth_core_free_discipline(card); qeth_core_free_discipline(card);
} }
@ -5195,7 +5193,7 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
int rc = 0; int rc = 0;
int def_discipline; int def_discipline;
if (!card->discipline.ccwgdriver) { if (!card->discipline) {
if (card->info.type == QETH_CARD_TYPE_IQD) if (card->info.type == QETH_CARD_TYPE_IQD)
def_discipline = QETH_DISCIPLINE_LAYER3; def_discipline = QETH_DISCIPLINE_LAYER3;
else else
@ -5203,11 +5201,11 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
rc = qeth_core_load_discipline(card, def_discipline); rc = qeth_core_load_discipline(card, def_discipline);
if (rc) if (rc)
goto err; goto err;
rc = card->discipline.ccwgdriver->probe(card->gdev); rc = card->discipline->setup(card->gdev);
if (rc) if (rc)
goto err; goto err;
} }
rc = card->discipline.ccwgdriver->set_online(gdev); rc = card->discipline->set_online(gdev);
err: err:
return rc; return rc;
} }
@ -5215,58 +5213,52 @@ err:
static int qeth_core_set_offline(struct ccwgroup_device *gdev) static int qeth_core_set_offline(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
return card->discipline.ccwgdriver->set_offline(gdev); return card->discipline->set_offline(gdev);
} }
static void qeth_core_shutdown(struct ccwgroup_device *gdev) static void qeth_core_shutdown(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->shutdown)
card->discipline.ccwgdriver->shutdown) card->discipline->shutdown(gdev);
card->discipline.ccwgdriver->shutdown(gdev);
} }
static int qeth_core_prepare(struct ccwgroup_device *gdev) static int qeth_core_prepare(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->prepare)
card->discipline.ccwgdriver->prepare) return card->discipline->prepare(gdev);
return card->discipline.ccwgdriver->prepare(gdev);
return 0; return 0;
} }
static void qeth_core_complete(struct ccwgroup_device *gdev) static void qeth_core_complete(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->complete)
card->discipline.ccwgdriver->complete) card->discipline->complete(gdev);
card->discipline.ccwgdriver->complete(gdev);
} }
static int qeth_core_freeze(struct ccwgroup_device *gdev) static int qeth_core_freeze(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->freeze)
card->discipline.ccwgdriver->freeze) return card->discipline->freeze(gdev);
return card->discipline.ccwgdriver->freeze(gdev);
return 0; return 0;
} }
static int qeth_core_thaw(struct ccwgroup_device *gdev) static int qeth_core_thaw(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->thaw)
card->discipline.ccwgdriver->thaw) return card->discipline->thaw(gdev);
return card->discipline.ccwgdriver->thaw(gdev);
return 0; return 0;
} }
static int qeth_core_restore(struct ccwgroup_device *gdev) static int qeth_core_restore(struct ccwgroup_device *gdev)
{ {
struct qeth_card *card = dev_get_drvdata(&gdev->dev); struct qeth_card *card = dev_get_drvdata(&gdev->dev);
if (card->discipline.ccwgdriver && if (card->discipline && card->discipline->restore)
card->discipline.ccwgdriver->restore) return card->discipline->restore(gdev);
return card->discipline.ccwgdriver->restore(gdev);
return 0; return 0;
} }

View File

@ -434,8 +434,8 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
goto out; goto out;
else { else {
card->info.mac_bits = 0; card->info.mac_bits = 0;
if (card->discipline.ccwgdriver) { if (card->discipline) {
card->discipline.ccwgdriver->remove(card->gdev); card->discipline->remove(card->gdev);
qeth_core_free_discipline(card); qeth_core_free_discipline(card);
} }
} }
@ -444,7 +444,7 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
if (rc) if (rc)
goto out; goto out;
rc = card->discipline.ccwgdriver->probe(card->gdev); rc = card->discipline->setup(card->gdev);
out: out:
mutex_unlock(&card->discipline_mutex); mutex_unlock(&card->discipline_mutex);
return rc ? rc : count; return rc ? rc : count;

View File

@ -882,12 +882,6 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev)
INIT_LIST_HEAD(&card->mc_list); INIT_LIST_HEAD(&card->mc_list);
card->options.layer2 = 1; card->options.layer2 = 1;
card->info.hwtrap = 0; card->info.hwtrap = 0;
card->discipline.start_poll = qeth_qdio_start_poll;
card->discipline.input_handler = (qdio_handler_t *)
qeth_qdio_input_handler;
card->discipline.output_handler = (qdio_handler_t *)
qeth_qdio_output_handler;
card->discipline.recover = qeth_l2_recover;
return 0; return 0;
} }
@ -1227,8 +1221,12 @@ out:
return rc; return rc;
} }
struct ccwgroup_driver qeth_l2_ccwgroup_driver = { struct qeth_discipline qeth_l2_discipline = {
.probe = qeth_l2_probe_device, .start_poll = qeth_qdio_start_poll,
.input_handler = (qdio_handler_t *) qeth_qdio_input_handler,
.output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
.recover = qeth_l2_recover,
.setup = qeth_l2_probe_device,
.remove = qeth_l2_remove_device, .remove = qeth_l2_remove_device,
.set_online = qeth_l2_set_online, .set_online = qeth_l2_set_online,
.set_offline = qeth_l2_set_offline, .set_offline = qeth_l2_set_offline,
@ -1237,7 +1235,7 @@ struct ccwgroup_driver qeth_l2_ccwgroup_driver = {
.thaw = qeth_l2_pm_resume, .thaw = qeth_l2_pm_resume,
.restore = qeth_l2_pm_resume, .restore = qeth_l2_pm_resume,
}; };
EXPORT_SYMBOL_GPL(qeth_l2_ccwgroup_driver); EXPORT_SYMBOL_GPL(qeth_l2_discipline);
static int qeth_osn_send_control_data(struct qeth_card *card, int len, static int qeth_osn_send_control_data(struct qeth_card *card, int len,
struct qeth_cmd_buffer *iob) struct qeth_cmd_buffer *iob)

View File

@ -3376,12 +3376,6 @@ static int qeth_l3_probe_device(struct ccwgroup_device *gdev)
qeth_l3_create_device_attributes(&gdev->dev); qeth_l3_create_device_attributes(&gdev->dev);
card->options.layer2 = 0; card->options.layer2 = 0;
card->info.hwtrap = 0; card->info.hwtrap = 0;
card->discipline.start_poll = qeth_qdio_start_poll;
card->discipline.input_handler = (qdio_handler_t *)
qeth_qdio_input_handler;
card->discipline.output_handler = (qdio_handler_t *)
qeth_qdio_output_handler;
card->discipline.recover = qeth_l3_recover;
return 0; return 0;
} }
@ -3656,8 +3650,12 @@ out:
return rc; return rc;
} }
struct ccwgroup_driver qeth_l3_ccwgroup_driver = { struct qeth_discipline qeth_l3_discipline = {
.probe = qeth_l3_probe_device, .start_poll = qeth_qdio_start_poll,
.input_handler = (qdio_handler_t *) qeth_qdio_input_handler,
.output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
.recover = qeth_l3_recover,
.setup = qeth_l3_probe_device,
.remove = qeth_l3_remove_device, .remove = qeth_l3_remove_device,
.set_online = qeth_l3_set_online, .set_online = qeth_l3_set_online,
.set_offline = qeth_l3_set_offline, .set_offline = qeth_l3_set_offline,
@ -3666,7 +3664,7 @@ struct ccwgroup_driver qeth_l3_ccwgroup_driver = {
.thaw = qeth_l3_pm_resume, .thaw = qeth_l3_pm_resume,
.restore = qeth_l3_pm_resume, .restore = qeth_l3_pm_resume,
}; };
EXPORT_SYMBOL_GPL(qeth_l3_ccwgroup_driver); EXPORT_SYMBOL_GPL(qeth_l3_discipline);
static int qeth_l3_ip_event(struct notifier_block *this, static int qeth_l3_ip_event(struct notifier_block *this,
unsigned long event, void *ptr) unsigned long event, void *ptr)