You are previewing Linux Device Drivers, 3rd Edition.
O'Reilly logo
Linux Device Drivers, 3rd Edition

Book Description

Device drivers literally drive everything you're interested in--disks, monitors, keyboards, modems--everything outside the computer chip and memory. And writing device drivers is one of the few areas of programming for the Linux operating system that calls for unique, Linux-specific knowledge. For years now, programmers have relied on the classic Linux Device Drivers from O'Reilly to master this critical subject. Now in its third edition, this bestselling guide provides all the information you'll need to write drivers for a wide range of devices. Over the years the book has helped countless programmers learn:

  • how to support computer peripherals under the Linux operating system

  • how to develop and write software for new hardware under Linux

  • the basics of Linux operation even if they are not expecting to write a driver

The new edition of Linux Device Drivers is better than ever. The book covers all the significant changes to Version 2.6 of the Linux kernel, which simplifies many activities, and contains subtle new features that can make a driver both more efficient and more flexible. Readers will find new chapters on important types of drivers not covered previously, such as consoles, USB drivers, and more. Best of all, you don't have to be a kernel hacker to understand and enjoy this book. All you need is an understanding of the C programming language and some background in Unix system calls. And for maximum ease-of-use, the book uses full-featured examples that you can compile and run without special hardware. Today Linux holds fast as the most rapidly growing segment of the computer market and continues to win over enthusiastic adherents in many application areas. With this increasing support, Linux is now absolutely mainstream, and viewed as a solid platform for embedded systems. If you're writing device drivers, you'll want this book. In fact, you'll wonder how drivers are ever written without it.

