Skip to content

Commit 6a82c77

Browse files
cgrogregkh
authored andcommitted
staging: most: remove struct device core driver
This patch removes the device from the MOST core driver and uses the device from the adapter driver. Signed-off-by: Christian Gromm <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2485055 commit 6a82c77

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

drivers/staging/most/core.c

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static struct ida mdev_id;
3030
static int dummy_num_buffers;
3131

3232
static struct mostcore {
33-
struct device dev;
3433
struct device_driver drv;
3534
struct bus_type bus;
3635
struct list_head comp_list;
@@ -151,7 +150,7 @@ static void flush_channel_fifos(struct most_channel *c)
151150
spin_unlock_irqrestore(&c->fifo_lock, hf_flags);
152151

153152
if (unlikely((!list_empty(&c->fifo) || !list_empty(&c->halt_fifo))))
154-
dev_warn(&mc.dev, "fifo | trash fifo not empty\n");
153+
dev_warn(&c->dev, "fifo | trash fifo not empty\n");
155154
}
156155

157156
/**
@@ -624,7 +623,7 @@ int most_set_cfg_datatype(char *mdev, char *mdev_ch, char *buf)
624623
}
625624

626625
if (i == ARRAY_SIZE(ch_data_type))
627-
dev_warn(&mc.dev, "invalid attribute settings\n");
626+
dev_warn(&c->dev, "invalid attribute settings\n");
628627
return 0;
629628
}
630629

@@ -643,7 +642,7 @@ int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf)
643642
} else if (!strcmp(buf, "tx")) {
644643
c->cfg.direction = MOST_CH_TX;
645644
} else {
646-
dev_err(&mc.dev, "Invalid direction\n");
645+
dev_err(&c->dev, "Invalid direction\n");
647646
return -ENODATA;
648647
}
649648
return 0;
@@ -796,7 +795,7 @@ static int hdm_enqueue_thread(void *data)
796795
mutex_unlock(&c->nq_mutex);
797796

798797
if (unlikely(ret)) {
799-
dev_err(&mc.dev, "hdm enqueue failed\n");
798+
dev_err(&c->dev, "hdm enqueue failed\n");
800799
nq_hdm_mbo(mbo);
801800
c->hdm_enqueue_task = NULL;
802801
return 0;
@@ -943,7 +942,7 @@ static void most_write_completion(struct mbo *mbo)
943942

944943
c = mbo->context;
945944
if (mbo->status == MBO_E_INVAL)
946-
dev_warn(&mc.dev, "Tx MBO status: invalid\n");
945+
dev_warn(&c->dev, "Tx MBO status: invalid\n");
947946
if (unlikely(c->is_poisoned || (mbo->status == MBO_E_CLOSE)))
948947
trash_mbo(mbo);
949948
else
@@ -1102,14 +1101,14 @@ int most_start_channel(struct most_interface *iface, int id,
11021101
goto out; /* already started by another component */
11031102

11041103
if (!try_module_get(iface->mod)) {
1105-
dev_err(&mc.dev, "failed to acquire HDM lock\n");
1104+
dev_err(&c->dev, "failed to acquire HDM lock\n");
11061105
mutex_unlock(&c->start_mutex);
11071106
return -ENOLCK;
11081107
}
11091108

