+clean_sed "
+s,^EXTRAVERSION.*,&-libre$extra,
+" Makefile 'Adding -libre to EXTRAVERSION'
+
+# Add reject_firmware and maybe_reject_firmware
+cat >> include/linux/firwmare.h <<\EOF
+#ifndef _LINUX_LIBRE_FIRMWARE_H
+#define _LINUX_LIBRE_FIRMWARE_H
+
+#define NONFREE_FIRMWARE "/*(DEBLOBBED)*/"
+
+static inline int reject_firmware(const struct firmware **fw,
+ const char *name,
+ struct device *device)
+{
+ struct firmware *xfw = NULL;
+ int retval = request_firmware(&xfw, NONFREE_FIRMWARE, device);
+ if (!retval)
+ release_firmware(xfw);
+ return -EINVAL;
+}
+static inline int maybe_reject_firmware(const struct firmware **fw,
+ const char *name,
+ struct device *device)
+{
+ if (strstr (name, NONFREE_FIRMWARE))
+ return reject_firmware(fw, name, device);
+ else
+ return request_firmware(fw, name, device);
+}
+static inline void discard_rejected_firmware(const struct firmware *fw,
+ void *context)
+{
+ release_firmware(fw);
+}
+static inline int reject_firmware_nowait(
+ struct module *module, int uevent,
+ const char *name, struct device *device, void *context,
+ void (*cont)(const struct firmware *fw, void *context))
+{
+ int retval = request_firmware_nowait(module, uevent, NONFREE_FIRMWARE,
+ device, NULL,
+ discard_rejected_firmware);
+ if (retval)
+ return retval;
+ return -EINVAL;
+}
+static inline int maybe_reject_firmware_nowait(
+ struct module *module, int uevent,
+ const char *name, struct device *device, void *context,
+ void (*cont)(const struct firmware *fw, void *context))
+{
+ if (strstr (name, NONFREE_FIRMWARE))
+ return reject_firmware_nowait(module, uevent, name,
+ device, context, cont);
+ else
+ return request_firmware_nowait(module, uevent, name,
+ device, context, cont);
+}
+
+#endif /* _LINUX_LIBRE_FIRMWARE_H */
+EOF