Commit 146bb64e authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Greg Kroah-Hartman

usb: typec: constify the struct device_type usage

Since commit aed65af1 ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move all the
device_type variables in use by the driver to be constant structures as
well, placing it into read-only memory which can not be modified at
runtime.
Signed-off-by: default avatarRicardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240218-device_cleanup-usb-v1-1-77423c4da262@marliere.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a09ebb32
...@@ -157,7 +157,7 @@ static const struct attribute_group source_fixed_supply_group = { ...@@ -157,7 +157,7 @@ static const struct attribute_group source_fixed_supply_group = {
}; };
__ATTRIBUTE_GROUPS(source_fixed_supply); __ATTRIBUTE_GROUPS(source_fixed_supply);
static struct device_type source_fixed_supply_type = { static const struct device_type source_fixed_supply_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = source_fixed_supply_groups, .groups = source_fixed_supply_groups,
...@@ -182,7 +182,7 @@ static const struct attribute_group sink_fixed_supply_group = { ...@@ -182,7 +182,7 @@ static const struct attribute_group sink_fixed_supply_group = {
}; };
__ATTRIBUTE_GROUPS(sink_fixed_supply); __ATTRIBUTE_GROUPS(sink_fixed_supply);
static struct device_type sink_fixed_supply_type = { static const struct device_type sink_fixed_supply_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = sink_fixed_supply_groups, .groups = sink_fixed_supply_groups,
...@@ -213,7 +213,7 @@ static struct attribute *source_variable_supply_attrs[] = { ...@@ -213,7 +213,7 @@ static struct attribute *source_variable_supply_attrs[] = {
}; };
ATTRIBUTE_GROUPS(source_variable_supply); ATTRIBUTE_GROUPS(source_variable_supply);
static struct device_type source_variable_supply_type = { static const struct device_type source_variable_supply_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = source_variable_supply_groups, .groups = source_variable_supply_groups,
...@@ -227,7 +227,7 @@ static struct attribute *sink_variable_supply_attrs[] = { ...@@ -227,7 +227,7 @@ static struct attribute *sink_variable_supply_attrs[] = {
}; };
ATTRIBUTE_GROUPS(sink_variable_supply); ATTRIBUTE_GROUPS(sink_variable_supply);
static struct device_type sink_variable_supply_type = { static const struct device_type sink_variable_supply_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = sink_variable_supply_groups, .groups = sink_variable_supply_groups,
...@@ -258,7 +258,7 @@ static struct attribute *source_battery_attrs[] = { ...@@ -258,7 +258,7 @@ static struct attribute *source_battery_attrs[] = {
}; };
ATTRIBUTE_GROUPS(source_battery); ATTRIBUTE_GROUPS(source_battery);
static struct device_type source_battery_type = { static const struct device_type source_battery_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = source_battery_groups, .groups = source_battery_groups,
...@@ -272,7 +272,7 @@ static struct attribute *sink_battery_attrs[] = { ...@@ -272,7 +272,7 @@ static struct attribute *sink_battery_attrs[] = {
}; };
ATTRIBUTE_GROUPS(sink_battery); ATTRIBUTE_GROUPS(sink_battery);
static struct device_type sink_battery_type = { static const struct device_type sink_battery_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = sink_battery_groups, .groups = sink_battery_groups,
...@@ -339,7 +339,7 @@ static struct attribute *source_pps_attrs[] = { ...@@ -339,7 +339,7 @@ static struct attribute *source_pps_attrs[] = {
}; };
ATTRIBUTE_GROUPS(source_pps); ATTRIBUTE_GROUPS(source_pps);
static struct device_type source_pps_type = { static const struct device_type source_pps_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = source_pps_groups, .groups = source_pps_groups,
...@@ -353,7 +353,7 @@ static struct attribute *sink_pps_attrs[] = { ...@@ -353,7 +353,7 @@ static struct attribute *sink_pps_attrs[] = {
}; };
ATTRIBUTE_GROUPS(sink_pps); ATTRIBUTE_GROUPS(sink_pps);
static struct device_type sink_pps_type = { static const struct device_type sink_pps_type = {
.name = "pdo", .name = "pdo",
.release = pdo_release, .release = pdo_release,
.groups = sink_pps_groups, .groups = sink_pps_groups,
...@@ -371,30 +371,30 @@ static const char * const apdo_supply_name[] = { ...@@ -371,30 +371,30 @@ static const char * const apdo_supply_name[] = {
[APDO_TYPE_PPS] = "programmable_supply", [APDO_TYPE_PPS] = "programmable_supply",
}; };
static struct device_type *source_type[] = { static const struct device_type *source_type[] = {
[PDO_TYPE_FIXED] = &source_fixed_supply_type, [PDO_TYPE_FIXED] = &source_fixed_supply_type,
[PDO_TYPE_BATT] = &source_battery_type, [PDO_TYPE_BATT] = &source_battery_type,
[PDO_TYPE_VAR] = &source_variable_supply_type, [PDO_TYPE_VAR] = &source_variable_supply_type,
}; };
static struct device_type *source_apdo_type[] = { static const struct device_type *source_apdo_type[] = {
[APDO_TYPE_PPS] = &source_pps_type, [APDO_TYPE_PPS] = &source_pps_type,
}; };
static struct device_type *sink_type[] = { static const struct device_type *sink_type[] = {
[PDO_TYPE_FIXED] = &sink_fixed_supply_type, [PDO_TYPE_FIXED] = &sink_fixed_supply_type,
[PDO_TYPE_BATT] = &sink_battery_type, [PDO_TYPE_BATT] = &sink_battery_type,
[PDO_TYPE_VAR] = &sink_variable_supply_type, [PDO_TYPE_VAR] = &sink_variable_supply_type,
}; };
static struct device_type *sink_apdo_type[] = { static const struct device_type *sink_apdo_type[] = {
[APDO_TYPE_PPS] = &sink_pps_type, [APDO_TYPE_PPS] = &sink_pps_type,
}; };
/* REVISIT: Export when EPR_*_Capabilities need to be supported. */ /* REVISIT: Export when EPR_*_Capabilities need to be supported. */
static int add_pdo(struct usb_power_delivery_capabilities *cap, u32 pdo, int position) static int add_pdo(struct usb_power_delivery_capabilities *cap, u32 pdo, int position)
{ {
struct device_type *type; const struct device_type *type;
const char *name; const char *name;
struct pdo *p; struct pdo *p;
int ret; int ret;
...@@ -460,7 +460,7 @@ static void pd_capabilities_release(struct device *dev) ...@@ -460,7 +460,7 @@ static void pd_capabilities_release(struct device *dev)
kfree(to_usb_power_delivery_capabilities(dev)); kfree(to_usb_power_delivery_capabilities(dev));
} }
static struct device_type pd_capabilities_type = { static const struct device_type pd_capabilities_type = {
.name = "capabilities", .name = "capabilities",
.release = pd_capabilities_release, .release = pd_capabilities_release,
}; };
...@@ -575,7 +575,7 @@ static void pd_release(struct device *dev) ...@@ -575,7 +575,7 @@ static void pd_release(struct device *dev)
kfree(pd); kfree(pd);
} }
static struct device_type pd_type = { static const struct device_type pd_type = {
.name = "usb_power_delivery", .name = "usb_power_delivery",
.release = pd_release, .release = pd_release,
.groups = pd_groups, .groups = pd_groups,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment