Class: Yast::HotplugClass

Inherits:
Module
  • Object
show all
Defined in:
library/system/src/modules/Hotplug.rb

Instance Method Summary collapse

Instance Method Details

#mainObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'library/system/src/modules/Hotplug.rb', line 40

def main
  Yast.import "Arch"
  Yast.import "ModuleLoading"
  Yast.import "HwStatus"
  Yast.import "Linuxrc"

  Yast.import "Mode"

  # if a usb controller was found and initialized
  @haveUSB = false

  # if a firewire controller was found and initialized
  @haveFireWire = false
end

#startController(controller) ⇒ Object

start a controller (by loading its module) return true if successfull return false if failed



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'library/system/src/modules/Hotplug.rb', line 59

def startController(controller)
  controller = deep_copy(controller)
  # check module information
  # skip controller if no module info available

  module_drivers = Ops.get_list(controller, "drivers", [])

  return true if Builtins.size(module_drivers) == 0

  # loop through all drivers checking if one is already active

  already_active = false
  Builtins.foreach(module_drivers) do |modulemap|
    already_active = true if Ops.get_boolean(modulemap, "active", true)
  end

  # save unique key for HwStatus::Set()
  unique_key = Ops.get_string(controller, "unique_key", "")

  if already_active
    HwStatus.Set(unique_key, :yes)
    return true
  end

  stop_loading = false
  one_module_failed = false

  # loop through all drivers defined for this controller
  # break after first successful load
  #   no need to check "active", already done before !

  Builtins.foreach(module_drivers) do |modulemap|
    Builtins.y2milestone("modulemap: %1", modulemap)
    module_modprobe = Ops.get_boolean(modulemap, "modprobe", false)
    all_modules_loaded = true
    if !stop_loading
      Builtins.foreach(Ops.get_list(modulemap, "modules", [])) do |module_entry|
        module_name = Ops.get_string(module_entry, 0, "")
        module_args = Ops.get_string(module_entry, 1, "")
        load_result = :ok
        if Linuxrc.manual
          vendor_device = ModuleLoading.prepareVendorDeviceInfo(controller)
          load_result = ModuleLoading.Load(
            module_name,
            module_args,
            Ops.get_string(vendor_device, 0, ""),
            Ops.get_string(vendor_device, 1, ""),
            true,
            module_modprobe
          )
        else
          load_result = ModuleLoading.Load(
            module_name,
            module_args,
            "",
            "",
            false,
            module_modprobe
          )
        end
        case load_result
        when :fail
          all_modules_loaded = false
        when :dont
          all_modules_loaded = true
        end
        # break out of module load loop if one module failed
        one_module_failed = true if !all_modules_loaded
      end
    end
    # break out of driver load loop if all modules of
    #   the current driver loaded successfully
    stop_loading = true if all_modules_loaded
  end

  HwStatus.Set(unique_key, one_module_failed ? :no : :yes)

  !one_module_failed
end

#StartFireWirevoid

This method returns an undefined value.

probe for firewire type, load appropriate modules, and mount usbfs to /proc/bus/usb

Parameters:

  • none


168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'library/system/src/modules/Hotplug.rb', line 168

def StartFireWire
  return if Arch.sparc # why this and why here ???

  firewire_controllers = Convert.convert(
    SCR.Read(path(".probe.ieee1394ctrl")),
    from: "any",
    to:   "list <map>"
  )

  Builtins.foreach(firewire_controllers) do |controller|
    start_result = startController(controller)
    @haveFireWire = true if start_result
  end

  Builtins.y2milestone("haveFireWire = %1", @haveFireWire)

  nil
end

#StartUSBvoid

This method returns an undefined value.

probe for usb type, load appropriate modules, and mount usbfs to /proc/bus/usb

Parameters:

  • none


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'library/system/src/modules/Hotplug.rb', line 145

def StartUSB
  usb_controllers = Convert.convert(
    SCR.Read(path(".probe.usbctrl")),
    from: "any",
    to:   "list <map>"
  )

  Builtins.foreach(usb_controllers) do |controller|
    start_result = startController(controller)
    @haveUSB = true if start_result
  end

  Builtins.y2milestone("haveUSB = %1", @haveUSB)

  nil
end