Skip to content

Commit eb52034

Browse files
rbmarliereWolfram Sang
authored andcommitted
i2c: constify the struct device_type usage
Since commit aed65af ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the i2c_adapter_type and i2c_client_type variables to be constant structures as well, placing it into read-only memory which can not be modified at runtime. Signed-off-by: Ricardo B. Marliere <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent b401b62 commit eb52034

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ const struct bus_type i2c_bus_type = {
701701
};
702702
EXPORT_SYMBOL_GPL(i2c_bus_type);
703703

704-
struct device_type i2c_client_type = {
704+
const struct device_type i2c_client_type = {
705705
.groups = i2c_dev_groups,
706706
.uevent = i2c_device_uevent,
707707
.release = i2c_client_dev_release,
@@ -1343,7 +1343,7 @@ static struct attribute *i2c_adapter_attrs[] = {
13431343
};
13441344
ATTRIBUTE_GROUPS(i2c_adapter);
13451345

1346-
struct device_type i2c_adapter_type = {
1346+
const struct device_type i2c_adapter_type = {
13471347
.groups = i2c_adapter_groups,
13481348
.release = i2c_adapter_dev_release,
13491349
};

include/linux/i2c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <uapi/linux/i2c.h>
2525

2626
extern const struct bus_type i2c_bus_type;
27-
extern struct device_type i2c_adapter_type;
28-
extern struct device_type i2c_client_type;
27+
extern const struct device_type i2c_adapter_type;
28+
extern const struct device_type i2c_client_type;
2929

3030
/* --- General options ------------------------------------------------ */
3131

0 commit comments

Comments
 (0)