Quoting Abhishek Pandit-Subedi (2024-12-13 10:33:19) > On Wed, Dec 11, 2024 at 1:58 PM Stephen Boyd <sboyd@xxxxxxxxxx> wrote: > > > > Quoting Abhishek Pandit-Subedi (2024-12-06 15:38:16) > > > diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c > > > new file mode 100644 > > > index 000000000000..bb7c7ad2ff6e > > > --- /dev/null > > > +++ b/drivers/platform/chrome/cros_typec_altmode.c > > > @@ -0,0 +1,281 @@ [...] > > > +struct typec_altmode * > > > +cros_typec_register_displayport(struct cros_typec_port *port, > > > + struct typec_altmode_desc *desc, > > > + bool ap_mode_entry) > > > +{ > > > + struct typec_altmode *alt; > > > + struct cros_typec_altmode_data *data; > > > + > > > + alt = typec_port_register_altmode(port->port, desc); > > > + if (IS_ERR(alt)) > > > + return alt; > > > + > > > + data = devm_kzalloc(&alt->dev, sizeof(*data), GFP_KERNEL); > > > + if (!data) { > > > + typec_unregister_altmode(alt); > > > + return ERR_PTR(-ENOMEM); > > > + } > > > + > > > + INIT_WORK(&data->work, cros_typec_altmode_work); > > > + mutex_init(&data->lock); > > > + data->alt = alt; > > > + data->port = port; > > > + data->ap_mode_entry = ap_mode_entry; > > > + data->sid = desc->svid; > > > + data->mode = desc->mode; > > > + > > > + typec_altmode_set_ops(alt, &cros_typec_altmode_ops); > > > + typec_altmode_set_drvdata(alt, data); > > > > 'data' is of type struct cros_typec_altmode_data here > This should have been allocated as cros_typec_dp_data. Missed during a > previous refactor that changed the type from a union to this format. It would be good to have the cros_typec_altmode_data member be somewhere besides the first member of cros_typec_dp_data so that this fails faster when stashing the pointer into the drvdata and treating it as the wrong type on the other side.