Table of Contents

  1. Linux Device Drivers, 3rd Edition
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Jon's Introduction
    2. Alessandro's Introduction
    3. Greg's Introduction
    4. Audience for This Book
    5. Organization of the Material
    6. Background Information
    7. Online Version and License
    8. Conventions Used in This Book
    9. Using Code Examples
    10. We'd Like to Hear from You
    11. Safari Enabled
    12. Acknowledgments
      1. Jon
      2. Alessandro
      3. Greg
  4. 1. An Introduction to Device Drivers
    1. 1.1. The Role of the Device Driver
    2. 1.2. Splitting the Kernel
      1. 1.2.1. Loadable Modules
    3. 1.3. Classes of Devices and Modules
    4. 1.4. Security Issues
    5. 1.5. Version Numbering
    6. 1.6. License Terms
    7. 1.7. Joining the Kernel Development Community
    8. 1.8. Overview of the Book
  5. 2. Building and Running Modules
    1. 2.1. Setting Up Your Test System
    2. 2.2. The Hello World Module
    3. 2.3. Kernel Modules Versus Applications
      1. 2.3.1. User Space and Kernel Space
      2. 2.3.2. Concurrency in the Kernel
      3. 2.3.3. The Current Process
      4. 2.3.4. A Few Other Details
    4. 2.4. Compiling and Loading
      1. 2.4.1. Compiling Modules
      2. 2.4.2. Loading and Unloading Modules
      3. 2.4.3. Version Dependency
      4. 2.4.4. Platform Dependency
    5. 2.5. The Kernel Symbol Table
    6. 2.6. Preliminaries
    7. 2.7. Initialization and Shutdown
      1. 2.7.1. The Cleanup Function
      2. 2.7.2. Error Handling During Initialization
      3. 2.7.3. Module-Loading Races
    8. 2.8. Module Parameters
    9. 2.9. Doing It in User Space
    10. 2.10. Quick Reference
  6. 3. Char Drivers
    1. 3.1. The Design of scull
    2. 3.2. Major and Minor Numbers
      1. 3.2.1. The Internal Representation of Device Numbers
      2. 3.2.2. Allocating and Freeing Device Numbers
      3. 3.2.3. Dynamic Allocation of Major Numbers
    3. 3.3. Some Important Data Structures
      1. 3.3.1. File Operations
      2. 3.3.2. The file Structure
      3. 3.3.3. The inode Structure
    4. 3.4. Char Device Registration
      1. 3.4.1. Device Registration in scull
      2. 3.4.2. The Older Way
    5. 3.5. open and release
      1. 3.5.1. The open Method
      2. 3.5.2. The release Method
    6. 3.6. scull's Memory Usage
    7. 3.7. read and write
      1. 3.7.1. The read Method
      2. 3.7.2. The write Method
      3. 3.7.3. readv and writev
    8. 3.8. Playing with the New Devices
    9. 3.9. Quick Reference
  7. 4. Debugging Techniques
    1. 4.1. Debugging Support in the Kernel
    2. 4.2. Debugging by Printing
      1. 4.2.1. printk
      2. 4.2.2. Redirecting Console Messages
      3. 4.2.3. How Messages Get Logged
      4. 4.2.4. Turning the Messages On and Off
      5. 4.2.5. Rate Limiting
      6. 4.2.6. Printing Device Numbers
    3. 4.3. Debugging by Querying
      1. 4.3.1. Using the /proc Filesystem
        1. 4.3.1.1. Implementing files in /proc
        2. 4.3.1.2. An older interface
        3. 4.3.1.3. Creating your /proc file
        4. 4.3.1.4. The seq_file interface
      2. 4.3.2. The ioctl Method
    4. 4.4. Debugging by Watching
    5. 4.5. Debugging System Faults
      1. 4.5.1. Oops Messages
      2. 4.5.2. System Hangs
    6. 4.6. Debuggers and Related Tools
      1. 4.6.1. Using gdb
      2. 4.6.2. The kdb Kernel Debugger
      3. 4.6.3. The kgdb Patches
      4. 4.6.4. The User-Mode Linux Port
      5. 4.6.5. The Linux Trace Toolkit
      6. 4.6.6. Dynamic Probes
  8. 5. Concurrency and Race Conditions
    1. 5.1. Pitfalls in scull
    2. 5.2. Concurrency and Its Management
    3. 5.3. Semaphores and Mutexes
      1. 5.3.1. The Linux Semaphore Implementation
      2. 5.3.2. Using Semaphores in scull
      3. 5.3.3. Reader/Writer Semaphores
    4. 5.4. Completions
    5. 5.5. Spinlocks
      1. 5.5.1. Introduction to the Spinlock API
      2. 5.5.2. Spinlocks and Atomic Context
      3. 5.5.3. The Spinlock Functions
      4. 5.5.4. Reader/Writer Spinlocks
    6. 5.6. Locking Traps
      1. 5.6.1. Ambiguous Rules
      2. 5.6.2. Lock Ordering Rules
      3. 5.6.3. Fine- Versus Coarse-Grained Locking
    7. 5.7. Alternatives to Locking
      1. 5.7.1. Lock-Free Algorithms
      2. 5.7.2. Atomic Variables
      3. 5.7.3. Bit Operations
      4. 5.7.4. seqlocks
      5. 5.7.5. Read-Copy-Update
    8. 5.8. Quick Reference
  9. 6. Advanced Char Driver Operations
    1. 6.1. ioctl
      1. 6.1.1. Choosing the ioctl Commands
      2. 6.1.2. The Return Value
      3. 6.1.3. The Predefined Commands
      4. 6.1.4. Using the ioctl Argument
      5. 6.1.5. Capabilities and Restricted Operations
      6. 6.1.6. The Implementation of the ioctl Commands
      7. 6.1.7. Device Control Without ioctl
    2. 6.2. Blocking I/O
      1. 6.2.1. Introduction to Sleeping
      2. 6.2.2. Simple Sleeping
      3. 6.2.3. Blocking and Nonblocking Operations
      4. 6.2.4. A Blocking I/O Example
      5. 6.2.5. Advanced Sleeping
        1. 6.2.5.1. How a process sleeps
        2. 6.2.5.2. Manual sleeps
        3. 6.2.5.3. Exclusive waits
        4. 6.2.5.4. The details of waking up
        5. 6.2.5.5. Ancient history: sleep_on
      6. 6.2.6. Testing the Scullpipe Driver
    3. 6.3. poll and select
      1. 6.3.1. Interaction with read and write
        1. 6.3.1.1. Reading data from the device
        2. 6.3.1.2. Writing to the device
        3. 6.3.1.3. Flushing pending output
      2. 6.3.2. The Underlying Data Structure
    4. 6.4. Asynchronous Notification
      1. 6.4.1. The Driver's Point of View
    5. 6.5. Seeking a Device
      1. 6.5.1. The llseek Implementation
    6. 6.6. Access Control on a Device File
      1. 6.6.1. Single-Open Devices
      2. 6.6.2. Restricting Access to a Single User at a Time
      3. 6.6.3. Blocking open as an Alternative to EBUSY
      4. 6.6.4. Cloning the Device on open
    7. 6.7. Quick Reference
  10. 7. Time, Delays, and Deferred Work
    1. 7.1. Measuring Time Lapses
      1. 7.1.1. Using the jiffies Counter
      2. 7.1.2. Processor-Specific Registers
    2. 7.2. Knowing the Current Time
    3. 7.3. Delaying Execution
      1. 7.3.1. Long Delays
        1. 7.3.1.1. Busy waiting
        2. 7.3.1.2. Yielding the processor
        3. 7.3.1.3. Timeouts
      2. 7.3.2. Short Delays
    4. 7.4. Kernel Timers
      1. 7.4.1. The Timer API
      2. 7.4.2. The Implementation of Kernel Timers
    5. 7.5. Tasklets
    6. 7.6. Workqueues
      1. 7.6.1. The Shared Queue
    7. 7.7. Quick Reference
      1. 7.7.1. Timekeeping
      2. 7.7.2. Delays
      3. 7.7.3. Kernel Timers
      4. 7.7.4. Tasklets
      5. 7.7.5. Workqueues
  11. 8. Allocating Memory
    1. 8.1. The Real Story of kmalloc
      1. 8.1.1. The Flags Argument
        1. 8.1.1.1. Memory zones
      2. 8.1.2. The Size Argument
    2. 8.2. Lookaside Caches
      1. 8.2.1. A scull Based on the Slab Caches: scullc
      2. 8.2.2. Memory Pools
    3. 8.3. get_free_page and Friends
      1. 8.3.1. A scull Using Whole Pages: scullp
      2. 8.3.2. The alloc_pages Interface
    4. 8.4. vmalloc and Friends
      1. 8.4.1. A scull Using Virtual Addresses: scullv
    5. 8.5. Per-CPU Variables
    6. 8.6. Obtaining Large Buffers
      1. 8.6.1. Acquiring a Dedicated Buffer at Boot Time
    7. 8.7. Quick Reference
  12. 9. Communicating with Hardware
    1. 9.1. I/O Ports and I/O Memory
      1. 9.1.1. I/O Registers and Conventional Memory
    2. 9.2. Using I/O Ports
      1. 9.2.1. I/O Port Allocation
      2. 9.2.2. Manipulating I/O ports
      3. 9.2.3. I/O Port Access from User Space
      4. 9.2.4. String Operations
      5. 9.2.5. Pausing I/O
      6. 9.2.6. Platform Dependencies
    3. 9.3. An I/O Port Example
      1. 9.3.1. An Overview of the Parallel Port
      2. 9.3.2. A Sample Driver
    4. 9.4. Using I/O Memory
      1. 9.4.1. I/O Memory Allocation and Mapping
      2. 9.4.2. Accessing I/O Memory
      3. 9.4.3. Ports as I/O Memory
      4. 9.4.4. Reusing short for I/O Memory
      5. 9.4.5. ISA Memory Below 1 MB
      6. 9.4.6. isa_readb and Friends
    5. 9.5. Quick Reference
  13. 10. Interrupt Handling
    1. 10.1. Preparing the Parallel Port
    2. 10.2. Installing an Interrupt Handler
      1. 10.2.1. The /proc Interface
      2. 10.2.2. Autodetecting the IRQ Number
        1. 10.2.2.1. Kernel-assisted probing
        2. 10.2.2.2. Do-it-yourself probing
      3. 10.2.3. Fast and Slow Handlers
        1. 10.2.3.1. The internals of interrupt handling on the x86
    3. 10.3. Implementing a Handler
      1. 10.3.1. Handler Arguments and Return Value
      2. 10.3.2. Enabling and Disabling Interrupts
        1. 10.3.2.1. Disabling a single interrupt
        2. 10.3.2.2. Disabling all interrupts
    4. 10.4. Top and Bottom Halves
      1. 10.4.1. Tasklets
      2. 10.4.2. Workqueues
    5. 10.5. Interrupt Sharing
      1. 10.5.1. Installing a Shared Handler
      2. 10.5.2. Running the Handler
      3. 10.5.3. The /proc Interface and Shared Interrupts
    6. 10.6. Interrupt-Driven I/O
      1. 10.6.1. A Write-Buffering Example
    7. 10.7. Quick Reference
  14. 11. Data Types in the Kernel
    1. 11.1. Use of Standard C Types
    2. 11.2. Assigning an Explicit Size to Data Items
    3. 11.3. Interface-Specific Types
    4. 11.4. Other Portability Issues
      1. 11.4.1. Time Intervals
      2. 11.4.2. Page Size
      3. 11.4.3. Byte Order
      4. 11.4.4. Data Alignment
      5. 11.4.5. Pointers and Error Values
    5. 11.5. Linked Lists
    6. 11.6. Quick Reference
  15. 12. PCI Drivers
    1. 12.1. The PCI Interface
      1. 12.1.1. PCI Addressing
      2. 12.1.2. Boot Time
      3. 12.1.3. Configuration Registers and Initialization
      4. 12.1.4. MODULE_DEVICE_TABLE
      5. 12.1.5. Registering a PCI Driver
      6. 12.1.6. Old-Style PCI Probing
      7. 12.1.7. Enabling the PCI Device
      8. 12.1.8. Accessing the Configuration Space
      9. 12.1.9. Accessing the I/O and Memory Spaces
      10. 12.1.10. PCI Interrupts
      11. 12.1.11. Hardware Abstractions
    2. 12.2. A Look Back: ISA
      1. 12.2.1. Hardware Resources
      2. 12.2.2. ISA Programming
      3. 12.2.3. The Plug-and-Play Specification
    3. 12.3. PC/104 and PC/104+
    4. 12.4. Other PC Buses
      1. 12.4.1. MCA
      2. 12.4.2. EISA
      3. 12.4.3. VLB
    5. 12.5. SBus
    6. 12.6. NuBus
    7. 12.7. External Buses
    8. 12.8. Quick Reference
  16. 13. USB Drivers
    1. 13.1. USB Device Basics
      1. 13.1.1. Endpoints
      2. 13.1.2. Interfaces
      3. 13.1.3. Configurations
    2. 13.2. USB and Sysfs
    3. 13.3. USB Urbs
      1. 13.3.1. struct urb
      2. 13.3.2. Creating and Destroying Urbs
        1. 13.3.2.1. Interrupt urbs
        2. 13.3.2.2. Bulk urbs
        3. 13.3.2.3. Control urbs
        4. 13.3.2.4. Isochronous urbs
      3. 13.3.3. Submitting Urbs
      4. 13.3.4. Completing Urbs: The Completion Callback Handler
      5. 13.3.5. Canceling Urbs
    4. 13.4. Writing a USB Driver
      1. 13.4.1. What Devices Does the Driver Support?
      2. 13.4.2. Registering a USB Driver
      3. 13.4.3. probe and disconnect in Detail
      4. 13.4.4. Submitting and Controlling a Urb
    5. 13.5. USB Transfers Without Urbs
      1. 13.5.1. usb_bulk_msg
      2. 13.5.2. usb_control_msg
      3. 13.5.3. Other USB Data Functions
    6. 13.6. Quick Reference
  17. 14. The Linux Device Model
    1. 14.1. Kobjects, Ksets, and Subsystems
      1. 14.1.1. Kobject Basics
        1. 14.1.1.1. Embedding kobjects
        2. 14.1.1.2. Kobject initialization
        3. 14.1.1.3. Reference count manipulation
        4. 14.1.1.4. Release functions and kobject types
      2. 14.1.2. Kobject Hierarchies, Ksets, and Subsystems
        1. 14.1.2.1. Ksets
        2. 14.1.2.2. Operations on ksets
        3. 14.1.2.3. Subsystems
    2. 14.2. Low-Level Sysfs Operations
      1. 14.2.1. Default Attributes
      2. 14.2.2. Nondefault Attributes
      3. 14.2.3. Binary Attributes
      4. 14.2.4. Symbolic Links
    3. 14.3. Hotplug Event Generation
      1. 14.3.1. Hotplug Operations
    4. 14.4. Buses, Devices, and Drivers
      1. 14.4.1. Buses
        1. 14.4.1.1. Bus registration
        2. 14.4.1.2. Bus methods
        3. 14.4.1.3. Iterating over devices and drivers
        4. 14.4.1.4. Bus attributes
      2. 14.4.2. Devices
        1. 14.4.2.1. Device registration
        2. 14.4.2.2. Device attributes
        3. 14.4.2.3. Device structure embedding
      3. 14.4.3. Device Drivers
        1. 14.4.3.1. Driver structure embedding
    5. 14.5. Classes
      1. 14.5.1. The class_simple Interface
      2. 14.5.2. The Full Class Interface
        1. 14.5.2.1. Managing classes
        2. 14.5.2.2. Class devices
        3. 14.5.2.3. Class interfaces
    6. 14.6. Putting It All Together
      1. 14.6.1. Add a Device
      2. 14.6.2. Remove a Device
      3. 14.6.3. Add a Driver
      4. 14.6.4. Remove a Driver
    7. 14.7. Hotplug
      1. 14.7.1. Dynamic Devices
      2. 14.7.2. The /sbin/hotplug Utility
        1. 14.7.2.1. IEEE1394 (FireWire)
        2. 14.7.2.2. Networking
        3. 14.7.2.3. PCI
        4. 14.7.2.4. Input
        5. 14.7.2.5. USB
        6. 14.7.2.6. SCSI
        7. 14.7.2.7. Laptop docking stations
        8. 14.7.2.8. S/390 and zSeries
      3. 14.7.3. Using /sbin/hotplug
        1. 14.7.3.1. Linux hotplug scripts
        2. 14.7.3.2. udev
    8. 14.8. Dealing with Firmware
      1. 14.8.1. The Kernel Firmware Interface
      2. 14.8.2. How It Works
    9. 14.9. Quick Reference
      1. 14.9.1. Kobjects
      2. 14.9.2. Sysfs Operations
      3. 14.9.3. Buses, Devices, and Drivers
      4. 14.9.4. Classes
      5. 14.9.5. Firmware
  18. 15. Memory Mapping and DMA
    1. 15.1. Memory Management in Linux
      1. 15.1.1. Address Types
      2. 15.1.2. Physical Addresses and Pages
      3. 15.1.3. High and Low Memory
      4. 15.1.4. The Memory Map and Struct Page
      5. 15.1.5. Page Tables
      6. 15.1.6. Virtual Memory Areas
        1. 15.1.6.1. The vm_area_struct structure
      7. 15.1.7. The Process Memory Map
    2. 15.2. The mmap Device Operation
      1. 15.2.1. Using remap_pfn_range
      2. 15.2.2. A Simple Implementation
      3. 15.2.3. Adding VMA Operations
      4. 15.2.4. Mapping Memory with nopage
      5. 15.2.5. Remapping Specific I/O Regions
      6. 15.2.6. Remapping RAM
        1. 15.2.6.1. Remapping RAM with the nopage method
      7. 15.2.7. Remapping Kernel Virtual Addresses
    3. 15.3. Performing Direct I/O
      1. 15.3.1. Asynchronous I/O
        1. 15.3.1.1. An asynchronous I/O example
    4. 15.4. Direct Memory Access
      1. 15.4.1. Overview of a DMA Data Transfer
      2. 15.4.2. Allocating the DMA Buffer
        1. 15.4.2.1. Do-it-yourself allocation
      3. 15.4.3. Bus Addresses
      4. 15.4.4. The Generic DMA Layer
        1. 15.4.4.1. Dealing with difficult hardware
        2. 15.4.4.2. DMA mappings
        3. 15.4.4.3. Setting up coherent DMA mappings
        4. 15.4.4.4. DMA pools
        5. 15.4.4.5. Setting up streaming DMA mappings
        6. 15.4.4.6. Single-page streaming mappings
        7. 15.4.4.7. Scatter/gather mappings
        8. 15.4.4.8. PCI double-address cycle mappings
        9. 15.4.4.9. A simple PCI DMA example
      5. 15.4.5. DMA for ISA Devices
        1. 15.4.5.1. Registering DMA usage
        2. 15.4.5.2. Talking to the DMA controller
    5. 15.5. Quick Reference
      1. 15.5.1. Introductory Material
      2. 15.5.2. Implementing mmap
      3. 15.5.3. Implementing Direct I/O
      4. 15.5.4. Direct Memory Access
  19. 16. Block Drivers
    1. 16.1. Registration
      1. 16.1.1. Block Driver Registration
      2. 16.1.2. Disk Registration
        1. 16.1.2.1. Block device operations
        2. 16.1.2.2. The gendisk structure
      3. 16.1.3. Initialization in sbull
      4. 16.1.4. A Note on Sector Sizes
    2. 16.2. The Block Device Operations
      1. 16.2.1. The open and release Methods
      2. 16.2.2. Supporting Removable Media
      3. 16.2.3. The ioctl Method
    3. 16.3. Request Processing
      1. 16.3.1. Introduction to the request Method
      2. 16.3.2. A Simple request Method
      3. 16.3.3. Request Queues
        1. 16.3.3.1. Queue creation and deletion
        2. 16.3.3.2. Queueing functions
        3. 16.3.3.3. Queue control functions
      4. 16.3.4. The Anatomy of a Request
        1. 16.3.4.1. The bio structure
        2. 16.3.4.2. Request structure fields
        3. 16.3.4.3. Barrier requests
        4. 16.3.4.4. Nonretryable requests
      5. 16.3.5. Request Completion Functions
        1. 16.3.5.1. Working with bios
        2. 16.3.5.2. Block requests and DMA
        3. 16.3.5.3. Doing without a request queue
    4. 16.4. Some Other Details
      1. 16.4.1. Command Pre-Preparation
      2. 16.4.2. Tagged Command Queueing
    5. 16.5. Quick Reference
  20. 17. Network Drivers
    1. 17.1. How snull Is Designed
      1. 17.1.1. Assigning IP Numbers
      2. 17.1.2. The Physical Transport of Packets
    2. 17.2. Connecting to the Kernel
      1. 17.2.1. Device Registration
      2. 17.2.2. Initializing Each Device
      3. 17.2.3. Module Unloading
    3. 17.3. The net_device Structure in Detail
      1. 17.3.1. Global Information
      2. 17.3.2. Hardware Information
      3. 17.3.3. Interface Information
      4. 17.3.4. The Device Methods
      5. 17.3.5. Utility Fields
    4. 17.4. Opening and Closing
    5. 17.5. Packet Transmission
      1. 17.5.1. Controlling Transmission Concurrency
      2. 17.5.2. Transmission Timeouts
      3. 17.5.3. Scatter/Gather I/O
    6. 17.6. Packet Reception
    7. 17.7. The Interrupt Handler
    8. 17.8. Receive Interrupt Mitigation
    9. 17.9. Changes in Link State
    10. 17.10. The Socket Buffers
      1. 17.10.1. The Important Fields
      2. 17.10.2. Functions Acting on Socket Buffers
    11. 17.11. MAC Address Resolution
      1. 17.11.1. Using ARP with Ethernet
      2. 17.11.2. Overriding ARP
      3. 17.11.3. Non-Ethernet Headers
    12. 17.12. Custom ioctl Commands
    13. 17.13. Statistical Information
    14. 17.14. Multicast
      1. 17.14.1. Kernel Support for Multicasting
      2. 17.14.2. A Typical Implementation
    15. 17.15. A Few Other Details
      1. 17.15.1. Media Independent Interface Support
      2. 17.15.2. Ethtool Support
      3. 17.15.3. Netpoll
    16. 17.16. Quick Reference
  21. 18. TTY Drivers
    1. 18.1. A Small TTY Driver
      1. 18.1.1. struct termios
    2. 18.2. tty_driver Function Pointers
      1. 18.2.1. open and close
      2. 18.2.2. Flow of Data
      3. 18.2.3. Other Buffering Functions
      4. 18.2.4. No read Function?
    3. 18.3. TTY Line Settings
      1. 18.3.1. set_termios
      2. 18.3.2. tiocmget and tiocmset
    4. 18.4. ioctls
    5. 18.5. proc and sysfs Handling of TTY Devices
    6. 18.6. The tty_driver Structure in Detail
    7. 18.7. The tty_operations Structure in Detail
    8. 18.8. The tty_struct Structure in Detail
    9. 18.9. Quick Reference
  22. 19. Bibliography
    1. 19.1. Books
      1. 19.1.1. Linux Kernel
      2. 19.1.2. Unix Design and Internals
    2. 19.2. Web Sites
  23. Index
  24. About the Authors
  25. Copyright