11101109
c->cfg.extra_len = 0;
11111110
if (c->iface->configure(c->iface, c->channel_id, &c->cfg)) {
1112-
dev_err(&mc.dev, "channel configuration failed. Go check settings...\n");
1111+
dev_err(&c->dev, "channel configuration failed. Go check settings...\n");
11131112
ret = -EINVAL;
11141113
goto err_put_module;
11151114
}
@@ -1163,7 +1162,7 @@ int most_stop_channel(struct most_interface *iface, int id,
11631162
struct most_channel *c;
11641163

11651164
if (unlikely((!iface) || (id >= iface->num_channels) || (id < 0))) {
1166-
dev_err(&mc.dev, "Bad interface or index out of range\n");
1165+
pr_err("Bad interface or index out of range\n");
11671166
return -EINVAL;
11681167
}
11691168
c = iface->p->channel[id];
@@ -1183,7 +1182,7 @@ int most_stop_channel(struct most_interface *iface, int id,
11831182

11841183
c->is_poisoned = true;
11851184
if (c->iface->poison_channel(c->iface, c->channel_id)) {
1186-
dev_err(&mc.dev, "Cannot stop channel %d of mdev %s\n", c->channel_id,
1185+
dev_err(&c->dev, "Cannot stop channel %d of mdev %s\n", c->channel_id,
11871186
c->iface->description);
11881187
mutex_unlock(&c->start_mutex);
11891188
return -EAGAIN;
@@ -1193,7 +1192,7 @@ int most_stop_channel(struct most_interface *iface, int id,
11931192

11941193
#ifdef CMPL_INTERRUPTIBLE
11951194
if (wait_for_completion_interruptible(&c->cleanup)) {
1196-
dev_err(&mc.dev, "Interrupted while clean up ch %d\n", c->channel_id);
1195+
dev_err(&c->dev, "Interrupted while clean up ch %d\n", c->channel_id);
11971196
mutex_unlock(&c->start_mutex);
11981197
return -EINTR;
11991198
}
@@ -1219,7 +1218,7 @@ EXPORT_SYMBOL_GPL(most_stop_channel);
12191218
int most_register_component(struct most_component *comp)
12201219
{
12211220
if (!comp) {
1222-
dev_err(&mc.dev, "Bad component\n");
1221+
pr_err("Bad component\n");
12231222
return -EINVAL;
12241223
}
12251224
list_add_tail(&comp->list, &mc.comp_list);
@@ -1252,7 +1251,7 @@ static int disconnect_channels(struct device *dev, void *data)
12521251
int most_deregister_component(struct most_component *comp)
12531252
{
12541253
if (!comp) {
1255-
dev_err(&mc.dev, "Bad component\n");
1254+
pr_err("Bad component\n");
12561255
return -EINVAL;
12571256
}
12581257

@@ -1284,13 +1283,13 @@ int most_register_interface(struct most_interface *iface)
12841283

12851284
if (!iface || !iface->enqueue || !iface->configure ||
12861285
!iface->poison_channel || (iface->num_channels > MAX_CHANNELS)) {
1287-
dev_err(&mc.dev, "Bad interface or channel overflow\n");
1286+
dev_err(iface->dev, "Bad interface or channel overflow\n");
12881287
return -EINVAL;
12891288
}
12901289

12911290
id = ida_simple_get(&mdev_id, 0, 0, GFP_KERNEL);
12921291
if (id < 0) {
1293-
dev_err(&mc.dev, "Failed to alloc mdev ID\n");
1292+
dev_err(iface->dev, "Failed to alloc mdev ID\n");
12941293
return id;
12951294
}
12961295

@@ -1304,11 +1303,10 @@ int most_register_interface(struct most_interface *iface)
13041303
iface->p->dev_id = id;
13051304
strscpy(iface->p->name, iface->description, sizeof(iface->p->name));
13061305
iface->dev->bus = &mc.bus;
1307-
iface->dev->parent = &mc.dev;
13081306
iface->dev->groups = interface_attr_groups;
13091307
dev_set_drvdata(iface->dev, iface);
13101308
if (device_register(iface->dev)) {
1311-
dev_err(&mc.dev, "registering iface->dev failed\n");
1309+
dev_err(iface->dev, "registering iface->dev failed\n");
13121310
kfree(iface->p);
13131311
put_device(iface->dev);
13141312
ida_simple_remove(&mdev_id, id);
@@ -1352,7 +1350,7 @@ int most_register_interface(struct most_interface *iface)
13521350
mutex_init(&c->nq_mutex);
13531351
list_add_tail(&c->list, &iface->p->channel_list);
13541352
if (device_register(&c->dev)) {
1355-
dev_err(&mc.dev, "registering c->dev failed\n");
1353+
dev_err(&c->dev, "registering c->dev failed\n");
13561354
goto err_free_most_channel;
13571355
}
13581356
}
@@ -1452,11 +1450,6 @@ void most_resume_enqueue(struct most_interface *iface, int id)
14521450
}
14531451
EXPORT_SYMBOL_GPL(most_resume_enqueue);
14541452

1455-
static void release_most_sub(struct device *dev)
1456-
{
1457-
dev_info(&mc.dev, "releasing most_subsystem\n");
1458-
}
1459-
14601453
static int __init most_init(void)
14611454
{
14621455
int err;
@@ -1472,33 +1465,24 @@ static int __init most_init(void)
14721465

14731466
err = bus_register(&mc.bus);
14741467
if (err) {
1475-
dev_err(&mc.dev, "Cannot register most bus\n");
1468+
pr_err("Cannot register most bus\n");
14761469
return err;
14771470
}
14781471
err = driver_register(&mc.drv);
14791472
if (err) {
1480-
dev_err(&mc.dev, "Cannot register core driver\n");
1473+
pr_err("Cannot register core driver\n");
14811474
goto err_unregister_bus;
14821475
}
1483-
mc.dev.init_name = "most_bus";
1484-
mc.dev.release = release_most_sub;
1485-
if (device_register(&mc.dev)) {
1486-
err = -ENOMEM;
1487-
goto err_unregister_driver;
1488-
}
14891476
configfs_init();
14901477
return 0;
14911478

1492-
err_unregister_driver:
1493-
driver_unregister(&mc.drv);
14941479
err_unregister_bus:
14951480
bus_unregister(&mc.bus);
14961481
return err;
14971482
}
14981483

14991484
static void __exit most_exit(void)
15001485
{
1501-
device_unregister(&mc.dev);
15021486
driver_unregister(&mc.drv);
15031487
bus_unregister(&mc.bus);
15041488
ida_destroy(&mdev_id);

drivers/staging/most/dim2/dim2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ static int dim2_probe(struct platform_device *pdev)
856856
dev->most_iface.driver_dev = &pdev->dev;
857857
dev->most_iface.dev = &dev->dev;
858858
dev->dev.init_name = "dim2_state";
859+
dev->dev.parent = &pdev->dev;
859860

860861
ret = most_register_interface(&dev->most_iface);
861862
if (ret) {

0 commit comments

Comments
 (0)