Skip to content

Commit aed65af

Browse files
Stephen Hemmingergregkh
authored andcommitted
drivers: make device_type const
The device_type structure does not contain data that changes during usage and should be const. This allows devices to declare the struct const. I have patches to change all the subsystems, but need the infra structure change first. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 695cca8 commit aed65af

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/base/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static void device_remove_groups(struct device *dev,
400400
static int device_add_attrs(struct device *dev)
401401
{
402402
struct class *class = dev->class;
403-
struct device_type *type = dev->type;
403+
const struct device_type *type = dev->type;
404404
int error;
405405

406406
if (class) {
@@ -440,7 +440,7 @@ static int device_add_attrs(struct device *dev)
440440
static void device_remove_attrs(struct device *dev)
441441
{
442442
struct class *class = dev->class;
443-
struct device_type *type = dev->type;
443+
const struct device_type *type = dev->type;
444444

445445
device_remove_groups(dev, dev->groups);
446446

include/linux/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ struct device {
408408

409409
struct kobject kobj;
410410
const char *init_name; /* initial name of the device */
411-
struct device_type *type;
411+
const struct device_type *type;
412412

413413
struct mutex mutex; /* mutex to synchronize calls to
414414
* its driver.

0 commit comments

Comments
 (0)