Skip to content

Commit 8a0a629

Browse files
nfrapradoTzung-Bi Shih
authored andcommitted
firmware: coreboot: Replace tag with id table in driver struct
Switch the plain 'tag' field in struct coreboot_driver for the newly created coreboot_device_id struct, which also contains a tag field and has the benefit of allowing modalias generation, and update all coreboot drivers accordingly. While at it, also add the id table for each driver to the module device table to allow automatically loading the module. Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Brian Norris <[email protected]> Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent f1cebae commit 8a0a629

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

drivers/firmware/google/cbmem.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,20 @@ static int cbmem_entry_probe(struct coreboot_device *dev)
114114
return 0;
115115
}
116116

117+
static const struct coreboot_device_id cbmem_ids[] = {
118+
{ .tag = LB_TAG_CBMEM_ENTRY },
119+
{ /* sentinel */ }
120+
};
121+
MODULE_DEVICE_TABLE(coreboot, cbmem_ids);
122+
117123
static struct coreboot_driver cbmem_entry_driver = {
118124
.probe = cbmem_entry_probe,
119125
.drv = {
120126
.name = "cbmem",
121127
.owner = THIS_MODULE,
122128
.dev_groups = dev_groups,
123129
},
124-
.tag = LB_TAG_CBMEM_ENTRY,
130+
.id_table = cbmem_ids,
125131
};
126132
module_coreboot_driver(cbmem_entry_driver);
127133

drivers/firmware/google/coreboot_table.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@ static int coreboot_bus_match(struct device *dev, struct device_driver *drv)
2828
{
2929
struct coreboot_device *device = CB_DEV(dev);
3030
struct coreboot_driver *driver = CB_DRV(drv);
31+
const struct coreboot_device_id *id;
3132

32-
return device->entry.tag == driver->tag;
33+
if (!driver->id_table)
34+
return 0;
35+
36+
for (id = driver->id_table; id->tag; id++) {
37+
if (device->entry.tag == id->tag)
38+
return 1;
39+
}
40+
41+
return 0;
3342
}
3443

3544
static int coreboot_bus_probe(struct device *dev)

drivers/firmware/google/coreboot_table.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define __COREBOOT_TABLE_H
1414

1515
#include <linux/device.h>
16+
#include <linux/mod_devicetable.h>
1617

1718
/* Coreboot table header structure */
1819
struct coreboot_table_header {
@@ -93,7 +94,7 @@ struct coreboot_driver {
9394
int (*probe)(struct coreboot_device *);
9495
void (*remove)(struct coreboot_device *);
9596
struct device_driver drv;
96-
u32 tag;
97+
const struct coreboot_device_id *id_table;
9798
};
9899

99100
/* Register a driver that uses the data from a coreboot table. */

drivers/firmware/google/framebuffer-coreboot.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ static void framebuffer_remove(struct coreboot_device *dev)
8080
platform_device_unregister(pdev);
8181
}
8282

83+
static const struct coreboot_device_id framebuffer_ids[] = {
84+
{ .tag = CB_TAG_FRAMEBUFFER },
85+
{ /* sentinel */ }
86+
};
87+
MODULE_DEVICE_TABLE(coreboot, framebuffer_ids);
88+
8389
static struct coreboot_driver framebuffer_driver = {
8490
.probe = framebuffer_probe,
8591
.remove = framebuffer_remove,
8692
.drv = {
8793
.name = "framebuffer",
8894
},
89-
.tag = CB_TAG_FRAMEBUFFER,
95+
.id_table = framebuffer_ids,
9096
};
9197
module_coreboot_driver(framebuffer_driver);
9298

drivers/firmware/google/memconsole-coreboot.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,19 @@ static void memconsole_remove(struct coreboot_device *dev)
9696
memconsole_exit();
9797
}
9898

99+
static const struct coreboot_device_id memconsole_ids[] = {
100+
{ .tag = CB_TAG_CBMEM_CONSOLE },
101+
{ /* sentinel */ }
102+
};
103+
MODULE_DEVICE_TABLE(coreboot, memconsole_ids);
104+
99105
static struct coreboot_driver memconsole_driver = {
100106
.probe = memconsole_probe,
101107
.remove = memconsole_remove,
102108
.drv = {
103109
.name = "memconsole",
104110
},
105-
.tag = CB_TAG_CBMEM_CONSOLE,
111+
.id_table = memconsole_ids,
106112
};
107113
module_coreboot_driver(memconsole_driver);
108114

drivers/firmware/google/vpd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,19 @@ static void vpd_remove(struct coreboot_device *dev)
306306
kobject_put(vpd_kobj);
307307
}
308308

309+
static const struct coreboot_device_id vpd_ids[] = {
310+
{ .tag = CB_TAG_VPD },
311+
{ /* sentinel */ }
312+
};
313+
MODULE_DEVICE_TABLE(coreboot, vpd_ids);
314+
309315
static struct coreboot_driver vpd_driver = {
310316
.probe = vpd_probe,
311317
.remove = vpd_remove,
312318
.drv = {
313319
.name = "vpd",
314320
},
315-
.tag = CB_TAG_VPD,
321+
.id_table = vpd_ids,
316322
};
317323
module_coreboot_driver(vpd_driver);
318324

0 commit comments

Comments
 (0)