Skip to content

Commit aa7d651

Browse files
committed
Merge tag 'tag-chrome-platform-firmware-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
Pull chrome platform firmware updates from Tzung-Bi Shih: - Allow userspace to automatically load coreboot modules by adding modaliases and sending uevents - Make bus_type const * tag 'tag-chrome-platform-firmware-for-v6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux: firmware: coreboot: Replace tag with id table in driver struct firmware: coreboot: Generate aliases for coreboot modules firmware: coreboot: Generate modalias uevent for devices firmware: coreboot: make coreboot_bus_type const
2 parents 61387b8 + 8a0a629 commit aa7d651

File tree

9 files changed

+73
-7
lines changed

9 files changed

+73
-7
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: 20 additions & 2 deletions
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)
@@ -53,11 +62,20 @@ static void coreboot_bus_remove(struct device *dev)
5362
driver->remove(device);
5463
}
5564

56-
static struct bus_type coreboot_bus_type = {
65+
static int coreboot_bus_uevent(const struct device *dev, struct kobj_uevent_env *env)
66+
{
67+
struct coreboot_device *device = CB_DEV(dev);
68+
u32 tag = device->entry.tag;
69+
70+
return add_uevent_var(env, "MODALIAS=coreboot:t%08X", tag);
71+
}
72+
73+
static const struct bus_type coreboot_bus_type = {
5774
.name = "coreboot",
5875
.match = coreboot_bus_match,
5976
.probe = coreboot_bus_probe,
6077
.remove = coreboot_bus_remove,
78+
.uevent = coreboot_bus_uevent,
6179
};
6280

6381
static void coreboot_device_release(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

include/linux/mod_devicetable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,4 +960,14 @@ struct vchiq_device_id {
960960
char name[32];
961961
};
962962

963+
/**
964+
* struct coreboot_device_id - Identifies a coreboot table entry
965+
* @tag: tag ID
966+
* @driver_data: driver specific data
967+
*/
968+
struct coreboot_device_id {
969+
__u32 tag;
970+
kernel_ulong_t driver_data;
971+
};
972+
963973
#endif /* LINUX_MOD_DEVICETABLE_H */

scripts/mod/devicetable-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,8 @@ int main(void)
274274
DEVID(vchiq_device_id);
275275
DEVID_FIELD(vchiq_device_id, name);
276276

277+
DEVID(coreboot_device_id);
278+
DEVID_FIELD(coreboot_device_id, tag);
279+
277280
return 0;
278281
}

scripts/mod/file2alias.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,15 @@ static int do_vchiq_entry(const char *filename, void *symval, char *alias)
14941494
return 1;
14951495
}
14961496

1497+
/* Looks like: coreboot:tN */
1498+
static int do_coreboot_entry(const char *filename, void *symval, char *alias)
1499+
{
1500+
DEF_FIELD(symval, coreboot_device_id, tag);
1501+
sprintf(alias, "coreboot:t%08X", tag);
1502+
1503+
return 1;
1504+
}
1505+
14971506
/* Does namelen bytes of name exactly match the symbol? */
14981507
static bool sym_is(const char *name, unsigned namelen, const char *symbol)
14991508
{
@@ -1575,6 +1584,7 @@ static const struct devtable devtable[] = {
15751584
{"ishtp", SIZE_ishtp_device_id, do_ishtp_entry},
15761585
{"cdx", SIZE_cdx_device_id, do_cdx_entry},
15771586
{"vchiq", SIZE_vchiq_device_id, do_vchiq_entry},
1587+
{"coreboot", SIZE_coreboot_device_id, do_coreboot_entry},
15781588
};
15791589

15801590
/* Create MODULE_ALIAS() statements.

0 commit comments

Comments
 (0)