STRUCT W1_BUS_MASTER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Okay bestie, welcome to struct w1_bus_master(9) from the Kernel API Manual ✨. This is the whole ops vibe for a bus master, and we’re gonna go through every single member together, no skips, fr fr πŸ’–.

✨ NAME ✨

struct w1_bus_master β€” operations available on a bus master. That’s the glow-up: it’s the set of operations you get on a bus master, periodt πŸ‘‘.

🌸 SYNOPSIS 🌸

Here’s the struct in all its iconic form β€” copy it exactly, bestie:

       struct w1_bus_master {
           void *data;
           u8 (*read_bit)(void *);
           void (*write_bit)(void *, u8);
           u8 (*touch_bit)(void *, u8);
           u8 (*read_byte)(void *);
           void (*write_byte)(void *, u8);
           u8 (*read_block)(void *, u8 *, int);
           void (*write_block)(void *, const u8 *, int);
           u8 (*triplet)(void *, u8);
           u8 (*reset_bus)(void *);
           u8 (*set_pullup)(void *, int);
           void (*search)(void *, struct w1_master *, u8,
       w1_slave_found_callback);
           char *dev_id;
        };

πŸ’… Members πŸ’…

  • data β€” the first parameter in all the functions below. The main-character pointer, basically 🫢.
  • read_bit β€” sample the line level, then return the level read (0 or 1).
  • write_bit β€” sets the line level.
  • touch_bit β€” the lowest-level function for devices that really support the 1-wire protocol. touch_bit(0) = write-0 cycle; touch_bit(1) = write-1 / read cycle; return the bit read (0 or 1).
  • read_byte β€” reads a byte. Same as 8 touch_bit(1) calls. Return the byte read.
  • write_byte β€” writes a byte. Same as 8 touch_bit(x) calls.
  • read_block β€” same as a series of read_byte calls; return the number of bytes read.
  • write_block β€” same as a series of write_byte calls.
  • triplet β€” combines two reads and a smart write for ROM searches; return bit0=Id, bit1=comp_id, bit2=dir_taken.
  • reset_bus β€” long write-0 with a read for the presence pulse detection; return -1=Error, 0=Device present, 1=No device present.
  • set_pullup β€” put out a strong pull-up pulse of the specified duration; return -1=Error, 0=completed.
  • search β€” really nice hardware can handle the different types of ROM search. w1_master* is passed to the slave found callback. The u8 is search_type, W1_SEARCH or W1_ALARM_SEARCH.
  • dev_id β€” optional device id string, which w1 slaves could use for creating names, which then give a connection to the w1 master.

⚠️ Note ⚠️

read_bit and write_bit are very low level functions and should only be used with hardware that doesn’t really support 1-wire operations, like a parallel/serial port. Either define read_bit and write_bit OR define, at minimum, touch_bit and reset_bus. No cap, that’s the rule πŸ’€.

πŸ‘€ SEE ALSO πŸ‘€

Kernel file ./include/linux/w1.h:

  • struct w1_reg_num(9)
  • struct w1_slave(9)
  • enum w1_master_flags(9)
  • struct w1_master(9)
  • struct w1_family_ops(9)
  • struct w1_family(9)
  • module_w1_family(9)

Signed off with love from ./include/linux β€” October 2026 β€” struct w1_bus_master(9) πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from