Skip to content

Commit

Permalink
Drop gt.target in favour of the standard systemd usb-gadget.target
Browse files Browse the repository at this point in the history
Also reword surrounding language so it still fits on the lines.

The usb-gadget.target is provided by systemd since 242.

Suggested-by: Sam Day (@samcday)
Fixes: linux-usb-gadgets#33
  • Loading branch information
pabs3 committed Mar 25, 2024
1 parent e979c8b commit 9b3ca92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
5 changes: 0 additions & 5 deletions examples/systemd/99-udc.rules

This file was deleted.

16 changes: 8 additions & 8 deletions examples/systemd/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ Udev rule
.. code-block:: console
SUBSYSTEM=="udc", ACTION=="add", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="gt.target"
TAG+="systemd", ENV{SYSTEMD_WANTS}+="usb-gadget.target"
The condition for taking the activity is that there is a kernel "add" event
from the "udc" subsystem, which means a new udc has just been made available.
The device in question is tagged with "systemd", which makes systemd
aware of the new device, and SYSTEMD_WANTS is set to the name of the target we
want to reach if the condition is met.
want to reach if the condition is met. This is provided by systemd since 242.

Systemd
=======
Expand All @@ -113,7 +113,7 @@ Target unit
The target is a simple target to be reached when the udev rule fires.
The service unit will use a "WantedBy" dependency to lend itself for being
managed with systemctl enable/disable.
managed with systemctl enable/disable. This is provided by systemd since 242.

Service unit
------------
Expand All @@ -134,16 +134,16 @@ The unit file is named [email protected] and is a template unit.
Type=simple
[Install]
WantedBy=gt.target
WantedBy=usb-gadget.target
This unit is a template unit, so system administrator is supposed to issue

.. code-block:: console
systemctl enable gt@<gadget scheme file basename>
This sets up appropriate symbolic links in gt.target.wants directory, which
in turn triggers executing the service unit the usual systemd way.
This sets up appropriate symbolic links in usb-gadget.target.wants directory,
which in turn triggers executing the service unit the usual systemd way.

The service itself uses gt to load gadget scheme with the name implied from
the template parameter, name the gadget accordingly and activate it. Upon
Expand Down Expand Up @@ -296,8 +296,8 @@ Discussion
==========

This document assumes there is only one UDC available in the gadget system.
If there are more, the first one to appear will cause reaching the gt.target,
so the first UDC becoming available will be used for running the gadget.service
The first UDC that becomes available will lead to reaching usb-gadget.target,
so the first UDC becoming available will be used for running the gadget service
on it. This might or might not be what you want.

This document does not address the case where actual USB device functionality
Expand Down
6 changes: 0 additions & 6 deletions examples/systemd/gt.target

This file was deleted.

2 changes: 1 addition & 1 deletion examples/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ ExecStop=gt rm -rf %i
Type=simple

[Install]
WantedBy=gt.target
WantedBy=usb-gadget.target

0 comments on commit 9b3ca92

Please sign in to comment.