Commit graph

4 commits

Author SHA1 Message Date
Heikki Krogerus bbe80c9a89 usb: typec: altmode: Remove the notification chain
Using the generic notification chain is not reasonable with
the alternate modes because it would require dependencies
between the drivers of the components that need the
notifications, and the typec drivers.

There are no users for the alternate mode notifications, so
removing the chain and the API for it completely.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200211112531.86510-6-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-12 10:51:21 -08:00
Heikki Krogerus 3370db3519 usb: typec: Registering real device entries for the muxes
Registering real device entries (struct device) for the mode
muxes as well as for the orientation switches.

The Type-C mux code was deliberately attempting to avoid
creation of separate device entries for the orientation
switch and the mode switch (alternate modes) because they
are not physical devices. They are functions of a single
physical multiplexer/demultiplexer switch device.

Unfortunately because of the dependency we still have on the
underlying mux device driver, we had to put in hacks like
the one in the commit 3e3b81965c ("usb: typec: mux: Take
care of driver module reference counting") to make sure the
driver does not disappear from underneath us. Even with
those hacks we were still left with a potential NUll pointer
dereference scenario, so just creating the device entries,
and letting the core take care of the dependencies. No more
hacks needed.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-06-03 10:55:38 +02:00
Arnd Bergmann 8160eac121 usb: typec: avoid format-overflow warning
gcc-8 points out that the fix-byte buffer might be too small if
desc->mode is a three-digit number:

drivers/usb/typec/class.c: In function 'typec_register_altmode':
drivers/usb/typec/class.c:502:32: error: '%d' directive writing between 1 and 3 bytes into a region of size 2 [-Werror=format-overflow=]
  sprintf(alt->group_name, "mode%d", desc->mode);
                                ^~
drivers/usb/typec/class.c:502:27: note: directive argument in the range [0, 255]
  sprintf(alt->group_name, "mode%d", desc->mode);
                           ^~~~~~~~
drivers/usb/typec/class.c:502:2: note: 'sprintf' output between 6 and 8 bytes into a destination of size 6
  sprintf(alt->group_name, "mode%d", desc->mode);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I assume this cannot happen in practice, but we can simply make the
string long enough to avoid the warning. This uses the two padding
bytes that already exist after the string.

Fixes: 4ab8c18d4d ("usb: typec: Register a device for every mode")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-06 16:36:19 +02:00
Heikki Krogerus 8a37d87d72 usb: typec: Bus type for alternate modes
Introducing a simple bus for the alternate modes. Bus allows
binding drivers to the discovered alternate modes the
partners support.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-02 17:42:36 +02:00