Skip to content

Commit

Permalink
i2c: make i2c_bus_type const
Browse files Browse the repository at this point in the history
Now that the driver core can properly handle constant struct bus_type,
move the i2c_bus_type variable to be a constant structure as well, placing
it into read-only memory which can not be modified at runtime.

Note, the sound/soc/rockchip/rk3399_gru_sound.c also needed tweaking as
it decided to save off a pointer to a bus type for internal stuff, and
it was using the i2c_bus_type as well.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Mark Brown <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
  • Loading branch information
gregkh authored and wsakernel committed Jan 18, 2024
1 parent 614ef4d commit 94959c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/i2c/i2c-core-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static struct attribute *i2c_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(i2c_dev);

struct bus_type i2c_bus_type = {
const struct bus_type i2c_bus_type = {
.name = "i2c",
.match = i2c_device_match,
.probe = i2c_device_probe,
Expand Down
2 changes: 1 addition & 1 deletion include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <linux/swab.h> /* for swab16 */
#include <uapi/linux/i2c.h>

extern struct bus_type i2c_bus_type;
extern const struct bus_type i2c_bus_type;
extern struct device_type i2c_adapter_type;
extern struct device_type i2c_client_type;

Expand Down
2 changes: 1 addition & 1 deletion sound/soc/rockchip/rk3399_gru_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static const struct rockchip_sound_route rockchip_routes[] = {

struct dailink_match_data {
const char *compatible;
struct bus_type *bus_type;
const struct bus_type *bus_type;
};

static const struct dailink_match_data dailink_match[] = {
Expand Down

0 comments on commit 94959c0

Please sign in to comment.