======================== CODE SNIPPETS ======================== TITLE: LinuxSH Board Setup Code Example DESCRIPTION: Provides a minimal C code example for `get_system_type()` and `platform_setup()` functions, which are required for new board support in LinuxSH. It demonstrates how to define the system type and perform initial hardware setup. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/arch/sh/new-machine.rst#_snippet_3 LANGUAGE: C CODE: ``` /*\n* arch/sh/boards/vapor/setup.c - Setup code for imaginary board\n*/\n#include \n\nconst char *get_system_type(void)\n{\n\treturn "FooTech Vaporboard";\n}\n\nint __init platform_setup(void)\n{\n\t/*\n\t* If our hardware actually existed, we would do real\n\t* setup here. Though it's also sane to leave this empty\n\t* if there's no real init work that has to be done for\n\t* this board.\n\t*/\n\n\t/* Start-up imaginary PCI ... */\n\n\t/* And whatever else ... */\n\n\treturn 0;\n} ``` ---------------------------------------- TITLE: Start Espeakup Program (Manual Installation) DESCRIPTION: For manual installations where Espeakup was built from source and 'make install' was run, this command directly executes the Espeakup binary. The binary is typically placed under /usr/bin. This operation requires root privileges. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/spkguide.txt#_snippet_25 LANGUAGE: bash CODE: ``` /usr/bin/espeakup ``` ---------------------------------------- TITLE: Start VDO Volume with dmsetup DESCRIPTION: Demonstrates how to start a previously-formatted VDO volume using `dmsetup create`. This example initializes a VDO volume named `vdo0` with 1 GB logical and 1 GB physical space, mapping it to `/dev/dm-1`. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/device-mapper/vdo.rst#_snippet_3 LANGUAGE: Shell CODE: ``` dmsetup create vdo0 --table \ "0 2097152 vdo V4 /dev/dm-1 262144 4096 32768 16380" ``` ---------------------------------------- TITLE: Start OrangeFS Server (Manual Build) DESCRIPTION: Starts the OrangeFS server daemon directly from the installed binaries using the specified configuration file. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/filesystems/orangefs.rst#_snippet_11 LANGUAGE: bash CODE: ``` /opt/ofs/sbin/pvfs2-server /etc/pvfs2.conf ``` ---------------------------------------- TITLE: Finalize Disk Image Setup in QEMU Guest DESCRIPTION: This command is executed inside the newly started s390 QEMU guest to complete the debootstrap installation process. This second stage is crucial for making the root filesystem fully functional and ready for use. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/bpf/s390.rst#_snippet_7 LANGUAGE: Bash CODE: ``` /debootstrap/debootstrap --second-stage ``` ---------------------------------------- TITLE: Start Espeakup Daemon (Distribution Package) DESCRIPTION: If Espeakup was installed as a package for your Linux distribution, this command starts the Espeakup daemon using the distribution's init script. You may need to replace 'init.d' with 'rc.d' depending on your system's init system. This requires root privileges. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/spkguide.txt#_snippet_24 LANGUAGE: bash CODE: ``` /etc/init.d/espeakup start ``` ---------------------------------------- TITLE: EP93xx Framebuffer Platform Setup Callback DESCRIPTION: This C code snippet provides an example of a platform setup callback function for the EP93xx framebuffer driver. It demonstrates how to retrieve the `ep93xxfb_mach_info` and `fb_info` structures from the `platform_device` argument for board-specific initialization. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/fb/ep93xx-fb.rst#_snippet_6 LANGUAGE: C CODE: ``` static int some_board_fb_setup(struct platform_device *pdev) { struct ep93xxfb_mach_info *mach_info = pdev->dev.platform_data; struct fb_info *fb_info = platform_get_drvdata(pdev); /* Board specific framebuffer setup */ } ``` ---------------------------------------- TITLE: Start or Restart PCMCIA Services DESCRIPTION: Commands to start or restart the pcmcia-cs services after driver installation and configuration. Provides examples for both BSD-style (`/etc/rc.d/rc.pcmcia start`) and SYSV-style (`/etc/init.d/pcmcia start`) init systems. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/scsi/NinjaSCSI.rst#_snippet_5 LANGUAGE: bash CODE: ``` # /etc/rc.d/rc.pcmcia start (BSD style) ``` LANGUAGE: bash CODE: ``` # /etc/init.d/pcmcia start (SYSV style) ``` ---------------------------------------- TITLE: Boot Setup Commands and Modprobe Parameters DESCRIPTION: Explains how to pass setup commands to the driver at boot time via LILO or as parameters to modprobe, demonstrating how to configure tagged commands, synchronous negotiation speed, and debug flags. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/scsi/sym53c8xx_2.rst#_snippet_13 LANGUAGE: Shell CODE: ``` lilo: linux root=/dev/sda2 sym53c8xx.cmd_per_lun=4 sym53c8xx.sync=10 sym53c8xx.debug=0x200 ``` LANGUAGE: Shell CODE: ``` modprobe sym53c8xx cmd_per_lun=4 sync=10 debug=0x200 ``` ---------------------------------------- TITLE: Quick Install D-Link DL2000 Driver on Linux DESCRIPTION: Provides a step-by-step guide for quickly installing and configuring the D-Link DL2000 driver, including compilation, module loading, network interface setup, and persistent configuration. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/networking/device_drivers/ethernet/dlink/dl2k.rst#_snippet_0 LANGUAGE: bash CODE: ``` make all insmod dl2k.ko ifconfig eth0 up 10.xxx.xxx.xxx netmask 255.0.0.0 cp dl2k.ko /lib/modules/`uname -r`/kernel/drivers/net # Add the following line to /etc/modprobe.d/dl2k.conf: alias eth0 dl2k depmod netconfig # or netconf ``` ---------------------------------------- TITLE: Example 'make help' Output for New Board (Linux Kernel) DESCRIPTION: After successfully adding a defconfig file for your new board, it will appear as a build target in the 'make help' output. This provides a convenient way for users to build the kernel specifically for your board. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/arch/sh/new-machine.rst#_snippet_10 LANGUAGE: Shell CODE: ``` Architecture specific targets (sh): ======================= ============================================= zImage Compressed kernel image (arch/sh/boot/zImage) adx_defconfig Build for adx cqreek_defconfig Build for cqreek dreamcast_defconfig Build for dreamcast ... vapor_defconfig Build for vapor ======================= ============================================= ``` ---------------------------------------- TITLE: C Example: Using setup_indirect for SETUP_E820_EXT DESCRIPTION: Illustrates how to configure a setup_data entry to use setup_indirect for pointing to SETUP_E820_EXT data. This example demonstrates the structure and values required for indirect data referencing in the boot protocol. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/arch/x86/boot.rst#_snippet_32 LANGUAGE: C CODE: ``` struct setup_data { .next = 0, /* or */ .type = SETUP_INDIRECT, .len = sizeof(setup_indirect), .data[sizeof(setup_indirect)] = (struct setup_indirect) { .type = SETUP_INDIRECT | SETUP_E820_EXT, .reserved = 0, .len = , .addr = , }, } ``` ---------------------------------------- TITLE: Install NCR53C8XX Driver with Insmod Options DESCRIPTION: Example of installing the ncr53c8xx driver module using 'insmod' with space-separated options. This achieves the same configuration as the LILO example, enabling tagged commands, setting synchronous negotiation speed, and activating a debug flag. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/scsi/ncr53c8xx.rst#_snippet_15 LANGUAGE: Shell CODE: ``` insmod ncr53c8xx.o ncr53c8xx="tags:4 sync:10 debug:0x200" ``` ---------------------------------------- TITLE: Initrd Boot Command-Line Options DESCRIPTION: Documentation for kernel boot parameters related to initrd, including options to load an initial RAM disk, preserve initrd data without mounting, and mount initrd as the root filesystem. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/initrd.rst#_snippet_4 LANGUAGE: APIDOC CODE: ``` initrd= Loads the specified file as the initial RAM disk. When using LILO, you have to specify the RAM disk image file in /etc/lilo.conf, using the INITRD configuration variable. noinitrd initrd data is preserved but it is not converted to a RAM disk and the "normal" root file system is mounted. initrd data can be read from /dev/initrd. Note that the data in initrd can have any structure in this case and doesn't necessarily have to be a file system image. This option is used mainly for debugging. Note: /dev/initrd is read-only and it can only be used once. As soon as the last process has closed it, all data is freed and /dev/initrd can't be opened anymore. root=/dev/ram0 initrd is mounted as root, and the normal boot procedure is followed, with the RAM disk mounted as root. ``` ---------------------------------------- TITLE: Example: Activating a Floppy Disk Controller (Linux Shell) DESCRIPTION: A step-by-step example demonstrating the process of activating a floppy disk controller using the Linux Plug and Play sysfs interface. It includes navigating to the device directory, checking its current status, viewing possible configurations, and finally activating it automatically. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/pnp.rst#_snippet_3 LANGUAGE: Linux Shell CODE: ``` # cd /driver/bus/pnp/devices/00:0f # cat name # cat resources # cat options # echo "auto" > resources # cat resources ``` ---------------------------------------- TITLE: Install stress-ng and paxtest Workload Tools on Debian DESCRIPTION: Commands to install `stress-ng` for generating various types of system load and `paxtest` for testing security features, used as example workloads for tracing. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/workload-tracing.rst#_snippet_2 LANGUAGE: bash CODE: ``` apt-get install stress-ng apt-get install paxtest ``` ---------------------------------------- TITLE: Start s390 QEMU Virtual Machine DESCRIPTION: This command launches an s390x QEMU virtual machine with specified CPU, memory, kernel, disk image, and networking configurations. It also sets up a 9P filesystem share for host directory access and configures a virtio-rng device for entropy. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/bpf/s390.rst#_snippet_6 LANGUAGE: Bash CODE: ``` qemu-system-s390x \ -cpu max,zpci=on \ -smp 2 \ -m 4G \ -kernel linux/arch/s390/boot/compressed/vmlinux \ -drive file=./s390.img,if=virtio,format=raw \ -nographic \ -append 'root=/dev/vda rw console=ttyS1' \ -virtfs local,path=./linux,security_model=none,mount_tag=linux \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-ccw,rng=rng0 \ -netdev user,id=net0 \ -device virtio-net-ccw,netdev=net0 ``` ---------------------------------------- TITLE: Install Coccinelle from source DESCRIPTION: These commands guide you through building and installing Coccinelle from its source code. First, run autogen, configure, and make as a regular user, then use sudo to install the compiled binaries system-wide. Coccinelle version 1.0.0-rc11 or above is required. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/dev-tools/coccinelle.rst#_snippet_0 LANGUAGE: Shell CODE: ``` ./autogen ./configure make sudo make install ``` ---------------------------------------- TITLE: Compile and Install Linux Kernel DESCRIPTION: After configuring the kernel, run `make` to create the compressed kernel image. If a bootloader like LILO is installed or your distribution provides an install script, `make install` can be used to automate the installation. Additionally, if any kernel components were configured as modules, `make modules_install` is necessary to install them. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/README.rst#_snippet_7 LANGUAGE: shell CODE: ``` make make install make modules_install ``` ---------------------------------------- TITLE: Sysfs CPU Information Output Example 2 (possible_cpus=144) DESCRIPTION: Another example of `/sys/devices/system/cpu` file outputs, where `NR_CPUS` is 128 but the kernel was started with `possible_cpus=144`. It illustrates a scenario where a CPU was manually taken offline. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/cputopology.rst#_snippet_4 LANGUAGE: Text CODE: ``` kernel_max: 127 offline: 2,4-127,128-143 online: 0-1,3 possible: 0-127 present: 0-3 ``` ---------------------------------------- TITLE: Prepare s390 QEMU Disk Image DESCRIPTION: This set of commands creates a raw disk image, formats it with ext4, mounts it, and then uses debootstrap to install a minimal s390x Debian root filesystem onto it. Finally, it unmounts the filesystem and detaches the loopback device, preparing the image for QEMU. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/bpf/s390.rst#_snippet_3 LANGUAGE: Bash CODE: ``` qemu-img create -f raw ./s390.img 1G sudo losetup -f ./s390.img sudo mkfs.ext4 /dev/loopX mkdir ./s390.rootfs sudo mount /dev/loopX ./s390.rootfs sudo debootstrap \ --foreign \ --arch=s390x \ --variant=minbase \ --include=" \ iproute2, \ iputils-ping, \ isc-dhcp-client, \ kmod, \ libcap2, \ libelf1, \ netcat, \ procps" \ testing \ ./s390.rootfs sudo umount ./s390.rootfs sudo losetup -d /dev/loopX ``` ---------------------------------------- TITLE: Setup DMA Receive Buffer (Linux Kernel C Pseudo-code) DESCRIPTION: A pseudo-code example demonstrating the setup of a receive buffer using dma_map_single. It includes error handling for DMA mapping failures and prepares the buffer for the hardware. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/core-api/dma-api-howto.rst#_snippet_35 LANGUAGE: C CODE: ``` my_card_setup_receive_buffer(struct my_card *cp, char *buffer, int len) { dma_addr_t mapping; mapping = dma_map_single(cp->dev, buffer, len, DMA_FROM_DEVICE); if (dma_mapping_error(cp->dev, mapping)) { /* * reduce current DMA mapping usage, * delay and try again later or * reset driver. */ goto map_error_handling; } cp->rx_buf = buffer; cp->rx_len = len; cp->rx_dma = mapping; give_rx_buf_to_card(cp); } ``` ---------------------------------------- TITLE: Create USB MIDI 2.0 Gadget Instance and Basic Configuration DESCRIPTION: Demonstrates the initial steps to set up a USB MIDI 2.0 gadget instance using configfs, including creating directories for the gadget and its configuration, and setting basic USB descriptors like product ID, vendor ID, manufacturer, product name, and serial number. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/sound/designs/midi-2.0.rst#_snippet_14 LANGUAGE: shell CODE: ``` cd /sys/kernel/config mkdir usb_gadget/g1 cd usb_gadget/g1 mkdir configs/c.1 mkdir functions/midi2.usb0 echo 0x0004 > idProduct echo 0x17b3 > idVendor mkdir strings/0x409 echo "ACME Enterprises" > strings/0x409/manufacturer echo "ACMESynth" > strings/0x409/product echo "ABCD12345" > strings/0x409/serialnumber mkdir configs/c.1/strings/0x409 echo "Monosynth" > configs/c.1/strings/0x409/configuration echo 120 > configs/c.1/MaxPower ``` ---------------------------------------- TITLE: Example kgdboc Serial Port Configurations DESCRIPTION: These are concrete examples of `kgdboc` strings for different serial port setups. The first configures `ttyS0` for an x86 target, and the second configures `ttyAMA1` for an ARM Versatile AB, both at 115200 baud. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/process/debugging/kgdb.rst#_snippet_5 LANGUAGE: Shell CODE: ``` kgdboc=ttyS0,115200 ``` LANGUAGE: Shell CODE: ``` kgdboc=ttyAMA1,115200 ``` ---------------------------------------- TITLE: Generated Kernel Command Line from Bootconfig Example DESCRIPTION: Illustrates how the parameters defined in the example `bootconfig` file are translated into the kernel command line string, showing the format for kernel and init parameters. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/bootconfig.rst#_snippet_15 LANGUAGE: text CODE: ``` root="01234567-89ab-cdef-0123-456789abcd" -- splash ``` ---------------------------------------- TITLE: Example: Configuring eMMC Partitions with blkdevparts DESCRIPTION: Demonstrates a practical application of the 'blkdevparts' kernel command line option for configuring partitions on eMMC devices, showing both the 'bootargs' string used during system boot and the corresponding 'dmesg' output from the kernel. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/block/cmdline-partition.rst#_snippet_1 LANGUAGE: Shell CODE: ``` bootargs:: 'blkdevparts=mmcblk0:1G(data0),1G(data1),-;mmcblk0boot0:1m(boot)ro,-(kernel)' ``` LANGUAGE: Linux Kernel CODE: ``` dmesg:: mmcblk0: p1(data0) p2(data1) p3() mmcblk0boot0: p1(boot) p2(kernel) ``` ---------------------------------------- TITLE: Device Tree Binding Example for OMAP-TWL4030 Audio DESCRIPTION: Example device tree node demonstrating the basic configuration for a TI OMAP-TWL4030 audio setup, specifying compatible string, model name, and McBSP phandle. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/sound/omap-twl4030.txt#_snippet_1 LANGUAGE: devicetree CODE: ``` sound { compatible = "ti,omap-twl4030"; ti,model = "omap3beagle"; ti,mcbsp = <&mcbsp2>; }; ``` ---------------------------------------- TITLE: Device Mapper Linear Target Attributes Format and Example DESCRIPTION: This section defines the 'linear' target attributes measured in the 'EVENT_DATA' for 'dm_table_load' events. It specifies the data format for target_attributes including target_name, target_version, device_name, and start. An example log entry demonstrates the format. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/device-mapper/dm-ima.rst#_snippet_17 LANGUAGE: APIDOC CODE: ``` target_attributes := "," "," <,> ";" target_name := "target_name=linear" target_version := "target_version=" "." "." device_name := "device_name=" start := "start=" ``` LANGUAGE: plaintext CODE: ``` dm_version=4.45.0; name=linear1,uuid=linear_uuid1,major=253,minor=2,minor_count=1,num_targets=1; target_index=0,target_begin=0,target_len=28672,target_name=linear,target_version=1.4.0, device_name=253:1,start=2048; ``` ---------------------------------------- TITLE: Prepare Environment for Linux Kernel Build and Bisect DESCRIPTION: This section outlines the necessary steps to set up your system for building Linux kernels. It includes removing conflicting software, ensuring Secure Boot compatibility, installing build tools, cloning repositories, and configuring the kernel. Initial configuration adjustments for storage space and debugging are also covered. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/verify-bugs-and-bisect-regressions.rst#_snippet_0 LANGUAGE: bash CODE: ``` # * Remove any software that depends on externally maintained kernel modules # or builds any automatically during bootup. # * Ensure Secure Boot permits booting self-compiled Linux kernels. # * If you are not already running the 'working' kernel, reboot into it. # * Install compilers and everything else needed for building Linux. # * Ensure to have 15 Gigabyte free space in your home directory. git clone -o mainline --no-checkout \\ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ~/linux/ cd ~/linux/ git remote add -t master stable \\ https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git git switch --detach v6.0 # * Hint: if you used an existing clone, ensure no stale .config is around. make olddefconfig # * Ensure the former command picked the .config of the 'working' kernel. # * Connect external hardware (USB keys, tokens, ...), start a VM, bring up # VPNs, mount network shares, and briefly try the feature that is broken. yes '' | make localmodconfig ./scripts/config --set-str CONFIG_LOCALVERSION '-local' ./scripts/config -e CONFIG_LOCALVERSION_AUTO # * Note, when short on storage space, check the guide for an alternative: ./scripts/config -d DEBUG_INFO_NONE -e KALLSYMS_ALL -e DEBUG_KERNEL \\ -e DEBUG_INFO -e DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -e KALLSYMS # * Hint: at this point you might want to adjust the build configuration; # you'll have to, if you are running Debian. make olddefconfig cp .config ~/kernel-config-working ``` ---------------------------------------- TITLE: Create and Test Minimal Initramfs with Hello World DESCRIPTION: This example demonstrates the process of creating a basic 'Hello world' C program, compiling it statically, packaging it into a gzipped cpio archive, and then testing it as an external initramfs image using QEMU. This setup allows for early userspace execution and debugging of a minimal root filesystem. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/filesystems/ramfs-rootfs-initramfs.rst#_snippet_4 LANGUAGE: C CODE: ``` cat > hello.c << EOF #include #include int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } EOF ``` LANGUAGE: Shell CODE: ``` gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz # Testing external initramfs using the initrd loading mechanism. qemu -kernel /boot/vmlinuz -initrd test.cpio.gz /dev/zero ``` ---------------------------------------- TITLE: Example NVRAM Device Setup Data Pattern DESCRIPTION: This hexadecimal snippet shows a common repeating pattern found in the device setup area of the NVRAM, likely representing default or common device configuration entries for Symbios SCSI controllers. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/scsi/sym53c8xx_2.rst#_snippet_35 LANGUAGE: Hex CODE: ``` 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 0f 00 08 08 64 00 0a 00 ``` ---------------------------------------- TITLE: C Example: Linux IIO Triggered Buffer Setup DESCRIPTION: Demonstrates a complete setup for an IIO triggered buffer in C, including defining buffer setup operations, a poll function (top half), a trigger handler (bottom half), and the final call to `iio_triggered_buffer_setup`. It illustrates how data is read from a device and pushed to buffers with a timestamp in an interrupt context. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/driver-api/iio/triggered-buffers.rst#_snippet_1 LANGUAGE: C CODE: ``` const struct iio_buffer_setup_ops sensor_buffer_setup_ops = { .preenable = sensor_buffer_preenable, .postenable = sensor_buffer_postenable, .postdisable = sensor_buffer_postdisable, .predisable = sensor_buffer_predisable, }; irqreturn_t sensor_iio_pollfunc(int irq, void *p) { pf->timestamp = iio_get_time_ns((struct indio_dev *)p); return IRQ_WAKE_THREAD; } irqreturn_t sensor_trigger_handler(int irq, void *p) { u16 buf[8]; int i = 0; /* read data for each active channel */ for_each_set_bit(bit, active_scan_mask, masklength) buf[i++] = sensor_get_data(bit); iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp); iio_trigger_notify_done(trigger); return IRQ_HANDLED; } /* setup triggered buffer, usually in probe function */ iio_triggered_buffer_setup(indio_dev, sensor_iio_polfunc, sensor_trigger_handler, sensor_buffer_setup_ops); ``` ---------------------------------------- TITLE: Run PCI Endpoint Kselftest and Example Output DESCRIPTION: Command to execute the pci_endpoint_test Kselftest and an example of its TAP-formatted output, showing various BAR and basic PCI endpoint tests. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/PCI/endpoint/pci-test-howto.rst#_snippet_10 LANGUAGE: bash CODE: ``` # pci_endpoint_test TAP version 13 1..16 # Starting 16 tests from 9 test cases. # RUN pci_ep_bar.BAR0.BAR_TEST ... # OK pci_ep_bar.BAR0.BAR_TEST ok 1 pci_ep_bar.BAR0.BAR_TEST # RUN pci_ep_bar.BAR1.BAR_TEST ... # OK pci_ep_bar.BAR1.BAR_TEST ok 2 pci_ep_bar.BAR1.BAR_TEST # RUN pci_ep_bar.BAR2.BAR_TEST ... # OK pci_ep_bar.BAR2.BAR_TEST ok 3 pci_ep_bar.BAR2.BAR_TEST # RUN pci_ep_bar.BAR3.BAR_TEST ... # OK pci_ep_bar.BAR3.BAR_TEST ok 4 pci_ep_bar.BAR3.BAR_TEST # RUN pci_ep_bar.BAR4.BAR_TEST ... # OK pci_ep_bar.BAR4.BAR_TEST ok 5 pci_ep_bar.BAR4.BAR_TEST # RUN pci_ep_bar.BAR5.BAR_TEST ... # OK pci_ep_bar.BAR5.BAR_TEST ok 6 pci_ep_bar.BAR5.BAR_TEST # RUN pci_ep_basic.CONSECUTIVE_BAR_TEST ... # OK pci_ep_basic.CONSECUTIVE_BAR_TEST ok 7 pci_ep_basic.CONSECUTIVE_BAR_TEST # RUN pci_ep_basic.LEGACY_IRQ_TEST ... ``` ---------------------------------------- TITLE: Read ALSA Jack Control ID DESCRIPTION: Example of reading the `kctl_id` file to get the identifier of a specific `jack_kctl`. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/sound/designs/jack-injection.rst#_snippet_2 LANGUAGE: Shell CODE: ``` sound/card1/Headphone_Jack# cat kctl_id Headphone Jack ``` ---------------------------------------- TITLE: Loading PWC Module with Configuration Parameters DESCRIPTION: Demonstrates how to load the 'pwc' kernel module using the 'modprobe' command, specifying initial configuration parameters such as video size, frames per second, and power saving mode directly on the command line. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/media/philips.rst#_snippet_4 LANGUAGE: Shell CODE: ``` # modprobe pwc size=cif fps=15 power_save=1 ``` ---------------------------------------- TITLE: Verifying Custom Python Script Location DESCRIPTION: An example listing of the `perf/scripts/python` directory in the kernel source tree, showing where your main Python script (`syscall-counts.py` in this example) must be placed for 'make install' to correctly copy it to the `libexec/perf-core/scripts/python` directory. SOURCE: https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/perf-script-python.txt#_snippet_16 LANGUAGE: shell CODE: ``` ls -al kernel-source/tools/perf/scripts/python total 32 drwxr-xr-x 4 trz trz 4096 2010-01-26 22:30 . drwxr-xr-x 4 trz trz 4096 2010-01-26 22:29 .. drwxr-xr-x 2 trz trz 4096 2010-01-26 22:29 bin -rw-r--r-- 1 trz trz 2548 2010-01-26 22:29 check-perf-script.py drwxr-xr-x 3 trz trz 4096 2010-01-26 22:49 Perf-Trace-Util -rw-r--r-- 1 trz trz 1462 2010-01-26 22:30 syscall-counts.py ``` ---------------------------------------- TITLE: Example: Request Specific Number of MSI/MSI-X Vectors DESCRIPTION: This example shows how to request an exact number of interrupt vectors for a PCI device. By setting both `min_vecs` and `max_vecs` to the desired count, the function will only succeed if it can allocate precisely that many vectors. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/translations/zh_CN/PCI/msi-howto.rst#_snippet_4 LANGUAGE: C CODE: ``` ret = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_ALL_TYPES); if (ret < 0) goto out_err; ``` ---------------------------------------- TITLE: Configure Direct Conversion Video Pipeline with media-ctl DESCRIPTION: This example sets up a more complex pipeline for direct conversion, capturing from OV5640, transmitting via MIPI CSI-2, and performing colorspace conversion and scaling at the IC output. It involves multiple linking and pad configuration steps. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/media/imx.rst#_snippet_18 LANGUAGE: Shell CODE: ``` # Setup links media-ctl -l "'ov5640 1-003c':0 -> 'imx6-mipi-csi2':0[1]" media-ctl -l "'imx6-mipi-csi2':1 -> 'ipu1_csi0_mux':0[1]" media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]" media-ctl -l "'ipu1_csi0':1 -> 'ipu1_ic_prp':0[1]" media-ctl -l "'ipu1_ic_prp':1 -> 'ipu1_ic_prpenc':0[1]" media-ctl -l "'ipu1_ic_prpenc':1 -> 'ipu1_ic_prpenc capture':0[1]" # Configure pads media-ctl -V "'ov5640 1-003c':0 [fmt:UYVY2X8/640x480]" media-ctl -V "'imx6-mipi-csi2':1 [fmt:UYVY2X8/640x480]" media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/640x480]" media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/640x480]" media-ctl -V "'ipu1_ic_prp':1 [fmt:AYUV32/640x480]" media-ctl -V "'ipu1_ic_prpenc':1 [fmt:ARGB8888_1X32/800x600]" # Set a format at the capture interface v4l2-ctl -d /dev/video1 --set-fmt-video=pixelformat=RGB3 ``` ---------------------------------------- TITLE: Linux Kernel: Kobject Release Method Example DESCRIPTION: This example demonstrates a typical `release()` method for a kobject. This method is crucial for asynchronous cleanup of the containing structure once the kobject's reference count reaches zero. It uses `container_of()` to get a pointer to the parent structure and then frees it. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/core-api/kobject.rst#_snippet_14 LANGUAGE: C CODE: ``` void my_object_release(struct kobject *kobj) { struct my_object *mine = container_of(kobj, struct my_object, kobj); /* Perform any additional cleanup on this object, then... */ kfree(mine); } ``` ---------------------------------------- TITLE: Start Link with Host for EP Controllers DESCRIPTION: Commands to initiate the link establishment process for both primary and secondary PCI endpoint controllers by writing '1' to their 'start' attribute. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/PCI/endpoint/pci-ntb-howto.rst#_snippet_7 LANGUAGE: bash CODE: ``` # echo 1 > controllers/2900000.pcie-ep/start # echo 1 > controllers/2910000.pcie-ep/start ``` ---------------------------------------- TITLE: I2C Board Information Setup for SHT21/SHT25 Driver DESCRIPTION: Example of how to declare the SHT21 sensor with its fixed I2C address (0x40) in the Linux kernel board setup code. This entry allows the driver to correctly identify and probe the device on the I2C bus. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/hwmon/sht21.rst#_snippet_0 LANGUAGE: C CODE: ``` I2C_BOARD_INFO("sht21", 0x40) ``` ---------------------------------------- TITLE: Build and Install a Trimmed Linux Kernel (TL;DR) DESCRIPTION: This set of commands provides a quick way to download the latest Linux mainline sources, configure a minimal kernel using `localmodconfig`, build it, and install it. It's designed for swift testing or daily use, assuming necessary build tools are already installed. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/quickly-build-trimmed-linux.rst#_snippet_0 LANGUAGE: bash CODE: ``` git clone --depth 1 -b master \ https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git ~/linux/ cd ~/linux/ # Hint: if you want to apply patches, do it at this point. See below for details. # Hint: it's recommended to tag your build at this point. See below for details. yes "" | make localmodconfig # Hint: at this point you might want to adjust the build configuration; you'll # have to, if you are running Debian. See below for details. make -j $(nproc --all) # Note: on many commodity distributions the next command suffices, but on Arch # Linux, its derivatives, and some others it does not. See below for details. command -v installkernel && sudo make modules_install install reboot ``` ---------------------------------------- TITLE: Configure Basic Video Capture Pipeline with media-ctl DESCRIPTION: This snippet demonstrates how to set up a basic video capture pipeline using `media-ctl` by linking and configuring pads for a simple capture scenario. It prepares the `ipu1_csi0` and related components for streaming. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/media/imx.rst#_snippet_14 LANGUAGE: Shell CODE: ``` media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]" # Configure pads media-ctl -V "'ov5640 1-003c':0 [fmt:UYVY2X8/640x480]" media-ctl -V "'imx6-mipi-csi2':1 [fmt:UYVY2X8/640x480]" media-ctl -V "'ipu1_csi0_mux':0 [fmt:UYVY2X8/640x480]" media-ctl -V "'ipu1_csi0':0 [fmt:AYUV32/640x480]" ``` ---------------------------------------- TITLE: Calculate Kernel Version String Offset Example DESCRIPTION: This example illustrates the relationship between the kernel version string offset and the 'setup_sects' field, demonstrating how to calculate the minimum 'setup_sects' value required for a given offset. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/arch/x86/boot.rst#_snippet_7 LANGUAGE: APIDOC CODE: ``` 0x1c00 < 15 * 0x200 (= 0x1e00) but 0x1c00 >= 14 * 0x200 (= 0x1c00) 0x1c00 >> 9 = 14, So the minimum value for setup_secs is 15. ``` ---------------------------------------- TITLE: Example Device Tree Node for Parallel Output Controller DESCRIPTION: An example device tree node configuration for the Imagination Technologies Parallel Output Controller, demonstrating the use of required and optional properties in a typical setup. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/sound/img,parallel-out.txt#_snippet_2 LANGUAGE: Device Tree CODE: ``` parallel_out: parallel-out@18100c00 { compatible = "img,parallel-out"; reg = <0x18100C00 0x100>; interrupts = ; dmas = <&mdc 16 0xffffffff 0>; dma-names = "tx"; clocks = <&cr_periph SYS_CLK_PAUD_OUT>, <&clk_core CLK_AUDIO_DAC>; clock-names = "sys", "ref"; resets = <&pistachio_reset PISTACHIO_RESET_PRL_OUT>; reset-names = "rst"; #sound-dai-cells = <0>; }; ``` ---------------------------------------- TITLE: Navigate to Rust Samples Menu DESCRIPTION: Instructions to access and enable Rust sample modules within the Linux kernel configuration menu (menuconfig) after a suitable Rust toolchain is found. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/rust/quick-start.rst#_snippet_19 LANGUAGE: Shell CODE: ``` Kernel hacking -> Sample kernel code -> Rust samples ``` ---------------------------------------- TITLE: Install VMA/Shared Policy for a Range (Linux Kernel API) DESCRIPTION: Installs the policy specified by (mode, nmask, maxnodes) as a VMA policy for the range of the calling task's address space specified by the 'start' and 'len' arguments. Additional actions may be requested via the 'flags' argument. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/mm/numa_memory_policy.rst#_snippet_11 LANGUAGE: APIDOC CODE: ``` long mbind(void *start, unsigned long len, int mode, const unsigned long *nmask, unsigned long maxnode, unsigned flags); ``` ---------------------------------------- TITLE: Example Non-Identity User Namespace ID Mapping DESCRIPTION: This snippet illustrates a typical non-identity idmapping used in user namespaces other than the initial one. It maps userspace IDs starting from 0 to kernel IDs starting from 10000, for a range of 10000 IDs. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/filesystems/idmappings.rst#_snippet_10 LANGUAGE: APIDOC CODE: ``` u0:k10000:r10000 ``` ---------------------------------------- TITLE: Initialize Linux Media Build Tree DESCRIPTION: Before using the `media_build` tree for the first time or after updates, run this script to prepare the build environment. It may need to be run twice if the tree is updated, or `make distclean` if switching kernel versions. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/media/building.rst#_snippet_15 LANGUAGE: bash CODE: ``` $ ./build ``` ---------------------------------------- TITLE: Example: Altering SUID Credential DESCRIPTION: A typical example function demonstrating the workflow for altering a single credential aspect, such as the SUID. It uses `prepare_creds()` to get a mutable copy, updates the SUID, performs security checks, and then either `abort_creds()` on failure or `commit_creds()` on success. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/security/credentials.rst#_snippet_13 LANGUAGE: C CODE: ``` int alter_suid(uid_t suid) { struct cred *new; int ret; new = prepare_creds(); if (!new) return -ENOMEM; new->suid = suid; ret = security_alter_suid(new); if (ret < 0) { abort_creds(new); return ret; } return commit_creds(new); } ``` ---------------------------------------- TITLE: LILO Configuration for initrd DESCRIPTION: Example LILO configuration snippet to include an initrd image and kernel boot parameters within the '/etc/lilo.conf' file. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/initrd.rst#_snippet_13 LANGUAGE: LILO Config CODE: ``` image = /bzImage initrd = /boot/initrd.gz append = "root=/dev/ram0 rw" ``` ---------------------------------------- TITLE: Example Device Tree Configuration for Micron MT9M111 DESCRIPTION: Provides a practical example of how to configure the Micron MT9M111 image sensor within a device tree, demonstrating the setup of its I2C address, clock connections, and video endpoint properties. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/media/i2c/micron,mt9m111.txt#_snippet_1 LANGUAGE: devicetree CODE: ``` i2c_master { mt9m111@5d { compatible = "micron,mt9m111"; reg = <0x5d>; clocks = <&mclk>; clock-names = "mclk"; port { mt9m111_1: endpoint { remote-endpoint = <&pxa_camera>; pclk-sample = <1>; }; }; }; }; ``` ---------------------------------------- TITLE: Example: Attaching and Listing BPF Programs to a Cgroup DESCRIPTION: Demonstrates the process of mounting the BPF filesystem, creating a cgroup, loading a BPF program, attaching it to the cgroup, and then listing attached programs. SOURCE: https://github.com/torvalds/linux/blob/master/tools/bpf/bpftool/Documentation/bpftool-cgroup.rst#_snippet_9 LANGUAGE: shell CODE: ``` # mount -t bpf none /sys/fs/bpf/ # mkdir /sys/fs/cgroup/test.slice # bpftool prog load ./device_cgroup.o /sys/fs/bpf/prog # bpftool cgroup attach /sys/fs/cgroup/test.slice/ device id 1 allow_multi # bpftool cgroup list /sys/fs/cgroup/test.slice/ ID AttachType AttachFlags Name 1 device allow_multi bpf_prog1 ``` ---------------------------------------- TITLE: Shell: Example Sound Card Listing DESCRIPTION: This snippet shows example output from a command (likely aplay -l) listing available sound cards on a system. It includes an ASoC platform card and two connected USB audio devices, providing their names and details. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/sound/soc/usb.rst#_snippet_21 LANGUAGE: Shell CODE: ``` 0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D SM8250-MTP-WCD9380-WSA8810-VA-DMIC 1 [Seri ]: USB-Audio - Plantronics Blackwire 3225 Seri Plantronics Plantronics Blackwire 3225 Seri at usb-xhci-hcd.1.auto-1.1, full sp 2 [C320M ]: USB-Audio - Plantronics C320-M Plantronics Plantronics C320-M at usb-xhci-hcd.1.auto-1.2, full speed ``` ---------------------------------------- TITLE: Memory Block Sysfs Path Example DESCRIPTION: Illustrates the sysfs path for a memory block and how its ID is derived from its physical start address and block size. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/mm/memory-hotplug.rst#_snippet_12 LANGUAGE: Shell CODE: ``` /sys/devices/system/memory/memoryXXX (0x100000000 / 1Gib = 4) ``` ---------------------------------------- TITLE: Example: Appending Pktgen Configurations with -a DESCRIPTION: Demonstrates how to use the '-a' parameter to append configurations for multiple devices without resetting the generator's state. This allows for creating different flows simultaneously and then starting joint traffic manually using 'pg_ctrl start'. SOURCE: https://github.com/torvalds/linux/blob/master/samples/pktgen/README.rst#_snippet_1 LANGUAGE: Shell CODE: ``` source ./samples/pktgen/functions.sh pg_ctrl reset # add first device ./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f0 -m 34:80:0d:a3:fc:c9 -t 8 # add second device ./pktgen_sample06_numa_awared_queue_irq_affinity.sh -a -i ens1f1 -m 34:80:0d:a3:fc:c9 -t 8 # run joint traffic on two devs pg_ctrl start ``` ---------------------------------------- TITLE: Install and Initialize FuseSoC for FPGA Development DESCRIPTION: Clones the FuseSoC repository, navigates into it, and installs it using pip. Finally, it initializes FuseSoC, preparing it for managing FPGA SoC builds. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/arch/openrisc/openrisc_port.rst#_snippet_3 LANGUAGE: Shell CODE: ``` git clone https://github.com/olofk/fusesoc cd fusesoc sudo pip install -e . fusesoc init ``` ---------------------------------------- TITLE: Basic CAN ISO-TP Node Setup in C DESCRIPTION: This C example illustrates the basic setup for a CAN ISO-TP node using normal physical addressing. It demonstrates socket creation, binding to a CAN interface, and configuring transmit (TX) and receive (RX) IDs with the `CAN_EFF_FLAG` for extended frames. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/networking/iso15765-2.rst#_snippet_14 LANGUAGE: C CODE: ``` int s; struct sockaddr_can addr; int ret; s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP); if (s < 0) exit(1); addr.can_family = AF_CAN; addr.can_ifindex = if_nametoindex("can0"); addr.can_addr.tp.tx_id = 0x18DA42F1 | CAN_EFF_FLAG; addr.can_addr.tp.rx_id = 0x18DAF142 | CAN_EFF_FLAG; ret = bind(s, (struct sockaddr *)&addr, sizeof(addr)); if (ret < 0) exit(1); /* Data can now be received using read(s, ...) and sent using write(s, ...) */ ``` ---------------------------------------- TITLE: Run BPF Selftests in s390 QEMU Guest DESCRIPTION: This snippet shows how to navigate to the installed BPF selftests directory within the QEMU guest and execute the full test suite using run_kselftest.sh. It also provides an example of running individual tests like test_verifier. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/bpf/s390.rst#_snippet_9 LANGUAGE: Bash CODE: ``` cd /linux/tools/testing/selftests/kselftest_install ./run_kselftest.sh cd /linux/tools/testing/selftests/bpf ./test_verifier ``` ---------------------------------------- TITLE: GPIO IRQchip Infrastructure Setup Example DESCRIPTION: Provides a typical C structure for containing struct gpio_chip within a driver's state. This structure is used when setting up GPIO IRQchip helpers via gpiolib, allowing the library to manage the additional irq_chip setup. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/driver-api/gpio/driver.rst#_snippet_6 LANGUAGE: C CODE: ``` /* Typical state container */ struct my_gpio { struct gpio_chip gc; }; ``` ---------------------------------------- TITLE: Example: Booting and Shutting Down a Remote Processor DESCRIPTION: A typical usage example demonstrating how to power on and boot a remote processor using rproc_boot(), perform some work, and then shut it down using rproc_shutdown(). Includes basic error handling for the boot process. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/staging/remoteproc.rst#_snippet_3 LANGUAGE: C CODE: ``` #include /* in case we were given a valid 'rproc' handle */ int dummy_rproc_example(struct rproc *my_rproc) { int ret; /* let's power on and boot our remote processor */ ret = rproc_boot(my_rproc); if (ret) { /* * something went wrong. handle it and leave. */ } /* * our remote processor is now powered on... give it some work */ /* let's shut it down now */ rproc_shutdown(my_rproc); } ``` ---------------------------------------- TITLE: Example Laptop Mode Configuration File DESCRIPTION: This snippet shows an example of the `/etc/default/laptop-mode` or `/etc/sysconfig/laptop-mode` configuration file, illustrating how to set parameters like `MAX_AGE`, `MINIMUM_BATTERY_MINUTES`, and `READAHEAD` to control laptop mode behavior. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/laptops/laptop-mode.rst#_snippet_5 LANGUAGE: Shell CODE: ``` # Maximum time, in seconds, of hard drive spindown time that you are # comfortable with. Worst case, it's possible that you could lose this # amount of work if your battery fails you while in laptop mode. #MAX_AGE=600 # Automatically disable laptop mode when the number of minutes of battery # that you have left goes below this threshold. MINIMUM_BATTERY_MINUTES=10 # Read-ahead, in 512-byte sectors. You can spin down the disk while playing MP3/OGG # by setting the disk readahead to 8MB (READAHEAD=16384). Effectively, the disk # will read a complete MP3 at once, and will then spin down while the MP3/OGG is # playing. #READAHEAD=4096 ``` ---------------------------------------- TITLE: Check GnuPG Version DESCRIPTION: Verify that your installed GnuPG version is 2.2 or later. Older versions may not support all commands mentioned in this guide. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/process/maintainer-pgp-guide.rst#_snippet_0 LANGUAGE: Shell CODE: ``` $ gpg --version | head -n1 ``` ---------------------------------------- TITLE: Linux Kernel: vmap_area Member Offsets DESCRIPTION: Offsets of the vmap_area's members. They carry vmalloc-specific information. Makedumpfile gets the start address of the vmalloc region from this. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/kdump/vmcoreinfo.rst#_snippet_24 LANGUAGE: APIDOC CODE: ``` vmap_area: va_start: Offset of the start address list: Offset of the list member ``` ---------------------------------------- TITLE: Install Versioned Rust Toolchain on Ubuntu 24.04 LTS and Older DESCRIPTION: Installs specific versioned Rust packages (e.g., 1.80) on Ubuntu 24.04 LTS and older versions. Includes commands to create symlinks for rustfmt and clippy-driver. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/rust/quick-start.rst#_snippet_7 LANGUAGE: Shell CODE: ``` apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 \ rust-1.80-clippy ln -s /usr/lib/rust-1.80/bin/rustfmt /usr/bin/rustfmt-1.80 ln -s /usr/lib/rust-1.80/bin/clippy-driver /usr/bin/clippy-driver-1.80 ``` ---------------------------------------- TITLE: Example 7: Stereo Stream with L and R channels rendered by two Masters to two Slaves on separate links DESCRIPTION: This example illustrates a stereo stream where two Master interfaces each render both Left and Right channels. Each Slave interface then receives the combined L + R stream. This setup is similar to Example 4, but with the Slaves placed on separate communication links. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/driver-api/soundwire/stream.rst#_snippet_7 LANGUAGE: ASCII Art CODE: ``` +---------------+ Clock Signal +---------------+ | Master +----------------------------------+ Slave | | Interface | | Interface | | 1 | | 1 | | | Data Signal | | | L + R +----------------------------------+ L + R | | (Data) | Data Direction | (Data) | +---------------+ +-----------------------> +---------------+ +---------------+ Clock Signal +---------------+ | Master +----------------------------------+ Slave | | Interface | | Interface | | 2 | | 2 | | | Data Signal | | | L + R +----------------------------------+ L + R | | (Data) | Data Direction | (Data) | +---------------+ +-----------------------> +---------------+ ``` ---------------------------------------- TITLE: Example dmsetup status Output for RAID Target DESCRIPTION: An example of the 'dmsetup status' command output for a RAID target, illustrating how the fields like RAID type, number of devices, health characters, and sync progress are displayed in a real-world scenario. SOURCE: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/device-mapper/dm-raid.rst#_snippet_11 LANGUAGE: APIDOC CODE: ``` 0 1960893648 raid raid4 5 AAAAA 2/490221568 init 0 ```