Lines Matching +full:firmware +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Firmware loading and handling functions.
7 #include <linux/firmware.h>
16 const struct firmware *helper, const struct firmware *mainfw) in lbs_fw_loaded()
20 lbs_deb_fw("firmware load complete, code %d\n", ret); in lbs_fw_loaded()
23 priv->fw_callback(priv, ret, helper, mainfw); in lbs_fw_loaded()
25 spin_lock_irqsave(&priv->driver_lock, flags); in lbs_fw_loaded()
26 priv->fw_callback = NULL; in lbs_fw_loaded()
27 wake_up(&priv->fw_waitq); in lbs_fw_loaded()
28 spin_unlock_irqrestore(&priv->driver_lock, flags); in lbs_fw_loaded()
31 static void do_load_firmware(struct lbs_private *priv, const char *name, in do_load_firmware() argument
32 void (*cb)(const struct firmware *fw, void *context)) in do_load_firmware()
36 lbs_deb_fw("Requesting %s\n", name); in do_load_firmware()
37 ret = request_firmware_nowait(THIS_MODULE, true, name, in do_load_firmware()
38 priv->fw_device, GFP_KERNEL, priv, cb); in do_load_firmware()
45 static void main_firmware_cb(const struct firmware *firmware, void *context) in main_firmware_cb() argument
49 if (!firmware) { in main_firmware_cb()
50 /* Failed to find firmware: try next table entry */ in main_firmware_cb()
55 /* Firmware found! */ in main_firmware_cb()
56 lbs_fw_loaded(priv, 0, priv->helper_fw, firmware); in main_firmware_cb()
57 if (priv->helper_fw) { in main_firmware_cb()
58 release_firmware (priv->helper_fw); in main_firmware_cb()
59 priv->helper_fw = NULL; in main_firmware_cb()
61 release_firmware (firmware); in main_firmware_cb()
64 static void helper_firmware_cb(const struct firmware *firmware, void *context) in helper_firmware_cb() argument
68 if (!firmware) { in helper_firmware_cb()
69 /* Failed to find firmware: try next table entry */ in helper_firmware_cb()
74 /* Firmware found! */ in helper_firmware_cb()
75 if (priv->fw_iter->fwname) { in helper_firmware_cb()
76 priv->helper_fw = firmware; in helper_firmware_cb()
77 do_load_firmware(priv, priv->fw_iter->fwname, main_firmware_cb); in helper_firmware_cb()
79 /* No main firmware needed for this helper --> success! */ in helper_firmware_cb()
80 lbs_fw_loaded(priv, 0, firmware, NULL); in helper_firmware_cb()
88 if (!priv->fw_iter) in load_next_firmware_from_table()
89 iter = priv->fw_table; in load_next_firmware_from_table()
91 iter = ++priv->fw_iter; in load_next_firmware_from_table()
93 if (priv->helper_fw) { in load_next_firmware_from_table()
94 release_firmware(priv->helper_fw); in load_next_firmware_from_table()
95 priv->helper_fw = NULL; in load_next_firmware_from_table()
99 if (!iter->helper) { in load_next_firmware_from_table()
101 lbs_fw_loaded(priv, -ENOENT, NULL, NULL); in load_next_firmware_from_table()
105 if (iter->model != priv->fw_model) { in load_next_firmware_from_table()
110 priv->fw_iter = iter; in load_next_firmware_from_table()
111 do_load_firmware(priv, iter->helper, helper_firmware_cb); in load_next_firmware_from_table()
116 wait_event(priv->fw_waitq, priv->fw_callback == NULL); in lbs_wait_for_firmware_load()
120 * lbs_get_firmware_async - Retrieves firmware asynchronously. Can load
121 * either a helper firmware and a main firmware (2-stage), or just the helper.
125 * @card_model: Bus-specific card model ID used to filter firmware table
127 * @fw_table: Table of firmware file names and device model numbers
128 * terminated by an entry with a NULL helper name
129 * @callback: User callback to invoke when firmware load succeeds or fails.
137 spin_lock_irqsave(&priv->driver_lock, flags); in lbs_get_firmware_async()
138 if (priv->fw_callback) { in lbs_get_firmware_async()
139 lbs_deb_fw("firmware load already in progress\n"); in lbs_get_firmware_async()
140 spin_unlock_irqrestore(&priv->driver_lock, flags); in lbs_get_firmware_async()
141 return -EBUSY; in lbs_get_firmware_async()
144 priv->fw_device = device; in lbs_get_firmware_async()
145 priv->fw_callback = callback; in lbs_get_firmware_async()
146 priv->fw_table = fw_table; in lbs_get_firmware_async()
147 priv->fw_iter = NULL; in lbs_get_firmware_async()
148 priv->fw_model = card_model; in lbs_get_firmware_async()
149 spin_unlock_irqrestore(&priv->driver_lock, flags); in lbs_get_firmware_async()
151 lbs_deb_fw("Starting async firmware load\n"); in lbs_get_firmware_async()
158 * lbs_get_firmware - Retrieves two-stage firmware
161 * @card_model: Bus-specific card model ID used to filter firmware table
163 * @fw_table: Table of firmware file names and device model numbers
164 * terminated by an entry with a NULL helper name
165 * @helper: On success, the helper firmware; caller must free
166 * @mainfw: On success, the main firmware; caller must free
170 * returns: 0 on success, non-zero on failure
174 const struct firmware **helper, in lbs_get_firmware()
175 const struct firmware **mainfw) in lbs_get_firmware()
183 /* Search for firmware to use from the table. */ in lbs_get_firmware()
185 while (iter && iter->helper) { in lbs_get_firmware()
186 if (iter->model != card_model) in lbs_get_firmware()
190 ret = request_firmware(helper, iter->helper, dev); in lbs_get_firmware()
194 /* If the device has one-stage firmware (ie cf8305) and in lbs_get_firmware()
196 * main firmware. in lbs_get_firmware()
198 if (iter->fwname == NULL) in lbs_get_firmware()
203 ret = request_firmware(mainfw, iter->fwname, dev); in lbs_get_firmware()
206 * mismatched firmware pairs. in lbs_get_firmware()
226 return -ENOENT; in lbs_get_firmware()