Skip to content

Commit 2c633a8

Browse files
andrzejtppoettering
authored andcommitted
units: add usb-gadget target
Linux can be run on a device meant to act as a USB peripheral. In order for a machine to act as such a USB device it has to be equipped with a UDC - USB Device Controller. This patch adds a target reached when UDC becomes available. It can be used for activating e.g. a service unit which composes a USB gadget with configfs and activates it.
1 parent 791cd15 commit 2c633a8

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

man/systemd.special.xml

+11
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<filename>time-sync.target</filename>,
8484
<filename>timers.target</filename>,
8585
<filename>umount.target</filename>,
86+
<filename>usb-gadget.target</filename>,
8687
<!-- slices --><filename>-.slice</filename>,
8788
<filename>system.slice</filename>,
8889
<filename>user.slice</filename>,
@@ -799,6 +800,16 @@
799800
dynamically when audio hardware is found.</para>
800801
</listitem>
801802
</varlistentry>
803+
<varlistentry>
804+
<term><filename>usb-gadget.target</filename></term>
805+
<listitem>
806+
<para>This target is started automatically as soon as a
807+
USB Device Controller becomes available at boot.</para>
808+
809+
<para>This may be used to pull in usb gadget
810+
dynamically when UDC hardware is found.</para>
811+
</listitem>
812+
</varlistentry>
802813
</variablelist>
803814
</refsect2>
804815

rules/99-systemd.rules.in

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ SUBSYSTEM=="printer", TAG+="systemd", ENV{SYSTEMD_WANTS}+="printer.target"
5656
SUBSYSTEM=="usb", KERNEL=="lp*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="printer.target"
5757
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:0701??:*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="printer.target"
5858

59+
SUBSYSTEM=="udc", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="usb-gadget.target"
60+
5961
# Apply sysctl variables to network devices (and only to those) as they appear.
6062
ACTION=="add", SUBSYSTEM=="net", KERNEL!="lo", RUN+="@rootlibexecdir@/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name"
6163

units/usb-gadget.target

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: LGPL-2.1+
2+
#
3+
# This file is part of systemd.
4+
#
5+
# systemd is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU Lesser General Public License as published by
7+
# the Free Software Foundation; either version 2.1 of the License, or
8+
# (at your option) any later version.
9+
10+
[Unit]
11+
Description=Hardware activated USB gadget
12+
Documentation=man:systemd.special(7)

0 commit comments

Comments
 (0)