static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
{
- struct sdw_slave *slave = to_sdw_slave_device(dev);
+ struct sdw_slave *slave;
char modalias[32];
- sdw_slave_modalias(slave, modalias, sizeof(modalias));
-
- if (add_uevent_var(env, "MODALIAS=%s", modalias))
- return -ENOMEM;
+ if (is_sdw_slave(dev)) {
+ slave = to_sdw_slave_device(dev);
+
+ sdw_slave_modalias(slave, modalias, sizeof(modalias));
+
+ if (add_uevent_var(env, "MODALIAS=%s", modalias))
+ return -ENOMEM;
+ } else {
+ /*
+ * We only need to handle uevents for the Slave device
+ * type. This error cannot happen unless the .uevent
+ * callback is set to use this function for a
+ * different device type (e.g. Master or Monitor)
+ */
+ dev_err(dev, "uevent for unknown Soundwire type\n");
+ return -EINVAL;
At this point and after next patch, the above code would be a no-op, do
we want this here, if so why?