summaryrefslogtreecommitdiff
path: root/backport
diff options
context:
space:
mode:
Diffstat (limited to 'backport')
-rw-r--r--backport/.blacklist.map11
-rw-r--r--backport/.gitignore22
-rw-r--r--backport/Kconfig.integrate37
-rw-r--r--backport/Kconfig.package25
-rw-r--r--backport/Kconfig.package.hacks8
-rw-r--r--backport/Kconfig.sources19
-rw-r--r--backport/Makefile164
-rw-r--r--backport/Makefile.build10
-rw-r--r--backport/Makefile.kernel55
-rw-r--r--backport/Makefile.real121
-rw-r--r--backport/backport-include/asm-generic/bug.h39
-rw-r--r--backport/backport-include/asm-generic/pci-dma-compat.h17
-rw-r--r--backport/backport-include/asm/atomic.h19
-rw-r--r--backport/backport-include/asm/barrier.h22
-rw-r--r--backport/backport-include/asm/errno.h23
-rw-r--r--backport/backport-include/asm/ioctls.h9
-rw-r--r--backport/backport-include/backport/backport.h16
-rw-r--r--backport/backport-include/backport/checks.h12
-rw-r--r--backport/backport-include/backport/leds-disabled.h198
-rw-r--r--backport/backport-include/backport/magic.h16
-rw-r--r--backport/backport-include/crypto/aead.h33
-rw-r--r--backport/backport-include/crypto/algapi.h16
-rw-r--r--backport/backport-include/crypto/hash.h38
-rw-r--r--backport/backport-include/generated/utsrelease.h21
-rw-r--r--backport/backport-include/keys/asymmetric-type.h35
-rw-r--r--backport/backport-include/keys/system_keyring.h10
-rw-r--r--backport/backport-include/linux/acpi.h72
-rw-r--r--backport/backport-include/linux/atomic.h54
-rw-r--r--backport/backport-include/linux/bcm47xx_nvram.h25
-rw-r--r--backport/backport-include/linux/bitops.h23
-rw-r--r--backport/backport-include/linux/bp-devcoredump.h32
-rw-r--r--backport/backport-include/linux/bug.h18
-rw-r--r--backport/backport-include/linux/build_bug.h10
-rw-r--r--backport/backport-include/linux/cache.h10
-rw-r--r--backport/backport-include/linux/clk.h116
-rw-r--r--backport/backport-include/linux/compat.h21
-rw-r--r--backport/backport-include/linux/compiler-gcc5.h1
-rw-r--r--backport/backport-include/linux/compiler-gcc6.h1
-rw-r--r--backport/backport-include/linux/compiler-gcc7.h1
-rw-r--r--backport/backport-include/linux/compiler-gccN.h126
-rw-r--r--backport/backport-include/linux/compiler.h95
-rw-r--r--backport/backport-include/linux/completion.h21
-rw-r--r--backport/backport-include/linux/cordic.h72
-rw-r--r--backport/backport-include/linux/crc7.h14
-rw-r--r--backport/backport-include/linux/debugfs.h63
-rw-r--r--backport/backport-include/linux/device.h280
-rw-r--r--backport/backport-include/linux/dma-buf.h54
-rw-r--r--backport/backport-include/linux/dma-mapping.h35
-rw-r--r--backport/backport-include/linux/dynamic_debug.h36
-rw-r--r--backport/backport-include/linux/eeprom_93cx6.h10
-rw-r--r--backport/backport-include/linux/err.h10
-rw-r--r--backport/backport-include/linux/etherdevice.h230
-rw-r--r--backport/backport-include/linux/ethtool.h18
-rw-r--r--backport/backport-include/linux/eventpoll.h49
-rw-r--r--backport/backport-include/linux/export.h19
-rw-r--r--backport/backport-include/linux/firmware.h20
-rw-r--r--backport/backport-include/linux/freezer.h32
-rw-r--r--backport/backport-include/linux/fs.h52
-rw-r--r--backport/backport-include/linux/ftrace_event.h10
-rw-r--r--backport/backport-include/linux/genetlink.h18
-rw-r--r--backport/backport-include/linux/gfp.h25
-rw-r--r--backport/backport-include/linux/gpio.h35
-rw-r--r--backport/backport-include/linux/gpio/driver.h10
-rw-r--r--backport/backport-include/linux/hashtable.h42
-rw-r--r--backport/backport-include/linux/hid.h87
-rw-r--r--backport/backport-include/linux/hrtimer.h10
-rw-r--r--backport/backport-include/linux/hwmon.h34
-rw-r--r--backport/backport-include/linux/i2c-mux.h14
-rw-r--r--backport/backport-include/linux/i2c.h37
-rw-r--r--backport/backport-include/linux/idr.h74
-rw-r--r--backport/backport-include/linux/if_arp.h14
-rw-r--r--backport/backport-include/linux/if_ether.h54
-rw-r--r--backport/backport-include/linux/if_vlan.h39
-rw-r--r--backport/backport-include/linux/init.h19
-rw-r--r--backport/backport-include/linux/input.h21
-rw-r--r--backport/backport-include/linux/interrupt.h17
-rw-r--r--backport/backport-include/linux/io.h9
-rw-r--r--backport/backport-include/linux/ioport.h9
-rw-r--r--backport/backport-include/linux/irq.h16
-rw-r--r--backport/backport-include/linux/irqdomain.h9
-rw-r--r--backport/backport-include/linux/jiffies.h30
-rw-r--r--backport/backport-include/linux/kconfig.h45
-rw-r--r--backport/backport-include/linux/kernel.h235
-rw-r--r--backport/backport-include/linux/key.h66
-rw-r--r--backport/backport-include/linux/kfifo.h51
-rw-r--r--backport/backport-include/linux/kmemleak.h5
-rw-r--r--backport/backport-include/linux/kref.h13
-rw-r--r--backport/backport-include/linux/ktime.h18
-rw-r--r--backport/backport-include/linux/leds.h69
-rw-r--r--backport/backport-include/linux/list.h91
-rw-r--r--backport/backport-include/linux/list_nulls.h9
-rw-r--r--backport/backport-include/linux/lockdep.h17
-rw-r--r--backport/backport-include/linux/math64.h27
-rw-r--r--backport/backport-include/linux/mdio.h87
-rw-r--r--backport/backport-include/linux/mei_cl_bus.h25
-rw-r--r--backport/backport-include/linux/mii.h154
-rw-r--r--backport/backport-include/linux/miscdevice.h9
-rw-r--r--backport/backport-include/linux/mm.h149
-rw-r--r--backport/backport-include/linux/mmc/host.h16
-rw-r--r--backport/backport-include/linux/mmc/sdio.h21
-rw-r--r--backport/backport-include/linux/mmc/sdio_func.h10
-rw-r--r--backport/backport-include/linux/mmc/sdio_ids.h14
-rw-r--r--backport/backport-include/linux/mod_devicetable.h17
-rw-r--r--backport/backport-include/linux/module.h69
-rw-r--r--backport/backport-include/linux/moduleparam.h44
-rw-r--r--backport/backport-include/linux/net.h112
-rw-r--r--backport/backport-include/linux/netdev_features.h53
-rw-r--r--backport/backport-include/linux/netdevice.h369
-rw-r--r--backport/backport-include/linux/netlink.h72
-rw-r--r--backport/backport-include/linux/nl80211.h10
-rw-r--r--backport/backport-include/linux/nospec.h12
-rw-r--r--backport/backport-include/linux/of.h259
-rw-r--r--backport/backport-include/linux/of_address.h18
-rw-r--r--backport/backport-include/linux/of_device.h33
-rw-r--r--backport/backport-include/linux/of_irq.h15
-rw-r--r--backport/backport-include/linux/of_net.h15
-rw-r--r--backport/backport-include/linux/of_platform.h38
-rw-r--r--backport/backport-include/linux/olpc-ec.h10
-rw-r--r--backport/backport-include/linux/page_ref.h23
-rw-r--r--backport/backport-include/linux/pci.h240
-rw-r--r--backport/backport-include/linux/percpu-defs.h13
-rw-r--r--backport/backport-include/linux/percpu.h19
-rw-r--r--backport/backport-include/linux/phy.h75
-rw-r--r--backport/backport-include/linux/platform_data/media/si4713.h10
-rw-r--r--backport/backport-include/linux/platform_data/media/soc_camera_platform.h10
-rw-r--r--backport/backport-include/linux/platform_data/media/timb_radio.h10
-rw-r--r--backport/backport-include/linux/platform_data/media/timb_video.h10
-rw-r--r--backport/backport-include/linux/platform_device.h36
-rw-r--r--backport/backport-include/linux/pm.h17
-rw-r--r--backport/backport-include/linux/pm_qos.h16
-rw-r--r--backport/backport-include/linux/pm_runtime.h40
-rw-r--r--backport/backport-include/linux/pnp.h19
-rw-r--r--backport/backport-include/linux/poll.h21
-rw-r--r--backport/backport-include/linux/printk.h154
-rw-r--r--backport/backport-include/linux/proc_fs.h29
-rw-r--r--backport/backport-include/linux/property.h15
-rw-r--r--backport/backport-include/linux/ptp_clock_kernel.h40
-rw-r--r--backport/backport-include/linux/random.h54
-rw-r--r--backport/backport-include/linux/rculist.h57
-rw-r--r--backport/backport-include/linux/rcupdate.h44
-rw-r--r--backport/backport-include/linux/regmap.h51
-rw-r--r--backport/backport-include/linux/regulator/driver.h33
-rw-r--r--backport/backport-include/linux/rfkill.h167
-rw-r--r--backport/backport-include/linux/rtnetlink.h29
-rw-r--r--backport/backport-include/linux/scatterlist.h128
-rw-r--r--backport/backport-include/linux/sched/signal.h10
-rw-r--r--backport/backport-include/linux/security.h18
-rw-r--r--backport/backport-include/linux/seq_file.h67
-rw-r--r--backport/backport-include/linux/skbuff.h410
-rw-r--r--backport/backport-include/linux/slab.h27
-rw-r--r--backport/backport-include/linux/socket.h18
-rw-r--r--backport/backport-include/linux/spi/spi.h69
-rw-r--r--backport/backport-include/linux/spinlock.h45
-rw-r--r--backport/backport-include/linux/static_key.h49
-rw-r--r--backport/backport-include/linux/stddef.h16
-rw-r--r--backport/backport-include/linux/string.h40
-rw-r--r--backport/backport-include/linux/suspend.h14
-rw-r--r--backport/backport-include/linux/sysfs.h11
-rw-r--r--backport/backport-include/linux/thermal.h150
-rw-r--r--backport/backport-include/linux/time.h7
-rw-r--r--backport/backport-include/linux/time64.h46
-rw-r--r--backport/backport-include/linux/timecounter.h25
-rw-r--r--backport/backport-include/linux/timekeeping.h100
-rw-r--r--backport/backport-include/linux/timer.h70
-rw-r--r--backport/backport-include/linux/tracepoint.h10
-rw-r--r--backport/backport-include/linux/tty.h36
-rw-r--r--backport/backport-include/linux/tty_flip.h11
-rw-r--r--backport/backport-include/linux/types.h14
-rw-r--r--backport/backport-include/linux/u64_stats_sync.h180
-rw-r--r--backport/backport-include/linux/uidgid.h221
-rw-r--r--backport/backport-include/linux/usb.h95
-rw-r--r--backport/backport-include/linux/usb/cdc.h61
-rw-r--r--backport/backport-include/linux/usb/ch9.h28
-rw-r--r--backport/backport-include/linux/uuid.h33
-rw-r--r--backport/backport-include/linux/verification.h28
-rw-r--r--backport/backport-include/linux/version.h17
-rw-r--r--backport/backport-include/linux/wait.h98
-rw-r--r--backport/backport-include/linux/watchdog.h11
-rw-r--r--backport/backport-include/linux/workqueue.h67
-rw-r--r--backport/backport-include/net/addrconf.h25
-rw-r--r--backport/backport-include/net/flow_keys.h21
-rw-r--r--backport/backport-include/net/genetlink.h184
-rw-r--r--backport/backport-include/net/inet_frag.h76
-rw-r--r--backport/backport-include/net/ip.h14
-rw-r--r--backport/backport-include/net/ip6_fib.h26
-rw-r--r--backport/backport-include/net/ipv6.h60
-rw-r--r--backport/backport-include/net/iw_handler.h40
-rw-r--r--backport/backport-include/net/net_namespace.h44
-rw-r--r--backport/backport-include/net/netlink.h551
-rw-r--r--backport/backport-include/net/sch_generic.h20
-rw-r--r--backport/backport-include/net/sock.h78
-rw-r--r--backport/backport-include/net/tso.h33
-rw-r--r--backport/backport-include/pcmcia/device_id.h23
-rw-r--r--backport/backport-include/pcmcia/ds.h29
-rw-r--r--backport/backport-include/sound/core.h20
-rw-r--r--backport/backport-include/sound/pcm.h29
-rw-r--r--backport/backport-include/trace/ftrace.h14
-rw-r--r--backport/backport-include/uapi/linux/genetlink.h14
-rw-r--r--backport/backport-include/uapi/linux/sockios.h31
-rw-r--r--backport/compat/.gitignore1
-rw-r--r--backport/compat/Kconfig190
-rw-r--r--backport/compat/Makefile72
-rw-r--r--backport/compat/backport-3.10.c237
-rw-r--r--backport/compat/backport-3.11.c124
-rw-r--r--backport/compat/backport-3.12.c72
-rw-r--r--backport/compat/backport-3.13.c169
-rw-r--r--backport/compat/backport-3.14.c90
-rw-r--r--backport/compat/backport-3.15.c88
-rw-r--r--backport/compat/backport-3.17.c184
-rw-r--r--backport/compat/backport-3.18.c332
-rw-r--r--backport/compat/backport-3.19.c165
-rw-r--r--backport/compat/backport-3.2.c25
-rw-r--r--backport/compat/backport-4.0.c198
-rw-r--r--backport/compat/backport-4.1.c84
-rw-r--r--backport/compat/backport-4.10.c276
-rw-r--r--backport/compat/backport-4.12.c24
-rw-r--r--backport/compat/backport-4.18.c11
-rw-r--r--backport/compat/backport-4.2.c76
-rw-r--r--backport/compat/backport-4.20.c379
-rw-r--r--backport/compat/backport-4.3.c304
-rw-r--r--backport/compat/backport-4.4.c160
-rw-r--r--backport/compat/backport-4.5.c152
-rw-r--r--backport/compat/backport-4.6.c103
-rw-r--r--backport/compat/backport-4.7.c184
-rw-r--r--backport/compat/backport-4.8.c196
-rw-r--r--backport/compat/backport-genetlink.c430
-rw-r--r--backport/compat/backports.h16
-rw-r--r--backport/compat/compat-3.0.c91
-rw-r--r--backport/compat/compat-3.1.c118
-rw-r--r--backport/compat/compat-3.3.c226
-rw-r--r--backport/compat/compat-3.4.c201
-rw-r--r--backport/compat/compat-3.5.c169
-rw-r--r--backport/compat/compat-3.6.c29
-rw-r--r--backport/compat/compat-3.7.c291
-rw-r--r--backport/compat/compat-3.8.c458
-rw-r--r--backport/compat/compat-3.9.c238
-rw-r--r--backport/compat/hid-ids.h866
-rw-r--r--backport/compat/main.c85
-rw-r--r--backport/compat/user_namespace.c68
-rw-r--r--backport/compat/verification/asn1parse.c393
-rw-r--r--backport/compat/verification/bignum.c2458
-rw-r--r--backport/compat/verification/key.c172
-rw-r--r--backport/compat/verification/mbedtls/asn1.h342
-rw-r--r--backport/compat/verification/mbedtls/bignum.h760
-rw-r--r--backport/compat/verification/mbedtls/bn_mul.h887
-rw-r--r--backport/compat/verification/mbedtls/config.h15
-rw-r--r--backport/compat/verification/mbedtls/md.h354
-rw-r--r--backport/compat/verification/mbedtls/md_internal.h116
-rw-r--r--backport/compat/verification/mbedtls/oid.h570
-rw-r--r--backport/compat/verification/mbedtls/pk.h618
-rw-r--r--backport/compat/verification/mbedtls/platform.h12
-rw-r--r--backport/compat/verification/mbedtls/rsa.h672
-rw-r--r--backport/compat/verification/mbedtls/sha1.h135
-rw-r--r--backport/compat/verification/mbedtls/sha256.h140
-rw-r--r--backport/compat/verification/md.c471
-rw-r--r--backport/compat/verification/md_wrap.c577
-rw-r--r--backport/compat/verification/oid.c709
-rw-r--r--backport/compat/verification/pkcs7.asn1.c355
-rw-r--r--backport/compat/verification/pkcs7.asn1.h27
-rw-r--r--backport/compat/verification/public_key.c131
-rw-r--r--backport/compat/verification/rsa.c1872
-rw-r--r--backport/compat/verification/rsapubkey.asn1.c38
-rw-r--r--backport/compat/verification/rsapubkey.asn1.h15
-rw-r--r--backport/compat/verification/sha256.c458
-rw-r--r--backport/compat/verification/verify.c65
-rw-r--r--backport/compat/verification/x509.asn1.c182
-rw-r--r--backport/compat/verification/x509.asn1.h22
-rw-r--r--backport/compat/verification/x509_akid.asn1.c144
-rw-r--r--backport/compat/verification/x509_akid.asn1.h15
-rw-r--r--backport/defconfigs/ar55238
-rw-r--r--backport/defconfigs/ath10k13
-rw-r--r--backport/defconfigs/ath5k8
-rw-r--r--backport/defconfigs/ath6kl7
-rw-r--r--backport/defconfigs/ath9k9
-rw-r--r--backport/defconfigs/ath9k-debug19
-rw-r--r--backport/defconfigs/b4320
-rw-r--r--backport/defconfigs/b43legacy13
-rw-r--r--backport/defconfigs/brcmfmac8
-rw-r--r--backport/defconfigs/brcmsmac9
-rw-r--r--backport/defconfigs/carl91708
-rw-r--r--backport/defconfigs/cw120010
-rw-r--r--backport/defconfigs/hwsim12
-rw-r--r--backport/defconfigs/iwlwifi18
-rw-r--r--backport/defconfigs/rtlwifi25
-rw-r--r--backport/defconfigs/wcn36xx13
-rw-r--r--backport/defconfigs/wifi149
-rw-r--r--backport/defconfigs/wil62105
-rw-r--r--backport/defconfigs/wwan6
-rw-r--r--backport/kconf/Makefile15
-rw-r--r--backport/kconf/conf.c723
-rw-r--r--backport/kconf/confdata.c1249
-rw-r--r--backport/kconf/expr.c1206
-rw-r--r--backport/kconf/expr.h240
-rw-r--r--backport/kconf/list.h131
-rw-r--r--backport/kconf/lkc.h186
-rw-r--r--backport/kconf/lkc_proto.h52
-rwxr-xr-xbackport/kconf/lxdialog/check-lxdialog.sh91
-rw-r--r--backport/kconf/lxdialog/checklist.c332
-rw-r--r--backport/kconf/lxdialog/dialog.h257
-rw-r--r--backport/kconf/lxdialog/inputbox.c301
-rw-r--r--backport/kconf/lxdialog/menubox.c437
-rw-r--r--backport/kconf/lxdialog/textbox.c408
-rw-r--r--backport/kconf/lxdialog/util.c713
-rw-r--r--backport/kconf/lxdialog/yesno.c114
-rw-r--r--backport/kconf/mconf.c1047
-rw-r--r--backport/kconf/menu.c720
-rw-r--r--backport/kconf/symbol.c1414
-rw-r--r--backport/kconf/util.c147
-rw-r--r--backport/kconf/zconf.hash.c297
-rw-r--r--backport/kconf/zconf.lex.c2473
-rw-r--r--backport/kconf/zconf.tab.c2471
-rwxr-xr-xbackport/scripts/blacklist.sh35
-rwxr-xr-xbackport/scripts/check_depmod.sh78
-rwxr-xr-xbackport/scripts/compress_modules.sh12
-rw-r--r--backport/scripts/mod_helpers.sh11
-rwxr-xr-xbackport/scripts/uninstall.sh19
-rwxr-xr-xbackport/scripts/update-initramfs.sh62
317 files changed, 0 insertions, 45828 deletions
diff --git a/backport/.blacklist.map b/backport/.blacklist.map
deleted file mode 100644
index c1bdcfc3..00000000
--- a/backport/.blacklist.map
+++ /dev/null
@@ -1,11 +0,0 @@
-# Update this map when a driver gets renamed or
-# symbols from old drivers get moved to a newer
-# driver. If you have the driver on the right
-# hand side it will be blacklisted upon installation
-# only if you actually installed the driver on the
-# left.
-
-# new-driver old-driver
-iwlwifi iwlagn
-iwl4965 iwlagn
-videodev v4l2-compat-ioctl32
diff --git a/backport/.gitignore b/backport/.gitignore
deleted file mode 100644
index c6cf6ce3..00000000
--- a/backport/.gitignore
+++ /dev/null
@@ -1,22 +0,0 @@
-Kconfig.kernel
-Kconfig.versions
-.kernel_config_md5
-.config
-.config.old
-*~
-*.o
-*.d
-.tmp_*
-*.ko
-*.cmd
-*.tmp
-*.ver
-modules.order
-backport-include/backport/autoconf.h
-modules
-kconf/mconf
-kconf/conf
-.tmp_versions
-Module.symvers
-*.mod.c
-.cache.mk
diff --git a/backport/Kconfig.integrate b/backport/Kconfig.integrate
deleted file mode 100644
index 45ab3ecd..00000000
--- a/backport/Kconfig.integrate
+++ /dev/null
@@ -1,37 +0,0 @@
-config BACKPORT_INTEGRATE
- bool
- def_bool y
-
-config BACKPORT_DIR
- string
- default "%%BACKPORT_DIR%%"
-
-config BACKPORT_VERSION
- string
- default "%%BACKPORTS_VERSION%%"
-
-config BACKPORT_KERNEL_VERSION
- string
- default "%%BACKPORTED_KERNEL_VERSION%%"
-
-config BACKPORT_KERNEL_NAME
- string
- default "%%BACKPORTED_KERNEL_NAME%%"
-
-menuconfig BACKPORT_LINUX
- bool "Backport %%BACKPORTED_KERNEL_NAME%% %%BACKPORTED_KERNEL_VERSION%% (backports %%BACKPORTS_VERSION%%)"
- default n
- ---help---
- Enabling this will let give you the opportunity to use features and
- drivers backported from %%BACKPORTED_KERNEL_NAME%% %%BACKPORTED_KERNEL_VERSION%%
- on the kernel your are using. This is experimental and you should
- say no unless you'd like to help test things or want to help debug
- this should we run into any issues.
-
-if BACKPORT_LINUX
-
-source "$BACKPORT_DIR/Kconfig.versions"
-source "$BACKPORT_DIR/Kconfig.sources"
-source "$BACKPORT_DIR/Kconfig.local"
-
-endif # BACKPORT_LINUX
diff --git a/backport/Kconfig.package b/backport/Kconfig.package
deleted file mode 100644
index 250cdf3e..00000000
--- a/backport/Kconfig.package
+++ /dev/null
@@ -1,25 +0,0 @@
-mainmenu "Backports from $BACKPORTED_KERNEL_NAME $BACKPORTED_KERNEL_VERSION (backports $BACKPORTS_VERSION)"
-
-config BACKPORT_DIR
- string
- option env="BACKPORT_DIR"
-config BACKPORTS_VERSION
- string
- option env="BACKPORTS_VERSION"
-config BACKPORTED_KERNEL_VERSION
- string
- option env="BACKPORTED_KERNEL_VERSION"
-config BACKPORTED_KERNEL_NAME
- string
- option env="BACKPORTED_KERNEL_NAME"
-
-# Packaging hacks
-source "$BACKPORT_DIR/Kconfig.package.hacks"
-
-# Code we backport
-source "$BACKPORT_DIR/Kconfig.sources"
-
-# these will be generated
-source "$BACKPORT_DIR/Kconfig.kernel"
-source "$BACKPORT_DIR/Kconfig.versions"
-source "$BACKPORT_DIR/Kconfig.local"
diff --git a/backport/Kconfig.package.hacks b/backport/Kconfig.package.hacks
deleted file mode 100644
index 6a429dd1..00000000
--- a/backport/Kconfig.package.hacks
+++ /dev/null
@@ -1,8 +0,0 @@
-# some hacks for when we use backports to generate a package
-# to build modules out of tree.
-config WIRELESS
- def_bool y
-config NET_CORE
- def_bool y
-config EXPERT
- def_bool y
diff --git a/backport/Kconfig.sources b/backport/Kconfig.sources
deleted file mode 100644
index c2713a14..00000000
--- a/backport/Kconfig.sources
+++ /dev/null
@@ -1,19 +0,0 @@
-# this has the configuration for the backport code
-source "$BACKPORT_DIR/compat/Kconfig"
-
-# these are copied from the kernel
-source "$BACKPORT_DIR/net/wireless/Kconfig"
-source "$BACKPORT_DIR/net/mac80211/Kconfig"
-source "$BACKPORT_DIR/net/bluetooth/Kconfig"
-source "$BACKPORT_DIR/drivers/net/wireless/Kconfig"
-source "$BACKPORT_DIR/drivers/net/ethernet/Kconfig"
-source "$BACKPORT_DIR/drivers/net/usb/Kconfig"
-
-source "$BACKPORT_DIR/drivers/ssb/Kconfig"
-source "$BACKPORT_DIR/drivers/bcma/Kconfig"
-
-source "$BACKPORT_DIR/drivers/tty/serdev/Kconfig"
-
-source "$BACKPORT_DIR/drivers/usb/class/Kconfig"
-
-source "$BACKPORT_DIR/drivers/staging/Kconfig"
diff --git a/backport/Makefile b/backport/Makefile
deleted file mode 100644
index 0fd4cdb2..00000000
--- a/backport/Makefile
+++ /dev/null
@@ -1,164 +0,0 @@
-#
-# Makefile for the output source package
-#
-
-ifeq ($(KERNELRELEASE),)
-
-MAKEFLAGS += --no-print-directory
-SHELL := /bin/bash
-BACKPORT_DIR := $(shell pwd)
-
-KMODDIR ?= updates
-ifneq ($(origin KLIB), undefined)
-KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
-else
-KLIB := /lib/modules/$(shell uname -r)/
-KMODPATH_ARG :=
-endif
-KLIB_BUILD ?= $(KLIB)/build/
-KERNEL_CONFIG := $(KLIB_BUILD)/.config
-KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
-CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
-
-export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG
-
-# disable built-in rules for this file
-.SUFFIXES:
-
-.PHONY: default
-default:
- @$(MAKE) modules
-
-.PHONY: mrproper
-mrproper:
- @test -f .config && $(MAKE) clean || true
- @rm -f .config
- @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel
- @rm -f backport-include/backport/autoconf.h
-
-.DEFAULT:
- @set -e ; test -f local-symbols || ( \
- echo "/--------------" ;\
- echo "| You shouldn't run make in the backports tree, but only in" ;\
- echo "| the generated output. This here is only the skeleton code" ;\
- echo "| copied into the output directory. To use the backport system" ;\
- echo "| from scratch, go into the top-level directory and run" ;\
- echo "| ./gentree.py /path/to/linux-next/ /tmp/output" ;\
- echo "| and then make menuconfig/... in the output directory. See" ;\
- echo "| ./gentree.py --help" ;\
- echo "| for more options." ;\
- echo "\\--" ;\
- false)
- @set -e ; test -f $(KERNEL_CONFIG) || ( \
- echo "/--------------" ;\
- echo "| Your kernel headers are incomplete/not installed." ;\
- echo "| Please install kernel headers, including a .config" ;\
- echo "| file or use the KLIB/KLIB_BUILD make variables to" ;\
- echo "| set the kernel to build against, e.g." ;\
- echo "| make KLIB=/lib/modules/3.1.7/" ;\
- echo "| to compile/install for the installed kernel 3.1.7" ;\
- echo "| (that isn't currently running.)" ;\
- echo "\\--" ;\
- false)
- @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\
- then \
- echo -n "Generating local configuration database from kernel ..." ;\
- grep -v -f local-symbols $(KERNEL_CONFIG) | grep = | ( \
- while read l ; do \
- if [ "$${l:0:7}" != "CONFIG_" ] ; then \
- continue ;\
- fi ;\
- l=$${l:7} ;\
- n=$${l%%=*} ;\
- v=$${l#*=} ;\
- if [ "$$v" = "m" ] ; then \
- echo config $$n ;\
- echo ' tristate' ;\
- elif [ "$$v" = "y" ] ; then \
- echo config $$n ;\
- echo ' bool' ;\
- else \
- continue ;\
- fi ;\
- echo " default $$v" ;\
- echo "" ;\
- done \
- ) > Kconfig.kernel ;\
- kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \
- sed 's/^\(\([3-4]\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\
- test "$$kver" != "" || echo "Kernel version parse failed!" ;\
- test "$$kver" != "" ;\
- kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\
- kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')" ;\
- kvers="$$kvers $$(seq 0 99 | sed 's/^/4./')" ;\
- print=0 ;\
- for v in $$kvers ; do \
- if [ "$$print" = "1" ] ; then \
- echo config KERNEL_$$(echo $$v | tr . _) ;\
- echo " def_bool y" ;\
- fi ;\
- if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\
- done > Kconfig.versions ;\
- # RHEL as well, sadly we need to grep for it ;\
- RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \
- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
- RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \
- sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
- for v in $$(seq 0 $$RHEL_MINOR) ; do \
- echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\
- echo " def_bool y" ;\
- done >> Kconfig.versions ;\
- echo " done." ;\
- fi ;\
- echo "$(CONFIG_MD5)" > .kernel_config_md5
- @$(MAKE) -f Makefile.real "$@"
-
-.PHONY: defconfig-help
-defconfig-help:
- @echo "Driver or subsystem configuration targets:"
- @set -e ;\
- bk_configs="$$(ls defconfigs/*)" ;\
- for cfg in $$bk_configs; do \
- echo " defconfig-$${cfg##defconfigs/}" ;\
- done
- @echo ""
-
-.PHONY: help
-help: defconfig-help
- @echo "Cleaning targets:"
- @echo " clean - Remove most generated files but keep the config and"
- @echo " enough build support to build external modules"
- @echo " mrproper - Remove all generated files + config + various backup files"
- @echo ""
- @echo "Driver configuration help:"
- @echo " defconfig-help - List all prearranged defconfig-targets we have"
- @echo " designed for you. You can use this to find"
- @echo " driver specific configs in case all you really"
- @echo " need is to just compile one or a small group "
- @echo " of drivers."
- @echo ""
- @echo "Configuration targets:"
- @echo " menuconfig - Update current config utilising a menu based program"
- @echo " oldconfig - Update current config utilising a provided .config as base"
- @echo " oldaskconfig - ??"
- @echo " silentoldconfig - Same as oldconfig, but quietly, additionally update deps"
- @echo " allnoconfig - New config where all options are answered with no"
- @echo " allyesconfig - New config where all options are accepted with yes"
- @echo " allmodconfig - New config selecting modules when possible"
- @echo " alldefconfig - New config with all symbols set to default"
- @echo " randconfig - New config with random answer to all options"
- @echo " listnewconfig - List new options"
- @echo " olddefconfig - Same as silentoldconfig but sets new symbols to their default value"
- @echo ""
- @echo "Other generic targets:"
- @echo " all - Build all targets marked with [*]"
- @echo "* modules - Build all modules"
- @echo ""
- @echo "Architecture specific targets:"
- @echo " install - Install modules"
- @echo " uninstall - Uninstall modules"
- @echo ""
- @echo "Execute "make" or "make all" to build all targets marked with [*]"
-else
-include $(BACKPORT_DIR)/Makefile.kernel
-endif
diff --git a/backport/Makefile.build b/backport/Makefile.build
deleted file mode 100644
index a848b37e..00000000
--- a/backport/Makefile.build
+++ /dev/null
@@ -1,10 +0,0 @@
--include .config
-export
-
-.PHONY: modules
-modules:
- @$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_DIR) modules
-
-.PHONY: clean
-clean:
- @$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_DIR) clean
diff --git a/backport/Makefile.kernel b/backport/Makefile.kernel
deleted file mode 100644
index 4264ebb1..00000000
--- a/backport/Makefile.kernel
+++ /dev/null
@@ -1,55 +0,0 @@
-ifeq ($(CONFIG_BACKPORT_INTEGRATE),)
-# Since 2.6.21, try-run is available, but cc-disable-warning
-# was only added later, so we add it here ourselves:
-backport-cc-disable-warning = $(call try-run,\
- $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
-
-NOSTDINC_FLAGS := \
- -I$(M)/backport-include/ \
- -I$(M)/backport-include/uapi \
- -I$(M)/include/ \
- -I$(M)/include/uapi \
- -include $(M)/backport-include/backport/backport.h \
- $(call backport-cc-disable-warning, unused-but-set-variable) \
- -DCPTCFG_VERSION=\"$(BACKPORTS_VERSION)\" \
- -DCPTCFG_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \
- -DCPTCFG_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \
- $(BACKPORTS_GIT_TRACKER_DEF) \
- $(CFLAGS)
-
-export backport_srctree = $(M)
-else
-export BACKPORT_DIR = backports/
-export backport_srctree = $(BACKPORT_DIR)
-NOSTDINC_FLAGS := \
- -I$(BACKPORT_DIR)/backport-include/ \
- -I$(BACKPORT_DIR)/backport-include/uapi \
- -I$(BACKPORT_DIR)/include/ \
- -I$(BACKPORT_DIR)/include/uapi \
- -include $(BACKPORT_DIR)/backport-include/backport/backport.h \
- $(CFLAGS)
-endif
-
-subdir-ccflags-y := $(call cc-option, -fno-pie) $(call cc-option, -no-pie)
-ifeq ($(CPTCFG_KERNEL_4_3),y)
-subdir-ccflags-y += -Wno-pointer-sign
-endif
-
-obj-y += compat/
-
-obj-$(CPTCFG_CFG80211) += net/wireless/
-obj-$(CPTCFG_MAC80211) += net/mac80211/
-obj-$(CPTCFG_WLAN) += drivers/net/wireless/
-obj-$(CPTCFG_BT) += net/bluetooth/
-obj-$(CPTCFG_BT) += drivers/bluetooth/
-obj-$(CPTCFG_SSB) += drivers/ssb/
-obj-$(CPTCFG_BCMA) += drivers/bcma/
-obj-$(CPTCFG_ETHERNET) += drivers/net/ethernet/
-obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/
-
-obj-$(CPTCFG_USB_WDM) += drivers/usb/class/
-obj-$(CPTCFG_USB_USBNET) += drivers/net/usb/
-
-obj-$(CPTCFG_SERIAL_DEV_BUS) += drivers/tty/serdev/
-
-obj-$(CPTCFG_STAGING) += drivers/staging/
diff --git a/backport/Makefile.real b/backport/Makefile.real
deleted file mode 100644
index 65508028..00000000
--- a/backport/Makefile.real
+++ /dev/null
@@ -1,121 +0,0 @@
-include versions
-export BACKPORTS_VERSION BACKPORTED_KERNEL_VERSION BACKPORTED_KERNEL_NAME
-ifdef BACKPORTS_GIT_TRACKED
-export BACKPORTS_GIT_TRACKER_DEF=-DBACKPORTS_GIT_TRACKED=\"$(BACKPORTS_GIT_TRACKED)\"
-else
-export BACKPORTS_GIT_TRACKER_DEF=
-endif
-
-# disable built-in rules for this file
-.SUFFIXES:
-
-export CONFIG_=CPTCFG_
-
-.PHONY: menuconfig
-menuconfig:
- @$(MAKE) -C kconf mconf
- @./kconf/mconf Kconfig
-
-.PHONY: listnewconfig oldaskconfig oldconfig \
- silentoldconfig olddefconfig oldnoconfig \
- allnoconfig allyesconfig allmodconfig \
- alldefconfig randconfig
-listnewconfig oldaskconfig oldconfig \
-silentoldconfig olddefconfig oldnoconfig \
-allnoconfig allyesconfig allmodconfig \
-alldefconfig randconfig:
- @$(MAKE) -C kconf conf
- @./kconf/conf --$@ Kconfig
-
-.PHONY: usedefconfig
-usedefconfig:
- @$(MAKE) -C kconf conf
- @./kconf/conf --defconfig=defconfig Kconfig
-
-.PHONY: savedefconfig
-savedefconfig:
- @$(MAKE) -C kconf conf
- @./kconf/conf --savedefconfig=defconfig Kconfig
-
-defconfig-%::
- @$(MAKE) -C kconf conf
- @./kconf/conf --defconfig=defconfigs/$(@:defconfig-%=%) Kconfig
-
-.config:
- @test -f defconfig && $(MAKE) usedefconfig || ( \
- echo "/--------------" ;\
- echo "| Your backport package isn't configured, please configure it" ;\
- echo "| using one of the following options:" ;\
- echo "| To configure manually:" ;\
- echo "| make oldconfig" ;\
- echo "| make menuconfig" ;\
- echo "|" ;\
- echo "| To get defaults for certain drivers:" ;\
- (cd defconfigs ; for f in $$(ls) ; do \
- echo "| make defconfig-$$f" ;\
- done ) ;\
- echo "\--" ;\
- false )
-
-backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel
- @$(MAKE) oldconfig
- @echo -n "Building backport-include/backport/autoconf.h ..."
- @grep -f local-symbols .config | ( \
- echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\
- echo "#define COMPAT_AUTOCONF_INCLUDED" ;\
- echo "/*" ;\
- echo " * Automatically generated file, don't edit!" ;\
- echo " * Changes will be overwritten" ;\
- echo " */" ;\
- echo "" ;\
- while read l ; do \
- n=$${l%%=*} ;\
- v=$${l#*=} ;\
- case $$v in \
- y) echo "#define $$n 1" ;; \
- m) echo "#define $${n}_MODULE 1" ;; \
- \"*) echo "#define $$n $$v" ;; \
- [0-9]*) echo "#define $$n $$v" ;; \
- *) echo "#warning unknown value for $$n";;\
- esac ;\
- done ;\
- echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\
- ) > backport-include/backport/autoconf.h
- @echo " done."
-
-.PHONY: modules
-modules: backport-include/backport/autoconf.h
- @$(MAKE) -f Makefile.build modules
-
-.PHONY: install
-install: modules
- @$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_DIR) \
- INSTALL_MOD_DIR=$(KMODDIR) $(KMODPATH_ARG) \
- modules_install
- @./scripts/blacklist.sh $(KLIB)/ $(KLIB)/$(KMODDIR)
- @./scripts/compress_modules.sh $(KLIB)/$(KMODDIR)
- @./scripts/check_depmod.sh
- @/sbin/depmod -a
- @./scripts/update-initramfs.sh $(KLIB)
- @echo
- @echo Your backported driver modules should be installed now.
- @echo Reboot.
- @echo
-
-.PHONY: modules_install
-modules_install: install
-
-.PHONY: uninstall
-uninstall:
- @./scripts/uninstall.sh
- @/sbin/depmod -a
- @./scripts/update-initramfs.sh $(KLIB)
- @echo
- @echo Your backported driver modules should be uninstalled now.
- @echo Reboot.
- @echo
-
-.PHONY: clean
-clean:
- @$(MAKE) -f Makefile.build clean
- @$(MAKE) -C kconf clean
diff --git a/backport/backport-include/asm-generic/bug.h b/backport/backport-include/asm-generic/bug.h
deleted file mode 100644
index 4e9e05f2..00000000
--- a/backport/backport-include/asm-generic/bug.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __BACKPORT_ASM_GENERIC_BUG_H
-#define __BACKPORT_ASM_GENERIC_BUG_H
-#include_next <asm-generic/bug.h>
-
-#ifndef __WARN
-#define __WARN(foo) dump_stack()
-#endif
-
-#ifndef WARN_ONCE
-#define WARN_ONCE(condition, format...) ({ \
- static int __warned; \
- int __ret_warn_once = !!(condition); \
- \
- if (unlikely(__ret_warn_once)) \
- if (WARN(!__warned, format)) \
- __warned = 1; \
- unlikely(__ret_warn_once); \
-})
-#endif
-
-#ifndef __WARN_printf
-/*
- * To port this properly we'd have to port warn_slowpath_null(),
- * which I'm lazy to do so just do a regular print for now. If you
- * want to port this read kernel/panic.c
- */
-#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
-#endif
-
-#ifndef WARN
-#define WARN(condition, format...) ({ \
- int __ret_warn_on = !!(condition); \
- if (unlikely(__ret_warn_on)) \
- __WARN_printf(format); \
- unlikely(__ret_warn_on); \
-})
-#endif
-
-#endif /* __BACKPORT_ASM_GENERIC_BUG_H */
diff --git a/backport/backport-include/asm-generic/pci-dma-compat.h b/backport/backport-include/asm-generic/pci-dma-compat.h
deleted file mode 100644
index 1b1433ef..00000000
--- a/backport/backport-include/asm-generic/pci-dma-compat.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H
-#define __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H
-#include_next <asm-generic/pci-dma-compat.h>
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#define pci_zalloc_consistent LINUX_BACKPORT(pci_zalloc_consistent)
-static inline void *pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
- dma_addr_t *dma_handle)
-{
- void *ret = pci_alloc_consistent(hwdev, size, dma_handle);
- if (ret)
- memset(ret, 0, size);
- return ret;
-}
-#endif
-
-#endif /* __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H */
diff --git a/backport/backport-include/asm/atomic.h b/backport/backport-include/asm/atomic.h
deleted file mode 100644
index 31bddc6b..00000000
--- a/backport/backport-include/asm/atomic.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __BACKPORT_ASM_ATOMIC_H
-#define __BACKPORT_ASM_ATOMIC_H
-#include_next <asm/atomic.h>
-#include <linux/version.h>
-#include <asm/barrier.h>
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-/*
- * In many versions, several architectures do not seem to include an
- * atomic64_t implementation, and do not include the software emulation from
- * asm-generic/atomic64_t.
- * Detect and handle this here.
- */
-#if (!defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !(defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64)))
-#include <asm-generic/atomic64.h>
-#endif
-#endif
-
-#endif /* __BACKPORT_ASM_ATOMIC_H */
diff --git a/backport/backport-include/asm/barrier.h b/backport/backport-include/asm/barrier.h
deleted file mode 100644
index 9e1e1f11..00000000
--- a/backport/backport-include/asm/barrier.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __BACKPORT_ASM_BARRIER_H
-#define __BACKPORT_ASM_BARRIER_H
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,4,0) || \
- defined(CONFIG_ALPHA) || defined(CONFIG_MIPS)
-#include_next <asm/barrier.h>
-#endif /* >= 3.4 */
-
-#ifndef dma_rmb
-#define dma_rmb() rmb()
-#endif
-
-#ifndef dma_wmb
-#define dma_wmb() wmb()
-#endif
-
-#ifndef smp_mb__after_atomic
-#define smp_mb__after_atomic smp_mb__after_clear_bit
-#endif
-
-#endif /* __BACKPORT_ASM_BARRIER_H */
diff --git a/backport/backport-include/asm/errno.h b/backport/backport-include/asm/errno.h
deleted file mode 100644
index 0a730b77..00000000
--- a/backport/backport-include/asm/errno.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __BACKPORT_ASM_ERRNO_H
-#define __BACKPORT_ASM_ERRNO_H
-#include_next <asm/errno.h>
-
-#ifndef ERFKILL
-#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC)
-#define ERFKILL 132 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_ALPHA
-#define ERFKILL 138 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_MIPS
-#define ERFKILL 167 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_PARISC
-#define ERFKILL 256 /* Operation not possible due to RF-kill */
-#endif
-#ifdef CONFIG_SPARC
-#define ERFKILL 134 /* Operation not possible due to RF-kill */
-#endif
-#endif
-
-#endif /* __BACKPORT_ASM_ERRNO_H */
diff --git a/backport/backport-include/asm/ioctls.h b/backport/backport-include/asm/ioctls.h
deleted file mode 100644
index 72c2f0a7..00000000
--- a/backport/backport-include/asm/ioctls.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __BACKPORT_ASM_IOCTLS_H
-#define __BACKPORT_ASM_IOCTLS_H
-#include_next <asm/ioctls.h>
-
-#ifndef TIOCPKT_IOCTL
-#define TIOCPKT_IOCTL 64
-#endif
-
-#endif /* __BACKPORT_ASM_IOCTLS_H */
diff --git a/backport/backport-include/backport/backport.h b/backport/backport-include/backport/backport.h
deleted file mode 100644
index d1d3b102..00000000
--- a/backport/backport-include/backport/backport.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __BACKPORT_H
-#define __BACKPORT_H
-#include <generated/autoconf.h>
-#ifndef CONFIG_BACKPORT_INTEGRATE
-#include <backport/autoconf.h>
-#endif
-#include <linux/kconfig.h>
-
-#ifndef __ASSEMBLY__
-#define LINUX_BACKPORT(__sym) backport_ ##__sym
-#ifndef CONFIG_BACKPORT_INTEGRATE
-#include <backport/checks.h>
-#endif
-#endif
-
-#endif /* __BACKPORT_H */
diff --git a/backport/backport-include/backport/checks.h b/backport/backport-include/backport/checks.h
deleted file mode 100644
index d2c34922..00000000
--- a/backport/backport-include/backport/checks.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __BACKPORT_CHECKS
-#define __BACKPORT_CHECKS
-
-#if defined(CONFIG_MAC80211) && defined(CPTCFG_MAC80211)
-#error "You must not have mac80211 built into your kernel if you want to enable it"
-#endif
-
-#if defined(CONFIG_CFG80211) && defined(CPTCFG_CFG80211)
-#error "You must not have cfg80211 built into your kernel if you want to enable it"
-#endif
-
-#endif /* __BACKPORT_CHECKS */
diff --git a/backport/backport-include/backport/leds-disabled.h b/backport/backport-include/backport/leds-disabled.h
deleted file mode 100644
index 5ab82e5b..00000000
--- a/backport/backport-include/backport/leds-disabled.h
+++ /dev/null
@@ -1,198 +0,0 @@
-#ifndef __BACKPORT_LED_DISABLED_SUPPORT
-#define __BACKPORT_LED_DISABLED_SUPPORT
-
-/*
- * LED support is strange, with the NEW_LEDS, LEDS_CLASS and LEDS_TRIGGERS
- * Kconfig symbols ... If any of them are not defined, we build our
- * "compatibility" code that really just makes it all non-working but
- * allows compilation.
- */
-
-#ifdef CPTCFG_BPAUTO_BUILD_LEDS
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/rwsem.h>
-#include <linux/mutex.h>
-#include <linux/workqueue.h>
-
-#define led_classdev LINUX_BACKPORT(led_classdev)
-#define led_trigger LINUX_BACKPORT(led_trigger)
-
-struct led_classdev {
- const char *name;
- enum led_brightness brightness;
- enum led_brightness max_brightness;
- int flags;
-
- /* Lower 16 bits reflect status */
-#ifndef LED_SUSPENDED
-#define LED_SUSPENDED (1 << 0)
- /* Upper 16 bits reflect control information */
-#define LED_CORE_SUSPENDRESUME (1 << 16)
-#define LED_BLINK_ONESHOT (1 << 17)
-#define LED_BLINK_ONESHOT_STOP (1 << 18)
-#define LED_BLINK_INVERT (1 << 19)
-#define LED_SYSFS_DISABLE (1 << 20)
-#define SET_BRIGHTNESS_ASYNC (1 << 21)
-#define SET_BRIGHTNESS_SYNC (1 << 22)
-#define LED_DEV_CAP_FLASH (1 << 23)
-#endif
-
- /* Set LED brightness level */
- /* Must not sleep, use a workqueue if needed */
- void (*brightness_set)(struct led_classdev *led_cdev,
- enum led_brightness brightness);
- /*
- * Set LED brightness level immediately - it can block the caller for
- * the time required for accessing a LED device register.
- */
- int (*brightness_set_sync)(struct led_classdev *led_cdev,
- enum led_brightness brightness);
- /* Get LED brightness level */
- enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
-
- /*
- * Activate hardware accelerated blink, delays are in milliseconds
- * and if both are zero then a sensible default should be chosen.
- * The call should adjust the timings in that case and if it can't
- * match the values specified exactly.
- * Deactivate blinking again when the brightness is set to a fixed
- * value via the brightness_set() callback.
- */
- int (*blink_set)(struct led_classdev *led_cdev,
- unsigned long *delay_on,
- unsigned long *delay_off);
-
- struct device *dev;
- const struct attribute_group **groups;
-
- struct list_head node; /* LED Device list */
- const char *default_trigger; /* Trigger to use */
-
- unsigned long blink_delay_on, blink_delay_off;
- struct timer_list blink_timer;
- int blink_brightness;
- void (*flash_resume)(struct led_classdev *led_cdev);
-
- struct work_struct set_brightness_work;
- int delayed_set_value;
-
- /* Protects the trigger data below */
- struct rw_semaphore trigger_lock;
-
- struct led_trigger *trigger;
- struct list_head trig_list;
- void *trigger_data;
- /* true if activated - deactivate routine uses it to do cleanup */
- bool activated;
-
- /* Ensures consistent access to the LED Flash Class device */
- struct mutex led_access;
-};
-
-struct led_trigger {
- const char *name;
- void (*activate)(struct led_classdev *led_cdev);
- void (*deactivate)(struct led_classdev *led_cdev);
- rwlock_t leddev_list_lock;
- struct list_head led_cdevs;
- struct list_head next_trig;
-};
-
-#undef led_classdev_register
-#define led_classdev_register LINUX_BACKPORT(led_classdev_register)
-#undef led_classdev_unregister
-#define led_classdev_unregister LINUX_BACKPORT(led_classdev_unregister)
-#undef led_blink_set
-#define led_blink_set LINUX_BACKPORT(led_blink_set)
-#undef led_set_brightness
-#define led_set_brightness LINUX_BACKPORT(led_set_brightness)
-#undef led_classdev_suspend
-#define led_classdev_suspend LINUX_BACKPORT(led_classdev_suspend)
-#undef led_classdev_resume
-#define led_classdev_resume LINUX_BACKPORT(led_classdev_resume)
-
-#undef led_trigger_register
-#define led_trigger_register LINUX_BACKPORT(led_trigger_register)
-#undef led_trigger_unregister
-#define led_trigger_unregister LINUX_BACKPORT(led_trigger_unregister)
-#undef led_trigger_register_simple
-#define led_trigger_register_simple LINUX_BACKPORT(led_trigger_register_simple)
-#undef led_trigger_unregister_simple
-#define led_trigger_unregister_simple LINUX_BACKPORT(led_trigger_unregister_simple)
-#undef led_trigger_event
-#define led_trigger_event LINUX_BACKPORT(led_trigger_event)
-
-#undef DEFINE_LED_TRIGGER
-#define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
-
-static inline int led_classdev_register(struct device *parent,
- struct led_classdev *led_cdev)
-{
- return 0;
-}
-
-static inline void led_classdev_unregister(struct led_classdev *led_cdev)
-{
-}
-
-static inline void led_trigger_register_simple(const char *name,
- struct led_trigger **trigger)
-{
-}
-
-static inline void led_trigger_unregister_simple(struct led_trigger *trigger)
-{
-}
-
-static inline void led_blink_set(struct led_classdev *led_cdev,
- unsigned long *delay_on,
- unsigned long *delay_off)
-{
-}
-
-static inline void led_set_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
-{
-}
-
-static inline void led_classdev_suspend(struct led_classdev *led_cdev)
-{
-}
-
-static inline void led_classdev_resume(struct led_classdev *led_cdev)
-{
-}
-
-static inline int led_trigger_register(struct led_trigger *trigger)
-{
- INIT_LIST_HEAD(&trigger->led_cdevs);
- INIT_LIST_HEAD(&trigger->next_trig);
- rwlock_init(&trigger->leddev_list_lock);
- return 0;
-}
-
-static inline void led_trigger_unregister(struct led_trigger *trigger)
-{
-}
-
-static inline void led_trigger_event(struct led_trigger *trigger,
- enum led_brightness event)
-{
-}
-
-static inline void led_trigger_blink(struct led_trigger *trigger,
- unsigned long *delay_on,
- unsigned long *delay_off)
-{
-}
-
-static inline void led_trigger_blink_oneshot(struct led_trigger *trigger,
- unsigned long *delay_on,
- unsigned long *delay_off,
- int invert)
-{
-}
-#endif
-
-#endif /* __BACKPORT_LED_DISABLED_SUPPORT */
diff --git a/backport/backport-include/backport/magic.h b/backport/backport-include/backport/magic.h
deleted file mode 100644
index d7e7cc96..00000000
--- a/backport/backport-include/backport/magic.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * These tricks are taken from
- * http://efesx.com/2010/07/17/variadic-macro-to-count-number-of-arguments/
- * and
- * http://efesx.com/2010/08/31/overloading-macros/
- */
-
-#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 6,5,4,3,2,1)
-#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,_6,N,...) N
-
-#define macro_dispatcher(func, ...) \
- macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
-#define macro_dispatcher_(func, nargs) \
- macro_dispatcher__(func, nargs)
-#define macro_dispatcher__(func, nargs) \
- func ## nargs
diff --git a/backport/backport-include/crypto/aead.h b/backport/backport-include/crypto/aead.h
deleted file mode 100644
index 26b13551..00000000
--- a/backport/backport-include/crypto/aead.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __BACKPORT_CRYPTO_AEAD_H
-#define __BACKPORT_CRYPTO_AEAD_H
-#include_next <crypto/aead.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define aead_request_set_ad LINUX_BACKPORT(aead_request_set_ad)
-static inline void aead_request_set_ad(struct aead_request *req,
- unsigned int assoclen)
-{
- req->assoclen = assoclen;
-}
-
-#define crypto_aead_reqsize LINUX_BACKPORT(crypto_aead_reqsize)
-unsigned int crypto_aead_reqsize(struct crypto_aead *tfm);
-
-struct aead_request *crypto_backport_convert(struct aead_request *req);
-
-static inline int backport_crypto_aead_encrypt(struct aead_request *req)
-{
- return crypto_aead_encrypt(crypto_backport_convert(req));
-}
-#define crypto_aead_encrypt LINUX_BACKPORT(crypto_aead_encrypt)
-
-static inline int backport_crypto_aead_decrypt(struct aead_request *req)
-{
- return crypto_aead_decrypt(crypto_backport_convert(req));
-}
-#define crypto_aead_decrypt LINUX_BACKPORT(crypto_aead_decrypt)
-
-#endif /* LINUX_VERSION_IS_LESS(4,2,0) */
-
-#endif /* __BACKPORT_CRYPTO_AEAD_H */
diff --git a/backport/backport-include/crypto/algapi.h b/backport/backport-include/crypto/algapi.h
deleted file mode 100644
index b6fbdd9b..00000000
--- a/backport/backport-include/crypto/algapi.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __BP_ALGAPI_H
-#define __BP_ALGAPI_H
-#include <linux/version.h>
-#include_next <crypto/algapi.h>
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#define __crypto_memneq LINUX_BACKPORT(__crypto_memneq)
-noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size);
-#define crypto_memneq LINUX_BACKPORT(crypto_memneq)
-static inline int crypto_memneq(const void *a, const void *b, size_t size)
-{
- return __crypto_memneq(a, b, size) != 0UL ? 1 : 0;
-}
-#endif
-
-#endif /* __BP_ALGAPI_H */
diff --git a/backport/backport-include/crypto/hash.h b/backport/backport-include/crypto/hash.h
deleted file mode 100644
index 96ae799d..00000000
--- a/backport/backport-include/crypto/hash.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef _BACKPORT_CRYPTO_HASH_H
-#define _BACKPORT_CRYPTO_HASH_H
-#include_next <crypto/hash.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,6,0)
-#define shash_desc_zero LINUX_BACKPORT(shash_desc_zero)
-static inline void shash_desc_zero(struct shash_desc *desc)
-{
- memzero_explicit(desc,
- sizeof(*desc) + crypto_shash_descsize(desc->tfm));
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,6,0)
-#define ahash_request_zero LINUX_BACKPORT(ahash_request_zero)
-static inline void ahash_request_zero(struct ahash_request *req)
-{
- memzero_explicit(req, sizeof(*req) +
- crypto_ahash_reqsize(crypto_ahash_reqtfm(req)));
-}
-#endif
-
-#ifndef AHASH_REQUEST_ON_STACK
-#define AHASH_REQUEST_ON_STACK(name, ahash) \
- char __##name##_desc[sizeof(struct ahash_request) + \
- crypto_ahash_reqsize(ahash)] CRYPTO_MINALIGN_ATTR; \
- struct ahash_request *name = (void *)__##name##_desc
-#endif
-
-#ifndef SHASH_DESC_ON_STACK
-#define SHASH_DESC_ON_STACK(shash, ctx) \
- char __##shash##_desc[sizeof(struct shash_desc) + \
- crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
- struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
-#endif
-
-#endif /* _BACKPORT_CRYPTO_HASH_H */
diff --git a/backport/backport-include/generated/utsrelease.h b/backport/backport-include/generated/utsrelease.h
deleted file mode 100644
index a149b7ab..00000000
--- a/backport/backport-include/generated/utsrelease.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_GENERATED_UTS_RELEASE_H
-#define __BACKPORT_GENERATED_UTS_RELEASE_H
-#include_next <generated/utsrelease.h>
-
-/*
- * We only want the UTS_UBUNTU_RELEASE_ABI var when we are on a normal
- * Ubuntu distribution kernel and not when we are on a Ubuntu mainline
- * kernel. Some of the Ubuntu mainline kernel do have an invalid octal
- * number in this field like 031418 and we do not want to evaluate this
- * at all on the Ubuntu mainline kernels. All Ubuntu distribution
- * kernel have CONFIG_VERSION_SIGNATURE set so this way we can detect
- * the which type of kernel we are on.
- */
-#ifndef UTS_UBUNTU_RELEASE_ABI
-#define UTS_UBUNTU_RELEASE_ABI 0
-#elif !defined(CONFIG_VERSION_SIGNATURE)
-#undef UTS_UBUNTU_RELEASE_ABI
-#define UTS_UBUNTU_RELEASE_ABI 0
-#endif
-
-#endif /* __BACKPORT_GENERATED_UTS_RELEASE_H */
diff --git a/backport/backport-include/keys/asymmetric-type.h b/backport/backport-include/keys/asymmetric-type.h
deleted file mode 100644
index 5744de9c..00000000
--- a/backport/backport-include/keys/asymmetric-type.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __BP_ASYMMETRIC_TYPE_H
-#define __BP_ASYMMETRIC_TYPE_H
-#ifdef CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION
-
-#include <linux/string.h>
-
-struct asymmetric_key_id {
- unsigned short len;
- unsigned char data[];
-};
-
-struct asymmetric_key_ids {
- struct asymmetric_key_id *id[2];
-};
-
-static inline bool asymmetric_key_id_same(const struct asymmetric_key_id *kid1,
- const struct asymmetric_key_id *kid2)
-{
- if (!kid1 || !kid2)
- return false;
- if (kid1->len != kid2->len)
- return false;
- return memcmp(kid1->data, kid2->data, kid1->len) == 0;
-}
-
-extern struct asymmetric_key_id *
-asymmetric_key_generate_id(const void *val_1, size_t len_1,
- const void *val_2, size_t len_2);
-
-extern struct key *find_asymmetric_key(struct key *keyring,
- const struct asymmetric_key_id *id_0,
- const struct asymmetric_key_id *id_1,
- bool partial);
-#endif
-#endif /* __BP_ASYMMETRIC_TYPE_H */
diff --git a/backport/backport-include/keys/system_keyring.h b/backport/backport-include/keys/system_keyring.h
deleted file mode 100644
index 00d2bfff..00000000
--- a/backport/backport-include/keys/system_keyring.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BP_SYSTEM_KEYRING_H
-#define __BP_SYSTEM_KEYRING_H
-#ifndef CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION
-#include_next <keys/system_keyring.h>
-#else
-#include <linux/key.h>
-
-#define is_hash_blacklisted(...) 0
-#endif /* CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION */
-#endif /* __BP_SYSTEM_KEYRING_H */
diff --git a/backport/backport-include/linux/acpi.h b/backport/backport-include/linux/acpi.h
deleted file mode 100644
index 2f1072f7..00000000
--- a/backport/backport-include/linux/acpi.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __BACKPORT_LINUX_ACPI_H
-#define __BACKPORT_LINUX_ACPI_H
-#include_next <linux/acpi.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,8,0)
-/*
- * Backports
- *
- * commit 95f8a082b9b1ead0c2859f2a7b1ac91ff63d8765
- * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
- * Date: Wed Nov 21 00:21:50 2012 +0100
- *
- * ACPI / driver core: Introduce struct acpi_dev_node and related macros
- *
- * To avoid adding an ACPI handle pointer to struct device on
- * architectures that don't use ACPI, or generally when CONFIG_ACPI is
- * not set, in which cases that pointer is useless, define struct
- * acpi_dev_node that will contain the handle pointer if CONFIG_ACPI is
- * set and will be empty otherwise and use it to represent the ACPI
- * device node field in struct device.
- *
- * In addition to that define macros for reading and setting the ACPI
- * handle of a device that don't generate code when CONFIG_ACPI is
- * unset. Modify the ACPI subsystem to use those macros instead of
- * referring to the given device's ACPI handle directly.
- *
- * Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
- * Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
- * Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- */
-#ifdef CONFIG_ACPI
-#define ACPI_HANDLE(dev) DEVICE_ACPI_HANDLE(dev)
-#else
-#define ACPI_HANDLE(dev) (NULL)
-#endif /* CONFIG_ACPI */
-#endif /* LINUX_VERSION_IS_LESS(3,8,0) */
-
-#ifndef ACPI_COMPANION
-#ifdef CONFIG_ACPI
-static inline struct acpi_device *_acpi_get_companion(struct device *dev)
-{
- struct acpi_device *adev;
- int ret;
-
- ret = acpi_bus_get_device(ACPI_HANDLE(dev), &adev);
- if (ret < 0)
- adev = NULL;
-
- return adev;
-}
-#define ACPI_COMPANION(dev) _acpi_get_companion(dev)
-#else
-#define ACPI_COMPANION(dev) (NULL)
-#endif /* CONFIG_ACPI */
-#endif /* ACPI_COMPANION */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define acpi_dev_remove_driver_gpios LINUX_BACKPORT(acpi_dev_remove_driver_gpios)
-static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
-#endif /* LINUX_VERSION_IS_LESS(3, 19, 0) */
-
-#if LINUX_VERSION_IN_RANGE(3,19,0, 4,13,0)
-#define devm_acpi_dev_add_driver_gpios LINUX_BACKPORT(devm_acpi_dev_add_driver_gpios)
-static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
- const struct acpi_gpio_mapping *gpios)
-{
- return -ENXIO;
-}
-#endif /* LINUX_VERSION_IN_RANGE(3,19,0, 4,13,0) */
-
-#endif /* __BACKPORT_LINUX_ACPI_H */
diff --git a/backport/backport-include/linux/atomic.h b/backport/backport-include/linux/atomic.h
deleted file mode 100644
index b4dd2e1d..00000000
--- a/backport/backport-include/linux/atomic.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __BP_ATOMIC_H
-#define __BP_ATOMIC_H
-#include_next <linux/atomic.h>
-
-/* atomic_cmpxchg_relaxed */
-#ifndef atomic_cmpxchg_relaxed
-#define atomic_cmpxchg_relaxed atomic_cmpxchg
-#define atomic_cmpxchg_acquire atomic_cmpxchg
-#define atomic_cmpxchg_release atomic_cmpxchg
-
-#else /* atomic_cmpxchg_relaxed */
-
-#ifndef atomic_cmpxchg_acquire
-#define atomic_cmpxchg_acquire(...) \
- __atomic_op_acquire(atomic_cmpxchg, __VA_ARGS__)
-#endif
-
-#ifndef atomic_cmpxchg_release
-#define atomic_cmpxchg_release(...) \
- __atomic_op_release(atomic_cmpxchg, __VA_ARGS__)
-#endif
-
-#ifndef atomic_cmpxchg
-#define atomic_cmpxchg(...) \
- __atomic_op_fence(atomic_cmpxchg, __VA_ARGS__)
-#endif
-#endif /* atomic_cmpxchg_relaxed */
-
-/* these were introduced together, so just a single check is enough */
-#ifndef atomic_try_cmpxchg_acquire
-#ifndef atomic_try_cmpxchg
-#define __atomic_try_cmpxchg(type, _p, _po, _n) \
-({ \
- typeof(_po) __po = (_po); \
- typeof(*(_po)) __r, __o = *__po; \
- __r = atomic_cmpxchg##type((_p), __o, (_n)); \
- if (unlikely(__r != __o)) \
- *__po = __r; \
- likely(__r == __o); \
-})
-
-#define atomic_try_cmpxchg(_p, _po, _n) __atomic_try_cmpxchg(, _p, _po, _n)
-#define atomic_try_cmpxchg_relaxed(_p, _po, _n) __atomic_try_cmpxchg(_relaxed, _p, _po, _n)
-#define atomic_try_cmpxchg_acquire(_p, _po, _n) __atomic_try_cmpxchg(_acquire, _p, _po, _n)
-#define atomic_try_cmpxchg_release(_p, _po, _n) __atomic_try_cmpxchg(_release, _p, _po, _n)
-#else /* atomic_try_cmpxchg */
-#define atomic_try_cmpxchg_relaxed atomic_try_cmpxchg
-#define atomic_try_cmpxchg_acquire atomic_try_cmpxchg
-#define atomic_try_cmpxchg_release atomic_try_cmpxchg
-#endif /* atomic_try_cmpxchg */
-
-#endif /* atomic_try_cmpxchg_acquire */
-
-#endif /* __BP_ATOMIC_H */
diff --git a/backport/backport-include/linux/bcm47xx_nvram.h b/backport/backport-include/linux/bcm47xx_nvram.h
deleted file mode 100644
index 5295a023..00000000
--- a/backport/backport-include/linux/bcm47xx_nvram.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __BACKPORTS_BCM47XX_NVRAM_H
-#define __BACKPORTS_BCM47XX_NVRAM_H
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(4,1,0)
-#include_next <linux/bcm47xx_nvram.h>
-#else
-#include <linux/types.h>
-#include <linux/kernel.h>
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define bcm47xx_nvram_get_contents LINUX_BACKPORT(bcm47xx_nvram_get_contents)
-static inline char *bcm47xx_nvram_get_contents(size_t *val_len)
-{
- return NULL;
-}
-
-#define bcm47xx_nvram_release_contents LINUX_BACKPORT(bcm47xx_nvram_release_contents)
-static inline void bcm47xx_nvram_release_contents(char *nvram)
-{
-}
-#endif /* LINUX_VERSION_IS_GEQ(4,1,0) */
-
-#endif /* __BACKPORTS_BCM47XX_NVRAM_H */
diff --git a/backport/backport-include/linux/bitops.h b/backport/backport-include/linux/bitops.h
deleted file mode 100644
index 86360d04..00000000
--- a/backport/backport-include/linux/bitops.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __BACKPORT_BITOPS_H
-#define __BACKPORT_BITOPS_H
-#include_next <linux/bitops.h>
-#include <linux/version.h>
-#include <generated/utsrelease.h>
-
-#ifndef GENMASK
-
-/*
- * Create a contiguous bitmask starting at bit position @l and ending at
- * position @h. For example
- * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
- */
-#define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
-#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
-
-#endif
-
-#ifndef BIT_ULL
-#define BIT_ULL(nr) (1ULL << (nr))
-#endif
-
-#endif /* __BACKPORT_BITOPS_H */
diff --git a/backport/backport-include/linux/bp-devcoredump.h b/backport/backport-include/linux/bp-devcoredump.h
deleted file mode 100644
index 1e4abf64..00000000
--- a/backport/backport-include/linux/bp-devcoredump.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __BACKPORT_LINUX_DEVCOREDUMP_H
-#define __BACKPORT_LINUX_DEVCOREDUMP_H
-#include <linux/version.h>
-#include <linux/scatterlist.h>
-
-/* We only need to add our wrapper inside the range from 3.18 until
- * 4.6, outside that we can let our BPAUTO mechanism handle it.
- */
-#if (LINUX_VERSION_IS_GEQ(3,18,0) && \
- LINUX_VERSION_IS_LESS(4,7,0))
-static inline
-void backport_dev_coredumpm(struct device *dev, struct module *owner,
- void *data, size_t datalen, gfp_t gfp,
- ssize_t (*read_fn)(char *buffer, loff_t offset,
- size_t count, void *data,
- size_t datalen),
- void (*free_fn)(void *data))
-{
- return dev_coredumpm(dev, owner, (const void *)data, datalen, gfp,
- (void *)read_fn, (void *)free_fn);
-}
-
-#define dev_coredumpm LINUX_BACKPORT(dev_coredumpm)
-
-#define dev_coredumpsg LINUX_BACKPORT(dev_coredumpsg)
-void dev_coredumpsg(struct device *dev, struct scatterlist *table,
- size_t datalen, gfp_t gfp);
-
-#endif /* (LINUX_VERSION_IS_GEQ(3,18,0) && \
- LINUX_VERSION_IS_LESS(4,7,0)) */
-
-#endif /* __BACKPORT_LINUX_DEVCOREDUMP_H */
diff --git a/backport/backport-include/linux/bug.h b/backport/backport-include/linux/bug.h
deleted file mode 100644
index 8595fd2b..00000000
--- a/backport/backport-include/linux/bug.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BP_BUG_H
-#define __BP_BUG_H
-#include_next <linux/bug.h>
-
-#ifndef __BUILD_BUG_ON_NOT_POWER_OF_2
-#ifdef __CHECKER__
-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
-#else
-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
- BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
-#endif /* __CHECKER__ */
-#endif /* __BUILD_BUG_ON_NOT_POWER_OF_2 */
-
-#ifndef BUILD_BUG_ON_MSG
-#define BUILD_BUG_ON_MSG(x, msg) BUILD_BUG_ON(x)
-#endif
-
-#endif /* __BP_BUG_H */
diff --git a/backport/backport-include/linux/build_bug.h b/backport/backport-include/linux/build_bug.h
deleted file mode 100644
index 13ee5d6a..00000000
--- a/backport/backport-include/linux/build_bug.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BP_BUILD_BUG_H
-#define __BP_BUILD_BUG_H
-
-#if LINUX_VERSION_IS_GEQ(4,13,0)
-#include_next <linux/build_bug.h>
-#else /* LINUX_VERSION_IS_GEQ(4,13,0) */
-#include <linux/bug.h>
-#endif /* LINUX_VERSION_IS_GEQ(4,13,0) */
-
-#endif /* __BP_BUILD_BUG_H */
diff --git a/backport/backport-include/linux/cache.h b/backport/backport-include/linux/cache.h
deleted file mode 100644
index bd7cdcfc..00000000
--- a/backport/backport-include/linux/cache.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _BACKPORT_CACHE_H
-#define _BACKPORT_CACHE_H
-
-#include_next <linux/cache.h>
-
-#ifndef __ro_after_init
-#define __ro_after_init
-#endif
-
-#endif /* _BACKPORT_CACHE_H */
diff --git a/backport/backport-include/linux/clk.h b/backport/backport-include/linux/clk.h
deleted file mode 100644
index 62d9218b..00000000
--- a/backport/backport-include/linux/clk.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef __BACKPORT_LINUX_CLK_H
-#define __BACKPORT_LINUX_CLK_H
-#include_next <linux/clk.h>
-#include <linux/version.h>
-
-/*
- * commit 93abe8e4 - we only backport the non CONFIG_COMMON_CLK
- * case as the CONFIG_COMMON_CLK case requires arch support. By
- * using the backport_ namespace for older kernels we force usage
- * of these helpers and that's required given that 3.5 added some
- * of these helpers expecting a few exported symbols for the non
- * CONFIG_COMMON_CLK case. The 3.5 kernel is not supported as
- * per kernel.org so we don't send a fix upstream for that.
- */
-#if LINUX_VERSION_IS_LESS(3,6,0)
-
-#ifndef CONFIG_COMMON_CLK
-
-/*
- * Whoopsie!
- *
- * clk_enable() and clk_disable() have been left without
- * a nop export symbols when !CONFIG_COMMON_CLK since its
- * introduction on v2.6.16, but fixed until 3.6.
- */
-#if 0
-#define clk_enable LINUX_BACKPORT(clk_enable)
-static inline int clk_enable(struct clk *clk)
-{
- return 0;
-}
-
-#define clk_disable LINUX_BACKPORT(clk_disable)
-static inline void clk_disable(struct clk *clk) {}
-#endif
-
-
-#define clk_get LINUX_BACKPORT(clk_get)
-static inline struct clk *clk_get(struct device *dev, const char *id)
-{
- return NULL;
-}
-
-#define devm_clk_get LINUX_BACKPORT(devm_clk_get)
-static inline struct clk *devm_clk_get(struct device *dev, const char *id)
-{
- return NULL;
-}
-
-#define clk_put LINUX_BACKPORT(clk_put)
-static inline void clk_put(struct clk *clk) {}
-
-#define devm_clk_put LINUX_BACKPORT(devm_clk_put)
-static inline void devm_clk_put(struct device *dev, struct clk *clk) {}
-
-#define clk_get_rate LINUX_BACKPORT(clk_get_rate)
-static inline unsigned long clk_get_rate(struct clk *clk)
-{
- return 0;
-}
-
-#define clk_set_rate LINUX_BACKPORT(clk_set_rate)
-static inline int clk_set_rate(struct clk *clk, unsigned long rate)
-{
- return 0;
-}
-
-#define clk_round_rate LINUX_BACKPORT(clk_round_rate)
-static inline long clk_round_rate(struct clk *clk, unsigned long rate)
-{
- return 0;
-}
-
-#define clk_set_parent LINUX_BACKPORT(clk_set_parent)
-static inline int clk_set_parent(struct clk *clk, struct clk *parent)
-{
- return 0;
-}
-
-#define clk_get_parent LINUX_BACKPORT(clk_get_parent)
-static inline struct clk *clk_get_parent(struct clk *clk)
-{
- return NULL;
-}
-#endif /* CONFIG_COMMON_CLK */
-
-#endif /* #if LINUX_VERSION_IS_LESS(3,0,0) */
-
-#if LINUX_VERSION_IS_LESS(3,3,0) && \
- LINUX_VERSION_IS_GEQ(3,2,0)
-#define clk_prepare_enable LINUX_BACKPORT(clk_prepare_enable)
-/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
-static inline int clk_prepare_enable(struct clk *clk)
-{
- int ret;
-
- ret = clk_prepare(clk);
- if (ret)
- return ret;
- ret = clk_enable(clk);
- if (ret)
- clk_unprepare(clk);
-
- return ret;
-}
-
-#define clk_disable_unprepare LINUX_BACKPORT(clk_disable_unprepare)
-/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
-static inline void clk_disable_unprepare(struct clk *clk)
-{
- clk_disable(clk);
- clk_unprepare(clk);
-}
-#endif /* < 3,3,0 && >= 3,2,0 */
-
-#endif /* __LINUX_CLK_H */
diff --git a/backport/backport-include/linux/compat.h b/backport/backport-include/linux/compat.h
deleted file mode 100644
index f41ee5e6..00000000
--- a/backport/backport-include/linux/compat.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_COMPAT_H
-#define __BACKPORT_COMPAT_H
-
-#include_next <linux/compat.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-#ifdef CONFIG_X86_X32_ABI
-#define COMPAT_USE_64BIT_TIME \
- (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
-#else
-#define COMPAT_USE_64BIT_TIME 0
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-#define compat_put_timespec LINUX_BACKPORT(compat_put_timespec)
-extern int compat_put_timespec(const struct timespec *, void __user *);
-#endif
-
-#endif /* __BACKPORT_COMPAT_H */
diff --git a/backport/backport-include/linux/compiler-gcc5.h b/backport/backport-include/linux/compiler-gcc5.h
deleted file mode 100644
index 9ff99f0d..00000000
--- a/backport/backport-include/linux/compiler-gcc5.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/compiler-gccN.h>
diff --git a/backport/backport-include/linux/compiler-gcc6.h b/backport/backport-include/linux/compiler-gcc6.h
deleted file mode 100644
index 9ff99f0d..00000000
--- a/backport/backport-include/linux/compiler-gcc6.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/compiler-gccN.h>
diff --git a/backport/backport-include/linux/compiler-gcc7.h b/backport/backport-include/linux/compiler-gcc7.h
deleted file mode 100644
index 9ff99f0d..00000000
--- a/backport/backport-include/linux/compiler-gcc7.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <linux/compiler-gccN.h>
diff --git a/backport/backport-include/linux/compiler-gccN.h b/backport/backport-include/linux/compiler-gccN.h
deleted file mode 100644
index 97e7541d..00000000
--- a/backport/backport-include/linux/compiler-gccN.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* gcc version specific checks */
-
-#ifndef GCC_VERSION
-#define GCC_VERSION (__GNUC__ * 10000 \
- + __GNUC_MINOR__ * 100 \
- + __GNUC_PATCHLEVEL__)
-#endif
-
-#if GCC_VERSION < 30200
-# error Sorry, your compiler is too old - please upgrade it.
-#endif
-
-#if GCC_VERSION < 30300
-# define __used __attribute__((__unused__))
-#else
-# define __used __attribute__((__used__))
-#endif
-
-#ifdef CONFIG_GCOV_KERNEL
-# if GCC_VERSION < 30400
-# error "GCOV profiling support for gcc versions below 3.4 not included"
-# endif /* __GNUC_MINOR__ */
-#endif /* CONFIG_GCOV_KERNEL */
-
-#if GCC_VERSION >= 30400
-#define __must_check __attribute__((warn_unused_result))
-#endif
-
-#if GCC_VERSION >= 40000
-
-/* GCC 4.1.[01] miscompiles __weak */
-#ifdef __KERNEL__
-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
-# error Your version of gcc miscompiles the __weak directive
-# endif
-#endif
-
-#define __used __attribute__((__used__))
-#define __compiler_offsetof(a, b) \
- __builtin_offsetof(a, b)
-
-#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
-# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
-#endif
-
-#if GCC_VERSION >= 40300
-/* Mark functions as cold. gcc will assume any path leading to a call
- * to them will be unlikely. This means a lot of manual unlikely()s
- * are unnecessary now for any paths leading to the usual suspects
- * like BUG(), printk(), panic() etc. [but let's keep them for now for
- * older compilers]
- *
- * Early snapshots of gcc 4.3 don't support this and we can't detect this
- * in the preprocessor, but we can live with this because they're unreleased.
- * Maketime probing would be overkill here.
- *
- * gcc also has a __attribute__((__hot__)) to move hot functions into
- * a special section, but I don't see any sense in this right now in
- * the kernel context
- */
-#define __cold __attribute__((__cold__))
-
-#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
-
-#ifndef __CHECKER__
-# define __compiletime_warning(message) __attribute__((warning(message)))
-# define __compiletime_error(message) __attribute__((error(message)))
-#endif /* __CHECKER__ */
-#endif /* GCC_VERSION >= 40300 */
-
-#if GCC_VERSION >= 40500
-/*
- * Mark a position in code as unreachable. This can be used to
- * suppress control flow warnings after asm blocks that transfer
- * control elsewhere.
- *
- * Early snapshots of gcc 4.5 don't support this and we can't detect
- * this in the preprocessor, but we can live with this because they're
- * unreleased. Really, we need to have autoconf for the kernel.
- */
-#define unreachable() __builtin_unreachable()
-
-/* Mark a function definition as prohibited from being cloned. */
-#define __noclone __attribute__((__noclone__))
-
-#endif /* GCC_VERSION >= 40500 */
-
-#if GCC_VERSION >= 40600
-/*
- * Tell the optimizer that something else uses this function or variable.
- */
-#define __visible __attribute__((externally_visible))
-#endif
-
-/*
- * GCC 'asm goto' miscompiles certain code sequences:
- *
- * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
- *
- * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
- *
- * (asm goto is automatically volatile - the naming reflects this.)
- */
-#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
-
-#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
-#if GCC_VERSION >= 40400
-#define __HAVE_BUILTIN_BSWAP32__
-#define __HAVE_BUILTIN_BSWAP64__
-#endif
-#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600)
-#define __HAVE_BUILTIN_BSWAP16__
-#endif
-#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
-
-#if GCC_VERSION >= 50000
-#define KASAN_ABI_VERSION 4
-#elif GCC_VERSION >= 40902
-#define KASAN_ABI_VERSION 3
-#endif
-
-#endif /* gcc version >= 40000 specific checks */
-
-#ifndef OPTIMIZER_HIDE_VAR
-#define OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "=r" (var) : "0" (var))
-#endif
diff --git a/backport/backport-include/linux/compiler.h b/backport/backport-include/linux/compiler.h
deleted file mode 100644
index 53c069df..00000000
--- a/backport/backport-include/linux/compiler.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __BACKPORT_LINUX_COMPILER_H
-#define __BACKPORT_LINUX_COMPILER_H
-#include_next <linux/compiler.h>
-
-#ifndef __rcu
-#define __rcu
-#endif
-
-#ifndef __always_unused
-#ifdef __GNUC__
-#define __always_unused __attribute__((unused))
-#else
-#define __always_unused /* unimplemented */
-#endif
-#endif
-
-#ifndef __PASTE
-/* Indirect macros required for expanded argument pasting, eg. __LINE__. */
-#define ___PASTE(a,b) a##b
-#define __PASTE(a,b) ___PASTE(a,b)
-#endif
-
-/* Not-quite-unique ID. */
-#ifndef __UNIQUE_ID
-# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__)
-#endif
-
-#ifndef barrier_data
-#ifdef __GNUC__
-#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
-#else /* __GNUC__ */
-# define barrier_data(ptr) barrier()
-#endif /* __GNUC__ */
-#endif
-
-#ifndef READ_ONCE
-#include <linux/types.h>
-
-#define __READ_ONCE_SIZE \
-({ \
- switch (size) { \
- case 1: *(__u8 *)res = *(volatile __u8 *)p; break; \
- case 2: *(__u16 *)res = *(volatile __u16 *)p; break; \
- case 4: *(__u32 *)res = *(volatile __u32 *)p; break; \
- case 8: *(__u64 *)res = *(volatile __u64 *)p; break; \
- default: \
- barrier(); \
- __builtin_memcpy((void *)res, (const void *)p, size); \
- barrier(); \
- } \
-})
-
-static __always_inline
-void __read_once_size(const volatile void *p, void *res, int size)
-{
- __READ_ONCE_SIZE;
-}
-
-#define __READ_ONCE(x, check) \
-({ \
- union { typeof(x) __val; char __c[1]; } __u; \
- __read_once_size(&(x), __u.__c, sizeof(x)); \
- __u.__val; \
-})
-
-#define READ_ONCE(x) __READ_ONCE(x, 1)
-
-static __always_inline void __write_once_size(volatile void *p, void *res, int size)
-{
- switch (size) {
- case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
- case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
- case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
- case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
- default:
- barrier();
- __builtin_memcpy((void *)p, (const void *)res, size);
- barrier();
- }
-}
-
-#define WRITE_ONCE(x, val) \
-({ \
- union { typeof(x) __val; char __c[1]; } __u = \
- { .__val = (__force typeof(x)) (val) }; \
- __write_once_size(&(x), __u.__c, sizeof(x)); \
- __u.__val; \
-})
-#endif
-
-#ifndef OPTIMIZER_HIDE_VAR
-#define OPTIMIZER_HIDE_VAR(var) barrier()
-#endif
-
-#endif /* __BACKPORT_LINUX_COMPILER_H */
diff --git a/backport/backport-include/linux/completion.h b/backport/backport-include/linux/completion.h
deleted file mode 100644
index f8ce5b1f..00000000
--- a/backport/backport-include/linux/completion.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_COMPLETION_H
-#define __BACKPORT_COMPLETION_H
-#include_next <linux/completion.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-/**
- * reinit_completion - reinitialize a completion structure
- * @x: pointer to completion structure that is to be reinitialized
- *
- * This inline function should be used to reinitialize a completion structure so it can
- * be reused. This is especially important after complete_all() is used.
- */
-#define reinit_completion LINUX_BACKPORT(reinit_completion)
-static inline void reinit_completion(struct completion *x)
-{
- x->done = 0;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) */
-
-#endif /* __BACKPORT_COMPLETION_H */
diff --git a/backport/backport-include/linux/cordic.h b/backport/backport-include/linux/cordic.h
deleted file mode 100644
index 67d6a4ae..00000000
--- a/backport/backport-include/linux/cordic.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef _BACKPORT_LINUX_CORDIC_H
-#define _BACKPORT_LINUX_CORDIC_H 1
-
-#include <linux/version.h>
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
-#include_next <linux/cordic.h>
-#else
-
-/*
- * Copyright (c) 2011 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#ifndef __CORDIC_H_
-#define __CORDIC_H_
-
-#include <linux/types.h>
-
-/**
- * struct cordic_iq - i/q coordinate.
- *
- * @i: real part of coordinate (in phase).
- * @q: imaginary part of coordinate (quadrature).
- */
-struct cordic_iq {
- s32 i;
- s32 q;
-};
-
-/**
- * cordic_calc_iq() - calculates the i/q coordinate for given angle.
- *
- * @theta: angle in degrees for which i/q coordinate is to be calculated.
- * @coord: function output parameter holding the i/q coordinate.
- *
- * The function calculates the i/q coordinate for a given angle using
- * cordic algorithm. The coordinate consists of a real (i) and an
- * imaginary (q) part. The real part is essentially the cosine of the
- * angle and the imaginary part is the sine of the angle. The returned
- * values are scaled by 2^16 for precision. The range for theta is
- * for -180 degrees to +180 degrees. Passed values outside this range are
- * converted before doing the actual calculation.
- */
-#define cordic_calc_iq LINUX_BACKPORT(cordic_calc_iq)
-struct cordic_iq cordic_calc_iq(s32 theta);
-
-#endif /* __CORDIC_H_ */
-#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) */
-
-#ifndef CORDIC_FLOAT
-#define CORDIC_ANGLE_GEN 39797
-#define CORDIC_PRECISION_SHIFT 16
-#define CORDIC_NUM_ITER (CORDIC_PRECISION_SHIFT + 2)
-
-#define CORDIC_FIXED(X) ((s32)((X) << CORDIC_PRECISION_SHIFT))
-#define CORDIC_FLOAT(X) (((X) >= 0) \
- ? ((((X) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1) \
- : -((((-(X)) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1))
-#endif
-
-#endif /* _BACKPORT_LINUX_CORDIC_H */
diff --git a/backport/backport-include/linux/crc7.h b/backport/backport-include/linux/crc7.h
deleted file mode 100644
index 50706ea9..00000000
--- a/backport/backport-include/linux/crc7.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _BACKPORT_LINUX_CRC7_H
-#define _BACKPORT_LINUX_CRC7_H
-#include_next <linux/crc7.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,16,0)
-#define crc7_be LINUX_BACKPORT(crc7_be)
-static inline u8 crc7_be(u8 crc, const u8 *buffer, size_t len)
-{
- return crc7(crc, buffer, len) << 1;
-}
-#endif /* < 3.16 */
-
-#endif /* _BACKPORT_LINUX_CRC7_H */
diff --git a/backport/backport-include/linux/debugfs.h b/backport/backport-include/linux/debugfs.h
deleted file mode 100644
index fb50c4f5..00000000
--- a/backport/backport-include/linux/debugfs.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef __BACKPORT_DEBUGFS_H_
-#define __BACKPORT_DEBUGFS_H_
-#include_next <linux/debugfs.h>
-#include <linux/version.h>
-#include <linux/device.h>
-#include <generated/utsrelease.h>
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define debugfs_create_devm_seqfile LINUX_BACKPORT(debugfs_create_devm_seqfile)
-#if defined(CONFIG_DEBUG_FS)
-struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
- struct dentry *parent,
- int (*read_fn)(struct seq_file *s,
- void *data));
-#else
-static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
- const char *name,
- struct dentry *parent,
- int (*read_fn)(struct seq_file *s,
- void *data))
-{
- return ERR_PTR(-ENODEV);
-}
-#endif /* CONFIG_DEBUG_FS */
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#if LINUX_VERSION_IS_LESS(4,4,0)
-#define debugfs_create_bool LINUX_BACKPORT(debugfs_create_bool)
-#ifdef CONFIG_DEBUG_FS
-struct dentry *debugfs_create_bool(const char *name, umode_t mode,
- struct dentry *parent, bool *value);
-#else
-static inline struct dentry *
-debugfs_create_bool(const char *name, umode_t mode,
- struct dentry *parent, bool *value)
-{
- return ERR_PTR(-ENODEV);
-}
-#endif
-#endif /* LINUX_VERSION_IS_LESS(4,4,0) */
-
-#if LINUX_VERSION_IS_LESS(4,9,0) && \
- !LINUX_VERSION_IN_RANGE(4,8,4, 4,9,0) && \
- !LINUX_VERSION_IN_RANGE(4,7,10, 4,8,0)
-static inline const struct file_operations *
-debugfs_real_fops(const struct file *filp)
-{
- /*
- * Neither the pointer to the struct file_operations, nor its
- * contents ever change -- srcu_dereference() is not needed here.
- */
- return filp->f_path.dentry->d_fsdata;
-}
-#endif /* <4.9.0 but not >= 4.8.4, 4.7.10 */
-
-#ifndef DEFINE_DEBUGFS_ATTRIBUTE
-#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
- DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)
-#define debugfs_create_file_unsafe(name, mode, parent, data, fops) \
- debugfs_create_file(name, mode, parent, data, fops)
-#endif
-
-#endif /* __BACKPORT_DEBUGFS_H_ */
diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h
deleted file mode 100644
index 8f282ca6..00000000
--- a/backport/backport-include/linux/device.h
+++ /dev/null
@@ -1,280 +0,0 @@
-#ifndef __BACKPORT_DEVICE_H
-#define __BACKPORT_DEVICE_H
-#include <linux/export.h>
-#include_next <linux/device.h>
-
-#include <linux/version.h>
-
-/*
- * string.h is usually included from the asm/ folder in most configuration,
- * but on some older kernels it doesn't. As we're using memcpy() in the code
- * below, we need to be safe and make sure string.h is indeed there.
- */
-#include <linux/string.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/* backport
- * commit 9f3b795a626ee79574595e06d1437fe0c7d51d29
- * Author: Michał Mirosław <mirq-linux@rere.qmqm.pl>
- * Date: Fri Feb 1 20:40:17 2013 +0100
- *
- * driver-core: constify data for class_find_device()
- */
-typedef int (backport_device_find_function_t)(struct device *, void *);
-#define class_find_device(cls, start, idx, fun) \
- class_find_device((cls), (start), (void *)(idx),\
- (backport_device_find_function_t *)(fun))
-#endif
-
-#ifndef module_driver
-/**
- * module_driver() - Helper macro for drivers that don't do anything
- * special in module init/exit. This eliminates a lot of boilerplate.
- * Each module may only use this macro once, and calling it replaces
- * module_init() and module_exit().
- *
- * Use this macro to construct bus specific macros for registering
- * drivers, and do not use it on its own.
- */
-#define module_driver(__driver, __register, __unregister) \
-static int __init __driver##_init(void) \
-{ \
- return __register(&(__driver)); \
-} \
-module_init(__driver##_init); \
-static void __exit __driver##_exit(void) \
-{ \
- __unregister(&(__driver)); \
-} \
-module_exit(__driver##_exit);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define devm_ioremap_resource LINUX_BACKPORT(devm_ioremap_resource)
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,5,0) && \
- LINUX_VERSION_IS_GEQ(3,2,0)
-#define devres_release LINUX_BACKPORT(devres_release)
-extern int devres_release(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-#include <linux/ratelimit.h>
-
-#define dev_level_ratelimited(dev_level, dev, fmt, ...) \
-do { \
- static DEFINE_RATELIMIT_STATE(_rs, \
- DEFAULT_RATELIMIT_INTERVAL, \
- DEFAULT_RATELIMIT_BURST); \
- if (__ratelimit(&_rs)) \
- dev_level(dev, fmt, ##__VA_ARGS__); \
-} while (0)
-
-#define dev_emerg_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
-#define dev_alert_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
-#define dev_crit_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__)
-#define dev_err_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__)
-#define dev_warn_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__)
-#define dev_notice_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
-#define dev_info_ratelimited(dev, fmt, ...) \
- dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
-
-
-#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
-#define dev_dbg_ratelimited(dev, fmt, ...) \
-do { \
- static DEFINE_RATELIMIT_STATE(_rs, \
- DEFAULT_RATELIMIT_INTERVAL, \
- DEFAULT_RATELIMIT_BURST); \
- DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
- if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
- __ratelimit(&_rs)) \
- __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
- ##__VA_ARGS__); \
-} while (0)
-#else
-#define dev_dbg_ratelimited(dev, fmt, ...) \
- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* dynamic debug */
-#endif /* <= 3.5 */
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0)
-static inline void
-backport_device_release_driver(struct device *dev)
-{
- device_release_driver(dev);
- device_lock(dev);
- dev_set_drvdata(dev, NULL);
- device_unlock(dev);
-}
-#define device_release_driver LINUX_BACKPORT(device_release_driver)
-
-#define kobj_to_dev LINUX_BACKPORT(kobj_to_dev)
-static inline struct device *kobj_to_dev(struct kobject *kobj)
-{
- return container_of(kobj, struct device, kobj);
-}
-#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-int devm_add_action(struct device *dev, void (*action) (void *), void *data);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,11,0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7,0)
-#ifndef DEVICE_ATTR_RO
-#define DEVICE_ATTR_RO(_name) \
-struct device_attribute dev_attr_ ## _name = __ATTR_RO(_name);
-#endif
-#ifndef DEVICE_ATTR_RW
-#define DEVICE_ATTR_RW(_name) \
-struct device_attribute dev_attr_ ## _name = __ATTR_RW(_name)
-#endif
-#endif
-
-#ifndef CLASS_ATTR_RW
-#define CLASS_ATTR_RW(_name) \
- struct class_attribute class_attr_##_name = __ATTR_RW(_name)
-#endif
-#ifndef CLASS_ATTR_RO
-#define CLASS_ATTR_RO(_name) \
- struct class_attribute class_attr_##_name = __ATTR_RO(_name)
-#endif
-
-#define ATTRIBUTE_GROUPS_BACKPORT(_name) \
-static struct BP_ATTR_GRP_STRUCT _name##_dev_attrs[ARRAY_SIZE(_name##_attrs)];\
-static void init_##_name##_attrs(void) \
-{ \
- int i; \
- for (i = 0; _name##_attrs[i]; i++) \
- _name##_dev_attrs[i] = \
- *container_of(_name##_attrs[i], \
- struct BP_ATTR_GRP_STRUCT, \
- attr); \
-}
-
-#ifndef __ATTRIBUTE_GROUPS
-#define __ATTRIBUTE_GROUPS(_name) \
-static const struct attribute_group *_name##_groups[] = { \
- &_name##_group, \
- NULL, \
-}
-#endif /* __ATTRIBUTE_GROUPS */
-
-#undef ATTRIBUTE_GROUPS
-#define ATTRIBUTE_GROUPS(_name) \
-static const struct attribute_group _name##_group = { \
- .attrs = _name##_attrs, \
-}; \
-static inline void init_##_name##_attrs(void) {} \
-__ATTRIBUTE_GROUPS(_name)
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#define devm_kmalloc(dev, size, flags) devm_kzalloc(dev, size, flags)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-#define devm_kstrdup LINUX_BACKPORT(devm_kstrdup)
-extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#define devm_kmalloc_array LINUX_BACKPORT(devm_kmalloc_array)
-static inline void *devm_kmalloc_array(struct device *dev,
- size_t n, size_t size, gfp_t flags)
-{
- if (size != 0 && n > SIZE_MAX / size)
- return NULL;
- return devm_kmalloc(dev, n * size, flags);
-}
-
-#define devm_kcalloc LINUX_BACKPORT(devm_kcalloc)
-static inline void *devm_kcalloc(struct device *dev,
- size_t n, size_t size, gfp_t flags)
-{
- return devm_kmalloc_array(dev, n, size, flags);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,16,0)
-#define devm_kmemdup LINUX_BACKPORT(devm_kmemdup)
-static inline void *devm_kmemdup(struct device *dev, const void *src,
- size_t len, gfp_t gfp)
-{
- void *p;
-
- p = devm_kmalloc(dev, len, gfp);
- if (p)
- memcpy(p, src, len);
-
- return p;
-}
-#endif
-
-#ifndef dev_level_once
-#ifdef CONFIG_PRINTK
-#define dev_level_once(dev_level, dev, fmt, ...) \
-do { \
- static bool __print_once __read_mostly; \
- \
- if (!__print_once) { \
- __print_once = true; \
- dev_level(dev, fmt, ##__VA_ARGS__); \
- } \
-} while (0)
-#else
-#define dev_level_once(dev_level, dev, fmt, ...) \
-do { \
- if (0) \
- dev_level(dev, fmt, ##__VA_ARGS__); \
-} while (0)
-#endif
-
-#define dev_emerg_once(dev, fmt, ...) \
- dev_level_once(dev_emerg, dev, fmt, ##__VA_ARGS__)
-#define dev_alert_once(dev, fmt, ...) \
- dev_level_once(dev_alert, dev, fmt, ##__VA_ARGS__)
-#define dev_crit_once(dev, fmt, ...) \
- dev_level_once(dev_crit, dev, fmt, ##__VA_ARGS__)
-#define dev_err_once(dev, fmt, ...) \
- dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__)
-#define dev_warn_once(dev, fmt, ...) \
- dev_level_once(dev_warn, dev, fmt, ##__VA_ARGS__)
-#define dev_notice_once(dev, fmt, ...) \
- dev_level_once(dev_notice, dev, fmt, ##__VA_ARGS__)
-#define dev_info_once(dev, fmt, ...) \
- dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__)
-#define dev_dbg_once(dev, fmt, ...) \
- dev_level_once(dev_dbg, dev, fmt, ##__VA_ARGS__)
-#endif /* dev_level_once */
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#define devm_kvasprintf LINUX_BACKPORT(devm_kvasprintf)
-extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
- va_list ap);
-#define devm_kasprintf LINUX_BACKPORT(devm_kasprintf)
-extern char *devm_kasprintf(struct device *dev, gfp_t gfp,
- const char *fmt, ...);
-#endif /* < 3.17 */
-
-#if LINUX_VERSION_IS_LESS(4, 1, 0)
-#define dev_of_node LINUX_BACKPORT(dev_of_node)
-static inline struct device_node *dev_of_node(struct device *dev)
-{
-#ifndef CONFIG_OF
- return NULL;
-#else
- return dev->of_node;
-#endif
-}
-#endif
-
-#endif /* __BACKPORT_DEVICE_H */
diff --git a/backport/backport-include/linux/dma-buf.h b/backport/backport-include/linux/dma-buf.h
deleted file mode 100644
index ef1d0d3d..00000000
--- a/backport/backport-include/linux/dma-buf.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef _BACKPORT_DMA_BUF_H__
-#define _BACKPORT_DMA_BUF_H__
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,3,0)
-#include_next <linux/dma-buf.h>
-#endif /* LINUX_VERSION_IS_GEQ(3,3,0) */
-#include <linux/dma-direction.h>
-#include <linux/dma-attrs.h>
-#include <linux/dma-mapping.h>
-
-#if !defined(DEFINE_DMA_BUF_EXPORT_INFO) && LINUX_VERSION_IS_GEQ(3,3,0)
-/**
- * helper macro for exporters; zeros and fills in most common values
- */
-#define DEFINE_DMA_BUF_EXPORT_INFO(a) \
- struct dma_buf_export_info a = { .exp_name = KBUILD_MODNAME }
-
-struct dma_buf_export_info {
- const char *exp_name;
- const struct dma_buf_ops *ops;
- size_t size;
- int flags;
- struct reservation_object *resv;
- void *priv;
-};
-
-#ifdef dma_buf_export
-#undef dma_buf_export
-#endif
-
-static inline
-struct dma_buf *backport_dma_buf_export(const struct dma_buf_export_info *exp_info)
-{
-#if LINUX_VERSION_IS_LESS(3,4,0)
- return dma_buf_export(exp_info->priv,
- (struct dma_buf_ops *)exp_info->ops,
- exp_info->size, exp_info->flags);
-#elif LINUX_VERSION_IS_LESS(3,10,0)
- return dma_buf_export(exp_info->priv, exp_info->ops,
- exp_info->size, exp_info->flags);
-#elif LINUX_VERSION_IS_LESS(3,17,0)
- return dma_buf_export_named(exp_info->priv, exp_info->ops,
- exp_info->size, exp_info->flags,
- exp_info->exp_name);
-#else
- return dma_buf_export_named(exp_info->priv, exp_info->ops,
- exp_info->size, exp_info->flags,
- exp_info->exp_name, exp_info->resv);
-#endif
-}
-#define dma_buf_export LINUX_BACKPORT(dma_buf_export)
-#endif /* !defined(DEFINE_DMA_BUF_EXPORT_INFO) */
-
-#endif /* _BACKPORT_DMA_BUF_H__ */
diff --git a/backport/backport-include/linux/dma-mapping.h b/backport/backport-include/linux/dma-mapping.h
deleted file mode 100644
index 16b0e3c6..00000000
--- a/backport/backport-include/linux/dma-mapping.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __BACKPORT_LINUX_DMA_MAPPING_H
-#define __BACKPORT_LINUX_DMA_MAPPING_H
-#include_next <linux/dma-mapping.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#define dma_zalloc_coherent LINUX_BACKPORT(dma_zalloc_coherent)
-static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
- dma_addr_t *dma_handle, gfp_t flag)
-{
- void *ret = dma_alloc_coherent(dev, size, dma_handle, flag);
- if (ret)
- memset(ret, 0, size);
- return ret;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-/*
- * Set both the DMA mask and the coherent DMA mask to the same thing.
- * Note that we don't check the return value from dma_set_coherent_mask()
- * as the DMA API guarantees that the coherent DMA mask can be set to
- * the same or smaller than the streaming DMA mask.
- */
-#define dma_set_mask_and_coherent LINUX_BACKPORT(dma_set_mask_and_coherent)
-static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
-{
- int rc = dma_set_mask(dev, mask);
- if (rc == 0)
- dma_set_coherent_mask(dev, mask);
- return rc;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) */
-
-#endif /* __BACKPORT_LINUX_DMA_MAPPING_H */
diff --git a/backport/backport-include/linux/dynamic_debug.h b/backport/backport-include/linux/dynamic_debug.h
deleted file mode 100644
index 1ff204be..00000000
--- a/backport/backport-include/linux/dynamic_debug.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __BACKPORT_LINUX_DYNAMIC_DEBUG_H
-#define __BACKPORT_LINUX_DYNAMIC_DEBUG_H
-#include <linux/version.h>
-#include_next <linux/dynamic_debug.h>
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-/* backports 07613b0b */
-#if defined(CONFIG_DYNAMIC_DEBUG)
-#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4))
-#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
- static struct _ddebug __used __aligned(8) \
- __attribute__((section("__verbose"))) name = { \
- .modname = KBUILD_MODNAME, \
- .function = __func__, \
- .filename = __FILE__, \
- .format = (fmt), \
- .lineno = __LINE__, \
- .flags = _DPRINTK_FLAGS_DEFAULT, \
- .enabled = false, \
- }
-#else
-#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
- static struct _ddebug __used __aligned(8) \
- __attribute__((section("__verbose"))) name = { \
- .modname = KBUILD_MODNAME, \
- .function = __func__, \
- .filename = __FILE__, \
- .format = (fmt), \
- .lineno = __LINE__, \
- .flags = _DPRINTK_FLAGS_DEFAULT, \
- }
-#endif /* RHEL_RELEASE_CODE < 6.4 */
-#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
-#endif /* < 3.2 */
-
-#endif /* __BACKPORT_LINUX_DYNAMIC_DEBUG_H */
diff --git a/backport/backport-include/linux/eeprom_93cx6.h b/backport/backport-include/linux/eeprom_93cx6.h
deleted file mode 100644
index 3385a3fb..00000000
--- a/backport/backport-include/linux/eeprom_93cx6.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _COMPAT_LINUX_EEPROM_93CX6_H
-#define _COMPAT_LINUX_EEPROM_93CX6_H 1
-
-#include_next <linux/eeprom_93cx6.h>
-
-#ifndef PCI_EEPROM_WIDTH_93C86
-#define PCI_EEPROM_WIDTH_93C86 8
-#endif /* PCI_EEPROM_WIDTH_93C86 */
-
-#endif /* _COMPAT_LINUX_EEPROM_93CX6_H */
diff --git a/backport/backport-include/linux/err.h b/backport/backport-include/linux/err.h
deleted file mode 100644
index d08968e5..00000000
--- a/backport/backport-include/linux/err.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_LINUX_ERR_H
-#define __BACKPORT_LINUX_ERR_H
-#include_next <linux/err.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,12,0)
-#define PTR_ERR_OR_ZERO(p) PTR_RET(p)
-#endif
-
-#endif /* __BACKPORT_LINUX_ERR_H */
diff --git a/backport/backport-include/linux/etherdevice.h b/backport/backport-include/linux/etherdevice.h
deleted file mode 100644
index a00e6660..00000000
--- a/backport/backport-include/linux/etherdevice.h
+++ /dev/null
@@ -1,230 +0,0 @@
-#ifndef _BACKPORT_LINUX_ETHERDEVICE_H
-#define _BACKPORT_LINUX_ETHERDEVICE_H
-#include_next <linux/etherdevice.h>
-#include <linux/version.h>
-/*
- * newer kernels include this already and some
- * users rely on getting this indirectly
- */
-#include <asm/unaligned.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random)
-static inline void eth_hw_addr_random(struct net_device *dev)
-{
- dev->addr_assign_type |= NET_ADDR_RANDOM;
- random_ether_addr(dev->dev_addr);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,6,0)
-#include <linux/random.h>
-/**
- * eth_broadcast_addr - Assign broadcast address
- * @addr: Pointer to a six-byte array containing the Ethernet address
- *
- * Assign the broadcast address to the given address array.
- */
-#define eth_broadcast_addr LINUX_BACKPORT(eth_broadcast_addr)
-static inline void eth_broadcast_addr(u8 *addr)
-{
- memset(addr, 0xff, ETH_ALEN);
-}
-
-/**
- * eth_random_addr - Generate software assigned random Ethernet address
- * @addr: Pointer to a six-byte array containing the Ethernet address
- *
- * Generate a random Ethernet address (MAC) that is not multicast
- * and has the local assigned bit set.
- */
-#define eth_random_addr LINUX_BACKPORT(eth_random_addr)
-static inline void eth_random_addr(u8 *addr)
-{
- get_random_bytes(addr, ETH_ALEN);
- addr[0] &= 0xfe; /* clear multicast bit */
- addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
-}
-#endif /* LINUX_VERSION_IS_LESS(3,6,0) */
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-
-/* This backports:
- *
- * commit 6d57e9078e880a3dd232d579f42ac437a8f1ef7b
- * Author: Duan Jiong <djduanjiong@gmail.com>
- * Date: Sat Sep 8 16:32:28 2012 +0000
- *
- * etherdevice: introduce help function eth_zero_addr()
- */
-#define eth_zero_addr LINUX_BACKPORT(eth_zero_addr)
-static inline void eth_zero_addr(u8 *addr)
-{
- memset(addr, 0x00, ETH_ALEN);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-#define ether_addr_equal LINUX_BACKPORT(ether_addr_equal)
-static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
-{
- return !compare_ether_addr(addr1, addr2);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define eth_prepare_mac_addr_change LINUX_BACKPORT(eth_prepare_mac_addr_change)
-extern int eth_prepare_mac_addr_change(struct net_device *dev, void *p);
-
-#define eth_commit_mac_addr_change LINUX_BACKPORT(eth_commit_mac_addr_change)
-extern void eth_commit_mac_addr_change(struct net_device *dev, void *p);
-#endif /* < 3.9 */
-
-#if LINUX_VERSION_IS_LESS(3,12,0)
-/**
- * eth_hw_addr_inherit - Copy dev_addr from another net_device
- * @dst: pointer to net_device to copy dev_addr to
- * @src: pointer to net_device to copy dev_addr from
- *
- * Copy the Ethernet address from one net_device to another along with
- * the address attributes (addr_assign_type).
- */
-static inline void eth_hw_addr_inherit(struct net_device *dst,
- struct net_device *src)
-{
- dst->addr_assign_type = src->addr_assign_type;
- memcpy(dst->dev_addr, src->dev_addr, ETH_ALEN);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) */
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-/**
- * ether_addr_equal_64bits - Compare two Ethernet addresses
- * @addr1: Pointer to an array of 8 bytes
- * @addr2: Pointer to an other array of 8 bytes
- *
- * Compare two Ethernet addresses, returns true if equal, false otherwise.
- *
- * The function doesn't need any conditional branches and possibly uses
- * word memory accesses on CPU allowing cheap unaligned memory reads.
- * arrays = { byte1, byte2, byte3, byte4, byte5, byte6, pad1, pad2 }
- *
- * Please note that alignment of addr1 & addr2 are only guaranteed to be 16 bits.
- */
-#define ether_addr_equal_64bits LINUX_BACKPORT(ether_addr_equal_64bits)
-static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
- const u8 addr2[6+2])
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
- u64 fold = (*(const u64 *)addr1) ^ (*(const u64 *)addr2);
-
-#ifdef __BIG_ENDIAN
- return (fold >> 16) == 0;
-#else
- return (fold << 16) == 0;
-#endif
-#else
- return ether_addr_equal(addr1, addr2);
-#endif
-}
-#endif /* LINUX_VERSION_IS_LESS(3,5,0) */
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-/**
- * ether_addr_equal_unaligned - Compare two not u16 aligned Ethernet addresses
- * @addr1: Pointer to a six-byte array containing the Ethernet address
- * @addr2: Pointer other six-byte array containing the Ethernet address
- *
- * Compare two Ethernet addresses, returns true if equal
- *
- * Please note: Use only when any Ethernet address may not be u16 aligned.
- */
-#define ether_addr_equal_unaligned LINUX_BACKPORT(ether_addr_equal_unaligned)
-static inline bool ether_addr_equal_unaligned(const u8 *addr1, const u8 *addr2)
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
- return ether_addr_equal(addr1, addr2);
-#else
- return memcmp(addr1, addr2, ETH_ALEN) == 0;
-#endif
-}
-
-/**
- * ether_addr_copy - Copy an Ethernet address
- * @dst: Pointer to a six-byte array Ethernet address destination
- * @src: Pointer to a six-byte array Ethernet address source
- *
- * Please note: dst & src must both be aligned to u16.
- */
-#define ether_addr_copy LINUX_BACKPORT(ether_addr_copy)
-static inline void ether_addr_copy(u8 *dst, const u8 *src)
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
- *(u32 *)dst = *(const u32 *)src;
- *(u16 *)(dst + 4) = *(const u16 *)(src + 4);
-#else
- u16 *a = (u16 *)dst;
- const u16 *b = (const u16 *)src;
-
- a[0] = b[0];
- a[1] = b[1];
- a[2] = b[2];
-#endif
-}
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#define eth_get_headlen LINUX_BACKPORT(eth_get_headlen)
-int eth_get_headlen(unsigned char *data, unsigned int max_len);
-#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define eth_skb_pad LINUX_BACKPORT(eth_skb_pad)
-/**
- * eth_skb_pad - Pad buffer to mininum number of octets for Ethernet frame
- * @skb: Buffer to pad
- *
- * An Ethernet frame should have a minimum size of 60 bytes. This function
- * takes short frames and pads them with zeros up to the 60 byte limit.
- */
-static inline int eth_skb_pad(struct sk_buff *skb)
-{
- return skb_put_padto(skb, ETH_ZLEN);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#if LINUX_VERSION_IS_LESS(4,11,0)
-/**
- * ether_addr_to_u64 - Convert an Ethernet address into a u64 value.
- * @addr: Pointer to a six-byte array containing the Ethernet address
- *
- * Return a u64 value of the address
- */
-static inline u64 ether_addr_to_u64(const u8 *addr)
-{
- u64 u = 0;
- int i;
-
- for (i = 0; i < ETH_ALEN; i++)
- u = u << 8 | addr[i];
-
- return u;
-}
-
-/**
- * u64_to_ether_addr - Convert a u64 to an Ethernet address.
- * @u: u64 to convert to an Ethernet MAC address
- * @addr: Pointer to a six-byte array to contain the Ethernet address
- */
-static inline void u64_to_ether_addr(u64 u, u8 *addr)
-{
- int i;
-
- for (i = ETH_ALEN - 1; i >= 0; i--) {
- addr[i] = u & 0xff;
- u = u >> 8;
- }
-}
-#endif /* LINUX_VERSION_IS_LESS(4,11,0) */
-
-#endif /* _BACKPORT_LINUX_ETHERDEVICE_H */
diff --git a/backport/backport-include/linux/ethtool.h b/backport/backport-include/linux/ethtool.h
deleted file mode 100644
index 7a78bb59..00000000
--- a/backport/backport-include/linux/ethtool.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_LINUX_ETHTOOL_H
-#define __BACKPORT_LINUX_ETHTOOL_H
-#include_next <linux/ethtool.h>
-#include <linux/version.h>
-
-#ifndef SPEED_UNKNOWN
-#define SPEED_UNKNOWN -1
-#endif /* SPEED_UNKNOWN */
-
-#ifndef DUPLEX_UNKNOWN
-#define DUPLEX_UNKNOWN 0xff
-#endif /* DUPLEX_UNKNOWN */
-
-#ifndef ETHTOOL_FWVERS_LEN
-#define ETHTOOL_FWVERS_LEN 32
-#endif
-
-#endif /* __BACKPORT_LINUX_ETHTOOL_H */
diff --git a/backport/backport-include/linux/eventpoll.h b/backport/backport-include/linux/eventpoll.h
deleted file mode 100644
index 7cc87aa0..00000000
--- a/backport/backport-include/linux/eventpoll.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __BACKPORT_LINUX_EVENTPOLL_H
-#define __BACKPORT_LINUX_EVENTPOLL_H
-#include_next <linux/eventpoll.h>
-
-#ifndef EPOLLIN
-#define EPOLLIN 0x00000001
-#endif
-
-#ifndef EPOLLPRI
-#define EPOLLPRI 0x00000002
-#endif
-
-#ifndef EPOLLOUT
-#define EPOLLOUT 0x00000004
-#endif
-
-#ifndef EPOLLERR
-#define EPOLLERR 0x00000008
-#endif
-
-#ifndef EPOLLHUP
-#define EPOLLHUP 0x00000010
-#endif
-
-#ifndef EPOLLRDNORM
-#define EPOLLRDNORM 0x00000040
-#endif
-
-#ifndef EPOLLRDBAND
-#define EPOLLRDBAND 0x00000080
-#endif
-
-#ifndef EPOLLWRNORM
-#define EPOLLWRNORM 0x00000100
-#endif
-
-#ifndef EPOLLWRBAND
-#define EPOLLWRBAND 0x00000200
-#endif
-
-#ifndef EPOLLMSG
-#define EPOLLMSG 0x00000400
-#endif
-
-#ifndef EPOLLRDHUP
-#define EPOLLRDHUP 0x00002000
-#endif
-
-#endif /* __BACKPORT_LINUX_EVENTPOLL_H */
diff --git a/backport/backport-include/linux/export.h b/backport/backport-include/linux/export.h
deleted file mode 100644
index a3c7799a..00000000
--- a/backport/backport-include/linux/export.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _COMPAT_LINUX_EXPORT_H
-#define _COMPAT_LINUX_EXPORT_H 1
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,1,0)
-#include_next <linux/export.h>
-#else
-#ifndef pr_fmt
-#define backport_undef_pr_fmt
-#endif
-#include <linux/module.h>
-#ifdef backport_undef_pr_fmt
-#undef pr_fmt
-#undef backport_undef_pr_fmt
-#endif
-#endif /* LINUX_VERSION_IS_GEQ(3,1,0) */
-
-#endif /* _COMPAT_LINUX_EXPORT_H */
diff --git a/backport/backport-include/linux/firmware.h b/backport/backport-include/linux/firmware.h
deleted file mode 100644
index b5bc16be..00000000
--- a/backport/backport-include/linux/firmware.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __BACKPORT_LINUX_FIRMWARE_H
-#define __BACKPORT_LINUX_FIRMWARE_H
-#include_next <linux/firmware.h>
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-#define request_firmware_direct(fw, name, device) request_firmware(fw, name, device)
-#endif
-#if LINUX_VERSION_IS_LESS(4,18,0)
-#define firmware_request_nowarn(fw, name, device) request_firmware(fw, name, device)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,17,0)
-#define firmware_request_cache LINUX_BACKPORT(firmware_request_cache)
-static inline int firmware_request_cache(struct device *device, const char *name)
-{
- return 0;
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_FIRMWARE_H */
diff --git a/backport/backport-include/linux/freezer.h b/backport/backport-include/linux/freezer.h
deleted file mode 100644
index c6053f30..00000000
--- a/backport/backport-include/linux/freezer.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __BACKPORT_FREEZER_H_INCLUDED
-#define __BACKPORT_FREEZER_H_INCLUDED
-#include_next <linux/freezer.h>
-
-#ifdef CONFIG_FREEZER
-#if LINUX_VERSION_IS_LESS(3,11,0)
-/*
- * Like schedule_hrtimeout_range(), but should not block the freezer. Do not
- * call this with locks held.
- */
-#define freezable_schedule_hrtimeout_range LINUX_BACKPORT(freezable_schedule_hrtimeout_range)
-static inline int freezable_schedule_hrtimeout_range(ktime_t *expires,
- unsigned long delta, const enum hrtimer_mode mode)
-{
- int __retval;
- freezer_do_not_count();
- __retval = schedule_hrtimeout_range(expires, delta, mode);
- freezer_count();
- return __retval;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,11,0) */
-
-#else /* !CONFIG_FREEZER */
-
-#ifndef freezable_schedule_hrtimeout_range
-#define freezable_schedule_hrtimeout_range(expires, delta, mode) \
- schedule_hrtimeout_range(expires, delta, mode)
-#endif
-
-#endif /* !CONFIG_FREEZER */
-
-#endif /* __BACKPORT_FREEZER_H_INCLUDED */
diff --git a/backport/backport-include/linux/fs.h b/backport/backport-include/linux/fs.h
deleted file mode 100644
index 6e4d4a53..00000000
--- a/backport/backport-include/linux/fs.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef _COMPAT_LINUX_FS_H
-#define _COMPAT_LINUX_FS_H
-#include_next <linux/fs.h>
-#include <linux/version.h>
-/*
- * some versions don't have this and thus don't
- * include it from the original fs.h
- */
-#include <linux/uidgid.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-#define simple_open LINUX_BACKPORT(simple_open)
-extern int simple_open(struct inode *inode, struct file *file);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/**
- * backport of:
- *
- * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
- * Author: Al Viro <viro@zeniv.linux.org.uk>
- * Date: Wed Jan 23 17:07:38 2013 -0500
- *
- * new helper: file_inode(file)
- */
-static inline struct inode *file_inode(struct file *f)
-{
- return f->f_path.dentry->d_inode;
-}
-#endif
-
-#ifndef replace_fops
-/*
- * This one is to be used *ONLY* from ->open() instances.
- * fops must be non-NULL, pinned down *and* module dependencies
- * should be sufficient to pin the caller down as well.
- */
-#define replace_fops(f, fops) \
- do { \
- struct file *__file = (f); \
- fops_put(__file->f_op); \
- BUG_ON(!(__file->f_op = (fops))); \
- } while(0)
-#endif /* replace_fops */
-
-#if (LINUX_VERSION_IS_LESS(4,5,0) && \
- LINUX_VERSION_IS_GEQ(3,2,0))
-#define no_seek_end_llseek LINUX_BACKPORT(no_seek_end_llseek)
-extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
-#endif /* < 4.5 && >= 3.2 */
-
-#endif /* _COMPAT_LINUX_FS_H */
diff --git a/backport/backport-include/linux/ftrace_event.h b/backport/backport-include/linux/ftrace_event.h
deleted file mode 100644
index edea21ee..00000000
--- a/backport/backport-include/linux/ftrace_event.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_LINUX_FTRACE_EVENT_H
-#define __BACKPORT_LINUX_FTRACE_EVENT_H
-#include_next <linux/ftrace_event.h>
-
-#if LINUX_VERSION_IS_LESS(4,0,0)
-const char *ftrace_print_array_seq(struct trace_seq *p,
- const void *buf, int buf_len,
- size_t el_size);
-#endif
-#endif /* __BACKPORT_LINUX_FTRACE_EVENT_H */
diff --git a/backport/backport-include/linux/genetlink.h b/backport/backport-include/linux/genetlink.h
deleted file mode 100644
index afd1f678..00000000
--- a/backport/backport-include/linux/genetlink.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_LINUX_GENETLINK_H
-#define __BACKPORT_LINUX_GENETLINK_H
-#include_next <linux/genetlink.h>
-
-/* This backports:
- *
- * commit e9412c37082b5c932e83364aaed0c38c2ce33acb
- * Author: Neil Horman <nhorman@tuxdriver.com>
- * Date: Tue May 29 09:30:41 2012 +0000
- *
- * genetlink: Build a generic netlink family module alias
- */
-#ifndef MODULE_ALIAS_GENL_FAMILY
-#define MODULE_ALIAS_GENL_FAMILY(family)\
- MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
-#endif
-
-#endif /* __BACKPORT_LINUX_GENETLINK_H */
diff --git a/backport/backport-include/linux/gfp.h b/backport/backport-include/linux/gfp.h
deleted file mode 100644
index d41d4277..00000000
--- a/backport/backport-include/linux/gfp.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __BACKPORT_LINUX_GFP_H
-#define __BACKPORT_LINUX_GFP_H
-#include_next <linux/gfp.h>
-
-#ifndef ___GFP_KSWAPD_RECLAIM
-#define ___GFP_KSWAPD_RECLAIM 0x0u
-#endif
-
-#ifndef __GFP_KSWAPD_RECLAIM
-#define __GFP_KSWAPD_RECLAIM ((__force gfp_t)___GFP_KSWAPD_RECLAIM) /* kswapd can wake */
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,10,0) && LINUX_VERSION_IS_GEQ(4,2,0)
-#define page_frag_alloc LINUX_BACKPORT(page_frag_alloc)
-static inline void *page_frag_alloc(struct page_frag_cache *nc,
- unsigned int fragsz, gfp_t gfp_mask)
-{
- return __alloc_page_frag(nc, fragsz, gfp_mask);
-}
-
-#define __page_frag_cache_drain LINUX_BACKPORT(__page_frag_cache_drain)
-void __page_frag_cache_drain(struct page *page, unsigned int count);
-#endif /* < 4.10 && >= 4.2 */
-
-#endif /* __BACKPORT_LINUX_GFP_H */
diff --git a/backport/backport-include/linux/gpio.h b/backport/backport-include/linux/gpio.h
deleted file mode 100644
index ef4a8f18..00000000
--- a/backport/backport-include/linux/gpio.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __BACKPORT_LINUX_GPIO_H
-#define __BACKPORT_LINUX_GPIO_H
-#include_next <linux/gpio.h>
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-#define devm_gpio_request_one LINUX_BACKPORT(devm_gpio_request_one)
-#define devm_gpio_request LINUX_BACKPORT(devm_gpio_request)
-#ifdef CONFIG_GPIOLIB
-int devm_gpio_request(struct device *dev, unsigned gpio, const char *label);
-int devm_gpio_request_one(struct device *dev, unsigned gpio,
- unsigned long flags, const char *label);
-void devm_gpio_free(struct device *dev, unsigned int gpio);
-#else
-static inline int devm_gpio_request(struct device *dev, unsigned gpio,
- const char *label)
-{
- WARN_ON(1);
- return -EINVAL;
-}
-
-static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
- unsigned long flags, const char *label)
-{
- WARN_ON(1);
- return -EINVAL;
-}
-
-static inline void devm_gpio_free(struct device *dev, unsigned int gpio)
-{
- WARN_ON(1);
-}
-#endif /* CONFIG_GPIOLIB */
-#endif
-
-#endif /* __BACKPORT_LINUX_GPIO_H */
diff --git a/backport/backport-include/linux/gpio/driver.h b/backport/backport-include/linux/gpio/driver.h
deleted file mode 100644
index 8df5c298..00000000
--- a/backport/backport-include/linux/gpio/driver.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BP_GPIO_DRIVER_H
-#define __BP_GPIO_DRIVER_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#include <asm-generic/gpio.h>
-#else
-#include_next <linux/gpio/driver.h>
-#endif
-
-#endif /* __BP_GPIO_DRIVER_H */
diff --git a/backport/backport-include/linux/hashtable.h b/backport/backport-include/linux/hashtable.h
deleted file mode 100644
index 33314dc5..00000000
--- a/backport/backport-include/linux/hashtable.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __BACKPORT_HASHTABLE_H
-#define __BACKPORT_HASHTABLE_H
-#include_next <linux/hashtable.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/**
- * backport:
- *
- * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
- * Author: Sasha Levin <sasha.levin@oracle.com>
- * Date: Thu Feb 7 12:32:18 2013 +1100
- *
- * hlist: drop the node parameter from iterators
- */
-#include <linux/list.h>
-#include <backport/magic.h>
-
-#undef hash_for_each
-#define hash_for_each(name, bkt, obj, member) \
- for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
- (bkt)++)\
- hlist_for_each_entry(obj, &name[bkt], member)
-
-#undef hash_for_each_safe
-#define hash_for_each_safe(name, bkt, tmp, obj, member) \
- for ((bkt) = 0, obj = NULL; obj == NULL && (bkt) < HASH_SIZE(name);\
- (bkt)++)\
- hlist_for_each_entry_safe(obj, tmp, &name[bkt], member)
-
-#undef hash_for_each_possible
-#define hash_for_each_possible(name, obj, member, key) \
- hlist_for_each_entry(obj, &name[hash_min(key, HASH_BITS(name))], member)
-
-#undef hash_for_each_possible_safe
-#define hash_for_each_possible_safe(name, obj, tmp, member, key) \
- hlist_for_each_entry_safe(obj, tmp,\
- &name[hash_min(key, HASH_BITS(name))], member)
-
-#endif
-
-#endif /* __BACKPORT_HASHTABLE_H */
diff --git a/backport/backport-include/linux/hid.h b/backport/backport-include/linux/hid.h
deleted file mode 100644
index 887c6b15..00000000
--- a/backport/backport-include/linux/hid.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef __BACKPORT_HID_H
-#define __BACKPORT_HID_H
-#include_next <linux/hid.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,8,0)
-#define hid_ignore LINUX_BACKPORT(hid_ignore)
-extern bool hid_ignore(struct hid_device *);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define HID_TYPE_USBNONE 2
-#endif
-
-#ifndef HID_QUIRK_NO_IGNORE
-#define HID_QUIRK_NO_IGNORE 0x40000000
-#endif
-
-#ifndef HID_QUIRK_HIDDEV_FORCE
-#define HID_QUIRK_HIDDEV_FORCE 0x00000010
-#endif
-
-#ifndef HID_QUIRK_IGNORE
-#define HID_QUIRK_IGNORE 0x00000004
-#endif
-
-#ifndef HID_USB_DEVICE
-#define HID_USB_DEVICE(ven, prod) \
- .bus = BUS_USB, .vendor = (ven), .product = (prod)
-#endif
-
-#ifndef HID_BLUETOOTH_DEVICE
-#define HID_BLUETOOTH_DEVICE(ven, prod) \
- .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod)
-#endif
-
-#ifndef hid_printk
-#define hid_printk(level, hid, fmt, arg...) \
- dev_printk(level, &(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_emerg
-#define hid_emerg(hid, fmt, arg...) \
- dev_emerg(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_crit
-#define hid_crit(hid, fmt, arg...) \
- dev_crit(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_alert
-#define hid_alert(hid, fmt, arg...) \
- dev_alert(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_err
-#define hid_err(hid, fmt, arg...) \
- dev_err(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_notice
-#define hid_notice(hid, fmt, arg...) \
- dev_notice(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_warn
-#define hid_warn(hid, fmt, arg...) \
- dev_warn(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_info
-#define hid_info(hid, fmt, arg...) \
- dev_info(&(hid)->dev, fmt, ##arg)
-#endif
-
-#ifndef hid_dbg
-#define hid_dbg(hid, fmt, arg...) \
- dev_dbg(&(hid)->dev, fmt, ##arg)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,12,0)
-#define hid_alloc_report_buf LINUX_BACKPORT(hid_alloc_report_buf)
-u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
-#endif
-
-#endif /* __BACKPORT_HID_H */
diff --git a/backport/backport-include/linux/hrtimer.h b/backport/backport-include/linux/hrtimer.h
deleted file mode 100644
index 2c186dd1..00000000
--- a/backport/backport-include/linux/hrtimer.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_LINUX_HRTIMER_H
-#define __BACKPORT_LINUX_HRTIMER_H
-#include_next <linux/hrtimer.h>
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-u64 bp_ktime_divns(const ktime_t kt, s64 div);
-#define ktime_divns bp_ktime_divns
-#endif /* < 3.17 */
-
-#endif /* __BACKPORT_LINUX_HRTIMER_H */
diff --git a/backport/backport-include/linux/hwmon.h b/backport/backport-include/linux/hwmon.h
deleted file mode 100644
index 3b61b268..00000000
--- a/backport/backport-include/linux/hwmon.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __BACKPORT_LINUX_HWMON_H
-#define __BACKPORT_LINUX_HWMON_H
-#include_next <linux/hwmon.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-/*
- * Backports
- *
- * commit bab2243ce1897865e31ea6d59b0478391f51812b
- * Author: Guenter Roeck <linux@roeck-us.net>
- * Date: Sat Jul 6 13:57:23 2013 -0700
- *
- * hwmon: Introduce hwmon_device_register_with_groups
- *
- * hwmon_device_register_with_groups() lets callers register a hwmon device
- * together with all sysfs attributes in a single call.
- *
- * When using hwmon_device_register_with_groups(), hwmon attributes are attached
- * to the hwmon device directly and no longer with its parent device.
- *
- * Signed-off-by: Guenter Roeck <linux@roeck-us.net>
- */
-struct device *
-hwmon_device_register_with_groups(struct device *dev, const char *name,
- void *drvdata,
- const struct attribute_group **groups);
-struct device *
-devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
- void *drvdata,
- const struct attribute_group **groups);
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) */
-
-#endif /* __BACKPORT_LINUX_HWMON_H */
diff --git a/backport/backport-include/linux/i2c-mux.h b/backport/backport-include/linux/i2c-mux.h
deleted file mode 100644
index d12658dc..00000000
--- a/backport/backport-include/linux/i2c-mux.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BACKPORT_LINUX_I2C_MUX_H
-#define __BACKPORT_LINUX_I2C_MUX_H
-#include_next <linux/i2c-mux.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-#define i2c_add_mux_adapter(parent, mux_dev, mux_priv, force_nr, chan_id, class, select, deselect) \
- i2c_add_mux_adapter(parent, mux_priv, force_nr, chan_id, select, deselect)
-#elif LINUX_VERSION_IS_LESS(3,7,0)
-#define i2c_add_mux_adapter(parent, mux_dev, mux_priv, force_nr, chan_id, class, select, deselect) \
- i2c_add_mux_adapter(parent, mux_dev, mux_priv, force_nr, chan_id, select, deselect)
-#endif
-
-#endif /* __BACKPORT_LINUX_I2C_MUX_H */
diff --git a/backport/backport-include/linux/i2c.h b/backport/backport-include/linux/i2c.h
deleted file mode 100644
index c8f7a8dc..00000000
--- a/backport/backport-include/linux/i2c.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __BACKPORT_LINUX_I2C_H
-#define __BACKPORT_LINUX_I2C_H
-#include_next <linux/i2c.h>
-#include <linux/version.h>
-
-/* This backports
- *
- * commit 14674e70119ea01549ce593d8901a797f8a90f74
- * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
- * Date: Wed May 30 10:55:34 2012 +0200
- *
- * i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING
- */
-#ifndef I2C_FUNC_NOSTART
-#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
-#endif
-
-/* This backports:
- *
- * commit 7c92784a546d2945b6d6973a30f7134be78eb7a4
- * Author: Lars-Peter Clausen <lars@metafoo.de>
- * Date: Wed Nov 16 10:13:36 2011 +0100
- *
- * I2C: Add helper macro for i2c_driver boilerplate
- */
-#ifndef module_i2c_driver
-#define module_i2c_driver(__i2c_driver) \
- module_driver(__i2c_driver, i2c_add_driver, \
- i2c_del_driver)
-#endif
-
-#ifndef I2C_CLIENT_SCCB
-#define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */
- /* Must match I2C_M_STOP|IGNORE_NAK */
-#endif
-
-#endif /* __BACKPORT_LINUX_I2C_H */
diff --git a/backport/backport-include/linux/idr.h b/backport/backport-include/linux/idr.h
deleted file mode 100644
index 01aa2c29..00000000
--- a/backport/backport-include/linux/idr.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef __BACKPORT_IDR_H
-#define __BACKPORT_IDR_H
-/* some versions have a broken idr header */
-#include <linux/spinlock.h>
-#include_next <linux/idr.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define ida_simple_get LINUX_BACKPORT(ida_simple_get)
-int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
- gfp_t gfp_mask);
-
-#define ida_simple_remove LINUX_BACKPORT(ida_simple_remove)
-void ida_simple_remove(struct ida *ida, unsigned int id);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#include <linux/errno.h>
-/**
- * backport of idr idr_alloc() usage
- *
- * This backports a patch series send by Tejun Heo:
- * https://lkml.org/lkml/2013/2/2/159
- */
-static inline void compat_idr_destroy(struct idr *idp)
-{
- idr_remove_all(idp);
- idr_destroy(idp);
-}
-#define idr_destroy(idp) compat_idr_destroy(idp)
-
-static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
- gfp_t gfp_mask)
-{
- int id, ret;
-
- do {
- if (!idr_pre_get(idr, gfp_mask))
- return -ENOMEM;
- ret = idr_get_new_above(idr, ptr, start, &id);
- if (!ret && id > end) {
- idr_remove(idr, id);
- ret = -ENOSPC;
- }
- } while (ret == -EAGAIN);
-
- return ret ? ret : id;
-}
-
-static inline void idr_preload(gfp_t gfp_mask)
-{
-}
-
-static inline void idr_preload_end(void)
-{
-}
-#endif
-
-#ifndef idr_for_each_entry
-#define idr_for_each_entry(idp, entry, id) \
- for (id = 0; ((entry) = idr_get_next(idp, &(id))) != NULL; ++id)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4, 11, 0)
-static inline void *backport_idr_remove(struct idr *idr, int id)
-{
- void *item = idr_find(idr, id);
- idr_remove(idr, id);
- return item;
-}
-#define idr_remove backport_idr_remove
-#endif
-
-#endif /* __BACKPORT_IDR_H */
diff --git a/backport/backport-include/linux/if_arp.h b/backport/backport-include/linux/if_arp.h
deleted file mode 100644
index b542423c..00000000
--- a/backport/backport-include/linux/if_arp.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _BACKPORTS_LINUX_AF_ARP_H
-#define _BACKPORTS_LINUX_AF_ARP_H 1
-
-#include_next <linux/if_arp.h>
-
-#ifndef ARPHRD_IEEE802154_MONITOR
-#define ARPHRD_IEEE802154_MONITOR 805 /* IEEE 802.15.4 network monitor */
-#endif
-
-#ifndef ARPHRD_6LOWPAN
-#define ARPHRD_6LOWPAN 825 /* IPv6 over LoWPAN */
-#endif
-
-#endif /* _BACKPORTS_LINUX_AF_ARP_H */
diff --git a/backport/backport-include/linux/if_ether.h b/backport/backport-include/linux/if_ether.h
deleted file mode 100644
index 344480a2..00000000
--- a/backport/backport-include/linux/if_ether.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __BACKPORT_IF_ETHER_H
-#define __BACKPORT_IF_ETHER_H
-#include_next <linux/if_ether.h>
-
-/* See commit b62faf3c in next-20140311 */
-#ifndef ETH_P_80221
-#define ETH_P_80221 0x8917 /* IEEE 802.21 Media Independent Handover Protocol */
-#endif
-
-/*
- * backport of:
- * commit e5c5d22e8dcf7c2d430336cbf8e180bd38e8daf1
- * Author: Simon Horman <horms@verge.net.au>
- * Date: Thu Mar 28 13:38:25 2013 +0900
- *
- * net: add ETH_P_802_3_MIN
- */
-#ifndef ETH_P_802_3_MIN
-#define ETH_P_802_3_MIN 0x0600
-#endif
-
-#ifndef ETH_P_TDLS
-#define ETH_P_TDLS 0x890D /* TDLS */
-#endif
-
-#ifndef ETH_P_LINK_CTL
-#define ETH_P_LINK_CTL 0x886c
-#endif
-
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif
-
-#ifndef ETH_P_TEB
-#define ETH_P_TEB 0x6558 /* Trans Ether Bridging */
-#endif
-
-#ifndef ETH_P_8021AD
-#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
-#endif
-
-#ifndef ETH_P_PREAUTH
-#define ETH_P_PREAUTH 0x88C7 /* 802.11 Preauthentication */
-#endif
-
-#ifndef ETH_MIN_MTU
-#define ETH_MIN_MTU 68
-#endif
-
-#ifndef ETH_MAX_MTU
-#define ETH_MAX_MTU 0xFFFFU
-#endif
-
-#endif /* __BACKPORT_IF_ETHER_H */
diff --git a/backport/backport-include/linux/if_vlan.h b/backport/backport-include/linux/if_vlan.h
deleted file mode 100644
index 18f63e80..00000000
--- a/backport/backport-include/linux/if_vlan.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __BACKPORT_LINUX_IF_VLAN_H_
-#define __BACKPORT_LINUX_IF_VLAN_H_
-#include_next <linux/if_vlan.h>
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-#define vlan_insert_tag(__skb, __vlan_proto, __vlan_tci) vlan_insert_tag(__skb, __vlan_tci)
-#define __vlan_put_tag(__skb, __vlan_proto, __vlan_tci) __vlan_put_tag(__skb, __vlan_tci)
-#define vlan_put_tag(__skb, __vlan_proto, __vlan_tci) vlan_put_tag(__skb, __vlan_tci)
-#define __vlan_hwaccel_put_tag(__skb, __vlan_proto, __vlan_tag) __vlan_hwaccel_put_tag(__skb, __vlan_tag)
-
-#define __vlan_find_dev_deep(__real_dev, __vlan_proto, __vlan_id) __vlan_find_dev_deep(__real_dev, __vlan_id)
-
-#endif
-
-#ifndef VLAN_PRIO_MASK
-#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */
-#endif
-
-#ifndef VLAN_PRIO_SHIFT
-#define VLAN_PRIO_SHIFT 13
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,16,0)
-#define __vlan_find_dev_deep_rcu(real_dev, vlan_proto, vlan_id) __vlan_find_dev_deep(real_dev, vlan_proto, vlan_id)
-#endif
-
-#ifndef skb_vlan_tag_present
-#define skb_vlan_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
-#endif
-
-#ifndef skb_vlan_tag_get
-#define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
-#endif
-
-#ifndef skb_vlan_tag_get_id
-#define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK)
-#endif
-
-#endif /* __BACKPORT_LINUX_IF_VLAN_H_ */
diff --git a/backport/backport-include/linux/init.h b/backport/backport-include/linux/init.h
deleted file mode 100644
index 3a122829..00000000
--- a/backport/backport-include/linux/init.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __BACKPORT_INIT_H
-#define __BACKPORT_INIT_H
-#include_next <linux/init.h>
-
-/*
- * Backports 312b1485fb509c9bc32eda28ad29537896658cb8
- * Author: Sam Ravnborg <sam@ravnborg.org>
- * Date: Mon Jan 28 20:21:15 2008 +0100
- *
- * Introduce new section reference annotations tags: __ref, __refdata, __refconst
- */
-#ifndef __ref
-#define __ref __init_refok
-#endif
-#ifndef __refdata
-#define __refdata __initdata_refok
-#endif
-
-#endif /* __BACKPORT_INIT_H */
diff --git a/backport/backport-include/linux/input.h b/backport/backport-include/linux/input.h
deleted file mode 100644
index 3442db0f..00000000
--- a/backport/backport-include/linux/input.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_INPUT_H
-#define __BACKPORT_INPUT_H
-#include_next <linux/input.h>
-
-#ifndef KEY_WIMAX
-#define KEY_WIMAX 246
-#endif
-
-#ifndef KEY_WPS_BUTTON
-#define KEY_WPS_BUTTON 0x211
-#endif
-
-#ifndef KEY_RFKILL
-#define KEY_RFKILL 247
-#endif
-
-#ifndef SW_RFKILL_ALL
-#define SW_RFKILL_ALL 0x03
-#endif
-
-#endif /* __BACKPORT_INPUT_H */
diff --git a/backport/backport-include/linux/interrupt.h b/backport/backport-include/linux/interrupt.h
deleted file mode 100644
index ad3cbf66..00000000
--- a/backport/backport-include/linux/interrupt.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _BP_LINUX_INTERRUPT_H
-#define _BP_LINUX_INTERRUPT_H
-#include <linux/version.h>
-#include_next <linux/interrupt.h>
-#include <linux/ktime.h>
-
-#if LINUX_VERSION_IS_LESS(4,10,0)
-static inline void backport_hrtimer_start(struct hrtimer *timer, s64 time,
- const enum hrtimer_mode mode)
-{
- ktime_t _time = { .tv64 = time };
- hrtimer_start(timer, _time, mode);
-}
-#define hrtimer_start LINUX_BACKPORT(hrtimer_start)
-#endif
-
-#endif /* _BP_LINUX_INTERRUPT_H */
diff --git a/backport/backport-include/linux/io.h b/backport/backport-include/linux/io.h
deleted file mode 100644
index 78ae4650..00000000
--- a/backport/backport-include/linux/io.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __BP_LINUX_IO_H
-#define __BP_LINUX_IO_H
-#include_next <linux/io.h>
-
-#ifndef IOMEM_ERR_PTR
-#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
-#endif
-
-#endif /* __BP_LINUX_IO_H */
diff --git a/backport/backport-include/linux/ioport.h b/backport/backport-include/linux/ioport.h
deleted file mode 100644
index 34244014..00000000
--- a/backport/backport-include/linux/ioport.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __BACKPORT_LINUX_IOPORT_H
-#define __BACKPORT_LINUX_IOPORT_H
-#include_next <linux/ioport.h>
-
-#ifndef IORESOURCE_REG
-#define IORESOURCE_REG 0x00000300
-#endif
-
-#endif /* __BACKPORT_LINUX_IOPORT_H */
diff --git a/backport/backport-include/linux/irq.h b/backport/backport-include/linux/irq.h
deleted file mode 100644
index e216f4f8..00000000
--- a/backport/backport-include/linux/irq.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __BACKPORT_LINUX_IRQ_H
-#define __BACKPORT_LINUX_IRQ_H
-#include_next <linux/irq.h>
-
-#ifdef CONFIG_HAVE_GENERIC_HARDIRQS
-#if LINUX_VERSION_IS_LESS(3,11,0)
-#define irq_get_trigger_type LINUX_BACKPORT(irq_get_trigger_type)
-static inline u32 irq_get_trigger_type(unsigned int irq)
-{
- struct irq_data *d = irq_get_irq_data(irq);
- return d ? irqd_get_trigger_type(d) : 0;
-}
-#endif
-#endif /* CONFIG_HAVE_GENERIC_HARDIRQS */
-
-#endif /* __BACKPORT_LINUX_IRQ_H */
diff --git a/backport/backport-include/linux/irqdomain.h b/backport/backport-include/linux/irqdomain.h
deleted file mode 100644
index 1878a29e..00000000
--- a/backport/backport-include/linux/irqdomain.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __BACKPORT_LINUX_IRQDOMAIN_H
-#define __BACKPORT_LINUX_IRQDOMAIN_H
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,1,0)
-#include_next <linux/irqdomain.h>
-#endif
-
-#endif /* __BACKPORT_LINUX_IRQDOMAIN_H */
diff --git a/backport/backport-include/linux/jiffies.h b/backport/backport-include/linux/jiffies.h
deleted file mode 100644
index bbadcc8c..00000000
--- a/backport/backport-include/linux/jiffies.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __BACKPORT_LNIUX_JIFFIES_H
-#define __BACKPORT_LNIUX_JIFFIES_H
-#include_next <linux/jiffies.h>
-
-#ifndef time_is_before_jiffies
-#define time_is_before_jiffies(a) time_after(jiffies, a)
-#endif
-
-#ifndef time_is_after_jiffies
-#define time_is_after_jiffies(a) time_before(jiffies, a)
-#endif
-
-#ifndef time_is_before_eq_jiffies
-#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
-#endif
-
-#ifndef time_is_after_eq_jiffies
-#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
-#endif
-
-/*
- * This function is available, but not exported in kernel < 3.17, add
- * an own version.
- */
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#define nsecs_to_jiffies LINUX_BACKPORT(nsecs_to_jiffies)
-extern unsigned long nsecs_to_jiffies(u64 n);
-#endif /* 3.17 */
-
-#endif /* __BACKPORT_LNIUX_JIFFIES_H */
diff --git a/backport/backport-include/linux/kconfig.h b/backport/backport-include/linux/kconfig.h
deleted file mode 100644
index d1faad9b..00000000
--- a/backport/backport-include/linux/kconfig.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __BACKPORT_LINUX_KCONFIG_H
-#define __BACKPORT_LINUX_KCONFIG_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,1,0)
-#include_next <linux/kconfig.h>
-#endif
-
-#ifndef __ARG_PLACEHOLDER_1
-#define __ARG_PLACEHOLDER_1 0,
-#define config_enabled(cfg) _config_enabled(cfg)
-#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
-#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
-#define ___config_enabled(__ignored, val, ...) val
-
-/*
- * 3.1 - 3.3 had a broken version of this, so undef
- * (they didn't have __ARG_PLACEHOLDER_1)
- */
-#undef IS_ENABLED
-#define IS_ENABLED(option) \
- (config_enabled(option) || config_enabled(option##_MODULE))
-#endif
-
-/*
- * Since 4.9 config_enabled has been removed in favor of __is_defined.
- */
-#ifndef config_enabled
-#define config_enabled(cfg) __is_defined(cfg)
-#endif
-
-#undef IS_BUILTIN
-#define IS_BUILTIN(option) config_enabled(option)
-
-#ifndef IS_REACHABLE
-/*
- * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled
- * code can call a function defined in code compiled based on CONFIG_FOO.
- * This is similar to IS_ENABLED(), but returns false when invoked from
- * built-in code when CONFIG_FOO is set to 'm'.
- */
-#define IS_REACHABLE(option) (config_enabled(option) || \
- (config_enabled(option##_MODULE) && config_enabled(MODULE)))
-#endif
-
-#endif
diff --git a/backport/backport-include/linux/kernel.h b/backport/backport-include/linux/kernel.h
deleted file mode 100644
index 332f1537..00000000
--- a/backport/backport-include/linux/kernel.h
+++ /dev/null
@@ -1,235 +0,0 @@
-#ifndef __BACKPORT_KERNEL_H
-#define __BACKPORT_KERNEL_H
-#include_next <linux/kernel.h>
-#if LINUX_VERSION_IS_GEQ(4,5,0)
-#include <linux/bug.h>
-#endif
-#include <linux/version.h>
-/*
- * some older kernels don't have this and thus don't
- * include it from kernel.h like new kernels
- */
-#include <linux/printk.h>
-
-/*
- * This backports:
- *
- * From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 2001
- * From: Xi Wang <xi.wang@gmail.com>
- * Date: Thu, 31 May 2012 16:26:04 -0700
- * Subject: [PATCH] introduce SIZE_MAX
- */
-#ifndef SIZE_MAX
-#define SIZE_MAX (~(size_t)0)
-#endif
-
-/* This backports:
- *
- * commit 36a26c69b4c70396ef569c3452690fba0c1dec08
- * Author: Nicholas Bellinger <nab@linux-iscsi.org>
- * Date: Tue Jul 26 00:35:26 2011 -0700
- *
- * kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
- */
-#ifndef DIV_ROUND_UP_ULL
-#define DIV_ROUND_UP_ULL(ll,d) \
- ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
-#endif
-
-#ifndef USHRT_MAX
-#define USHRT_MAX ((u16)(~0U))
-#endif
-
-#ifndef SHRT_MAX
-#define SHRT_MAX ((s16)(USHRT_MAX>>1))
-#endif
-
-#ifndef SHRT_MIN
-#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
-#endif
-
-#ifndef U8_MAX
-#define U8_MAX ((u8)~0U)
-#endif
-
-#ifndef S8_MAX
-#define S8_MAX ((s8)(U8_MAX>>1))
-#endif
-
-#ifndef S8_MIN
-#define S8_MIN ((s8)(-S8_MAX - 1))
-#endif
-
-#ifndef U16_MAX
-#define U16_MAX ((u16)~0U)
-#endif
-
-#ifndef S16_MAX
-#define S16_MAX ((s16)(U16_MAX>>1))
-#endif
-
-#ifndef S16_MIN
-#define S16_MIN ((s16)(-S16_MAX - 1))
-#endif
-
-#ifndef U32_MAX
-#define U32_MAX ((u32)~0U)
-#endif
-
-#ifndef S32_MAX
-#define S32_MAX ((s32)(U32_MAX>>1))
-#endif
-
-#ifndef S32_MIN
-#define S32_MIN ((s32)(-S32_MAX - 1))
-#endif
-
-#ifndef __round_mask
-#define __round_mask(x, y) ((__typeof__(x))((y)-1))
-#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
-#define round_down(x, y) ((x) & ~__round_mask(x, y))
-#endif
-
-#ifndef DIV_ROUND_CLOSEST
-#define DIV_ROUND_CLOSEST(x, divisor)( \
-{ \
- typeof(x) __x = x; \
- typeof(divisor) __d = divisor; \
- (((typeof(x))-1) > 0 || \
- ((typeof(divisor))-1) > 0 || (__x) > 0) ? \
- (((__x) + ((__d) / 2)) / (__d)) : \
- (((__x) - ((__d) / 2)) / (__d)); \
-} \
-)
-#endif
-
-#ifndef DIV_ROUND_CLOSEST_ULL
-#define DIV_ROUND_CLOSEST_ULL(x, divisor)( \
-{ \
- typeof(divisor) __d = divisor; \
- unsigned long long _tmp = (x) + (__d) / 2; \
- do_div(_tmp, __d); \
- _tmp; \
-} \
-)
-#endif
-
-#ifndef swap
-#define swap(a, b) \
- do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
-#endif
-
-#ifndef lower_32_bits
-#define lower_32_bits(n) ((u32)(n))
-#endif
-
-#ifndef clamp
-#define clamp(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(min) __min = (min); \
- typeof(max) __max = (max); \
- (void) (&__val == &__min); \
- (void) (&__val == &__max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-#endif
-
-#ifndef clamp_t
-#define clamp_t(type, val, min, max) ({ \
- type __val = (val); \
- type __min = (min); \
- type __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-#endif
-
-#ifndef clamp_val
-#define clamp_val(val, min, max) ({ \
- typeof(val) __val = (val); \
- typeof(val) __min = (min); \
- typeof(val) __max = (max); \
- __val = __val < __min ? __min: __val; \
- __val > __max ? __max: __val; })
-#endif
-
-#ifndef rounddown
-#define rounddown(x, y) ( \
-{ \
- typeof(x) __x = (x); \
- __x - (__x % (y)); \
-} \
-)
-#endif /* rounddown */
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#define hex_byte_pack pack_hex_byte
-
-/* kernels before 3.2 didn't have error checking for the function */
-#define hex2bin LINUX_BACKPORT(hex2bin)
-int __must_check hex2bin(u8 *dst, const char *src, size_t count);
-#endif /* < 3.2 */
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#undef clamp
-#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
-#endif /* < 3.18 */
-
-#if LINUX_VERSION_IS_LESS(4,6,0)
-#define kstrtobool LINUX_BACKPORT(kstrtobool)
-int __must_check kstrtobool(const char *s, bool *res);
-#define kstrtobool_from_user LINUX_BACKPORT(kstrtobool_from_user)
-int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool *res);
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-
-#undef abs
-/**
- * abs - return absolute value of an argument
- * @x: the value. If it is unsigned type, it is converted to signed type first.
- * char is treated as if it was signed (regardless of whether it really is)
- * but the macro's return type is preserved as char.
- *
- * Return: an absolute value of x.
- */
-#define abs(x) __abs_choose_expr(x, long long, \
- __abs_choose_expr(x, long, \
- __abs_choose_expr(x, int, \
- __abs_choose_expr(x, short, \
- __abs_choose_expr(x, char, \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(x), char), \
- (char)({ signed char __x = (x); __x<0?-__x:__x; }), \
- ((void)0)))))))
-
-#define __abs_choose_expr(x, type, other) __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(x), signed type) || \
- __builtin_types_compatible_p(typeof(x), unsigned type), \
- ({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
-
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
-{
- return (u32)(((u64) val * ep_ro) >> 32);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#define bin2hex LINUX_BACKPORT(bin2hex)
-extern char *bin2hex(char *dst, const void *src, size_t count);
-#endif
-
-#endif /* __BACKPORT_KERNEL_H */
-
-/*
- * We have to do this outside the include guard, because
- * out own header (linux/export.h) has to include kernel.h
- * indirectly (through module.h) and then undef's pr_fmt.
- * Then, when the real kernel.h gets included again, it's
- * not defined and we get problems ...
- */
-#ifndef pr_fmt
-#define pr_fmt(msg) msg
-#endif
diff --git a/backport/backport-include/linux/key.h b/backport/backport-include/linux/key.h
deleted file mode 100644
index e7abbf47..00000000
--- a/backport/backport-include/linux/key.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef __BP_KEY_H
-#define __BP_KEY_H
-#ifndef CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION
-#include_next <linux/key.h>
-#else
-#include <linux/types.h>
-#include <linux/refcount.h>
-#include <linux/list.h>
-#include <keys/asymmetric-type.h>
-
-typedef uint32_t key_perm_t;
-
-struct key {
- refcount_t refcount;
- const char *description;
- s32 serial;
- struct list_head list;
-
- struct asymmetric_key_ids kids;
- struct public_key *public_key;
- struct public_key_signature *sig;
-
- bool keyring;
-};
-
-typedef struct __key_reference_with_attributes *key_ref_t;
-
-static inline key_ref_t make_key_ref(const struct key *key,
- bool possession)
-{
- return (key_ref_t) ((unsigned long) key | possession);
-}
-
-static inline struct key *key_ref_to_ptr(const key_ref_t key_ref)
-{
- return (struct key *) ((unsigned long) key_ref & ~1UL);
-}
-
-#define key_put LINUX_BACKPORT(key_put)
-extern void key_put(struct key *key);
-
-static inline void key_ref_put(key_ref_t key_ref)
-{
- key_put(key_ref_to_ptr(key_ref));
-}
-
-#define key_create_or_update(keyring, type, desc, payload, plen, perm, flags) \
- bp_key_create_or_update(keyring, desc, payload, plen)
-
-extern key_ref_t bp_key_create_or_update(key_ref_t keyring,
- const char *description,
- const void *payload,
- size_t plen);
-
-#define keyring_alloc(desc, uid, gid, cred, perm, flags, restrict, dest) \
- bp_keyring_alloc();
-
-extern struct key *bp_keyring_alloc(void);
-
-static inline s32 key_serial(const struct key *key)
-{
- return key ? key->serial : 0;
-}
-
-#endif /* CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION */
-#endif /* __BP_KEY_H */
diff --git a/backport/backport-include/linux/kfifo.h b/backport/backport-include/linux/kfifo.h
deleted file mode 100644
index b4fda3c3..00000000
--- a/backport/backport-include/linux/kfifo.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef BACKPORT_LINUX_KFIFO_H
-#define BACKPORT_LINUX_KFIFO_H
-
-#include <linux/version.h>
-#include_next <linux/kfifo.h>
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#undef kfifo_put
-/**
- * kfifo_put - put data into the fifo
- * @fifo: address of the fifo to be used
- * @val: the data to be added
- *
- * This macro copies the given value into the fifo.
- * It returns 0 if the fifo was full. Otherwise it returns the number
- * processed elements.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these macro.
- */
-#define kfifo_put(fifo, val) \
-({ \
- typeof((fifo) + 1) __tmp = (fifo); \
- typeof((&val) + 1) __val = (&val); \
- unsigned int __ret; \
- const size_t __recsize = sizeof(*__tmp->rectype); \
- struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
- __dummy = (typeof(__val))NULL; \
- } \
- if (__recsize) \
- __ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
- __recsize); \
- else { \
- __ret = !kfifo_is_full(__tmp); \
- if (__ret) { \
- (__is_kfifo_ptr(__tmp) ? \
- ((typeof(__tmp->type))__kfifo->data) : \
- (__tmp->buf) \
- )[__kfifo->in & __tmp->kfifo.mask] = \
- *(typeof(__tmp->type))__val; \
- smp_wmb(); \
- __kfifo->in++; \
- } \
- } \
- __ret; \
-})
-#endif
-
-#endif /* BACKPORT_LINUX_KFIFO_H */
diff --git a/backport/backport-include/linux/kmemleak.h b/backport/backport-include/linux/kmemleak.h
deleted file mode 100644
index 9af3d670..00000000
--- a/backport/backport-include/linux/kmemleak.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef __BACKPORT_KMEMLEAK_H
-#define __BACKPORT_KMEMLEAK_H
-#include <linux/types.h>
-#include_next <linux/kmemleak.h>
-#endif /* __BACKPORT_KMEMLEAK_H */
diff --git a/backport/backport-include/linux/kref.h b/backport/backport-include/linux/kref.h
deleted file mode 100644
index 631488f5..00000000
--- a/backport/backport-include/linux/kref.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __BACKPORT_LINUX_KREF_H
-#define __BACKPORT_LINUX_KREF_H
-#include_next <linux/kref.h>
-
-#if LINUX_VERSION_IS_LESS(4,11,0)
-#include <linux/refcount.h>
-static inline unsigned int kref_read(const struct kref *kref)
-{
- return refcount_read((const refcount_t *)&kref->refcount);
-}
-#endif /* < 4.11 */
-
-#endif /* __BACKPORT_LINUX_KREF_H */
diff --git a/backport/backport-include/linux/ktime.h b/backport/backport-include/linux/ktime.h
deleted file mode 100644
index 94272968..00000000
--- a/backport/backport-include/linux/ktime.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_LINUX_KTIME_H
-#define __BACKPORT_LINUX_KTIME_H
-#include_next <linux/ktime.h>
-#include <linux/timekeeping.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#define ktime_get_raw LINUX_BACKPORT(ktime_get_raw)
-extern ktime_t ktime_get_raw(void);
-
-#endif /* < 3.17 */
-
-#ifndef ktime_to_timespec64
-/* Map the ktime_t to timespec conversion to ns_to_timespec function */
-#define ktime_to_timespec64(kt) ns_to_timespec64((kt).tv64)
-#endif
-
-#endif /* __BACKPORT_LINUX_KTIME_H */
diff --git a/backport/backport-include/linux/leds.h b/backport/backport-include/linux/leds.h
deleted file mode 100644
index b98f8a51..00000000
--- a/backport/backport-include/linux/leds.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef __BACKPORT_LINUX_LEDS_H
-#define __BACKPORT_LINUX_LEDS_H
-#include_next <linux/leds.h>
-#include <linux/version.h>
-
-#include <backport/leds-disabled.h>
-
-#ifndef CPTCFG_BPAUTO_BUILD_LEDS
-#if LINUX_VERSION_IS_LESS(3,6,0)
-/*
- * Backports
- *
- * commit 959d62fa865d2e616b61a509e1cc5b88741f065e
- * Author: Shuah Khan <shuahkhan@gmail.com>
- * Date: Thu Jun 14 04:34:30 2012 +0800
- *
- * leds: Rename led_brightness_set() to led_set_brightness()
- *
- * Rename leds external interface led_brightness_set() to led_set_brightness().
- * This is the second phase of the change to reduce confusion between the
- * leds internal and external interfaces that set brightness. With this change,
- * now the external interface is led_set_brightness(). The first phase renamed
- * the internal interface led_set_brightness() to __led_set_brightness().
- * There are no changes to the interface implementations.
- *
- * Signed-off-by: Shuah Khan <shuahkhan@gmail.com>
- * Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
- */
-#define led_set_brightness(_dev, _switch) led_brightness_set(_dev, _switch)
-#endif /* LINUX_VERSION_IS_LESS(3,6,0) */
-#endif /* CPTCFG_BPAUTO_BUILD_LEDS */
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-/*
- * There is no LINUX_BACKPORT() guard here because we want it to point to
- * the original function which is exported normally.
- */
-#ifdef CONFIG_LEDS_TRIGGERS
-extern void led_trigger_remove(struct led_classdev *led_cdev);
-#else
-static inline void led_trigger_remove(struct led_classdev *led_cdev) {}
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,5,0) && \
- LINUX_VERSION_IS_GEQ(3,19,0)
-#define led_set_brightness_sync LINUX_BACKPORT(led_set_brightness_sync)
-/**
- * led_set_brightness_sync - set LED brightness synchronously
- * @led_cdev: the LED to set
- * @brightness: the brightness to set it to
- *
- * Set an LED's brightness immediately. This function will block
- * the caller for the time required for accessing device registers,
- * and it can sleep.
- *
- * Returns: 0 on success or negative error value on failure
- */
-extern int led_set_brightness_sync(struct led_classdev *led_cdev,
- enum led_brightness value);
-#endif /* < 4.5 && >= 3.19 */
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define devm_led_trigger_register LINUX_BACKPORT(devm_led_trigger_register)
-extern int devm_led_trigger_register(struct device *dev,
- struct led_trigger *trigger);
-#endif /* < 4.5 */
-
-#endif /* __BACKPORT_LINUX_LEDS_H */
diff --git a/backport/backport-include/linux/list.h b/backport/backport-include/linux/list.h
deleted file mode 100644
index 13ab9762..00000000
--- a/backport/backport-include/linux/list.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef __BACKPORT_LIST_H
-#define __BACKPORT_LIST_H
-#include_next <linux/list.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/**
- * backport:
- *
- * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
- * Author: Sasha Levin <sasha.levin@oracle.com>
- * Date: Thu Feb 7 12:32:18 2013 +1100
- *
- * hlist: drop the node parameter from iterators
- */
-#include <backport/magic.h>
-
-#undef hlist_entry_safe
-#define hlist_entry_safe(ptr, type, member) \
- ({ typeof(ptr) ____ptr = (ptr); \
- ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
- })
-
-#define hlist_for_each_entry4(tpos, pos, head, member) \
- for (pos = (head)->first; \
- pos && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;});\
- pos = pos->next)
-
-#define hlist_for_each_entry_safe5(tpos, pos, n, head, member) \
- for (pos = (head)->first; \
- pos && ({ n = pos->next; 1; }) && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;});\
- pos = n)
-
-#define hlist_for_each_entry3(pos, head, member) \
- for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
- pos; \
- pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
-
-#define hlist_for_each_entry_safe4(pos, n, head, member) \
- for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
- pos && ({ n = pos->member.next; 1; }); \
- pos = hlist_entry_safe(n, typeof(*pos), member))
-
-#undef hlist_for_each_entry
-#define hlist_for_each_entry(...) \
- macro_dispatcher(hlist_for_each_entry, __VA_ARGS__)(__VA_ARGS__)
-#undef hlist_for_each_entry_safe
-#define hlist_for_each_entry_safe(...) \
- macro_dispatcher(hlist_for_each_entry_safe, __VA_ARGS__)(__VA_ARGS__)
-
-#endif
-
-#ifndef list_first_entry_or_null
-/**
- * list_first_entry_or_null - get the first element from a list
- * @ptr: the list head to take the element from.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- *
- * Note that if the list is empty, it returns NULL.
- */
-#define list_first_entry_or_null(ptr, type, member) \
- (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
-#endif /* list_first_entry_or_null */
-
-#ifndef list_next_entry
-/**
- * list_next_entry - get the next element in list
- * @pos: the type * to cursor
- * @member: the name of the list_struct within the struct.
- */
-#define list_next_entry(pos, member) \
- list_entry((pos)->member.next, typeof(*(pos)), member)
-#endif /* list_next_entry */
-
-#ifndef list_last_entry
-/**
- * list_last_entry - get the last element from a list
- * @ptr: the list head to take the element from.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- *
- * Note, that list is expected to be not empty.
- */
-#define list_last_entry(ptr, type, member) \
- list_entry((ptr)->prev, type, member)
-#endif
-
-#endif /* __BACKPORT_LIST_H */
diff --git a/backport/backport-include/linux/list_nulls.h b/backport/backport-include/linux/list_nulls.h
deleted file mode 100644
index ba28834f..00000000
--- a/backport/backport-include/linux/list_nulls.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __BACKPORT_LIST_NULLS
-#define __BACKPORT_LIST_NULLS
-#include_next <linux/list_nulls.h>
-
-#ifndef NULLS_MARKER
-#define NULLS_MARKER(value) (1UL | (((long)value) << 1))
-#endif
-
-#endif /* __BACKPORT_LIST_NULLS */
diff --git a/backport/backport-include/linux/lockdep.h b/backport/backport-include/linux/lockdep.h
deleted file mode 100644
index 5a5d0d0e..00000000
--- a/backport/backport-include/linux/lockdep.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __BACKPORT_LINUX_LOCKDEP_H
-#define __BACKPORT_LINUX_LOCKDEP_H
-#include_next <linux/lockdep.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#undef lockdep_assert_held
-#ifdef CONFIG_LOCKDEP
-#define lockdep_assert_held(l) do { \
- WARN_ON(debug_locks && !lockdep_is_held(l)); \
- } while (0)
-#else
-#define lockdep_assert_held(l) do { (void)(l); } while (0)
-#endif /* CONFIG_LOCKDEP */
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-#endif /* __BACKPORT_LINUX_LOCKDEP_H */
diff --git a/backport/backport-include/linux/math64.h b/backport/backport-include/linux/math64.h
deleted file mode 100644
index 4aeb0dfb..00000000
--- a/backport/backport-include/linux/math64.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __BACKPORT_LINUX_MATH64_H
-#define __BACKPORT_LINUX_MATH64_H
-#include_next <linux/math64.h>
-
-#if LINUX_VERSION_IS_LESS(3,12,0)
-
-#if BITS_PER_LONG == 64
-/**
- * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
- */
-#define div64_u64_rem LINUX_BACKPORT(div64_u64_rem)
-static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
-{
- *remainder = dividend % divisor;
- return dividend / divisor;
-}
-#elif BITS_PER_LONG == 32
-#ifndef div64_u64_rem
-#define div64_u64_rem LINUX_BACKPORT(div64_u64_rem)
-#define backports_div64_u64_rem_add 1
-extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
-#endif
-
-#endif /* BITS_PER_LONG */
-#endif /* < 3.12 */
-
-#endif /* __BACKPORT_LINUX_MATH64_H */
diff --git a/backport/backport-include/linux/mdio.h b/backport/backport-include/linux/mdio.h
deleted file mode 100644
index e12f4467..00000000
--- a/backport/backport-include/linux/mdio.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef __BACKPORT_LINUX_MDIO_H
-#define __BACKPORT_LINUX_MDIO_H
-#include_next <linux/mdio.h>
-
-#ifndef MDIO_EEE_100TX
-/* EEE Supported/Advertisement/LP Advertisement registers.
- *
- * EEE capability Register (3.20), Advertisement (7.60) and
- * Link partner ability (7.61) registers have and can use the same identical
- * bit masks.
- */
-#define MDIO_AN_EEE_ADV_100TX 0x0002 /* Advertise 100TX EEE cap */
-#define MDIO_AN_EEE_ADV_1000T 0x0004 /* Advertise 1000T EEE cap */
-/* Note: the two defines above can be potentially used by the user-land
- * and cannot remove them now.
- * So, we define the new generic MDIO_EEE_100TX and MDIO_EEE_1000T macros
- * using the previous ones (that can be considered obsolete).
- */
-#define MDIO_EEE_100TX MDIO_AN_EEE_ADV_100TX /* 100TX EEE cap */
-#define MDIO_EEE_1000T MDIO_AN_EEE_ADV_1000T /* 1000T EEE cap */
-#define MDIO_EEE_10GT 0x0008 /* 10GT EEE cap */
-#define MDIO_EEE_1000KX 0x0010 /* 1000KX EEE cap */
-#define MDIO_EEE_10GKX4 0x0020 /* 10G KX4 EEE cap */
-#define MDIO_EEE_10GKR 0x0040 /* 10G KR EEE cap */
-#endif /* MDIO_EEE_100TX */
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-/**
- * mmd_eee_adv_to_ethtool_adv_t
- * @eee_adv: value of the MMD EEE Advertisement/Link Partner Ability registers
- *
- * A small helper function that translates the MMD EEE Advertisment (7.60)
- * and MMD EEE Link Partner Ability (7.61) bits to ethtool advertisement
- * settings.
- */
-#define mmd_eee_adv_to_ethtool_adv_t LINUX_BACKPORT(mmd_eee_adv_to_ethtool_adv_t)
-static inline u32 mmd_eee_adv_to_ethtool_adv_t(u16 eee_adv)
-{
- u32 adv = 0;
-
- if (eee_adv & MDIO_EEE_100TX)
- adv |= ADVERTISED_100baseT_Full;
- if (eee_adv & MDIO_EEE_1000T)
- adv |= ADVERTISED_1000baseT_Full;
- if (eee_adv & MDIO_EEE_10GT)
- adv |= ADVERTISED_10000baseT_Full;
- if (eee_adv & MDIO_EEE_1000KX)
- adv |= ADVERTISED_1000baseKX_Full;
- if (eee_adv & MDIO_EEE_10GKX4)
- adv |= ADVERTISED_10000baseKX4_Full;
- if (eee_adv & MDIO_EEE_10GKR)
- adv |= ADVERTISED_10000baseKR_Full;
-
- return adv;
-}
-
-#define ethtool_adv_to_mmd_eee_adv_t LINUX_BACKPORT(ethtool_adv_to_mmd_eee_adv_t)
-/**
- * ethtool_adv_to_mmd_eee_adv_t
- * @adv: the ethtool advertisement settings
- *
- * A small helper function that translates ethtool advertisement settings
- * to EEE advertisements for the MMD EEE Advertisement (7.60) and
- * MMD EEE Link Partner Ability (7.61) registers.
- */
-static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv)
-{
- u16 reg = 0;
-
- if (adv & ADVERTISED_100baseT_Full)
- reg |= MDIO_EEE_100TX;
- if (adv & ADVERTISED_1000baseT_Full)
- reg |= MDIO_EEE_1000T;
- if (adv & ADVERTISED_10000baseT_Full)
- reg |= MDIO_EEE_10GT;
- if (adv & ADVERTISED_1000baseKX_Full)
- reg |= MDIO_EEE_1000KX;
- if (adv & ADVERTISED_10000baseKX4_Full)
- reg |= MDIO_EEE_10GKX4;
- if (adv & ADVERTISED_10000baseKR_Full)
- reg |= MDIO_EEE_10GKR;
-
- return reg;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-
-#endif /* __BACKPORT_LINUX_MDIO_H */
diff --git a/backport/backport-include/linux/mei_cl_bus.h b/backport/backport-include/linux/mei_cl_bus.h
deleted file mode 100644
index c0e522f6..00000000
--- a/backport/backport-include/linux/mei_cl_bus.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __BACKPORT_LINUX_MEI_CL_BUS_H
-#define __BACKPORT_LINUX_MEI_CL_BUS_H
-#include_next <linux/mei_cl_bus.h>
-
-#if LINUX_VERSION_IS_LESS(4,3,0)
-#define mei_cldev_register_event_cb(cldev, event_mask, read_cb, context) \
- mei_cl_register_event_cb(cldev, read_cb, context)
-#elif LINUX_VERSION_IS_LESS(4,4,0)
-#define mei_cldev_register_event_cb(cldev, event_mask, read_cb, context) \
- mei_cl_register_event_cb(cldev, event_mask, read_cb, context)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,4,0)
-#define __mei_cldev_driver_register(cldrv, owner) __mei_cl_driver_register(cldrv, owner)
-#define mei_cldev_driver_register(cldrv) mei_cl_driver_register(cldrv)
-#define mei_cldev_driver_unregister(cldrv) mei_cl_driver_unregister(cldrv)
-#define mei_cldev_send(cldev, buf, length) mei_cl_send(cldev, buf, length)
-#define mei_cldev_recv(cldev, buf, length) mei_cl_recv(cldev, buf, length)
-#define mei_cldev_get_drvdata(cldev) mei_cl_get_drvdata(cldev)
-#define mei_cldev_set_drvdata(cldev, data) mei_cl_set_drvdata(cldev, data)
-#define mei_cldev_enable(cldev) mei_cl_enable_device(cldev)
-#define mei_cldev_disable(cldev) mei_cl_disable_device(cldev)
-#endif
-
-#endif /* __BACKPORT_LINUX_MEI_CL_BUS_H */
diff --git a/backport/backport-include/linux/mii.h b/backport/backport-include/linux/mii.h
deleted file mode 100644
index e5aad0f6..00000000
--- a/backport/backport-include/linux/mii.h
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef __BACKPORT_LINUX_MII_H
-#define __BACKPORT_LINUX_MII_H
-#include_next <linux/mii.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#include <linux/ethtool.h>
-
-#define ethtool_adv_to_mii_adv_t LINUX_BACKPORT(ethtool_adv_to_mii_adv_t)
-static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
-{
- u32 result = 0;
-
- if (ethadv & ADVERTISED_10baseT_Half)
- result |= ADVERTISE_10HALF;
- if (ethadv & ADVERTISED_10baseT_Full)
- result |= ADVERTISE_10FULL;
- if (ethadv & ADVERTISED_100baseT_Half)
- result |= ADVERTISE_100HALF;
- if (ethadv & ADVERTISED_100baseT_Full)
- result |= ADVERTISE_100FULL;
- if (ethadv & ADVERTISED_Pause)
- result |= ADVERTISE_PAUSE_CAP;
- if (ethadv & ADVERTISED_Asym_Pause)
- result |= ADVERTISE_PAUSE_ASYM;
-
- return result;
-}
-
-#define mii_adv_to_ethtool_adv_t LINUX_BACKPORT(mii_adv_to_ethtool_adv_t)
-static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
-{
- u32 result = 0;
-
- if (adv & ADVERTISE_10HALF)
- result |= ADVERTISED_10baseT_Half;
- if (adv & ADVERTISE_10FULL)
- result |= ADVERTISED_10baseT_Full;
- if (adv & ADVERTISE_100HALF)
- result |= ADVERTISED_100baseT_Half;
- if (adv & ADVERTISE_100FULL)
- result |= ADVERTISED_100baseT_Full;
- if (adv & ADVERTISE_PAUSE_CAP)
- result |= ADVERTISED_Pause;
- if (adv & ADVERTISE_PAUSE_ASYM)
- result |= ADVERTISED_Asym_Pause;
-
- return result;
-}
-
-#define ethtool_adv_to_mii_ctrl1000_t LINUX_BACKPORT(ethtool_adv_to_mii_ctrl1000_t)
-static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
-{
- u32 result = 0;
-
- if (ethadv & ADVERTISED_1000baseT_Half)
- result |= ADVERTISE_1000HALF;
- if (ethadv & ADVERTISED_1000baseT_Full)
- result |= ADVERTISE_1000FULL;
-
- return result;
-}
-
-#define mii_ctrl1000_to_ethtool_adv_t LINUX_BACKPORT(mii_ctrl1000_to_ethtool_adv_t)
-static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv)
-{
- u32 result = 0;
-
- if (adv & ADVERTISE_1000HALF)
- result |= ADVERTISED_1000baseT_Half;
- if (adv & ADVERTISE_1000FULL)
- result |= ADVERTISED_1000baseT_Full;
-
- return result;
-}
-
-#define mii_lpa_to_ethtool_lpa_t LINUX_BACKPORT(mii_lpa_to_ethtool_lpa_t)
-static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa)
-{
- u32 result = 0;
-
- if (lpa & LPA_LPACK)
- result |= ADVERTISED_Autoneg;
-
- return result | mii_adv_to_ethtool_adv_t(lpa);
-}
-
-#define mii_stat1000_to_ethtool_lpa_t LINUX_BACKPORT(mii_stat1000_to_ethtool_lpa_t)
-static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
-{
- u32 result = 0;
-
- if (lpa & LPA_1000HALF)
- result |= ADVERTISED_1000baseT_Half;
- if (lpa & LPA_1000FULL)
- result |= ADVERTISED_1000baseT_Full;
-
- return result;
-}
-
-#define ethtool_adv_to_mii_adv_x LINUX_BACKPORT(ethtool_adv_to_mii_adv_x)
-static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
-{
- u32 result = 0;
-
- if (ethadv & ADVERTISED_1000baseT_Half)
- result |= ADVERTISE_1000XHALF;
- if (ethadv & ADVERTISED_1000baseT_Full)
- result |= ADVERTISE_1000XFULL;
- if (ethadv & ADVERTISED_Pause)
- result |= ADVERTISE_1000XPAUSE;
- if (ethadv & ADVERTISED_Asym_Pause)
- result |= ADVERTISE_1000XPSE_ASYM;
-
- return result;
-}
-
-#define mii_adv_to_ethtool_adv_x LINUX_BACKPORT(mii_adv_to_ethtool_adv_x)
-static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
-{
- u32 result = 0;
-
- if (adv & ADVERTISE_1000XHALF)
- result |= ADVERTISED_1000baseT_Half;
- if (adv & ADVERTISE_1000XFULL)
- result |= ADVERTISED_1000baseT_Full;
- if (adv & ADVERTISE_1000XPAUSE)
- result |= ADVERTISED_Pause;
- if (adv & ADVERTISE_1000XPSE_ASYM)
- result |= ADVERTISED_Asym_Pause;
-
- return result;
-}
-
-#define mii_lpa_to_ethtool_lpa_x LINUX_BACKPORT(mii_lpa_to_ethtool_lpa_x)
-static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
-{
- u32 result = 0;
-
- if (lpa & LPA_LPACK)
- result |= ADVERTISED_Autoneg;
-
- return result | mii_adv_to_ethtool_adv_x(lpa);
-}
-#endif
-
-#if LINUX_VERSION_IN_RANGE(4,6,0, 4,11,0)
-extern int mii_ethtool_get_link_ksettings(
- struct mii_if_info *mii, struct ethtool_link_ksettings *cmd);
-extern int mii_ethtool_set_link_ksettings(
- struct mii_if_info *mii, const struct ethtool_link_ksettings *cmd);
-#endif /* LINUX_VERSION_IN_RANGE(4,6,0, 4,11,0) */
-
-#endif /* __BACKPORT_LINUX_MII_H */
diff --git a/backport/backport-include/linux/miscdevice.h b/backport/backport-include/linux/miscdevice.h
deleted file mode 100644
index 9c273346..00000000
--- a/backport/backport-include/linux/miscdevice.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _BACKPORT_LINUX_MISCDEVICE_H
-#define _BACKPORT_LINUX_MISCDEVICE_H
-#include_next <linux/miscdevice.h>
-
-#ifndef VHCI_MINOR
-#define VHCI_MINOR 137
-#endif
-
-#endif /* _BACKPORT_LINUX_MISCDEVICE_H */
diff --git a/backport/backport-include/linux/mm.h b/backport/backport-include/linux/mm.h
deleted file mode 100644
index 1b0672b5..00000000
--- a/backport/backport-include/linux/mm.h
+++ /dev/null
@@ -1,149 +0,0 @@
-#ifndef __BACKPORT_MM_H
-#define __BACKPORT_MM_H
-#include_next <linux/mm.h>
-#include <linux/page_ref.h>
-#include <linux/sched.h>
-#include <linux/overflow.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-#define kvfree LINUX_BACKPORT(kvfree)
-void kvfree(const void *addr);
-#endif /* < 3.15 */
-
-#if LINUX_VERSION_IS_LESS(3,20,0)
-#define get_user_pages_locked LINUX_BACKPORT(get_user_pages_locked)
-long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
- int write, int force, struct page **pages, int *locked);
-#define get_user_pages_unlocked LINUX_BACKPORT(get_user_pages_unlocked)
-long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
- int write, int force, struct page **pages);
-#elif LINUX_VERSION_IS_LESS(4,6,0) && !LINUX_VERSION_IN_RANGE(4,4,168, 4,5,0)
-static inline
-long backport_get_user_pages_locked(unsigned long start, unsigned long nr_pages,
- int write, int force, struct page **pages, int *locked)
-{
- return get_user_pages_locked(current, current->mm, start, nr_pages,
- write, force, pages, locked);
-}
-#define get_user_pages_locked LINUX_BACKPORT(get_user_pages_locked)
-
-static inline
-long backport_get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
- int write, int force, struct page **pages)
-{
- return get_user_pages_unlocked(current, current->mm, start, nr_pages,
- write, force, pages);
-}
-#define get_user_pages_unlocked LINUX_BACKPORT(get_user_pages_unlocked)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,6,0) && !LINUX_VERSION_IN_RANGE(4,4,168, 4,5,0)
-static inline
-long backport_get_user_pages(unsigned long start, unsigned long nr_pages,
- int write, int force, struct page **pages,
- struct vm_area_struct **vmas)
-{
- return get_user_pages(current, current->mm, start, nr_pages,
- write, force, pages, vmas);
-}
-#define get_user_pages LINUX_BACKPORT(get_user_pages)
-#endif
-
-#ifndef FOLL_TRIED
-#define FOLL_TRIED 0x800 /* a retry, previous pass started an IO */
-#endif
-
-#ifdef CPTCFG_BPAUTO_BUILD_FRAME_VECTOR
-/* Container for pinned pfns / pages */
-struct frame_vector {
- unsigned int nr_allocated; /* Number of frames we have space for */
- unsigned int nr_frames; /* Number of frames stored in ptrs array */
- bool got_ref; /* Did we pin pages by getting page ref? */
- bool is_pfns; /* Does array contain pages or pfns? */
- void *ptrs[0]; /* Array of pinned pfns / pages. Use
- * pfns_vector_pages() or pfns_vector_pfns()
- * for access */
-};
-
-struct frame_vector *frame_vector_create(unsigned int nr_frames);
-void frame_vector_destroy(struct frame_vector *vec);
-int get_vaddr_frames(unsigned long start, unsigned int nr_pfns,
- bool write, bool force, struct frame_vector *vec);
-void put_vaddr_frames(struct frame_vector *vec);
-int frame_vector_to_pages(struct frame_vector *vec);
-void frame_vector_to_pfns(struct frame_vector *vec);
-
-static inline unsigned int frame_vector_count(struct frame_vector *vec)
-{
- return vec->nr_frames;
-}
-
-static inline struct page **frame_vector_pages(struct frame_vector *vec)
-{
- if (vec->is_pfns) {
- int err = frame_vector_to_pages(vec);
-
- if (err)
- return ERR_PTR(err);
- }
- return (struct page **)(vec->ptrs);
-}
-
-static inline unsigned long *frame_vector_pfns(struct frame_vector *vec)
-{
- if (!vec->is_pfns)
- frame_vector_to_pfns(vec);
- return (unsigned long *)(vec->ptrs);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,1,9) && \
- LINUX_VERSION_IS_GEQ(3,6,0)
-#define page_is_pfmemalloc LINUX_BACKPORT(page_is_pfmemalloc)
-static inline bool page_is_pfmemalloc(struct page *page)
-{
- return page->pfmemalloc;
-}
-#endif /* < 4.2 */
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-#define kvmalloc LINUX_BACKPORT(kvmalloc)
-static inline void *kvmalloc(size_t size, gfp_t flags)
-{
- gfp_t kmalloc_flags = flags;
- void *ret;
-
- if ((flags & GFP_KERNEL) != GFP_KERNEL)
- return kmalloc(size, flags);
-
- if (size > PAGE_SIZE)
- kmalloc_flags |= __GFP_NOWARN | __GFP_NORETRY;
-
- ret = kmalloc(size, flags);
- if (ret || size < PAGE_SIZE)
- return ret;
-
- return vmalloc(size);
-}
-
-#define kvmalloc_array LINUX_BACKPORT(kvmalloc_array)
-static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags)
-{
- size_t bytes;
-
- if (unlikely(check_mul_overflow(n, size, &bytes)))
- return NULL;
-
- return kvmalloc(bytes, flags);
-}
-
-#define kvzalloc LINUX_BACKPORT(kvzalloc)
-static inline void *kvzalloc(size_t size, gfp_t flags)
-{
- return kvmalloc(size, flags | __GFP_ZERO);
-}
-#endif
-
-#endif /* __BACKPORT_MM_H */
diff --git a/backport/backport-include/linux/mmc/host.h b/backport/backport-include/linux/mmc/host.h
deleted file mode 100644
index 2a60cdec..00000000
--- a/backport/backport-include/linux/mmc/host.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _BACKPORTLINUX_MMC_HOST_H
-#define _BACKPORTLINUX_MMC_HOST_H
-#include_next <linux/mmc/host.h>
-#include <linux/version.h>
-#include <linux/mmc/card.h>
-
-#if LINUX_VERSION_IS_LESS(3,16,0)
-#define mmc_card_hs LINUX_BACKPORT(mmc_card_hs)
-static inline int mmc_card_hs(struct mmc_card *card)
-{
- return card->host->ios.timing == MMC_TIMING_SD_HS ||
- card->host->ios.timing == MMC_TIMING_MMC_HS;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,16,0) */
-
-#endif /* _BACKPORTLINUX_MMC_HOST_H */
diff --git a/backport/backport-include/linux/mmc/sdio.h b/backport/backport-include/linux/mmc/sdio.h
deleted file mode 100644
index 31d88330..00000000
--- a/backport/backport-include/linux/mmc/sdio.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_MMC_SDIO_H
-#define __BACKPORT_MMC_SDIO_H
-#include <linux/version.h>
-#include_next <linux/mmc/sdio.h>
-
-/* backports b4625dab */
-#ifndef SDIO_CCCR_REV_3_00
-#define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */
-#endif
-#ifndef SDIO_SDIO_REV_3_00
-#define SDIO_SDIO_REV_3_00 4 /* SDIO Spec Version 3.00 */
-#endif
-
-#ifndef SDIO_BUS_ECSI
-#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
-#endif
-#ifndef SDIO_BUS_SCSI
-#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
-#endif
-
-#endif /* __BACKPORT_MMC_SDIO_H */
diff --git a/backport/backport-include/linux/mmc/sdio_func.h b/backport/backport-include/linux/mmc/sdio_func.h
deleted file mode 100644
index 2d3e92b6..00000000
--- a/backport/backport-include/linux/mmc/sdio_func.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_MMC_SDIO_FUNC_H
-#define __BACKPORT_MMC_SDIO_FUNC_H
-#include <linux/version.h>
-#include_next <linux/mmc/sdio_func.h>
-
-#ifndef dev_to_sdio_func
-#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
-#endif
-
-#endif /* __BACKPORT_MMC_SDIO_FUNC_H */
diff --git a/backport/backport-include/linux/mmc/sdio_ids.h b/backport/backport-include/linux/mmc/sdio_ids.h
deleted file mode 100644
index 64fe8ec4..00000000
--- a/backport/backport-include/linux/mmc/sdio_ids.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BACKPORT_MMC_SDIO_IDS_H
-#define __BACKPORT_MMC_SDIO_IDS_H
-#include <linux/version.h>
-#include_next <linux/mmc/sdio_ids.h>
-
-#ifndef SDIO_CLASS_BT_AMP
-#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */
-#endif
-
-#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN
-#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104
-#endif
-
-#endif /* __BACKPORT_MMC_SDIO_IDS_H */
diff --git a/backport/backport-include/linux/mod_devicetable.h b/backport/backport-include/linux/mod_devicetable.h
deleted file mode 100644
index ec0a3e62..00000000
--- a/backport/backport-include/linux/mod_devicetable.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __BACKPORT_MOD_DEVICETABLE_H
-#define __BACKPORT_MOD_DEVICETABLE_H
-#include_next <linux/mod_devicetable.h>
-
-#ifndef HID_BUS_ANY
-#define HID_BUS_ANY 0xffff
-#endif
-
-#ifndef HID_GROUP_ANY
-#define HID_GROUP_ANY 0x0000
-#endif
-
-#ifndef HID_ANY_ID
-#define HID_ANY_ID (~0)
-#endif
-
-#endif /* __BACKPORT_MOD_DEVICETABLE_H */
diff --git a/backport/backport-include/linux/module.h b/backport/backport-include/linux/module.h
deleted file mode 100644
index 1a2c82f4..00000000
--- a/backport/backport-include/linux/module.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef __BACKPORT_LINUX_MODULE_H
-#define __BACKPORT_LINUX_MODULE_H
-#include_next <linux/module.h>
-#include <linux/rcupdate.h>
-
-/*
- * The define overwriting module_init is based on the original module_init
- * which looks like this:
- * #define module_init(initfn) \
- * static inline initcall_t __inittest(void) \
- * { return initfn; } \
- * int init_module(void) __attribute__((alias(#initfn)));
- *
- * To the call to the initfn we added the symbol dependency on compat
- * to make sure that compat.ko gets loaded for any compat modules.
- */
-extern void backport_dependency_symbol(void);
-
-#ifdef BACKPORTS_GIT_TRACKED
-#define BACKPORT_MOD_VERSIONS MODULE_VERSION(BACKPORTS_GIT_TRACKED);
-#else
-#define BACKPORT_MOD_VERSIONS \
- MODULE_VERSION("backported from " CPTCFG_KERNEL_NAME \
- " (" CPTCFG_KERNEL_VERSION ")" \
- " using backports " CPTCFG_VERSION);
-#endif
-
-#ifdef MODULE
-#undef module_init
-#define module_init(initfn) \
- static int __init __init_backport(void) \
- { \
- backport_dependency_symbol(); \
- return initfn(); \
- } \
- int init_module(void) __attribute__((alias("__init_backport")));\
- BACKPORT_MOD_VERSIONS
-
-/*
- * The define overwriting module_exit is based on the original module_exit
- * which looks like this:
- * #define module_exit(exitfn) \
- * static inline exitcall_t __exittest(void) \
- * { return exitfn; } \
- * void cleanup_module(void) __attribute__((alias(#exitfn)));
- *
- * We replaced the call to the actual function exitfn() with a call to our
- * function which calls the original exitfn() and then rcu_barrier()
- *
- * As a module will not be unloaded that ofter it should not have a big
- * performance impact when rcu_barrier() is called on every module exit,
- * also when no kfree_rcu() backport is used in that module.
- */
-#undef module_exit
-#define module_exit(exitfn) \
- static void __exit __exit_compat(void) \
- { \
- exitfn(); \
- rcu_barrier(); \
- } \
- void cleanup_module(void) __attribute__((alias("__exit_compat")));
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#undef param_check_bool
-#define param_check_bool(name, p) __param_check(name, p, bool)
-#endif
-
-#endif /* __BACKPORT_LINUX_MODULE_H */
diff --git a/backport/backport-include/linux/moduleparam.h b/backport/backport-include/linux/moduleparam.h
deleted file mode 100644
index 914baadc..00000000
--- a/backport/backport-include/linux/moduleparam.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __BACKPORT_LINUX_MODULEPARAM_H
-#define __BACKPORT_LINUX_MODULEPARAM_H
-#include_next <linux/moduleparam.h>
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define kernel_param_lock LINUX_BACKPORT(kernel_param_lock)
-static inline void kernel_param_lock(struct module *mod)
-{
- __kernel_param_lock();
-}
-#define kernel_param_unlock LINUX_BACKPORT(kernel_param_unlock)
-static inline void kernel_param_unlock(struct module *mod)
-{
- __kernel_param_unlock();
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,8,0)
-#undef __MODULE_INFO
-#ifdef MODULE
-#define __MODULE_INFO(tag, name, info) \
-static const char __UNIQUE_ID(name)[] \
- __used __attribute__((section(".modinfo"), unused, aligned(1))) \
- = __stringify(tag) "=" info
-#else /* !MODULE */
-/* This struct is here for syntactic coherency, it is not used */
-#define __MODULE_INFO(tag, name, info) \
- struct __UNIQUE_ID(name) {}
-#endif
-#endif /* < 3.8 */
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-extern struct kernel_param_ops param_ops_ullong;
-extern int param_set_ullong(const char *val, const struct kernel_param *kp);
-extern int param_get_ullong(char *buffer, const struct kernel_param *kp);
-#define param_check_ullong(name, p) __param_check(name, p, unsigned long long)
-#endif
-
-#ifndef module_param_hw_array
-#define module_param_hw_array(name, type, hwtype, nump, perm) \
- module_param_array(name, type, nump, perm)
-#endif
-
-#endif /* __BACKPORT_LINUX_MODULEPARAM_H */
diff --git a/backport/backport-include/linux/net.h b/backport/backport-include/linux/net.h
deleted file mode 100644
index 738ff8b1..00000000
--- a/backport/backport-include/linux/net.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef __BACKPORT_LINUX_NET_H
-#define __BACKPORT_LINUX_NET_H
-#include_next <linux/net.h>
-#include <linux/static_key.h>
-
-/* This backports:
- *
- * commit 2033e9bf06f07e049bbc77e9452856df846714cc -- from v3.5
- * Author: Neil Horman <nhorman@tuxdriver.com>
- * Date: Tue May 29 09:30:40 2012 +0000
- *
- * net: add MODULE_ALIAS_NET_PF_PROTO_NAME
- */
-#ifndef MODULE_ALIAS_NET_PF_PROTO_NAME
-#define MODULE_ALIAS_NET_PF_PROTO_NAME(pf, proto, name) \
- MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
- name)
-#endif
-
-#ifndef net_ratelimited_function
-#define net_ratelimited_function(function, ...) \
-do { \
- if (net_ratelimit()) \
- function(__VA_ARGS__); \
-} while (0)
-
-#define net_emerg_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
-#define net_alert_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
-#define net_crit_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
-#define net_err_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
-#define net_notice_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
-#define net_warn_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
-#define net_info_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
-#define net_dbg_ratelimited(fmt, ...) \
- net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
-#endif
-
-#ifndef DECLARE_SOCKADDR
-#define DECLARE_SOCKADDR(type, dst, src) \
- type dst = ({ __sockaddr_check_size(sizeof(*dst)); (type) src; })
-#endif
-
-/*
- * Avoid backporting this if a distro did the work already, this
- * takes the check a bit further than just using LINUX_BACKPORT()
- * namespace, curious if any distro will hit a wall with this.
- * Also curious if any distro will be daring enough to even try
- * to backport this to a release older than 3.5.
- */
-#ifndef ___NET_RANDOM_STATIC_KEY_INIT
-/*
- * Backporting this before 3.5 is extremely tricky -- I tried, due
- * to the fact that it relies on static keys, which were refactored
- * and optimized through a series of generation of patches from jump
- * labels. These in turn have also been optimized through kernel revisions
- * and have architecture specific code, which if you commit to backporting
- * may affect tracing. My recommendation is that if you have a need for
- * static keys you just require at least 3.5 to remain sane.
- */
-#if LINUX_VERSION_IS_GEQ(3,5,0) && !defined(net_get_random_once)
-#define __BACKPORT_NET_GET_RANDOM_ONCE 1
-#endif
-#endif /* ___NET_RANDOM_STATIC_KEY_INIT */
-
-#ifdef __BACKPORT_NET_GET_RANDOM_ONCE
-#define __net_get_random_once LINUX_BACKPORT(__net_get_random_once)
-bool __net_get_random_once(void *buf, int nbytes, bool *done,
- struct static_key *done_key);
-
-#ifdef HAVE_JUMP_LABEL
-#define ___NET_RANDOM_STATIC_KEY_INIT ((struct static_key) \
- { .enabled = ATOMIC_INIT(0), .entries = (void *)1 })
-#else /* !HAVE_JUMP_LABEL */
-#define ___NET_RANDOM_STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
-#endif /* HAVE_JUMP_LABEL */
-
-#define net_get_random_once(buf, nbytes) \
- ({ \
- bool ___ret = false; \
- static bool ___done = false; \
- static struct static_key ___done_key = \
- ___NET_RANDOM_STATIC_KEY_INIT; \
- if (!static_key_true(&___done_key)) \
- ___ret = __net_get_random_once(buf, \
- nbytes, \
- &___done, \
- &___done_key); \
- ___ret; \
- })
-
-#endif /* __BACKPORT_NET_GET_RANDOM_ONCE */
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define sock_create_kern(net, family, type, proto, res) \
- __sock_create(net, family, type, proto, res, 1)
-#endif
-
-#ifndef SOCKWQ_ASYNC_NOSPACE
-#define SOCKWQ_ASYNC_NOSPACE SOCK_ASYNC_NOSPACE
-#endif
-#ifndef SOCKWQ_ASYNC_WAITDATA
-#define SOCKWQ_ASYNC_WAITDATA SOCK_ASYNC_WAITDATA
-#endif
-
-#endif /* __BACKPORT_LINUX_NET_H */
diff --git a/backport/backport-include/linux/netdev_features.h b/backport/backport-include/linux/netdev_features.h
deleted file mode 100644
index 09568ce4..00000000
--- a/backport/backport-include/linux/netdev_features.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef __BACKPORT_NETDEV_FEATURES_H
-#define __BACKPORT_NETDEV_FEATURES_H
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#include <linux/netdevice.h>
-#include <linux/types.h>
-
-/* added via 9356b8fc */
-#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX
-#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
-
-/* added via d314774c */
-#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
-
-/* c8f44aff made this u32 but later a861a8b2 changed it to u64 both on v3.3 */
-typedef u32 netdev_features_t;
-
-#else
-#include_next <linux/netdev_features.h>
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-/* See commit f646968f8f on next-20130423 */
-#define NETIF_F_HW_VLAN_CTAG_TX_BIT NETIF_F_HW_VLAN_TX_BIT
-#define NETIF_F_HW_VLAN_CTAG_RX_BIT NETIF_F_HW_VLAN_RX_BIT
-#define NETIF_F_HW_VLAN_CTAG_FILTER_BIT NETIF_F_HW_VLAN_FILTER_BIT
-
-#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
-#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX
-#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
-#endif
-
-#endif /* LINUX_VERSION_IS_LESS(3,3,0) */
-
-#if !defined(NETIF_F_RXCSUM)
-#define NETIF_F_RXCSUM 0
-#endif
-
-#if !defined(NETIF_F_RXALL)
-#define NETIF_F_RXALL 0
-#endif
-
-#if !defined(NETIF_F_RXFCS)
-#define NETIF_F_RXFCS 0
-#endif
-
-/* this was renamed in commit 53692b1de : sctp: Rename NETIF_F_SCTP_CSUM to NETIF_F_SCTP_CRC */
-#ifndef NETIF_F_SCTP_CRC
-#define NETIF_F_SCTP_CRC __NETIF_F(SCTP_CSUM)
-#endif
-
-#endif /* __BACKPORT_NETDEV_FEATURES_H */
diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
deleted file mode 100644
index 4b1fddff..00000000
--- a/backport/backport-include/linux/netdevice.h
+++ /dev/null
@@ -1,369 +0,0 @@
-#ifndef __BACKPORT_NETDEVICE_H
-#define __BACKPORT_NETDEVICE_H
-#include_next <linux/netdevice.h>
-#include <linux/netdev_features.h>
-#include <linux/version.h>
-#include <backport/magic.h>
-
-/*
- * This is declared implicitly in newer kernels by netdevice.h using
- * this pointer in struct net_device, but declare it here anyway so
- * pointers to it are accepted as function arguments without warning.
- */
-struct inet6_dev;
-
-/* older kernels don't include this here, we need it */
-#include <linux/ethtool.h>
-#include <linux/rculist.h>
-/*
- * new kernels include <net/netprio_cgroup.h> which
- * has this ... and some drivers rely on it :-(
- */
-#include <linux/hardirq.h>
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-/*
- * Backports note: if in-kernel support is provided we could then just
- * take the kernel's implementation of __dev_kfree_skb_irq() as it requires
- * raise_softirq_irqoff() which is not exported. For the backport case we
- * just use slightly less optimized version and we don't get the ability
- * to distinguish the two different reasons to free the skb -- whether it
- * was consumed or dropped.
- *
- * The upstream documentation for this:
- *
- * It is not allowed to call kfree_skb() or consume_skb() from hardware
- * interrupt context or with hardware interrupts being disabled.
- * (in_irq() || irqs_disabled())
- *
- * We provide four helpers that can be used in following contexts :
- *
- * dev_kfree_skb_irq(skb) when caller drops a packet from irq context,
- * replacing kfree_skb(skb)
- *
- * dev_consume_skb_irq(skb) when caller consumes a packet from irq context.
- * Typically used in place of consume_skb(skb) in TX completion path
- *
- * dev_kfree_skb_any(skb) when caller doesn't know its current irq context,
- * replacing kfree_skb(skb)
- *
- * dev_consume_skb_any(skb) when caller doesn't know its current irq context,
- * and consumed a packet. Used in place of consume_skb(skb)
- */
-#define skb_free_reason LINUX_BACKPORT(skb_free_reason)
-enum skb_free_reason {
- SKB_REASON_CONSUMED,
- SKB_REASON_DROPPED,
-};
-
-#define __dev_kfree_skb_irq LINUX_BACKPORT(__dev_kfree_skb_irq)
-static inline void __dev_kfree_skb_irq(struct sk_buff *skb,
- enum skb_free_reason reason)
-{
- dev_kfree_skb_irq(skb);
-}
-
-#define __dev_kfree_skb_any LINUX_BACKPORT(__dev_kfree_skb_any)
-static inline void __dev_kfree_skb_any(struct sk_buff *skb,
- enum skb_free_reason reason)
-{
- dev_kfree_skb_any(skb);
-}
-
-#define dev_consume_skb_irq LINUX_BACKPORT(dev_consume_skb_irq)
-static inline void dev_consume_skb_irq(struct sk_buff *skb)
-{
- dev_kfree_skb_irq(skb);
-}
-
-#define dev_consume_skb_any LINUX_BACKPORT(dev_consume_skb_any)
-static inline void dev_consume_skb_any(struct sk_buff *skb)
-{
- dev_kfree_skb_any(skb);
-}
-
-#if (LINUX_VERSION_CODE != KERNEL_VERSION(3,13,11) || UTS_UBUNTU_RELEASE_ABI < 24)
-struct pcpu_sw_netstats {
- u64 rx_packets;
- u64 rx_bytes;
- u64 tx_packets;
- u64 tx_bytes;
- struct u64_stats_sync syncp;
-};
-#endif
-
-#define netdev_tstats(dev) ((struct pcpu_sw_netstats *)dev->ml_priv)
-#define netdev_assign_tstats(dev, e) dev->ml_priv = (e);
-#else
-#define netdev_tstats(dev) dev->tstats
-#define netdev_assign_tstats(dev, e) dev->tstats = (e);
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-
-#if LINUX_VERSION_IS_LESS(3,7,8)
-#define netdev_set_default_ethtool_ops LINUX_BACKPORT(netdev_set_default_ethtool_ops)
-extern void netdev_set_default_ethtool_ops(struct net_device *dev,
- const struct ethtool_ops *ops);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-/*
- * BQL was added as of v3.3 but some Linux distributions
- * have backported BQL to their v3.2 kernels or older. To
- * address this we assume that they also enabled CONFIG_BQL
- * and test for that here and simply avoid adding the static
- * inlines if it was defined
- */
-#ifndef CONFIG_BQL
-#define netdev_tx_sent_queue LINUX_BACKPORT(netdev_tx_sent_queue)
-static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
- unsigned int bytes)
-{
-}
-
-#define netdev_sent_queue LINUX_BACKPORT(netdev_sent_queue)
-static inline void netdev_sent_queue(struct net_device *dev, unsigned int bytes)
-{
-}
-
-#define netdev_tx_completed_queue LINUX_BACKPORT(netdev_tx_completed_queue)
-static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,
- unsigned pkts, unsigned bytes)
-{
-}
-
-#define netdev_completed_queue LINUX_BACKPORT(netdev_completed_queue)
-static inline void netdev_completed_queue(struct net_device *dev,
- unsigned pkts, unsigned bytes)
-{
-}
-
-#define netdev_tx_reset_queue LINUX_BACKPORT(netdev_tx_reset_queue)
-static inline void netdev_tx_reset_queue(struct netdev_queue *q)
-{
-}
-
-#define netdev_reset_queue LINUX_BACKPORT(netdev_reset_queue)
-static inline void netdev_reset_queue(struct net_device *dev_queue)
-{
-}
-#endif /* CONFIG_BQL */
-#endif /* < 3.3 */
-
-#ifndef NETDEV_PRE_UP
-#define NETDEV_PRE_UP 0x000D
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,11,0)
-#define netdev_notifier_info_to_dev(ndev) ndev
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define netdev_notify_peers(dev) netif_notify_peers(dev)
-#define napi_gro_flush(napi, old) napi_gro_flush(napi)
-#endif
-
-#ifndef IFF_LIVE_ADDR_CHANGE
-#define IFF_LIVE_ADDR_CHANGE 0x100000
-#endif
-
-#ifndef IFF_SUPP_NOFCS
-#define IFF_SUPP_NOFCS 0x80000 /* device supports sending custom FCS */
-#endif
-
-#ifndef IFF_UNICAST_FLT
-#define IFF_UNICAST_FLT 0x20000 /* Supports unicast filtering */
-#endif
-
-#ifndef QUEUE_STATE_ANY_XOFF
-#define __QUEUE_STATE_DRV_XOFF __QUEUE_STATE_XOFF
-#define __QUEUE_STATE_STACK_XOFF __QUEUE_STATE_XOFF
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#ifndef NET_NAME_UNKNOWN
-#define NET_NAME_UNKNOWN 0
-#endif
-#ifndef NET_NAME_ENUM
-#define NET_NAME_ENUM 1
-#endif
-#ifndef NET_NAME_PREDICTABLE
-#define NET_NAME_PREDICTABLE 2
-#endif
-#ifndef NET_NAME_USER
-#define NET_NAME_USER 3
-#endif
-#ifndef NET_NAME_RENAMED
-#define NET_NAME_RENAMED 4
-#endif
-
-#define alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, txqs, rxqs) \
- alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
-
-#undef alloc_netdev
-#define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
- alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, 1, 1)
-
-#undef alloc_netdev_mq
-#define alloc_netdev_mq(sizeof_priv, name, name_assign_type, setup, count) \
- alloc_netdev_mqs(sizeof_priv, name, name_assign_type, setup, count, \
- count)
-#endif /* LINUX_VERSION_IS_LESS(3,17,0) */
-
-/*
- * This backports this commit from upstream:
- * commit 87757a917b0b3c0787e0563c679762152be81312
- * net: force a list_del() in unregister_netdevice_many()
- */
-#if (!(LINUX_VERSION_IS_GEQ(3,10,45) && \
- LINUX_VERSION_IS_LESS(3,11,0)) && \
- !(LINUX_VERSION_IS_GEQ(3,12,23) && \
- LINUX_VERSION_IS_LESS(3,13,0)) && \
- !(LINUX_VERSION_IS_GEQ(3,14,9) && \
- LINUX_VERSION_IS_LESS(3,15,0)) && \
- !(LINUX_VERSION_IS_GEQ(3,15,2) && \
- LINUX_VERSION_IS_LESS(3,16,0)) && \
- LINUX_VERSION_IS_LESS(3,16,0))
-static inline void backport_unregister_netdevice_many(struct list_head *head)
-{
- unregister_netdevice_many(head);
-
- if (!(head->next == LIST_POISON1 && head->prev == LIST_POISON2))
- list_del(head);
-}
-#define unregister_netdevice_many LINUX_BACKPORT(unregister_netdevice_many)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define napi_alloc_frag(fragsz) netdev_alloc_frag(fragsz)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-/* RSS keys are 40 or 52 bytes long */
-#define NETDEV_RSS_KEY_LEN 52
-#define netdev_rss_key_fill LINUX_BACKPORT(netdev_rss_key_fill)
-void netdev_rss_key_fill(void *buffer, size_t len);
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define napi_alloc_skb LINUX_BACKPORT(napi_alloc_skb)
-static inline struct sk_buff *napi_alloc_skb(struct napi_struct *napi,
- unsigned int length)
-{
- return netdev_alloc_skb_ip_align(napi->dev, length);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#ifndef IFF_TX_SKB_SHARING
-#define IFF_TX_SKB_SHARING 0
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,1,0)
-netdev_features_t passthru_features_check(struct sk_buff *skb,
- struct net_device *dev,
- netdev_features_t features);
-#endif /* LINUX_VERSION_IS_LESS(4,1,0) */
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#undef u64_stats_init
-static inline void u64_stats_init(struct u64_stats_sync *syncp)
-{
-#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
- seqcount_init(&syncp->seq);
-#endif
-}
-#endif /* LINUX_VERSION_IS_LESS(4,2,0) */
-
-#ifndef netdev_alloc_pcpu_stats
-#define netdev_alloc_pcpu_stats(type) \
-({ \
- typeof(type) __percpu *pcpu_stats = alloc_percpu(type); \
- if (pcpu_stats) { \
- int i; \
- for_each_possible_cpu(i) { \
- typeof(type) *stat; \
- stat = per_cpu_ptr(pcpu_stats, i); \
- u64_stats_init(&stat->syncp); \
- } \
- } \
- pcpu_stats; \
-})
-#endif /* netdev_alloc_pcpu_stats */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define napi_complete_done LINUX_BACKPORT(napi_complete_done)
-static inline void napi_complete_done(struct napi_struct *n, int work_done)
-{
- napi_complete(n);
-}
-#endif /* < 3.19 */
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define netif_tx_napi_add LINUX_BACKPORT(netif_tx_napi_add)
-/**
- * netif_tx_napi_add - initialize a napi context
- * @dev: network device
- * @napi: napi context
- * @poll: polling function
- * @weight: default weight
- *
- * This variant of netif_napi_add() should be used from drivers using NAPI
- * to exclusively poll a TX queue.
- * This will avoid we add it into napi_hash[], thus polluting this hash table.
- */
-static inline void netif_tx_napi_add(struct net_device *dev,
- struct napi_struct *napi,
- int (*poll)(struct napi_struct *, int),
- int weight)
-{
- netif_napi_add(dev, napi, poll, weight);
-}
-#endif /* < 4.5 */
-
-#ifndef NETIF_F_CSUM_MASK
-#define NETIF_F_CSUM_MASK NETIF_F_ALL_CSUM
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,7,0)
-#define netif_trans_update LINUX_BACKPORT(netif_trans_update)
-static inline void netif_trans_update(struct net_device *dev)
-{
- dev->trans_start = jiffies;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,11,9)
-#define netdev_set_priv_destructor(_dev, _destructor) \
- (_dev)->destructor = __ ## _destructor
-#define netdev_set_def_destructor(_dev) \
- (_dev)->destructor = free_netdev
-#else
-#define netdev_set_priv_destructor(_dev, _destructor) \
- (_dev)->needs_free_netdev = true; \
- (_dev)->priv_destructor = (_destructor);
-#define netdev_set_def_destructor(_dev) \
- (_dev)->needs_free_netdev = true;
-#endif
-
-#if LINUX_VERSION_IN_RANGE(3,10,0, 4,14,0)
-static inline int _bp_netdev_upper_dev_link(struct net_device *dev,
- struct net_device *upper_dev)
-{
- return netdev_upper_dev_link(dev, upper_dev);
-}
-#define netdev_upper_dev_link3(dev, upper, extack) \
- netdev_upper_dev_link(dev, upper)
-#define netdev_upper_dev_link2(dev, upper) \
- netdev_upper_dev_link(dev, upper)
-#define netdev_upper_dev_link(...) \
- macro_dispatcher(netdev_upper_dev_link, __VA_ARGS__)(__VA_ARGS__)
-#endif
-
-#if LINUX_VERSION_IS_LESS(5,0,0)
-static inline int backport_dev_open(struct net_device *dev, struct netlink_ext_ack *extack)
-{
- return dev_open(dev);
-}
-#define dev_open LINUX_BACKPORT(dev_open)
-#endif
-
-#endif /* __BACKPORT_NETDEVICE_H */
diff --git a/backport/backport-include/linux/netlink.h b/backport/backport-include/linux/netlink.h
deleted file mode 100644
index 0fb8e0f3..00000000
--- a/backport/backport-include/linux/netlink.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef __BACKPORT_LINUX_NETLINK_H
-#define __BACKPORT_LINUX_NETLINK_H
-#include_next <linux/netlink.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,14,0)
-struct nla_bitfield32 {
- __u32 value;
- __u32 selector;
-};
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-#define NETLINK_MAX_COOKIE_LEN 20
-
-struct netlink_ext_ack {
- const char *_msg;
- const struct nlattr *bad_attr;
- u8 cookie[NETLINK_MAX_COOKIE_LEN];
- u8 cookie_len;
-
- /* backport only field */
- void *__bp_doit;
-};
-
-#define NL_SET_ERR_MSG(extack, msg) do { \
- static const char _msg[] = (msg); \
- \
- (extack)->_msg = _msg; \
-} while (0)
-#endif
-
-#ifndef NL_SET_ERR_MSG_ATTR
-#define NL_SET_ERR_MSG_ATTR(extack, attr, msg) do { \
- static const char __msg[] = msg; \
- struct netlink_ext_ack *__extack = (extack); \
- \
- if (__extack) { \
- __extack->_msg = __msg; \
- __extack->bad_attr = (attr); \
- } \
-} while (0)
-#endif
-
-/* this is for patches we apply */
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define netlink_notify_portid(__notify) (__notify->pid)
-#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).pid
-#else
-#define netlink_notify_portid(__notify) (__notify->portid)
-#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).portid
-#endif
-
-#ifndef NL_SET_BAD_ATTR
-#define NL_SET_BAD_ATTR(extack, attr) do { \
- if ((extack)) \
- (extack)->bad_attr = (attr); \
-} while (0)
-#endif /* NL_SET_BAD_ATTR */
-
-#if LINUX_VERSION_IS_LESS(5,0,0)
-static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack,
- u64 cookie)
-{
- u64 __cookie = cookie;
-
- memcpy(extack->cookie, &__cookie, sizeof(__cookie));
- extack->cookie_len = sizeof(__cookie);
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_NETLINK_H */
diff --git a/backport/backport-include/linux/nl80211.h b/backport/backport-include/linux/nl80211.h
deleted file mode 100644
index d49057a6..00000000
--- a/backport/backport-include/linux/nl80211.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_LINUX_NL80211_H
-#define __BACKPORT_LINUX_NL80211_H
-#include_next <linux/nl80211.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#define NL80211_FEATURE_SK_TX_STATUS 0
-#endif
-
-#endif /* __BACKPORT_LINUX_NL80211_H */
diff --git a/backport/backport-include/linux/nospec.h b/backport/backport-include/linux/nospec.h
deleted file mode 100644
index 50cf4673..00000000
--- a/backport/backport-include/linux/nospec.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _BACKPORT_LINUX_NOSPEC_H
-#define _BACKPORT_LINUX_NOSPEC_H
-
-#if LINUX_VERSION_IS_GEQ(4,14,18) || \
- LINUX_VERSION_IN_RANGE(4,9,81, 4,10,0) || \
- LINUX_VERSION_IN_RANGE(4,4,118, 4,5,0)
-#include_next <linux/nospec.h>
-#else
-#define array_index_nospec(index, size) (index)
-#endif
-
-#endif /* _BACKPORT_LINUX_NOSPEC_H */
diff --git a/backport/backport-include/linux/of.h b/backport/backport-include/linux/of.h
deleted file mode 100644
index bbb5acd2..00000000
--- a/backport/backport-include/linux/of.h
+++ /dev/null
@@ -1,259 +0,0 @@
-#ifndef _COMPAT_LINUX_OF_H
-#define _COMPAT_LINUX_OF_H 1
-
-#include <linux/version.h>
-#include_next <linux/of.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#ifdef CONFIG_OF
-extern struct device_node *of_get_child_by_name(const struct device_node *node,
- const char *name);
-#else
-static inline struct device_node *of_get_child_by_name(
- const struct device_node *node,
- const char *name)
-{
- return NULL;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#ifndef CONFIG_OF
-static inline struct device_node *of_find_node_by_name(struct device_node *from,
- const char *name)
-{
- return NULL;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-
-#if LINUX_VERSION_IS_LESS(3,8,0)
-#define of_property_read_u8_array LINUX_BACKPORT(of_property_read_u8_array)
-#ifdef CONFIG_OF
-extern int of_property_read_u8_array(const struct device_node *np,
- const char *propname, u8 *out_values, size_t sz);
-#else
-static inline int of_property_read_u8_array(const struct device_node *np,
- const char *propname, u8 *out_values, size_t sz)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,8,0) */
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define of_property_read_u32_array LINUX_BACKPORT(of_property_read_u32_array)
-#ifdef CONFIG_OF
-extern int of_property_read_u32_array(const struct device_node *np,
- const char *propname,
- u32 *out_values,
- size_t sz);
-#else
-static inline int of_property_read_u32_array(const struct device_node *np,
- const char *propname,
- u32 *out_values, size_t sz)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_OF */
-#define of_property_read_u32 LINUX_BACKPORT(of_property_read_u32)
-static inline int of_property_read_u32(const struct device_node *np,
- const char *propname,
- u32 *out_value)
-{
- return of_property_read_u32_array(np, propname, out_value, 1);
-}
-#ifndef CONFIG_OF
-#define of_get_property LINUX_BACKPORT(of_get_property)
-static inline const void *of_get_property(const struct device_node *node,
- const char *name,
- int *lenp)
-{
- return NULL;
-}
-
-#endif
-#endif /* LINUX_VERSION_IS_LESS(3,1,0) */
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-#define of_property_read_u32_index LINUX_BACKPORT(of_property_read_u32_index)
-#ifdef CONFIG_OF
-extern int of_property_read_u32_index(const struct device_node *np,
- const char *propname,
- u32 index, u32 *out_value);
-#else
-static inline int of_property_read_u32_index(const struct device_node *np,
- const char *propname, u32 index, u32 *out_value)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-#define of_property_count_elems_of_size LINUX_BACKPORT(of_property_count_elems_of_size)
-#ifdef CONFIG_OF
-extern int of_property_count_elems_of_size(const struct device_node *np,
- const char *propname, int elem_size);
-#else
-static inline int of_property_count_elems_of_size(const struct device_node *np,
- const char *propname, int elem_size)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,15,0) */
-
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-/**
- * of_property_count_u32_elems - Count the number of u32 elements in a property
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- *
- * Search for a property in a device node and count the number of u32 elements
- * in it. Returns number of elements on sucess, -EINVAL if the property does
- * not exist or its length does not match a multiple of u32 and -ENODATA if the
- * property does not have a value.
- */
-#define of_property_count_u32_elems LINUX_BACKPORT(of_property_count_u32_elems)
-static inline int of_property_count_u32_elems(const struct device_node *np,
- const char *propname)
-{
- return of_property_count_elems_of_size(np, propname, sizeof(u32));
-}
-#endif /* LINUX_VERSION_IS_LESS(3,15,0) */
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#ifndef CONFIG_OF
-#define of_node_get LINUX_BACKPORT(of_node_get)
-/* Dummy ref counting routines - to be implemented later */
-static inline struct device_node *of_node_get(struct device_node *node)
-{
- return node;
-}
-static inline void of_node_put(struct device_node *node) { }
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,3,0) */
-
-#ifndef of_match_ptr
-#ifdef CONFIG_OF
-#define of_match_ptr(_ptr) (_ptr)
-#else
-#define of_match_ptr(_ptr) NULL
-#endif /* CONFIG_OF */
-#endif /* of_match_ptr */
-
-#ifndef for_each_compatible_node
-#define for_each_compatible_node(dn, type, compatible) \
- for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
- dn = of_find_compatible_node(dn, type, compatible))
-#endif /* for_each_compatible_node */
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#ifndef CONFIG_OF
-static inline struct device_node *of_find_compatible_node(
- struct device_node *from,
- const char *type,
- const char *compat)
-{
- return NULL;
-}
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#define of_property_read_u64_array LINUX_BACKPORT(of_property_read_u64_array)
-#ifdef CONFIG_OF
-/* This is static in the kernel, but we need it in multiple places */
-void *of_find_property_value_of_size(const struct device_node *np,
- const char *propname, u32 len);
-extern int of_property_read_u64_array(const struct device_node *np,
- const char *propname,
- u64 *out_values,
- size_t sz);
-#else
-static inline int of_property_read_u64_array(const struct device_node *np,
- const char *propname,
- u64 *out_values, size_t sz)
-{
- return -ENOSYS;
-}
-#endif /* CONFIG_OF */
-#endif /* LINUX_VERSION_IS_LESS(3,15,0) */
-
-#if LINUX_VERSION_IS_LESS(3,6,0)
-#define of_node_full_name LINUX_BACKPORT(of_node_full_name)
-#ifdef CONFIG_OF
-static inline const char *of_node_full_name(const struct device_node *np)
-{
- return np ? np->full_name : "<no-node>";
-}
-#else
-static inline const char* of_node_full_name(const struct device_node *np)
-{
- return "<no-node>";
-}
-#endif /* CONFIG_OF */
-#endif /* < 3.6 */
-
-#ifndef for_each_child_of_node
-#define for_each_child_of_node(parent, child) \
- while (0)
-#endif
-
-#ifndef CONFIG_OF
-#if LINUX_VERSION_IS_LESS(3,10,0)
-static inline int of_device_is_available(const struct device_node *device)
-{
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,6,0) && !LINUX_VERSION_IN_RANGE(3,2,70, 3,3,0)
-static inline int of_property_match_string(struct device_node *np,
- const char *propname,
- const char *string)
-{
- return -ENOSYS;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-static inline struct property *of_find_property(const struct device_node *np,
- const char *name, int *lenp)
-{
- return NULL;
-}
-
-static inline int of_device_is_compatible(const struct device_node *device,
- const char *name)
-{
- return 0;
-}
-
-static inline struct device_node *of_parse_phandle(struct device_node *np,
- const char *phandle_name,
- int index)
-{
- return NULL;
-}
-
-#define of_match_node(_matches, _node) NULL
-#endif
-
-#endif /* CONFIG_OF */
-
-#if LINUX_VERSION_IS_LESS(3,4,0) && !LINUX_VERSION_IN_RANGE(3,2,44, 3,3,0)
-static inline bool of_property_read_bool(const struct device_node *np,
- const char *propname)
-{
- struct property *prop = of_find_property(np, propname, NULL);
-
- return prop ? true : false;
-}
-#endif
-
-#endif /* _COMPAT_LINUX_OF_H */
diff --git a/backport/backport-include/linux/of_address.h b/backport/backport-include/linux/of_address.h
deleted file mode 100644
index e3a5167a..00000000
--- a/backport/backport-include/linux/of_address.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_OF_ADDRESS_H
-#define __BACKPORT_OF_ADDRESS_H
-#include_next <linux/of_address.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,4,0) && !defined(CONFIG_OF_ADDRESS)
-#ifndef OF_BAD_ADDR
-#define OF_BAD_ADDR ((u64)-1)
-#endif
-#define of_translate_address LINUX_BACKPORT(of_translate_addres)
-static inline u64 of_translate_address(struct device_node *np,
- const __be32 *addr)
-{
- return OF_BAD_ADDR;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,4,0) */
-
-#endif /* __BACKPORT_OF_IRQ_H */
diff --git a/backport/backport-include/linux/of_device.h b/backport/backport-include/linux/of_device.h
deleted file mode 100644
index 827c7fb1..00000000
--- a/backport/backport-include/linux/of_device.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __BP_OF_DEVICE_H
-#define __BP_OF_DEVICE_H
-#include_next <linux/of_device.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,18,0)
-static inline int backport_of_dma_configure(struct device *dev,
- struct device_node *np,
- bool force_dma)
-{
-#if LINUX_VERSION_IS_GEQ(4,15,0)
- dev->bus->force_dma = force_dma;
- return of_dma_configure(dev, np);
-#elif LINUX_VERSION_IS_GEQ(4,12,0)
- return of_dma_configure(dev, np);
-#elif LINUX_VERSION_IS_GEQ(4,1,0)
- of_dma_configure(dev, np);
- return 0;
-#else
- return 0;
-#endif
-}
-#define of_dma_configure LINUX_BACKPORT(of_dma_configure)
-#endif /* < 4.18 */
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-#if LINUX_VERSION_IS_GEQ(4,4,0)
-ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len);
-#define of_device_modalias bp_of_device_modalias
-#endif /* > 4.4.0 */
-#endif /* < 4.12 */
-
-#endif /* __BP_OF_DEVICE_H */
diff --git a/backport/backport-include/linux/of_irq.h b/backport/backport-include/linux/of_irq.h
deleted file mode 100644
index 58108e2c..00000000
--- a/backport/backport-include/linux/of_irq.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __BACKPORT_OF_IRQ_H
-#define __BACKPORT_OF_IRQ_H
-#include_next <linux/of_irq.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,5,0) && !defined(CONFIG_OF)
-#define irq_of_parse_and_map LINUX_BACKPORT(irq_of_parse_and_map)
-static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
- int index)
-{
- return 0;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,5,0) */
-
-#endif /* __BACKPORT_OF_IRQ_H */
diff --git a/backport/backport-include/linux/of_net.h b/backport/backport-include/linux/of_net.h
deleted file mode 100644
index 7f4b688f..00000000
--- a/backport/backport-include/linux/of_net.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _BP_OF_NET_H
-#define _BP_OF_NET_H
-#include_next <linux/of_net.h>
-#include <linux/version.h>
-
-#ifndef CONFIG_OF
-#if LINUX_VERSION_IS_LESS(3,10,0)
-static inline const void *of_get_mac_address(struct device_node *np)
-{
- return NULL;
-}
-#endif
-#endif
-
-#endif /* _BP_OF_NET_H */
diff --git a/backport/backport-include/linux/of_platform.h b/backport/backport-include/linux/of_platform.h
deleted file mode 100644
index 625ee9ed..00000000
--- a/backport/backport-include/linux/of_platform.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __BACKPORT_LINUX_OF_PLATFORM_H
-#define __BACKPORT_LINUX_OF_PLATFORM_H
-#include_next <linux/of_platform.h>
-#include <linux/version.h>
-#include <linux/of.h>
-/* upstream now includes this here and some people rely on it */
-#include <linux/of_device.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0) && !defined(CONFIG_OF_DEVICE)
-struct of_dev_auxdata;
-#define of_platform_populate LINUX_BACKPORT(of_platform_populate)
-static inline int of_platform_populate(struct device_node *root,
- const struct of_device_id *matches,
- const struct of_dev_auxdata *lookup,
- struct device *parent)
-{
- return -ENODEV;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,4,0) */
-
-#if LINUX_VERSION_IS_LESS(3,11,0) && !defined(CONFIG_OF_DEVICE)
-extern const struct of_device_id of_default_bus_match_table[];
-#endif /* LINUX_VERSION_IS_LESS(3,11,0) */
-
-#if LINUX_VERSION_IS_LESS(4,3,0) && !defined(CONFIG_OF_DEVICE)
-struct of_dev_auxdata;
-#define of_platform_default_populate \
- LINUX_BACKPORT(of_platform_default_populate)
-static inline int
-of_platform_default_populate(struct device_node *root,
- const struct of_dev_auxdata *lookup,
- struct device *parent)
-{
- return -ENODEV;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,3,0) */
-
-#endif /* __BACKPORT_LINUX_OF_PLATFORM_H */
diff --git a/backport/backport-include/linux/olpc-ec.h b/backport/backport-include/linux/olpc-ec.h
deleted file mode 100644
index 353107f6..00000000
--- a/backport/backport-include/linux/olpc-ec.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _COMPAT_LINUX_OLPC_EC_H
-#define _COMPAT_LINUX_OLPC_EC_H
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,6,0)
-#include_next <linux/olpc-ec.h>
-#endif /* LINUX_VERSION_IS_GEQ(3,6,0) */
-
-#endif /* _COMPAT_LINUX_OLPC_EC_H */
diff --git a/backport/backport-include/linux/page_ref.h b/backport/backport-include/linux/page_ref.h
deleted file mode 100644
index e45734ec..00000000
--- a/backport/backport-include/linux/page_ref.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __BP_PAGE_REF_H
-#define __BP_PAGE_REF_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,6,0)
-#include_next <linux/page_ref.h>
-#else
-static inline void page_ref_inc(struct page *page)
-{
- atomic_inc(&page->_count);
-}
-
-static inline int page_ref_count(struct page *page)
-{
- return atomic_read(&page->_count);
-}
-
-static inline int page_ref_sub_and_test(struct page *page, int nr)
-{
- return atomic_sub_and_test(nr, &page->_count);
-}
-#endif
-
-#endif /* __BP_PAGE_REF_H */
diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h
deleted file mode 100644
index 42b3dc53..00000000
--- a/backport/backport-include/linux/pci.h
+++ /dev/null
@@ -1,240 +0,0 @@
-#ifndef _BACKPORT_LINUX_PCI_H
-#define _BACKPORT_LINUX_PCI_H
-#include_next <linux/pci.h>
-#include <linux/version.h>
-
-#ifndef module_pci_driver
-/**
- * module_pci_driver() - Helper macro for registering a PCI driver
- * @__pci_driver: pci_driver struct
- *
- * Helper macro for PCI drivers which do not do anything special in module
- * init/exit. This eliminates a lot of boilerplate. Each module may only
- * use this macro once, and calling it replaces module_init() and module_exit()
- */
-#define module_pci_driver(__pci_driver) \
- module_driver(__pci_driver, pci_register_driver, \
- pci_unregister_driver)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-void pci_stop_and_remove_bus_device(struct pci_dev *dev);
-#endif
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
-int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
-#define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword)
-int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
-#define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word)
-int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
-#define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword)
-int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
-#define pcie_capability_clear_and_set_word LINUX_BACKPORT(pcie_capability_clear_and_set_word)
-int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
- u16 clear, u16 set);
-#define pcie_capability_clear_and_set_dword LINUX_BACKPORT(pcie_capability_clear_and_set_dword)
-int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
- u32 clear, u32 set);
-
-#define pcie_capability_set_word LINUX_BACKPORT(pcie_capability_set_word)
-static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
- u16 set)
-{
- return pcie_capability_clear_and_set_word(dev, pos, 0, set);
-}
-
-#define pcie_capability_set_dword LINUX_BACKPORT(pcie_capability_set_dword)
-static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
- u32 set)
-{
- return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
-}
-
-#define pcie_capability_clear_word LINUX_BACKPORT(pcie_capability_clear_word)
-static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
- u16 clear)
-{
- return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
-}
-
-#define pcie_capability_clear_dword LINUX_BACKPORT(pcie_capability_clear_dword)
-static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
- u32 clear)
-{
- return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
-}
-
-int pci_pcie_type(struct pci_dev *dev);
-#endif
-
-#ifndef PCI_DEVICE_SUB
-/**
- * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
- * @vend: the 16 bit PCI Vendor ID
- * @dev: the 16 bit PCI Device ID
- * @subvend: the 16 bit PCI Subvendor ID
- * @subdev: the 16 bit PCI Subdevice ID
- *
- * This macro is used to create a struct pci_device_id that matches a
- * specific device with subsystem information.
- */
-#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
- .vendor = (vend), .device = (dev), \
- .subvendor = (subvend), .subdevice = (subdev)
-#endif /* PCI_DEVICE_SUB */
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#define pci_dev_flags LINUX_BACKPORT(pci_dev_flags)
-#define PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG LINUX_BACKPORT(PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG)
-#define PCI_DEV_FLAGS_NO_D3 LINUX_BACKPORT(PCI_DEV_FLAGS_NO_D3)
-#define PCI_DEV_FLAGS_ASSIGNED LINUX_BACKPORT(PCI_DEV_FLAGS_ASSIGNED)
-enum pci_dev_flags {
- /* INTX_DISABLE in PCI_COMMAND register disables MSI
- * generation too.
- */
- PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
- /* Device configuration is irrevocably lost if disabled into D3 */
- PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
- /* Provide indication device is assigned by a Virtual Machine Manager */
- PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4,
-};
-#endif /* LINUX_VERSION_IS_LESS(3,2,0) */
-
-#if LINUX_VERSION_IS_LESS(3,8,0)
-#define pci_sriov_set_totalvfs LINUX_BACKPORT(pci_sriov_set_totalvfs)
-int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
-#endif /* LINUX_VERSION_IS_LESS(3,8,0) */
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-/* Taken from drivers/pci/pci.h */
-struct pci_sriov {
- int pos; /* capability position */
- int nres; /* number of resources */
- u32 cap; /* SR-IOV Capabilities */
- u16 ctrl; /* SR-IOV Control */
- u16 total_VFs; /* total VFs associated with the PF */
- u16 initial_VFs; /* initial VFs associated with the PF */
- u16 num_VFs; /* number of VFs available */
- u16 offset; /* first VF Routing ID offset */
- u16 stride; /* following VF stride */
- u32 pgsz; /* page size for BAR alignment */
- u8 link; /* Function Dependency Link */
- u16 driver_max_VFs; /* max num VFs driver supports */
- struct pci_dev *dev; /* lowest numbered PF */
- struct pci_dev *self; /* this PF */
- struct mutex lock; /* lock for VF bus */
- struct work_struct mtask; /* VF Migration task */
- u8 __iomem *mstate; /* VF Migration State Array */
-};
-
-#define pci_vfs_assigned LINUX_BACKPORT(pci_vfs_assigned)
-#ifdef CONFIG_PCI_IOV
-int pci_vfs_assigned(struct pci_dev *dev);
-#else
-static inline int pci_vfs_assigned(struct pci_dev *dev)
-{
- return 0;
-}
-#endif
-
-#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
-
-#if LINUX_VERSION_IS_LESS(4,8,0)
-#define pci_alloc_irq_vectors LINUX_BACKPORT(pci_alloc_irq_vectors)
-#ifdef CONFIG_PCI_MSI
-int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
- unsigned int max_vecs, unsigned int flags);
-#else
-static inline int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
- unsigned int max_vecs, unsigned int flags)
-{ return -ENOSYS; }
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,8,0)
-#define pci_free_irq_vectors LINUX_BACKPORT(pci_free_irq_vectors)
-static inline void pci_free_irq_vectors(struct pci_dev *dev)
-{
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-#define pci_enable_msi_range LINUX_BACKPORT(pci_enable_msi_range)
-#ifdef CONFIG_PCI_MSI
-int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec);
-#else
-static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec,
- int maxvec)
-{ return -ENOSYS; }
-#endif
-#endif
-
-#ifdef CONFIG_PCI
-#if LINUX_VERSION_IS_LESS(3,14,0)
-#define pci_enable_msix_range LINUX_BACKPORT(pci_enable_msix_range)
-#ifdef CONFIG_PCI_MSI
-int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
- int minvec, int maxvec);
-#else
-static inline int pci_enable_msix_range(struct pci_dev *dev,
- struct msix_entry *entries, int minvec, int maxvec)
-{ return -ENOSYS; }
-#endif
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#define pci_device_is_present LINUX_BACKPORT(pci_device_is_present)
-bool pci_device_is_present(struct pci_dev *pdev);
-#endif
-
-#ifdef CONFIG_PCI
-#if LINUX_VERSION_IS_LESS(3,14,0)
-#define pci_enable_msix_exact LINUX_BACKPORT(pci_enable_msix_exact)
-#ifdef CONFIG_PCI_MSI
-static inline int pci_enable_msix_exact(struct pci_dev *dev,
- struct msix_entry *entries, int nvec)
-{
- int rc = pci_enable_msix_range(dev, entries, nvec, nvec);
- if (rc < 0)
- return rc;
- return 0;
-}
-#else
-static inline int pci_enable_msix_exact(struct pci_dev *dev,
- struct msix_entry *entries, int nvec)
-{ return -ENOSYS; }
-#endif /* CONFIG_PCI_MSI */
-#endif
-#endif /* CONFIG_PCI */
-
-#if LINUX_VERSION_IS_LESS(4,9,0) && \
- !LINUX_VERSION_IN_RANGE(3,12,69, 3,13,0) && \
- !LINUX_VERSION_IN_RANGE(4,4,37, 4,5,0) && \
- !LINUX_VERSION_IN_RANGE(4,8,13, 4,9,0)
-
-static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
-{
- while (1) {
- if (!pci_is_pcie(dev))
- break;
- if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
- return dev;
- if (!dev->bus->self)
- break;
- dev = dev->bus->self;
- }
- return NULL;
-}
-
-#endif/* <4.9.0 but not >= 3.12.69, 4.4.37, 4.8.13 */
-
-#ifndef PCI_IRQ_LEGACY
-#define PCI_IRQ_LEGACY (1 << 0) /* Allow legacy interrupts */
-#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */
-#define PCI_IRQ_MSIX (1 << 2) /* Allow MSI-X interrupts */
-#define PCI_IRQ_ALL_TYPES \
- (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
-#endif
-
-#endif /* _BACKPORT_LINUX_PCI_H */
diff --git a/backport/backport-include/linux/percpu-defs.h b/backport/backport-include/linux/percpu-defs.h
deleted file mode 100644
index 87a92e07..00000000
--- a/backport/backport-include/linux/percpu-defs.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __BACKPORT_PERCPU_DEFS_H
-#define __BACKPORT_PERCPU_DEFS_H
-#include_next <linux/percpu-defs.h>
-
-/* override this with the array-safe version */
-#undef __verify_pcpu_ptr
-#define __verify_pcpu_ptr(ptr) \
-do { \
- const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
- (void)__vpp_verify; \
-} while (0)
-
-#endif /* __BACKPORT_PERCPU_DEFS_H */
diff --git a/backport/backport-include/linux/percpu.h b/backport/backport-include/linux/percpu.h
deleted file mode 100644
index 10be03cb..00000000
--- a/backport/backport-include/linux/percpu.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2018 Intel Corporation
- */
-#ifndef __BACKPORT_PERCPU_H
-#define __BACKPORT_PERCPU_H
-#include_next <linux/percpu.h>
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-static inline void __percpu *__alloc_gfp_warn(void)
-{
- WARN(1, "Cannot backport alloc_percpu_gfp");
- return NULL;
-}
-
-#define alloc_percpu_gfp(type, gfp) \
- ({ (gfp == GFP_KERNEL) ? alloc_percpu(type) : __alloc_gfp_warn(); })
-#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
-
-#endif /* __BACKPORT_PERCPU_H */
diff --git a/backport/backport-include/linux/phy.h b/backport/backport-include/linux/phy.h
deleted file mode 100644
index f331428b..00000000
--- a/backport/backport-include/linux/phy.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef __BACKPORT_LINUX_PHY_H
-#define __BACKPORT_LINUX_PHY_H
-#include_next <linux/phy.h>
-#include <linux/compiler.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define phy_connect(dev, bus_id, handler, interface) \
- phy_connect(dev, bus_id, handler, 0, interface)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define phydev_name LINUX_BACKPORT(phydev_name)
-static inline const char *phydev_name(const struct phy_device *phydev)
-{
- return dev_name(&phydev->dev);
-}
-
-#define mdiobus_is_registered_device LINUX_BACKPORT(mdiobus_is_registered_device)
-static inline bool mdiobus_is_registered_device(struct mii_bus *bus, int addr)
-{
- return bus->phy_map[addr];
-}
-
-#define phy_attached_print LINUX_BACKPORT(phy_attached_print)
-void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
- __printf(2, 3);
-#define phy_attached_info LINUX_BACKPORT(phy_attached_info)
-void phy_attached_info(struct phy_device *phydev);
-
-static inline int backport_mdiobus_register(struct mii_bus *bus)
-{
- bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
- if (!bus->irq) {
- pr_err("mii_bus irq allocation failed\n");
- return -ENOMEM;
- }
-
- memset(bus->irq, PHY_POLL, sizeof(int) * PHY_MAX_ADDR);
-
-/* in kernel 4.3 a #define for mdiobus_register is added to the kernel. */
-#ifndef mdiobus_register
- return mdiobus_register(bus);
-#else
- return __mdiobus_register(bus, THIS_MODULE);
-#endif
-}
-#ifdef mdiobus_register
-#undef mdiobus_register
-#endif
-#define mdiobus_register LINUX_BACKPORT(mdiobus_register)
-
-static inline void backport_mdiobus_unregister(struct mii_bus *bus)
-{
- kfree(bus->irq);
- mdiobus_unregister(bus);
-}
-#define mdiobus_unregister LINUX_BACKPORT(mdiobus_unregister)
-#endif /* < 4.5 */
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define phydev_get_addr LINUX_BACKPORT(phydev_get_addr)
-static inline int phydev_get_addr(struct phy_device *phydev)
-{
- return phydev->addr;
-}
-#else
-#define phydev_get_addr LINUX_BACKPORT(phydev_get_addr)
-static inline int phydev_get_addr(struct phy_device *phydev)
-{
- return phydev->mdio.addr;
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_PHY_H */
diff --git a/backport/backport-include/linux/platform_data/media/si4713.h b/backport/backport-include/linux/platform_data/media/si4713.h
deleted file mode 100644
index 3d49c32f..00000000
--- a/backport/backport-include/linux/platform_data/media/si4713.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_SI4713_H
-#define __BACKPORT_SI4713_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,5,0)
-#include_next <linux/platform_data/media/si4713.h>
-#else
-#include <media/si4713.h>
-#endif /* < 4.5 */
-
-#endif /* __BACKPORT_SI4713_H */
diff --git a/backport/backport-include/linux/platform_data/media/soc_camera_platform.h b/backport/backport-include/linux/platform_data/media/soc_camera_platform.h
deleted file mode 100644
index 927bf8fa..00000000
--- a/backport/backport-include/linux/platform_data/media/soc_camera_platform.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_SOC_CAMERA_H__
-#define __BACKPORT_SOC_CAMERA_H__
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,5,0)
-#include_next <linux/platform_data/media/soc_camera_platform.h>
-#else
-#include <media/soc_camera_platform.h>
-#endif /* < 4.5 */
-
-#endif /* __BACKPORT_SOC_CAMERA_H__ */
diff --git a/backport/backport-include/linux/platform_data/media/timb_radio.h b/backport/backport-include/linux/platform_data/media/timb_radio.h
deleted file mode 100644
index f1fb47a2..00000000
--- a/backport/backport-include/linux/platform_data/media/timb_radio.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_TIMB_RADIO_
-#define __BACKPORT_TIMB_RADIO_
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,5,0)
-#include_next <linux/platform_data/media/timb_radio.h>
-#else
-#include <media/timb_radio.h>
-#endif /* < 4.5 */
-
-#endif /* __BACKPORT_TIMB_RADIO_ */
diff --git a/backport/backport-include/linux/platform_data/media/timb_video.h b/backport/backport-include/linux/platform_data/media/timb_video.h
deleted file mode 100644
index 82ff7887..00000000
--- a/backport/backport-include/linux/platform_data/media/timb_video.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __BACKPORT_TIMB_VIDEO_
-#define __BACKPORT_TIMB_VIDEO_
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,5,0)
-#include_next <linux/platform_data/media/timb_video.h>
-#else
-#include <media/timb_video.h>
-#endif /* < 4.5 */
-
-#endif /* __BACKPORT_TIMB_VIDEO_ */
diff --git a/backport/backport-include/linux/platform_device.h b/backport/backport-include/linux/platform_device.h
deleted file mode 100644
index 5b821ee4..00000000
--- a/backport/backport-include/linux/platform_device.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __BACKPORT_PLATFORM_DEVICE_H
-#define __BACKPORT_PLATFORM_DEVICE_H
-
-#include_next <linux/platform_device.h>
-#include <linux/version.h>
-
-#ifndef module_platform_driver_probe
-#define module_platform_driver_probe(__platform_driver, __platform_probe) \
-static int __init __platform_driver##_init(void) \
-{ \
- return platform_driver_probe(&(__platform_driver), \
- __platform_probe); \
-} \
-module_init(__platform_driver##_init); \
-static void __exit __platform_driver##_exit(void) \
-{ \
- platform_driver_unregister(&(__platform_driver)); \
-} \
-module_exit(__platform_driver##_exit);
-#endif
-
-#ifndef PLATFORM_DEVID_NONE
-#define PLATFORM_DEVID_NONE (-1)
-#endif
-
-#ifndef PLATFORM_DEVID_AUTO
-#define PLATFORM_DEVID_AUTO (-1)
-#endif
-
-#ifndef module_platform_driver
-#define module_platform_driver(__platform_driver) \
- module_driver(__platform_driver, platform_driver_register, \
- platform_driver_unregister)
-#endif
-
-#endif /* __BACKPORT_PLATFORM_DEVICE_H */
diff --git a/backport/backport-include/linux/pm.h b/backport/backport-include/linux/pm.h
deleted file mode 100644
index 926b0bf1..00000000
--- a/backport/backport-include/linux/pm.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __BACKPORT_PM_H
-#define __BACKPORT_PM_H
-#include_next <linux/pm.h>
-
-#ifndef PM_EVENT_AUTO
-#define PM_EVENT_AUTO 0x0400
-#endif
-
-#ifndef PM_EVENT_SLEEP
-#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND)
-#endif
-
-#ifndef PMSG_IS_AUTO
-#define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0)
-#endif
-
-#endif /* __BACKPORT_PM_H */
diff --git a/backport/backport-include/linux/pm_qos.h b/backport/backport-include/linux/pm_qos.h
deleted file mode 100644
index d5bfc9bc..00000000
--- a/backport/backport-include/linux/pm_qos.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _COMPAT_LINUX_PM_QOS_H
-#define _COMPAT_LINUX_PM_QOS_H 1
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-#include_next <linux/pm_qos.h>
-#else
-#include <linux/pm_qos_params.h>
-#endif /* LINUX_VERSION_IS_GEQ(3,2,0) */
-
-#ifndef PM_QOS_DEFAULT_VALUE
-#define PM_QOS_DEFAULT_VALUE -1
-#endif
-
-#endif /* _COMPAT_LINUX_PM_QOS_H */
diff --git a/backport/backport-include/linux/pm_runtime.h b/backport/backport-include/linux/pm_runtime.h
deleted file mode 100644
index e16cd30b..00000000
--- a/backport/backport-include/linux/pm_runtime.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __BACKPORT_PM_RUNTIME_H
-#define __BACKPORT_PM_RUNTIME_H
-#include_next <linux/pm_runtime.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define pm_runtime_active LINUX_BACKPORT(pm_runtime_active)
-#ifdef CONFIG_PM
-static inline bool pm_runtime_active(struct device *dev)
-{
- return dev->power.runtime_status == RPM_ACTIVE
- || dev->power.disable_depth;
-}
-#else
-static inline bool pm_runtime_active(struct device *dev) { return true; }
-#endif /* CONFIG_PM */
-
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-static inline int pm_runtime_force_suspend(struct device *dev)
-{
-#ifdef CONFIG_PM
- /* cannot backport properly, I think */
- WARN_ON_ONCE(1);
- return -EINVAL;
-#endif
- return 0;
-}
-static inline int pm_runtime_force_resume(struct device *dev)
-{
-#ifdef CONFIG_PM
- /* cannot backport properly, I think */
- WARN_ON_ONCE(1);
- return -EINVAL;
-#endif
- return 0;
-}
-#endif
-
-#endif /* __BACKPORT_PM_RUNTIME_H */
diff --git a/backport/backport-include/linux/pnp.h b/backport/backport-include/linux/pnp.h
deleted file mode 100644
index 0a88455b..00000000
--- a/backport/backport-include/linux/pnp.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __BACKPORT_LINUX_PNP_H
-#define __BACKPORT_LINUX_PNP_H
-#include_next <linux/pnp.h>
-
-#ifndef module_pnp_driver
-/**
- * module_pnp_driver() - Helper macro for registering a PnP driver
- * @__pnp_driver: pnp_driver struct
- *
- * Helper macro for PnP drivers which do not do anything special in module
- * init/exit. This eliminates a lot of boilerplate. Each module may only
- * use this macro once, and calling it replaces module_init() and module_exit()
- */
-#define module_pnp_driver(__pnp_driver) \
- module_driver(__pnp_driver, pnp_register_driver, \
- pnp_unregister_driver)
-#endif
-
-#endif /* __BACKPORT_LINUX_PNP_H */
diff --git a/backport/backport-include/linux/poll.h b/backport/backport-include/linux/poll.h
deleted file mode 100644
index aea64048..00000000
--- a/backport/backport-include/linux/poll.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __BACKPORT_LINUX_POLL_H
-#define __BACKPORT_LINUX_POLL_H
-#include_next <linux/poll.h>
-#include <linux/version.h>
-#include <linux/eventpoll.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-#define poll_does_not_wait LINUX_BACKPORT(poll_does_not_wait)
-static inline bool poll_does_not_wait(const poll_table *p)
-{
- return p == NULL || p->qproc == NULL;
-}
-
-#define poll_requested_events LINUX_BACKPORT(poll_requested_events)
-static inline unsigned long poll_requested_events(const poll_table *p)
-{
- return p ? p->key : ~0UL;
-}
-#endif /* < 3.4 */
-
-#endif /* __BACKPORT_LINUX_POLL_H */
diff --git a/backport/backport-include/linux/printk.h b/backport/backport-include/linux/printk.h
deleted file mode 100644
index 22851d7f..00000000
--- a/backport/backport-include/linux/printk.h
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef _COMPAT_LINUX_PRINTK_H
-#define _COMPAT_LINUX_PRINTK_H 1
-
-#include <linux/version.h>
-#include_next <linux/printk.h>
-
-/* see pr_fmt at end of file */
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/* backports 7a555613 */
-#if defined(CONFIG_DYNAMIC_DEBUG)
-#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
- groupsize, buf, len, ascii) \
-do { \
- DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, \
- __builtin_constant_p(prefix_str) ? prefix_str : "hexdump");\
- if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
- print_hex_dump(KERN_DEBUG, prefix_str, \
- prefix_type, rowsize, groupsize, \
- buf, len, ascii); \
-} while (0)
-#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
- groupsize, buf, len, ascii) \
- dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
- groupsize, buf, len, ascii)
-#else
-#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
- groupsize, buf, len, ascii) \
- print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
- groupsize, buf, len, ascii)
-#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
-
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-#ifndef pr_warn
-#define pr_warn pr_warning
-#endif
-
-#ifndef printk_once
-#define printk_once(x...) ({ \
- static bool __print_once; \
- \
- if (!__print_once) { \
- __print_once = true; \
- printk(x); \
- } \
-})
-#endif
-
-#ifndef printk_ratelimited
-/*
- * ratelimited messages with local ratelimit_state,
- * no local ratelimit_state used in the !PRINTK case
- */
-#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) \
-({ \
- static DEFINE_RATELIMIT_STATE(_rs, \
- DEFAULT_RATELIMIT_INTERVAL, \
- DEFAULT_RATELIMIT_BURST); \
- \
- if (__ratelimit(&_rs)) \
- printk(fmt, ##__VA_ARGS__); \
-})
-#else
-#define printk_ratelimited(fmt, ...) \
- no_printk(fmt, ##__VA_ARGS__)
-#endif
-#endif /* printk_ratelimited */
-
-#ifndef pr_emerg_ratelimited
-#define pr_emerg_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_emerg_ratelimited */
-
-#ifndef pr_alert_ratelimited
-#define pr_alert_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_alert_ratelimited */
-
-#ifndef pr_crit_ratelimited
-#define pr_crit_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_crit_ratelimited */
-
-#ifndef pr_err_ratelimited
-#define pr_err_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_err_ratelimited */
-
-#ifndef pr_warn_ratelimited
-#define pr_warn_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_warn_ratelimited */
-
-#ifndef pr_notice_ratelimited
-#define pr_notice_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_notice_ratelimited */
-
-#ifndef pr_info_ratelimited
-#define pr_info_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
-#endif /* pr_info_ratelimited */
-
-/* no pr_cont_ratelimited, don't do that... */
-
-#ifndef pr_devel_ratelimited
-#if defined(DEBUG)
-#define pr_devel_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#else
-#define pr_devel_ratelimited(fmt, ...) \
- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif
-#endif /* pr_devel_ratelimited */
-
-#ifndef pr_debug_ratelimited
-/* If you are writing a driver, please use dev_dbg instead */
-#if defined(CONFIG_DYNAMIC_DEBUG)
-/* descriptor check is first to prevent flooding with "callbacks suppressed" */
-#define pr_debug_ratelimited(fmt, ...) \
-do { \
- static DEFINE_RATELIMIT_STATE(_rs, \
- DEFAULT_RATELIMIT_INTERVAL, \
- DEFAULT_RATELIMIT_BURST); \
- DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
- if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
- __ratelimit(&_rs)) \
- __dynamic_pr_debug(&descriptor, fmt, ##__VA_ARGS__); \
-} while (0)
-#elif defined(DEBUG)
-#define pr_debug_ratelimited(fmt, ...) \
- printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#else
-#define pr_debug_ratelimited(fmt, ...) \
- no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
-#endif
-#endif /* pr_debug_ratelimited */
-
-/* replace hex_dump_to_buffer() with a version which returns the length */
-#if LINUX_VERSION_IS_LESS(4,0,0)
-#define hex_dump_to_buffer LINUX_BACKPORT(hex_dump_to_buffer)
-extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
- int groupsize, char *linebuf, size_t linebuflen,
- bool ascii);
-#endif
-
-#endif /* _COMPAT_LINUX_PRINTK_H */
-
-/* This must be outside -- see also kernel.h */
-#ifndef pr_fmt
-#define pr_fmt(fmt) fmt
-#endif
diff --git a/backport/backport-include/linux/proc_fs.h b/backport/backport-include/linux/proc_fs.h
deleted file mode 100644
index be239bf8..00000000
--- a/backport/backport-include/linux/proc_fs.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __BACKPORT_PROC_FS_H
-#define __BACKPORT_PROC_FS_H
-#include_next <linux/proc_fs.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-
-#ifdef CONFIG_PROC_FS
-/*
- * backport of:
- * procfs: new helper - PDE_DATA(inode)
- */
-#define PDE_DATA LINUX_BACKPORT(PDE_DATA)
-static inline void *PDE_DATA(const struct inode *inode)
-{
- return PROC_I(inode)->pde->data;
-}
-extern void proc_set_size(struct proc_dir_entry *, loff_t);
-extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
-#else
-#define PDE_DATA LINUX_BACKPORT(PDE_DATA)
-static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
-static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
-static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
-#endif /* CONFIG_PROC_FS */
-
-#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
-
-#endif /* __BACKPORT_PROC_FS_H */
diff --git a/backport/backport-include/linux/property.h b/backport/backport-include/linux/property.h
deleted file mode 100644
index a0d7bed1..00000000
--- a/backport/backport-include/linux/property.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __BACKPORT_LINUX_PROPERTY_H_
-#define __BACKPORT_LINUX_PROPERTY_H_
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,18,17)
-#include_next <linux/property.h>
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,3,0)
-
-#define device_get_mac_address LINUX_BACKPORT(device_get_mac_address)
-void *device_get_mac_address(struct device *dev, char *addr, int alen);
-
-#endif /* < 4.3 */
-
-#endif /* __BACKPORT_LINUX_PROPERTY_H_ */
diff --git a/backport/backport-include/linux/ptp_clock_kernel.h b/backport/backport-include/linux/ptp_clock_kernel.h
deleted file mode 100644
index e4483c0e..00000000
--- a/backport/backport-include/linux/ptp_clock_kernel.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __BACKPORT_PTP_CLOCK_KERNEL_H
-#define __BACKPORT_PTP_CLOCK_KERNEL_H
-
-#include <linux/version.h>
-#include_next <linux/ptp_clock_kernel.h>
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-#include <linux/posix-clock.h>
-
-#define PTP_MAX_TIMESTAMPS 128
-#define PTP_BUF_TIMESTAMPS 30
-
-struct timestamp_event_queue {
- struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
- int head;
- int tail;
- spinlock_t lock;
-};
-
-struct ptp_clock {
- struct posix_clock clock;
- struct device *dev;
- struct ptp_clock_info *info;
- dev_t devid;
- int index; /* index into clocks.map */
- struct pps_device *pps_source;
- struct timestamp_event_queue tsevq; /* simple fifo for time stamps */
- struct mutex tsevq_mux; /* one process at a time reading the fifo */
- wait_queue_head_t tsev_wq;
- int defunct; /* tells readers to go away when clock is being removed */
-};
-
-extern int ptp_clock_index(struct ptp_clock *ptp);
-#endif /* LINUX_VERSION_IS_LESS(3,5,0) */
-
-#if LINUX_VERSION_IS_LESS(3,7,0) && !defined(CONFIG_SUSE_KERNEL)
-#define ptp_clock_register(info,parent) ptp_clock_register(info)
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-
-#endif /* __BACKPORT_PTP_CLOCK_KERNEL_H */
diff --git a/backport/backport-include/linux/random.h b/backport/backport-include/linux/random.h
deleted file mode 100644
index fa016cce..00000000
--- a/backport/backport-include/linux/random.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef __BACKPORT_RANDOM_H
-#define __BACKPORT_RANDOM_H
-#include_next <linux/random.h>
-#include <linux/version.h>
-
-#if (LINUX_VERSION_IS_GEQ(3,3,0) && LINUX_VERSION_IS_LESS(3,4,10)) || \
- (LINUX_VERSION_IS_GEQ(3,1,0) && LINUX_VERSION_IS_LESS(3,2,27)) || \
- LINUX_VERSION_IS_LESS(3,0,41)
-#define add_device_randomness LINUX_BACKPORT(add_device_randomness)
-static inline void add_device_randomness(const void *buf, unsigned int size)
-{
-}
-#endif
-
-/* #if LINUX_VERSION_IS_LESS(3,8,0) */
-/* already backported in our kernels */
-#if 0
-/* backports 496f2f9 */
-#define prandom_seed(_seed) srandom32(_seed)
-#define prandom_u32() random32()
-#define prandom_u32_state(_state) prandom32(_state)
-/* backport 6582c665d6b882dad8329e05749fbcf119f1ab88 */
-#define prandom_bytes LINUX_BACKPORT(prandom_bytes)
-void prandom_bytes(void *buf, int bytes);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-/**
- * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
- * @ep_ro: right open interval endpoint
- *
- * Returns a pseudo-random number that is in interval [0, ep_ro). Note
- * that the result depends on PRNG being well distributed in [0, ~0U]
- * u32 space. Here we use maximally equidistributed combined Tausworthe
- * generator, that is, prandom_u32(). This is useful when requesting a
- * random index of an array containing ep_ro elements, for example.
- *
- * Returns: pseudo-random number in interval [0, ep_ro)
- */
-#define prandom_u32_max LINUX_BACKPORT(prandom_u32_max)
-static inline u32 prandom_u32_max(u32 ep_ro)
-{
- return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-
-#if LINUX_VERSION_IS_LESS(4,11,0)
-static inline u32 get_random_u32(void)
-{
- return get_random_int();
-}
-#endif
-
-#endif /* __BACKPORT_RANDOM_H */
diff --git a/backport/backport-include/linux/rculist.h b/backport/backport-include/linux/rculist.h
deleted file mode 100644
index 9671e7c4..00000000
--- a/backport/backport-include/linux/rculist.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __BACKPORT_RCULIST_H
-#define __BACKPORT_RCULIST_H
-#include_next <linux/rculist.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#include <backport/magic.h>
-#define hlist_for_each_entry_rcu4(tpos, pos, head, member) \
- for (pos = rcu_dereference_raw(hlist_first_rcu(head)); \
- pos && \
- ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; });\
- pos = rcu_dereference_raw(hlist_next_rcu(pos)))
-
-#define hlist_for_each_entry_rcu3(pos, head, member) \
- for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
- typeof(*(pos)), member); \
- pos; \
- pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
- &(pos)->member)), typeof(*(pos)), member))
-
-#undef hlist_for_each_entry_rcu
-#define hlist_for_each_entry_rcu(...) \
- macro_dispatcher(hlist_for_each_entry_rcu, __VA_ARGS__)(__VA_ARGS__)
-#endif /* < 3.9 */
-
-#ifndef list_for_each_entry_continue_rcu
-#define list_for_each_entry_continue_rcu(pos, head, member) \
- for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
- pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
-#endif
-
-#ifndef list_entry_rcu
-#define list_entry_rcu(ptr, type, member) \
- container_of(rcu_dereference(ptr), type, member)
-#endif
-
-#ifndef list_first_or_null_rcu
-/**
- * list_first_or_null_rcu - get the first element from a list
- * @ptr: the list head to take the element from.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_struct within the struct.
- *
- * Note that if the list is empty, it returns NULL.
- *
- * This primitive may safely run concurrently with the _rcu list-mutation
- * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
- */
-#define list_first_or_null_rcu(ptr, type, member) \
-({ \
- struct list_head *__ptr = (ptr); \
- struct list_head *__next = ACCESS_ONCE(__ptr->next); \
- likely(__ptr != __next) ? list_entry_rcu(__next, type, member) : NULL; \
-})
-#endif /* list_first_or_null_rcu */
-
-#endif /* __BACKPORT_RCULIST_H */
diff --git a/backport/backport-include/linux/rcupdate.h b/backport/backport-include/linux/rcupdate.h
deleted file mode 100644
index b96ef496..00000000
--- a/backport/backport-include/linux/rcupdate.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __BACKPORT_LINUX_RCUPDATE_H
-#define __BACKPORT_LINUX_RCUPDATE_H
-#include_next <linux/rcupdate.h>
-
-/*
- * This adds a nested function everywhere kfree_rcu() was called. This
- * function frees the memory and is given as a function to call_rcu().
- * The rcu callback could happen every time also after the module was
- * unloaded and this will cause problems. To address that problem, we
- * put rcu_barrier() into each module_exit() in module.h.
- */
-#if !defined(kfree_rcu)
-#define kfree_rcu(data, rcuhead) do { \
- void __kfree_rcu_fn(struct rcu_head *rcu_head) \
- { \
- void *___ptr; \
- ___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\
- kfree(___ptr); \
- } \
- call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \
- } while (0)
-#endif
-
-#ifndef RCU_INIT_POINTER
-#define RCU_INIT_POINTER(p, v) \
- p = (typeof(*v) __force __rcu *)(v)
-#endif
-
-#ifndef rcu_dereference_check
-#define rcu_dereference_check(p, c) rcu_dereference(p)
-#endif
-
-#ifndef rcu_dereference_protected
-#define rcu_dereference_protected(p, c) (p)
-#endif
-#ifndef rcu_access_pointer
-#define rcu_access_pointer(p) ACCESS_ONCE(p)
-#endif
-
-#ifndef rcu_dereference_raw
-#define rcu_dereference_raw(p) rcu_dereference(p)
-#endif
-
-#endif /* __BACKPORT_LINUX_RCUPDATE_H */
diff --git a/backport/backport-include/linux/regmap.h b/backport/backport-include/linux/regmap.h
deleted file mode 100644
index 4b73c46b..00000000
--- a/backport/backport-include/linux/regmap.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef __BACKPORT_LINUX_REGMAP_H
-#define __BACKPORT_LINUX_REGMAP_H
-#include_next <linux/regmap.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,5,0) && \
- LINUX_VERSION_IS_GEQ(3,2,0)
-#define dev_get_regmap LINUX_BACKPORT(dev_get_regmap)
-static inline
-struct regmap *dev_get_regmap(struct device *dev, const char *name)
-{
- return NULL;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,4,0) && \
- LINUX_VERSION_IS_GEQ(3,2,0)
-#if defined(CONFIG_REGMAP)
-#define devm_regmap_init LINUX_BACKPORT(devm_regmap_init)
-struct regmap *devm_regmap_init(struct device *dev,
- const struct regmap_bus *bus,
- const struct regmap_config *config);
-#if defined(CONFIG_REGMAP_I2C)
-#define devm_regmap_init_i2c LINUX_BACKPORT(devm_regmap_init_i2c)
-struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
- const struct regmap_config *config);
-#endif /* defined(CONFIG_REGMAP_I2C) */
-
-/*
- * We can't backport these unless we try to backport
- * the full regmap into core so warn if used.
- * No drivers are using this yet anyway.
- */
-#define regmap_raw_write_async LINUX_BACKPORT(regmap_raw_write_async)
-static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
- const void *val, size_t val_len)
-{
- WARN_ONCE(1, "regmap API is disabled");
- return -EINVAL;
-}
-
-#define regmap_async_complete LINUX_BACKPORT(regmap_async_complete)
-static inline void regmap_async_complete(struct regmap *map)
-{
- WARN_ONCE(1, "regmap API is disabled");
-}
-
-#endif /* defined(CONFIG_REGMAP) */
-#endif /* 3.2 <= version < 3.4 */
-
-#endif /* __BACKPORT_LINUX_REGMAP_H */
diff --git a/backport/backport-include/linux/regulator/driver.h b/backport/backport-include/linux/regulator/driver.h
deleted file mode 100644
index f88d9bef..00000000
--- a/backport/backport-include/linux/regulator/driver.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * driver.h -- SoC Regulator driver support.
- *
- * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
- *
- * Author: Liam Girdwood <lrg@slimlogic.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Regulator Driver Interface.
- */
-
-#ifndef __BACKPORT_LINUX_REGULATOR_DRIVER_H_
-#define __BACKPORT_LINUX_REGULATOR_DRIVER_H_
-
-#include <linux/version.h>
-#include_next <linux/regulator/driver.h>
-
-#if LINUX_VERSION_IS_LESS(3,13,0) && \
- LINUX_VERSION_IS_GEQ(3,5,0)
-#define devm_regulator_register LINUX_BACKPORT(devm_regulator_register)
-struct regulator_dev *
-devm_regulator_register(struct device *dev,
- const struct regulator_desc *regulator_desc,
- const struct regulator_config *config);
-#define devm_regulator_unregister LINUX_BACKPORT(devm_regulator_unregister)
-void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev);
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) &&
- LINUX_VERSION_IS_GEQ(3,5,0) */
-
-#endif /* __BACKPORT_LINUX_REGULATOR_DRIVER_H_ */
diff --git a/backport/backport-include/linux/rfkill.h b/backport/backport-include/linux/rfkill.h
deleted file mode 100644
index 99015af7..00000000
--- a/backport/backport-include/linux/rfkill.h
+++ /dev/null
@@ -1,167 +0,0 @@
-#ifndef __COMPAT_RFKILL_H
-#define __COMPAT_RFKILL_H
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,10,0)
-#include_next <linux/rfkill.h>
-#else
-/* API only slightly changed since then */
-#define rfkill_type old_rfkill_type
-#define RFKILL_TYPE_ALL OLD_RFKILL_TYPE_ALL
-#define RFKILL_TYPE_WLAN OLD_RFKILL_TYPE_WLAN
-#define RFKILL_TYPE_BLUETOOTH OLD_RFKILL_TYPE_BLUETOOTH
-#define RFKILL_TYPE_UWB OLD_RFKILL_TYPE_UWB
-#define RFKILL_TYPE_WIMAX OLD_RFKILL_TYPE_WIMAX
-#define RFKILL_TYPE_WWAN OLD_RFKILL_TYPE_WWAN
-#define RFKILL_TYPE_GPS OLD_RFKILL_TYPE_GPS
-#define RFKILL_TYPE_FM OLD_RFKILL_TYPE_FM
-#define RFKILL_TYPE_NFC OLD_RFKILL_TYPE_NFC
-#define NUM_RFKILL_TYPES OLD_NUM_RFKILL_TYPES
-#include_next <linux/rfkill.h>
-#undef rfkill_type
-#undef RFKILL_TYPE_ALL
-#undef RFKILL_TYPE_WLAN
-#undef RFKILL_TYPE_BLUETOOTH
-#undef RFKILL_TYPE_UWB
-#undef RFKILL_TYPE_WIMAX
-#undef RFKILL_TYPE_WWAN
-#undef RFKILL_TYPE_GPS
-#undef RFKILL_TYPE_FM
-#undef RFKILL_TYPE_NFC
-#undef NUM_RFKILL_TYPES
-#define HAVE_OLD_RFKILL
-
-/* this changes infrequently, backport manually */
-enum rfkill_type {
- RFKILL_TYPE_ALL = 0,
- RFKILL_TYPE_WLAN,
- RFKILL_TYPE_BLUETOOTH,
- RFKILL_TYPE_UWB,
- RFKILL_TYPE_WIMAX,
- RFKILL_TYPE_WWAN,
- RFKILL_TYPE_GPS,
- RFKILL_TYPE_FM,
- RFKILL_TYPE_NFC,
- NUM_RFKILL_TYPES,
-};
-
-static inline struct rfkill * __must_check
-backport_rfkill_alloc(const char *name,
- struct device *parent,
- const enum rfkill_type type,
- const struct rfkill_ops *ops,
- void *ops_data)
-{
-#ifdef HAVE_OLD_RFKILL
- if ((unsigned int)type >= (unsigned int)OLD_NUM_RFKILL_TYPES)
- return ERR_PTR(-ENODEV);
- return rfkill_alloc(name, parent, (enum old_rfkill_type)type,
- ops, ops_data);
-#else
- return ERR_PTR(-ENODEV);
-#endif
-}
-#define rfkill_alloc backport_rfkill_alloc
-
-static inline int __must_check backport_rfkill_register(struct rfkill *rfkill)
-{
- if (rfkill == ERR_PTR(-ENODEV))
- return 0;
-#ifdef HAVE_OLD_RFKILL
- return rfkill_register(rfkill);
-#else
- return -EINVAL;
-#endif
-}
-#define rfkill_register backport_rfkill_register
-
-static inline void backport_rfkill_pause_polling(struct rfkill *rfkill)
-{
-#ifdef HAVE_OLD_RFKILL
- rfkill_pause_polling(rfkill);
-#endif
-}
-#define rfkill_pause_polling backport_rfkill_pause_polling
-
-static inline void backport_rfkill_resume_polling(struct rfkill *rfkill)
-{
-#ifdef HAVE_OLD_RFKILL
- rfkill_resume_polling(rfkill);
-#endif
-}
-#define rfkill_resume_polling backport_rfkill_resume_polling
-
-static inline void backport_rfkill_unregister(struct rfkill *rfkill)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill == ERR_PTR(-ENODEV))
- return;
- rfkill_unregister(rfkill);
-#endif
-}
-#define rfkill_unregister backport_rfkill_unregister
-
-static inline void backport_rfkill_destroy(struct rfkill *rfkill)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill == ERR_PTR(-ENODEV))
- return;
- rfkill_destroy(rfkill);
-#endif
-}
-#define rfkill_destroy backport_rfkill_destroy
-
-static inline bool backport_rfkill_set_hw_state(struct rfkill *rfkill,
- bool blocked)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill != ERR_PTR(-ENODEV))
- return rfkill_set_hw_state(rfkill, blocked);
-#endif
- return blocked;
-}
-#define rfkill_set_hw_state backport_rfkill_set_hw_state
-
-static inline bool backport_rfkill_set_sw_state(struct rfkill *rfkill,
- bool blocked)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill != ERR_PTR(-ENODEV))
- return rfkill_set_sw_state(rfkill, blocked);
-#endif
- return blocked;
-}
-#define rfkill_set_sw_state backport_rfkill_set_sw_state
-
-static inline void backport_rfkill_init_sw_state(struct rfkill *rfkill,
- bool blocked)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill != ERR_PTR(-ENODEV))
- rfkill_init_sw_state(rfkill, blocked);
-#endif
-}
-#define rfkill_init_sw_state backport_rfkill_init_sw_state
-
-static inline void backport_rfkill_set_states(struct rfkill *rfkill,
- bool sw, bool hw)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill != ERR_PTR(-ENODEV))
- rfkill_set_states(rfkill, sw, hw);
-#endif
-}
-#define rfkill_set_states backport_rfkill_set_states
-
-static inline bool backport_rfkill_blocked(struct rfkill *rfkill)
-{
-#ifdef HAVE_OLD_RFKILL
- if (rfkill != ERR_PTR(-ENODEV))
- return rfkill_blocked(rfkill);
-#endif
- return false;
-}
-#define rfkill_blocked backport_rfkill_blocked
-#endif
-
-#endif
diff --git a/backport/backport-include/linux/rtnetlink.h b/backport/backport-include/linux/rtnetlink.h
deleted file mode 100644
index 59beffa8..00000000
--- a/backport/backport-include/linux/rtnetlink.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __BACKPORT_LINUX_RTNETLINK_H
-#define __BACKPORT_LINUX_RTNETLINK_H
-#include_next <linux/rtnetlink.h>
-
-#ifndef rtnl_dereference
-#define rtnl_dereference(p) \
- rcu_dereference_protected(p, lockdep_rtnl_is_held())
-#endif
-
-#ifndef rcu_dereference_rtnl
-#define rcu_dereference_rtnl(p) \
- rcu_dereference_check(p, rcu_read_lock_held() || \
- lockdep_rtnl_is_held())
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, flags) \
- ndo_dflt_fdb_add(ndm, tb, dev, addr, flags)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,13,0) && \
- !defined(CONFIG_PROVE_LOCKING)
-static inline bool lockdep_rtnl_is_held(void)
-{
- return true;
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_RTNETLINK_H */
diff --git a/backport/backport-include/linux/scatterlist.h b/backport/backport-include/linux/scatterlist.h
deleted file mode 100644
index 06934b6b..00000000
--- a/backport/backport-include/linux/scatterlist.h
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef __BACKPORT_SCATTERLIST_H
-#define __BACKPORT_SCATTERLIST_H
-#include_next <linux/scatterlist.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-int sg_nents(struct scatterlist *sg);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3, 9, 0)
-
-/*
- * sg page iterator
- *
- * Iterates over sg entries page-by-page. On each successful iteration,
- * @piter->page points to the current page, @piter->sg to the sg holding this
- * page and @piter->sg_pgoffset to the page's page offset within the sg. The
- * iteration will stop either when a maximum number of sg entries was reached
- * or a terminating sg (sg_last(sg) == true) was reached.
- */
-struct sg_page_iter {
- struct page *page; /* current page */
- struct scatterlist *sg; /* sg holding the page */
- unsigned int sg_pgoffset; /* page offset within the sg */
-
- /* these are internal states, keep away */
- unsigned int __nents; /* remaining sg entries */
- int __pg_advance; /* nr pages to advance at the
- * next step */
-};
-
-struct backport_sg_mapping_iter {
- /* the following three fields can be accessed directly */
- struct page *page; /* currently mapped page */
- void *addr; /* pointer to the mapped area */
- size_t length; /* length of the mapped area */
- size_t consumed; /* number of consumed bytes */
- struct sg_page_iter piter; /* page iterator */
-
- /* these are internal states, keep away */
- unsigned int __offset; /* offset within page */
- unsigned int __remaining; /* remaining bytes on page */
- unsigned int __flags;
-};
-#define sg_mapping_iter LINUX_BACKPORT(sg_mapping_iter)
-
-/**
- * sg_page_iter_page - get the current page held by the page iterator
- * @piter: page iterator holding the page
- */
-static inline struct page *sg_page_iter_page(struct sg_page_iter *piter)
-{
- return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
-}
-
-bool __sg_page_iter_next(struct sg_page_iter *piter);
-void __sg_page_iter_start(struct sg_page_iter *piter,
- struct scatterlist *sglist, unsigned int nents,
- unsigned long pgoffset);
-
-void backport_sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl,
- unsigned int nents, unsigned int flags);
-bool backport_sg_miter_next(struct sg_mapping_iter *miter);
-void backport_sg_miter_stop(struct sg_mapping_iter *miter);
-#define sg_miter_start LINUX_BACKPORT(sg_miter_start)
-#define sg_miter_next LINUX_BACKPORT(sg_miter_next)
-#define sg_miter_stop LINUX_BACKPORT(sg_miter_stop)
-
-/**
- * for_each_sg_page - iterate over the pages of the given sg list
- * @sglist: sglist to iterate over
- * @piter: page iterator to hold current page, sg, sg_pgoffset
- * @nents: maximum number of sg entries to iterate over
- * @pgoffset: starting page offset
- */
-#define for_each_sg_page(sglist, piter, nents, pgoffset) \
- for (__sg_page_iter_start((piter), (sglist), (nents), (pgoffset)); \
- __sg_page_iter_next(piter);)
-
-#endif /* LINUX_VERSION_IS_LESS(3, 9, 0) */
-
-#if LINUX_VERSION_IS_LESS(3, 11, 0)
-size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
- size_t buflen, off_t skip, bool to_buffer);
-
-#define sg_pcopy_to_buffer LINUX_BACKPORT(sg_pcopy_to_buffer)
-
-static inline
-size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen, off_t skip)
-{
- return sg_copy_buffer(sgl, nents, buf, buflen, skip, true);
-}
-
-#define sg_pcopy_from_buffer LINUX_BACKPORT(sg_pcopy_from_buffer)
-
-static inline
-size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents,
- void *buf, size_t buflen, off_t skip)
-{
- return sg_copy_buffer(sgl, nents, buf, buflen, skip, false);
-}
-
-#endif /* LINUX_VERSION_IS_LESS(3, 11, 0) */
-
-#if LINUX_VERSION_IS_LESS(4, 17, 0)
-
-#define sg_init_marker LINUX_BACKPORT(sg_init_marker)
-/**
- * sg_init_marker - Initialize markers in sg table
- * @sgl: The SG table
- * @nents: Number of entries in table
- *
- **/
-static inline void sg_init_marker(struct scatterlist *sgl,
- unsigned int nents)
-{
-#ifdef CONFIG_DEBUG_SG
- unsigned int i;
-
- for (i = 0; i < nents; i++)
- sgl[i].sg_magic = SG_MAGIC;
-#endif
- sg_mark_end(&sgl[nents - 1]);
-}
-
-#endif /* LINUX_VERSION_IS_LESS(4, 17, 0) */
-
-#endif /* __BACKPORT_SCATTERLIST_H */
diff --git a/backport/backport-include/linux/sched/signal.h b/backport/backport-include/linux/sched/signal.h
deleted file mode 100644
index ec89925d..00000000
--- a/backport/backport-include/linux/sched/signal.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _BACKPORT_LINUX_SCHED_SIGNAL_H
-#define _BACKPORT_LINUX_SCHED_SIGNAL_H
-
-#if LINUX_VERSION_IS_LESS(4, 11, 0)
-#include <linux/sched.h>
-#else
-#include_next <linux/sched/signal.h>
-#endif
-
-#endif /* _BACKPORT_LINUX_SCHED_SIGNAL_H */
diff --git a/backport/backport-include/linux/security.h b/backport/backport-include/linux/security.h
deleted file mode 100644
index 2dfb964b..00000000
--- a/backport/backport-include/linux/security.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_LINUX_SECURITY_H
-#define __BACKPORT_LINUX_SECURITY_H
-#include_next <linux/security.h>
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-/*
- * This has been defined in include/linux/security.h for some time, but was
- * only given an EXPORT_SYMBOL for 3.1. Add a compat_* definition to avoid
- * breaking the compile.
- */
-#define security_sk_clone(a, b) compat_security_sk_clone(a, b)
-
-static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
-{
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_SECURITY_H */
diff --git a/backport/backport-include/linux/seq_file.h b/backport/backport-include/linux/seq_file.h
deleted file mode 100644
index 5b88f6f8..00000000
--- a/backport/backport-include/linux/seq_file.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef __BACKPORT_SEQ_FILE_H
-#define __BACKPORT_SEQ_FILE_H
-#include_next <linux/seq_file.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#include <linux/user_namespace.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#ifdef CONFIG_USER_NS
-static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
-{
- struct file *f = container_of((void *) seq, struct file, private_data);
-
- return f->f_cred->user_ns;
-}
-#else
-static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
-{
- extern struct user_namespace init_user_ns;
- return &init_user_ns;
-}
-#endif /* CONFIG_USER_NS */
-#endif /* < 3.7 */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define seq_has_overflowed LINUX_BACKPORT(seq_has_overflowed)
-/**
- * seq_has_overflowed - check if the buffer has overflowed
- * @m: the seq_file handle
- *
- * seq_files have a buffer which may overflow. When this happens a larger
- * buffer is reallocated and all the data will be printed again.
- * The overflow state is true when m->count == m->size.
- *
- * Returns true if the buffer received more than it can hold.
- */
-static inline bool seq_has_overflowed(struct seq_file *m)
-{
- return m->count == m->size;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,3,0)
-#define seq_hex_dump LINUX_BACKPORT(seq_hex_dump)
-void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
- int rowsize, int groupsize, const void *buf, size_t len,
- bool ascii);
-#endif
-
-#ifndef DEFINE_SHOW_ATTRIBUTE
-#define DEFINE_SHOW_ATTRIBUTE(__name) \
-static int __name ## _open(struct inode *inode, struct file *file) \
-{ \
- return single_open(file, __name ## _show, inode->i_private); \
-} \
- \
-static const struct file_operations __name ## _fops = { \
- .owner = THIS_MODULE, \
- .open = __name ## _open, \
- .read = seq_read, \
- .llseek = seq_lseek, \
- .release = single_release, \
-}
-#endif /* DEFINE_SHOW_ATTRIBUTE */
-
-#endif /* __BACKPORT_SEQ_FILE_H */
diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h
deleted file mode 100644
index 7b1fe6ed..00000000
--- a/backport/backport-include/linux/skbuff.h
+++ /dev/null
@@ -1,410 +0,0 @@
-#ifndef __BACKPORT_SKBUFF_H
-#define __BACKPORT_SKBUFF_H
-#include_next <linux/skbuff.h>
-#include <linux/version.h>
-#include <generated/utsrelease.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0) && \
- (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4)) && \
- !(defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_IS_GEQ(3,0,0))
-#define skb_add_rx_frag(skb, i, page, off, size, truesize) \
- skb_add_rx_frag(skb, i, page, off, size)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#define __pskb_copy LINUX_BACKPORT(__pskb_copy)
-extern struct sk_buff *__pskb_copy(struct sk_buff *skb,
- int headroom, gfp_t gfp_mask);
-
-#define skb_complete_wifi_ack LINUX_BACKPORT(skb_complete_wifi_ack)
-static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
-{
- WARN_ON(1);
-}
-
-/* define to 0 so checks for it are always false */
-#define SKBTX_WIFI_STATUS 0
-#elif LINUX_VERSION_IS_LESS(3,18,0)
-#define skb_complete_wifi_ack LINUX_BACKPORT(skb_complete_wifi_ack)
-void skb_complete_wifi_ack(struct sk_buff *skb, bool acked);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#include <linux/dma-mapping.h>
-
-/* mask skb_frag_page as RHEL6 backports this */
-#define skb_frag_page LINUX_BACKPORT(skb_frag_page)
-static inline struct page *skb_frag_page(const skb_frag_t *frag)
-{
- return frag->page;
-}
-
-#define skb_frag_size LINUX_BACKPORT(skb_frag_size)
-static inline unsigned int skb_frag_size(const skb_frag_t *frag)
-{
- return frag->size;
-}
-
-/* mask skb_frag_dma_map as RHEL6 backports this */
-#define skb_frag_dma_map LINUX_BACKPORT(skb_frag_dma_map)
-static inline dma_addr_t skb_frag_dma_map(struct device *dev,
- const skb_frag_t *frag,
- size_t offset, size_t size,
- enum dma_data_direction dir)
-{
- return dma_map_page(dev, skb_frag_page(frag),
- frag->page_offset + offset, size, dir);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-/* mask __netdev_alloc_skb_ip_align as RHEL6 backports this */
-#define __netdev_alloc_skb_ip_align(a,b,c) compat__netdev_alloc_skb_ip_align(a,b,c)
-static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev,
- unsigned int length, gfp_t gfp)
-{
- struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp);
-
- if (NET_IP_ALIGN && skb)
- skb_reserve(skb, NET_IP_ALIGN);
- return skb;
-}
-#endif
-
-#ifndef skb_walk_frags
-#define skb_walk_frags(skb, iter) \
- for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#define skb_frag_size_sub LINUX_BACKPORT(skb_frag_size_sub)
-static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
-{
- frag->size -= delta;
-}
-
-/**
- * skb_frag_address - gets the address of the data contained in a paged fragment
- * @frag: the paged fragment buffer
- *
- * Returns the address of the data within @frag. The page must already
- * be mapped.
- */
-#define skb_frag_address LINUX_BACKPORT(skb_frag_address)
-static inline void *skb_frag_address(const skb_frag_t *frag)
-{
- return page_address(skb_frag_page(frag)) + frag->page_offset;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,2,0) */
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#ifndef NETDEV_FRAG_PAGE_MAX_ORDER
-#define NETDEV_FRAG_PAGE_MAX_ORDER get_order(32768)
-#endif
-#ifndef NETDEV_FRAG_PAGE_MAX_SIZE
-#define NETDEV_FRAG_PAGE_MAX_SIZE (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)
-#endif
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define skb_unclone LINUX_BACKPORT(skb_unclone)
-static inline int skb_unclone(struct sk_buff *skb, gfp_t pri)
-{
- might_sleep_if(pri & __GFP_WAIT);
- if (skb_cloned(skb))
- return pskb_expand_head(skb, 0, 0, pri);
- return 0;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-
-#define skb_frag_address_safe LINUX_BACKPORT(skb_frag_address_safe)
-/**
- * skb_frag_address_safe - gets the address of the data contained in a paged fragment
- * @frag: the paged fragment buffer
- *
- * Returns the address of the data within @frag. Checks that the page
- * is mapped and returns %NULL otherwise.
- */
-static inline void *skb_frag_address_safe(const skb_frag_t *frag)
-{
- void *ptr = page_address(skb_frag_page(frag));
- if (unlikely(!ptr))
- return NULL;
-
- return ptr + frag->page_offset;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,2,0) */
-
-#if LINUX_VERSION_IS_LESS(3,14,0) && \
- RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7,0) && \
- !(LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
-/*
- * Packet hash types specify the type of hash in skb_set_hash.
- *
- * Hash types refer to the protocol layer addresses which are used to
- * construct a packet's hash. The hashes are used to differentiate or identify
- * flows of the protocol layer for the hash type. Hash types are either
- * layer-2 (L2), layer-3 (L3), or layer-4 (L4).
- *
- * Properties of hashes:
- *
- * 1) Two packets in different flows have different hash values
- * 2) Two packets in the same flow should have the same hash value
- *
- * A hash at a higher layer is considered to be more specific. A driver should
- * set the most specific hash possible.
- *
- * A driver cannot indicate a more specific hash than the layer at which a hash
- * was computed. For instance an L3 hash cannot be set as an L4 hash.
- *
- * A driver may indicate a hash level which is less specific than the
- * actual layer the hash was computed on. For instance, a hash computed
- * at L4 may be considered an L3 hash. This should only be done if the
- * driver can't unambiguously determine that the HW computed the hash at
- * the higher layer. Note that the "should" in the second property above
- * permits this.
- */
-enum pkt_hash_types {
- PKT_HASH_TYPE_NONE, /* Undefined type */
- PKT_HASH_TYPE_L2, /* Input: src_MAC, dest_MAC */
- PKT_HASH_TYPE_L3, /* Input: src_IP, dst_IP */
- PKT_HASH_TYPE_L4, /* Input: src_IP, dst_IP, src_port, dst_port */
-};
-
-static inline void
-skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
-{
-#if LINUX_VERSION_IS_GEQ(3,2,0) /* 4031ae6edb */
- skb->l4_rxhash = (type == PKT_HASH_TYPE_L4);
-#endif
-#if LINUX_VERSION_IS_GEQ(3,4,0) /* bdeab99191 */
- skb->rxhash = hash;
-#endif
-}
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-
-#if LINUX_VERSION_IS_LESS(3,16,0)
-#define __pskb_copy_fclone LINUX_BACKPORT(__pskb_copy_fclone)
-static inline struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb,
- int headroom, gfp_t gfp_mask,
- bool fclone)
-{
- return __pskb_copy(skb, headroom, gfp_mask);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#define skb_clone_sk LINUX_BACKPORT(skb_clone_sk)
-struct sk_buff *skb_clone_sk(struct sk_buff *skb);
-#endif
-
-static inline bool skb_xmit_more(struct sk_buff *skb)
-{
-#if LINUX_VERSION_IS_LESS(3,18,0)
- return false;
-#else
- return skb->xmit_more;
-#endif
-}
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-/**
- * __dev_alloc_pages - allocate page for network Rx
- * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
- * @order: size of the allocation
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
-*/
-#define __dev_alloc_pages LINUX_BACKPORT(__dev_alloc_pages)
-static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
- unsigned int order)
-{
- /* This piece of code contains several assumptions.
- * 1. This is for device Rx, therefor a cold page is preferred.
- * 2. The expectation is the user wants a compound page.
- * 3. If requesting a order 0 page it will not be compound
- * due to the check to see if order has a value in prep_new_page
- * 4. __GFP_MEMALLOC is ignored if __GFP_NOMEMALLOC is set due to
- * code in gfp_to_alloc_flags that should be enforcing this.
- */
- gfp_mask |= __GFP_COLD | __GFP_COMP;
-#if LINUX_VERSION_IS_GEQ(3,6,0)
- gfp_mask |= __GFP_MEMALLOC;
-#endif
-
- return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
-}
-
-#define dev_alloc_pages LINUX_BACKPORT(dev_alloc_pages)
-static inline struct page *dev_alloc_pages(unsigned int order)
-{
- return __dev_alloc_pages(GFP_ATOMIC, order);
-}
-
-/**
- * __dev_alloc_page - allocate a page for network Rx
- * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
- */
-#define __dev_alloc_page LINUX_BACKPORT(__dev_alloc_page)
-static inline struct page *__dev_alloc_page(gfp_t gfp_mask)
-{
- return __dev_alloc_pages(gfp_mask, 0);
-}
-
-#define dev_alloc_page LINUX_BACKPORT(dev_alloc_page)
-static inline struct page *dev_alloc_page(void)
-{
- return __dev_alloc_page(GFP_ATOMIC);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-#define skb_copy_datagram_msg LINUX_BACKPORT(skb_copy_datagram_msg)
-static inline int skb_copy_datagram_msg(const struct sk_buff *from, int offset,
- struct msghdr *msg, int size)
-{
- return skb_copy_datagram_iovec(from, offset, msg->msg_iov, size);
-}
-
-#define memcpy_from_msg LINUX_BACKPORT(memcpy_from_msg)
-static inline int memcpy_from_msg(void *data, struct msghdr *msg, int len)
-{
- return memcpy_fromiovec(data, msg->msg_iov, len);
-}
-
-/**
- * skb_put_padto - increase size and pad an skbuff up to a minimal size
- * @skb: buffer to pad
- * @len: minimal length
- *
- * Pads up a buffer to ensure the trailing bytes exist and are
- * blanked. If the buffer already contains sufficient data it
- * is untouched. Otherwise it is extended. Returns zero on
- * success. The skb is freed on error.
- */
-#define skb_put_padto LINUX_BACKPORT(skb_put_padto)
-static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
-{
- unsigned int size = skb->len;
-
- if (unlikely(size < len)) {
- len -= size;
- if (skb_pad(skb, len))
- return -ENOMEM;
- __skb_put(skb, len);
- }
- return 0;
-}
-
-#define skb_ensure_writable LINUX_BACKPORT(skb_ensure_writable)
-int skb_ensure_writable(struct sk_buff *skb, int write_len);
-
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-static inline void skb_free_frag(void *data)
-{
- put_page(virt_to_head_page(data));
-}
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-
-static inline u32 skb_get_hash_perturb(struct sk_buff *skb, u32 key)
-{
- return 0;
-}
-
-#else
-#include <net/flow_keys.h>
-#include <linux/jhash.h>
-
-static inline u32 skb_get_hash_perturb(struct sk_buff *skb, u32 key)
-{
- struct flow_keys keys;
-
- skb_flow_dissect(skb, &keys);
- return jhash_3words((__force u32)keys.dst,
- (__force u32)keys.src ^ keys.ip_proto,
- (__force u32)keys.ports, key);
-}
-#endif /* LINUX_VERSION_IS_LESS(3,3,0) */
-#endif /* LINUX_VERSION_IS_LESS(4,2,0) */
-
-#if LINUX_VERSION_IS_LESS(4,13,0)
-static inline void *backport_skb_put(struct sk_buff *skb, unsigned int len)
-{
- return skb_put(skb, len);
-}
-#define skb_put LINUX_BACKPORT(skb_put)
-
-static inline void *backport_skb_push(struct sk_buff *skb, unsigned int len)
-{
- return skb_push(skb, len);
-}
-#define skb_push LINUX_BACKPORT(skb_push)
-
-static inline void *backport___skb_push(struct sk_buff *skb, unsigned int len)
-{
- return __skb_push(skb, len);
-}
-#define __skb_push LINUX_BACKPORT(__skb_push)
-
-static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len)
-{
- void *tmp = skb_put(skb, len);
-
- memset(tmp, 0, len);
-
- return tmp;
-}
-
-static inline void *skb_put_data(struct sk_buff *skb, const void *data,
- unsigned int len)
-{
- void *tmp = skb_put(skb, len);
-
- memcpy(tmp, data, len);
-
- return tmp;
-}
-
-static inline void skb_put_u8(struct sk_buff *skb, u8 val)
-{
- *(u8 *)skb_put(skb, 1) = val;
-}
-
-static inline void *__skb_put_zero(struct sk_buff *skb, unsigned int len)
-{
- void *tmp = __skb_put(skb, len);
-
- memset(tmp, 0, len);
- return tmp;
-}
-
-static inline void *__skb_put_data(struct sk_buff *skb, const void *data,
- unsigned int len)
-{
- void *tmp = __skb_put(skb, len);
-
- memcpy(tmp, data, len);
- return tmp;
-}
-
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,20,0)
-static inline struct sk_buff *__skb_peek(const struct sk_buff_head *list_)
-{
- return list_->next;
-}
-#endif
-
-#endif /* __BACKPORT_SKBUFF_H */
diff --git a/backport/backport-include/linux/slab.h b/backport/backport-include/linux/slab.h
deleted file mode 100644
index 66f0cc0d..00000000
--- a/backport/backport-include/linux/slab.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __BACKPORT_SLAB_H
-#define __BACKPORT_SLAB_H
-#include_next <linux/slab.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,4,0)
-/* This backports:
- *
- * commit a8203725dfded5c1f79dca3368a4a273e24b59bb
- * Author: Xi Wang <xi.wang@gmail.com>
- * Date: Mon Mar 5 15:14:41 2012 -0800
- *
- * slab: introduce kmalloc_array()
- */
-
-#include <linux/kernel.h> /* for SIZE_MAX */
-
-#define kmalloc_array LINUX_BACKPORT(kmalloc_array)
-static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
-{
- if (size != 0 && n > SIZE_MAX / size)
- return NULL;
- return __kmalloc(n * size, flags);
-}
-#endif
-
-#endif /* __BACKPORT_SLAB_H */
diff --git a/backport/backport-include/linux/socket.h b/backport/backport-include/linux/socket.h
deleted file mode 100644
index 8b6453ec..00000000
--- a/backport/backport-include/linux/socket.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef __BACKPORT_SOCKET_H
-#define __BACKPORT_SOCKET_H
-#include_next <linux/socket.h>
-
-#ifndef SOL_NFC
-/*
- * backport SOL_NFC -- see commit:
- * NFC: llcp: Implement socket options
- */
-#define SOL_NFC 280
-#endif
-
-#ifndef __sockaddr_check_size
-#define __sockaddr_check_size(size) \
- BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage)))
-#endif
-
-#endif /* __BACKPORT_SOCKET_H */
diff --git a/backport/backport-include/linux/spi/spi.h b/backport/backport-include/linux/spi/spi.h
deleted file mode 100644
index 6d2de15f..00000000
--- a/backport/backport-include/linux/spi/spi.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef _BACKPORTS_LINUX_SPI_H
-#define _BACKPORTS_LINUX_SPI_H 1
-
-#include_next <linux/spi/spi.h>
-
-#ifndef module_spi_driver
-/**
- * module_spi_driver() - Helper macro for registering a SPI driver
- * @__spi_driver: spi_driver struct
- *
- * Helper macro for SPI drivers which do not do anything special in module
- * init/exit. This eliminates a lot of boilerplate. Each module may only
- * use this macro once, and calling it replaces module_init() and module_exit()
- */
-#define module_spi_driver(__spi_driver) \
- module_driver(__spi_driver, spi_register_driver, \
- spi_unregister_driver)
-#endif
-
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/**
- * spi_message_init_with_transfers - Initialize spi_message and append transfers
- * @m: spi_message to be initialized
- * @xfers: An array of spi transfers
- * @num_xfers: Number of items in the xfer array
- *
- * This function initializes the given spi_message and adds each spi_transfer in
- * the given array to the message.
- */
-#define spi_message_init_with_transfers LINUX_BACKPORT(spi_message_init_with_transfers)
-static inline void
-spi_message_init_with_transfers(struct spi_message *m,
-struct spi_transfer *xfers, unsigned int num_xfers)
-{
- unsigned int i;
-
- spi_message_init(m);
- for (i = 0; i < num_xfers; ++i)
- spi_message_add_tail(&xfers[i], m);
-}
-
-/**
- * spi_sync_transfer - synchronous SPI data transfer
- * @spi: device with which data will be exchanged
- * @xfers: An array of spi_transfers
- * @num_xfers: Number of items in the xfer array
- * Context: can sleep
- *
- * Does a synchronous SPI data transfer of the given spi_transfer array.
- *
- * For more specific semantics see spi_sync().
- *
- * It returns zero on success, else a negative error code.
- */
-#define spi_sync_transfer LINUX_BACKPORT(spi_sync_transfer)
-static inline int
-spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
- unsigned int num_xfers)
-{
- struct spi_message msg;
-
- spi_message_init_with_transfers(&msg, xfers, num_xfers);
-
- return spi_sync(spi, &msg);
-}
-#endif /* < 3.9 */
-
-#endif /* _BACKPORTS_LINUX_SPI_H */
diff --git a/backport/backport-include/linux/spinlock.h b/backport/backport-include/linux/spinlock.h
deleted file mode 100644
index b27f9171..00000000
--- a/backport/backport-include/linux/spinlock.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __BACKPORT_SPINLOCK_H
-#define __BACKPORT_SPINLOCK_H
-#include_next <linux/spinlock.h>
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#ifndef CONFIG_DEBUG_LOCK_ALLOC
-#undef raw_spin_lock_nested
-/*
- * Always evaluate the 'subclass' argument to avoid that the compiler
- * warns about set-but-not-used variables when building with
- * CONFIG_DEBUG_LOCK_ALLOC=n and with W=1.
- */
-# define raw_spin_lock_nested(lock, subclass) \
- _raw_spin_lock(((void)(subclass), (lock)))
-# define raw_spin_lock_nest_lock(lock, nest_lock) _raw_spin_lock(lock)
-#endif
-#endif /* LINUX_VERSION_IS_LESS(3,18,0) */
-
-
-#if LINUX_VERSION_IS_LESS(4,16,0)
-int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
- size_t max_size, unsigned int cpu_mult,
- gfp_t gfp);
-
-void free_bucket_spinlocks(spinlock_t *locks);
-#endif /* LINUX_VERSION_IS_LESS(4,16,0) */
-
-#if LINUX_VERSION_IS_LESS(4,19,0)
-int __alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
- size_t max_size, unsigned int cpu_mult,
- gfp_t gfp, const char *name,
- struct lock_class_key *key);
-
-#define alloc_bucket_spinlocks(locks, lock_mask, max_size, cpu_mult, gfp) \
- ({ \
- static struct lock_class_key key; \
- int ret; \
- \
- ret = __alloc_bucket_spinlocks(locks, lock_mask, max_size, \
- cpu_mult, gfp, #locks, &key); \
- ret; \
- })
-#endif /* LINUX_VERSION_IS_LESS(4,19,0) */
-
-#endif /* __BACKPORT_SPINLOCK_H */
diff --git a/backport/backport-include/linux/static_key.h b/backport/backport-include/linux/static_key.h
deleted file mode 100644
index 4b82eec2..00000000
--- a/backport/backport-include/linux/static_key.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _BACKPORTS_LINUX_STATIC_KEY_H
-#define _BACKPORTS_LINUX_STATIC_KEY_H 1
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(3,3,0) /* kernels >= 3.3 */
-/*
- * XXX: NOTE!
- *
- * Some 3.3 kernels carry <linux/static.h> but some don't even though its
- * its including <linux/jump_label.h>. What makes it more confusing is that
- * later all this got shuffled. The safe thing to do then is to just assume
- * kernels 3.3..3.4 don't have it and include <linux/jump_label.h> instead,
- * and for newer kernels include <linux/static_key.h>.
- */
-#if LINUX_VERSION_IS_GEQ(3,5,0)
-#include_next <linux/static_key.h>
-#else
-#include <linux/jump_label.h>
-#endif
-
-#else /* kernels < 3.3 */
-/*
- * in between 2.6.37 - 3.5 there's a slew of changes that make
- * it hard to backport this properly. If you are interested in
- * trying you can use this as reference:
- *
- * http://drvbp1.linux-foundation.org/~mcgrof/examples/2014/04/01/backport-static-keys.patch
- *
- * And these notes:
- *
- * < v2.6.37 - No tracing support
- * bf5438fc - v2.6.37 - Jump label support added primarily for tracing but
- * tracing was broken, later kernels started sporting
- * functional tracing.
- * d430d3d7e - v3.0 - Static branch optimizations for jump labels
- * c5905afb - v3.3 - Static keys split out, note on the below issue
- * c5905afb - v3.5 - git describe --contains c5905afb claims but not true!
- * c4b2c0c5f - v3.13 - Adds static_key_initialized(), STATIC_KEY_CHECK_USE()
- *
- * Because all of this we skip 2.6.37 - 3.3 but and adding support for older
- * can be done by of carrying over the non-architecture optimized code.
- * Carrying new changes into this file is a burden though so if we really
- * find use for this we could just split the non optimized versions upstream
- * and copy that through an automatic process.
- */
-#endif /* kernels < 3.3 */
-
-#endif /* _BACKPORTS_LINUX_STATIC_KEY_H */
diff --git a/backport/backport-include/linux/stddef.h b/backport/backport-include/linux/stddef.h
deleted file mode 100644
index 2c836b00..00000000
--- a/backport/backport-include/linux/stddef.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __BACKPORT_LINUX_STDDEF_H
-#define __BACKPORT_LINUX_STDDEF_H
-#include_next <linux/stddef.h>
-
-#ifndef offsetofend
-/**
- * offsetofend(TYPE, MEMBER)
- *
- * @TYPE: The type of the structure
- * @MEMBER: The member within the structure to get the end offset of
- */
-#define offsetofend(TYPE, MEMBER) \
- (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
-#endif
-
-#endif /* __BACKPORT_LINUX_STDDEF_H */
diff --git a/backport/backport-include/linux/string.h b/backport/backport-include/linux/string.h
deleted file mode 100644
index 2bfdf747..00000000
--- a/backport/backport-include/linux/string.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __BACKPORT_LINUX_STRING_H
-#define __BACKPORT_LINUX_STRING_H
-#include_next <linux/string.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define memdup_user_nul LINUX_BACKPORT(memdup_user_nul)
-extern void *memdup_user_nul(const void __user *, size_t);
-#endif
-
-/* this was added in v3.2.65, v3.4.106, v3.10.60, v3.12.33, v3.14.24,
- * v3.17.3 and v3.18 */
-#if !(LINUX_VERSION_IS_GEQ(3,17,3) || \
- (LINUX_VERSION_IS_GEQ(3,14,24) && \
- LINUX_VERSION_IS_LESS(3,15,0)) || \
- (LINUX_VERSION_IS_GEQ(3,12,33) && \
- LINUX_VERSION_IS_LESS(3,13,0)) || \
- (LINUX_VERSION_IS_GEQ(3,10,60) && \
- LINUX_VERSION_IS_LESS(3,11,0)) || \
- (LINUX_VERSION_IS_GEQ(3,4,106) && \
- LINUX_VERSION_IS_LESS(3,5,0)) || \
- (LINUX_VERSION_IS_GEQ(3,2,65) && \
- LINUX_VERSION_IS_LESS(3,3,0)))
-#define memzero_explicit LINUX_BACKPORT(memzero_explicit)
-void memzero_explicit(void *s, size_t count);
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,3,0)
-ssize_t strscpy(char *dest, const char *src, size_t count);
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-char *strreplace(char *s, char old, char new);
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,6,0)
-int match_string(const char * const *array, size_t n, const char *string);
-#endif /* LINUX_VERSION_IS_LESS(4,5,0) */
-
-#endif /* __BACKPORT_LINUX_STRING_H */
diff --git a/backport/backport-include/linux/suspend.h b/backport/backport-include/linux/suspend.h
deleted file mode 100644
index 60307182..00000000
--- a/backport/backport-include/linux/suspend.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BP_LINUX_SUSPEND_H
-#define __BP_LINUX_SUSPEND_H
-#include_next <linux/suspend.h>
-
-#if LINUX_VERSION_IS_LESS(3,18,0)
-static inline void pm_system_wakeup(void)
-{
-#if LINUX_VERSION_IS_GEQ(3,10,0)
- freeze_wake();
-#endif
-}
-#endif
-
-#endif /* __BP_LINUX_SUSPEND_H */
diff --git a/backport/backport-include/linux/sysfs.h b/backport/backport-include/linux/sysfs.h
deleted file mode 100644
index 0b71db54..00000000
--- a/backport/backport-include/linux/sysfs.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __BACKPORT_LINUX_SYSFS_H
-#define __BACKPORT_LINUX_SYSFS_H
-#include_next <linux/sysfs.h>
-#include <linux/version.h>
-
-#ifndef __ATTR_RW
-#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \
- _name##_show, _name##_store)
-#endif
-
-#endif /* __BACKPORT_LINUX_SYSFS_H */
diff --git a/backport/backport-include/linux/thermal.h b/backport/backport-include/linux/thermal.h
deleted file mode 100644
index ad61a90a..00000000
--- a/backport/backport-include/linux/thermal.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef __BACKPORT_LINUX_THERMAL_H
-#define __BACKPORT_LINUX_THERMAL_H
-#include_next <linux/thermal.h>
-#include <linux/version.h>
-
-#ifdef CONFIG_THERMAL
-#if LINUX_VERSION_IS_LESS(3,8,0)
-#include <linux/errno.h>
-#include <linux/err.h>
-
-enum thermal_trend {
- THERMAL_TREND_STABLE, /* temperature is stable */
- THERMAL_TREND_RAISING, /* temperature is raising */
- THERMAL_TREND_DROPPING, /* temperature is dropping */
- THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
- THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
-};
-
-struct backport_thermal_zone_device_ops {
- int (*bind) (struct thermal_zone_device *,
- struct thermal_cooling_device *);
- int (*unbind) (struct thermal_zone_device *,
- struct thermal_cooling_device *);
- int (*get_temp) (struct thermal_zone_device *, int *);
- int (*get_mode) (struct thermal_zone_device *,
- enum thermal_device_mode *);
- int (*set_mode) (struct thermal_zone_device *,
- enum thermal_device_mode);
- int (*get_trip_type) (struct thermal_zone_device *, int,
- enum thermal_trip_type *);
- int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
- int (*set_trip_temp) (struct thermal_zone_device *, int, int);
- int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
- int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
- int (*get_crit_temp) (struct thermal_zone_device *, int *);
- int (*set_emul_temp) (struct thermal_zone_device *, int);
- int (*get_trend) (struct thermal_zone_device *, int,
- enum thermal_trend *);
- int (*notify) (struct thermal_zone_device *, int,
- enum thermal_trip_type);
-};
-#define thermal_zone_device_ops LINUX_BACKPORT(thermal_zone_device_ops)
-
-struct thermal_bind_params {
- struct thermal_cooling_device *cdev;
- int weight;
- int trip_mask;
- int (*match)(struct thermal_zone_device *tz,
- struct thermal_cooling_device *cdev);
-};
-
-struct thermal_zone_params {
- int num_tbps;
- struct thermal_bind_params *tbp;
-};
-
-static inline struct thermal_zone_device *
-backport_thermal_zone_device_register(const char *type, int trips, int mask,
- void *devdata,
- struct thermal_zone_device_ops *ops,
- const struct thermal_zone_params *tzp,
- int passive_delay, int polling_delay)
-{
- return ERR_PTR(-EOPNOTSUPP);
-}
-#define thermal_zone_device_register backport_thermal_zone_device_register
-
-static inline void thermal_notify_framework(struct thermal_zone_device *tz,
- int trip)
-{ }
-#else /* < 3.8.0 */
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-#define thermal_notify_framework notify_thermal_framework
-#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
-
-#if LINUX_VERSION_IS_LESS(4,3,0)
-
-typedef struct thermal_zone_device_ops old_thermal_zone_device_ops_t;
-
-/* also add a way to call the old register and unregister functions */
-static inline struct thermal_zone_device *old_thermal_zone_device_register(
- const char *type, int trips, int mask, void *devdata,
- old_thermal_zone_device_ops_t *_ops,
- const struct thermal_zone_params *_tzp,
- int passive_delay, int polling_delay)
-{
- struct thermal_zone_device_ops *ops =
- (struct thermal_zone_device_ops *) _ops;
-
- /* cast the const away */
- struct thermal_zone_params *tzp =
- (struct thermal_zone_params *)_tzp;
-
- return thermal_zone_device_register(type, trips, mask, devdata,
- ops, tzp, passive_delay,
- polling_delay);
-}
-
-static inline
-void old_thermal_zone_device_unregister(struct thermal_zone_device *dev)
-{
- thermal_zone_device_unregister(dev);
-}
-
-struct backport_thermal_zone_device_ops {
- int (*bind) (struct thermal_zone_device *,
- struct thermal_cooling_device *);
- int (*unbind) (struct thermal_zone_device *,
- struct thermal_cooling_device *);
- int (*get_temp) (struct thermal_zone_device *, int *);
- int (*get_mode) (struct thermal_zone_device *,
- enum thermal_device_mode *);
- int (*set_mode) (struct thermal_zone_device *,
- enum thermal_device_mode);
- int (*get_trip_type) (struct thermal_zone_device *, int,
- enum thermal_trip_type *);
- int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
- int (*set_trip_temp) (struct thermal_zone_device *, int, int);
- int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
- int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
- int (*get_crit_temp) (struct thermal_zone_device *, int *);
- int (*set_emul_temp) (struct thermal_zone_device *, int);
- int (*get_trend) (struct thermal_zone_device *, int,
- enum thermal_trend *);
- int (*notify) (struct thermal_zone_device *, int,
- enum thermal_trip_type);
-};
-#define thermal_zone_device_ops LINUX_BACKPORT(thermal_zone_device_ops)
-
-#undef thermal_zone_device_register
-struct thermal_zone_device *backport_thermal_zone_device_register(
- const char *type, int trips, int mask, void *devdata,
- struct thermal_zone_device_ops *ops,
- const struct thermal_zone_params *tzp,
- int passive_delay, int polling_delay);
-
-#define thermal_zone_device_register \
- LINUX_BACKPORT(thermal_zone_device_register)
-
-#undef thermal_zone_device_unregister
-void backport_thermal_zone_device_unregister(struct thermal_zone_device *);
-#define thermal_zone_device_unregister \
- LINUX_BACKPORT(thermal_zone_device_unregister)
-
-#endif /* LINUX_VERSION_IS_LESS(4,3,0) */
-#endif /* ! < 3.8.0 */
-#endif /* CONFIG_THERMAL */
-
-#endif /* __BACKPORT_LINUX_THERMAL_H */
diff --git a/backport/backport-include/linux/time.h b/backport/backport-include/linux/time.h
deleted file mode 100644
index 3191047d..00000000
--- a/backport/backport-include/linux/time.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __BACKPORT_LINUX_TIME_H
-#define __BACKPORT_LINUX_TIME_H
-#include_next <linux/time.h>
-
-#include <linux/time64.h>
-
-#endif /* __BACKPORT_LINUX_TIME_H */
diff --git a/backport/backport-include/linux/time64.h b/backport/backport-include/linux/time64.h
deleted file mode 100644
index 49805da9..00000000
--- a/backport/backport-include/linux/time64.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef __BACKPORT_LINUX_TIME64_H
-#define __BACKPORT_LINUX_TIME64_H
-#if LINUX_VERSION_IS_GEQ(3,17,0)
-#include_next <linux/time64.h>
-#else
-#include <linux/time.h>
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#define timespec64_equal timespec_equal
-#define timespec64_compare timespec_compare
-#define set_normalized_timespec64 set_normalized_timespec
-#define timespec64_add_safe timespec_add_safe
-#define timespec64_add timespec_add
-#define timespec64_sub timespec_sub
-#define timespec64_valid timespec_valid
-#define timespec64_valid_strict timespec_valid_strict
-#define timespec64_to_ns timespec_to_ns
-#define ns_to_timespec64 ns_to_timespec
-#define timespec64_add_ns timespec_add_ns
-#define timespec64 timespec
-#endif /* LINUX_VERSION_IS_LESS(3,17,0) */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-static inline time64_t mktime64(const unsigned int year0, const unsigned int mon0,
- const unsigned int day, const unsigned int hour,
- const unsigned int min, const unsigned int sec)
-{
- unsigned int mon = mon0, year = year0;
-
- /* 1..12 -> 11,12,1..10 */
- if (0 >= (int) (mon -= 2)) {
- mon += 12; /* Puts Feb last since it has leap day */
- year -= 1;
- }
-
- return ((((time64_t)
- (year/4 - year/100 + year/400 + 367*mon/12 + day) +
- year*365 - 719499
- )*24 + hour /* now have hours - midnight tomorrow handled here */
- )*60 + min /* now have minutes */
- )*60 + sec; /* finally seconds */
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_TIME64_H */
diff --git a/backport/backport-include/linux/timecounter.h b/backport/backport-include/linux/timecounter.h
deleted file mode 100644
index 596015b1..00000000
--- a/backport/backport-include/linux/timecounter.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __BACKPORT_LINUX_TIMECOUNTER_H
-#define __BACKPORT_LINUX_TIMECOUNTER_H
-
-#if LINUX_VERSION_IS_GEQ(3,20,0)
-#include_next <linux/timecounter.h>
-#else
-#include <linux/clocksource.h>
-
-/**
- * timecounter_adjtime - Shifts the time of the clock.
- * @delta: Desired change in nanoseconds.
- */
-#define timecounter_adjtime LINUX_BACKPORT(timecounter_adjtime)
-static inline void timecounter_adjtime(struct timecounter *tc, s64 delta)
-{
- tc->nsec += delta;
-}
-#endif
-
-#ifndef CYCLECOUNTER_MASK
-/* simplify initialization of mask field */
-#define CYCLECOUNTER_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
-#endif
-
-#endif /* __BACKPORT_LINUX_TIMECOUNTER_H */
diff --git a/backport/backport-include/linux/timekeeping.h b/backport/backport-include/linux/timekeeping.h
deleted file mode 100644
index a0d65fba..00000000
--- a/backport/backport-include/linux/timekeeping.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef __BACKPORT_TIMEKEEPING_H
-#define __BACKPORT_TIMEKEEPING_H
-#include <linux/version.h>
-#include <linux/types.h>
-
-#if LINUX_VERSION_IS_GEQ(3,17,0)
-#include_next <linux/timekeeping.h>
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-#if BITS_PER_LONG < 64
-extern u64 ktime_divns(const ktime_t kt, s64 div);
-#else /* BITS_PER_LONG < 64 */
-# define ktime_divns(kt, div) (u64)((kt).tv64 / (div))
-#endif
-#define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
-extern ktime_t ktime_get(void);
-#define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
-static inline u64 ktime_get_ns(void)
-{
- return ktime_to_ns(ktime_get());
-}
-
-extern ktime_t ktime_get_boottime(void);
-#define ktime_get_boot_ns LINUX_BACKPORT(ktime_get_boot_ns)
-static inline u64 ktime_get_boot_ns(void)
-{
- return ktime_to_ns(ktime_get_boottime());
-}
-#endif /* < 3.17 */
-
-#if LINUX_VERSION_IS_LESS(4,18,0)
-extern time64_t ktime_get_boottime_seconds(void);
-#endif /* < 4.18 */
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-static inline time64_t ktime_get_seconds(void)
-{
- struct timespec t;
-
- ktime_get_ts(&t);
-
- return t.tv_sec;
-}
-
-static inline time64_t ktime_get_real_seconds(void)
-{
- struct timeval tv;
-
- do_gettimeofday(&tv);
-
- return tv.tv_sec;
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-static inline void ktime_get_ts64(struct timespec64 *ts)
-{
- ktime_get_ts(ts);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-/* This was introduced in 4.15, but we only need it in the
- * ktime_get_raw_ts64 backport() for < 3.17.
- */
-#if __BITS_PER_LONG == 64
-static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
-{
- return *(const struct timespec64 *)&ts;
-}
-
-#else
-static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
-{
- struct timespec64 ret;
-
- ret.tv_sec = ts.tv_sec;
- ret.tv_nsec = ts.tv_nsec;
- return ret;
-}
-#endif
-#endif /* < 3.17 */
-
-#if LINUX_VERSION_IS_LESS(4,18,0)
-#define ktime_get_raw_ts64 LINUX_BACKPORT(ktime_get_raw_ts64)
-static inline void ktime_get_raw_ts64(struct timespec64 *ts)
-{
-#if LINUX_VERSION_IS_LESS(3,19,0)
- struct timespec64 ts64;
-
- getrawmonotonic(&ts64);
- *ts = timespec_to_timespec64(ts64);
-#else
- return getrawmonotonic64(ts);
-#endif /* < 3.19 */
-}
-#endif
-
-#endif /* __BACKPORT_TIMEKEEPING_H */
diff --git a/backport/backport-include/linux/timer.h b/backport/backport-include/linux/timer.h
deleted file mode 100644
index 69590bb7..00000000
--- a/backport/backport-include/linux/timer.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef _BACKPORT_TIMER_H
-#define _BACKPORT_TIMER_H
-
-#include_next <linux/timer.h>
-
-#ifndef setup_deferrable_timer
-/*
- * The TIMER_DEFERRABLE flag has not been around since 3.0 so
- * two different backports are needed here.
- */
-#ifdef TIMER_DEFERRABLE
-#define setup_deferrable_timer(timer, fn, data) \
- __setup_timer((timer), (fn), (data), TIMER_DEFERRABLE)
-#else
-static inline void setup_deferrable_timer_key(struct timer_list *timer,
- const char *name,
- struct lock_class_key *key,
- void (*func)(unsigned long),
- unsigned long data)
-{
- timer->function = func;
- timer->data = data;
- init_timer_deferrable_key(timer, name, key);
-}
-#define setup_deferrable_timer(timer, fn, data) \
- do { \
- static struct lock_class_key __key; \
- setup_deferrable_timer_key((timer), #timer, &__key, \
- (fn), (data)); \
- } while (0)
-#endif
-#endif
-
-#ifndef TIMER_DEFERRABLE
-#define TIMER_DEFERRABLE 1
-#endif
-
-#ifndef from_timer
-#define TIMER_DATA_TYPE unsigned long
-#define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE)
-
-static inline void timer_setup(struct timer_list *timer,
- void (*callback) (struct timer_list *),
- unsigned int flags)
-{
-#ifdef __setup_timer
- __setup_timer(timer, (TIMER_FUNC_TYPE) callback,
- (TIMER_DATA_TYPE) timer, flags);
-#else
- if (flags & TIMER_DEFERRABLE)
- setup_deferrable_timer(timer, (TIMER_FUNC_TYPE) callback,
- (TIMER_DATA_TYPE) timer);
- else
- setup_timer(timer, (TIMER_FUNC_TYPE) callback,
- (TIMER_DATA_TYPE) timer);
-#endif
-}
-
-#define from_timer(var, callback_timer, timer_fieldname) \
- container_of(callback_timer, typeof(*var), timer_fieldname)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,15,0)
-#undef DEFINE_TIMER
-#define DEFINE_TIMER(_name, _function) \
- struct timer_list _name = \
- __TIMER_INITIALIZER(_function, 0, 0, 0)
-#endif
-
-#endif /* _BACKPORT_TIMER_H */
diff --git a/backport/backport-include/linux/tracepoint.h b/backport/backport-include/linux/tracepoint.h
deleted file mode 100644
index a695c6fc..00000000
--- a/backport/backport-include/linux/tracepoint.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#include_next <linux/tracepoint.h>
-
-#ifndef __BACKPORT_LINUX_TRACEPOINT_H
-#define __BACKPORT_LINUX_TRACEPOINT_H
-
-#ifndef TRACE_DEFINE_ENUM
-#define TRACE_DEFINE_ENUM(a)
-#endif
-
-#endif /* __BACKPORT_LINUX_TRACEPOINT_H */
diff --git a/backport/backport-include/linux/tty.h b/backport/backport-include/linux/tty.h
deleted file mode 100644
index 987a1157..00000000
--- a/backport/backport-include/linux/tty.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef __BACKPORT_LINUX_TTY_H
-#define __BACKPORT_LINUX_TTY_H
-#include_next <linux/tty.h>
-
-/*
- * This really belongs into uapi/asm-generic/termbits.h but
- * that doesn't usually get included directly.
- */
-#ifndef EXTPROC
-#define EXTPROC 0200000
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-/* Backports tty_lock: Localise the lock */
-#define tty_lock(__tty) tty_lock()
-#define tty_unlock(__tty) tty_unlock()
-
-#define tty_port_register_device(port, driver, index, device) \
- tty_register_device(driver, index, device)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-extern void tty_port_tty_wakeup(struct tty_port *port);
-extern void tty_port_tty_hangup(struct tty_port *port, bool check_clocal);
-#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
-
-#if LINUX_VERSION_IS_LESS(4,1,0) && \
- LINUX_VERSION_IS_GEQ(4,0,0)
-extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
-#endif /* LINUX_VERSION_IS_LESS(4,1,0) */
-
-#ifndef N_NCI
-#define N_NCI 25 /* NFC NCI UART */
-#endif
-
-#endif /* __BACKPORT_LINUX_TTY_H */
diff --git a/backport/backport-include/linux/tty_flip.h b/backport/backport-include/linux/tty_flip.h
deleted file mode 100644
index e6c0684e..00000000
--- a/backport/backport-include/linux/tty_flip.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __BACKPORT_TTY_FLIP_H
-#define __BACKPORT_TTY_FLIP_H
-#include_next <linux/tty_flip.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty)
-#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size)
-#endif
-
-#endif /* __BACKPORT_TTY_FLIP_H */
diff --git a/backport/backport-include/linux/types.h b/backport/backport-include/linux/types.h
deleted file mode 100644
index 0671e140..00000000
--- a/backport/backport-include/linux/types.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BACKPORT_TYPES
-#define __BACKPORT_TYPES
-#include <linux/version.h>
-#include_next <linux/types.h>
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-typedef __s64 time64_t;
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,16,0)
-typedef unsigned __poll_t;
-#endif
-
-#endif /* __BACKPORT_TYPES */
diff --git a/backport/backport-include/linux/u64_stats_sync.h b/backport/backport-include/linux/u64_stats_sync.h
deleted file mode 100644
index 251373a7..00000000
--- a/backport/backport-include/linux/u64_stats_sync.h
+++ /dev/null
@@ -1,180 +0,0 @@
-#ifndef __BACKPORT_LINUX_U64_STATS_SYNC_H
-#define __BACKPORT_LINUX_U64_STATS_SYNC_H
-
-#include <linux/version.h>
-#include <generated/utsrelease.h>
-#if LINUX_VERSION_IS_GEQ(3,6,0)
-#include_next <linux/u64_stats_sync.h>
-#else
-
-/*
- * To properly implement 64bits network statistics on 32bit and 64bit hosts,
- * we provide a synchronization point, that is a noop on 64bit or UP kernels.
- *
- * Key points :
- * 1) Use a seqcount on SMP 32bits, with low overhead.
- * 2) Whole thing is a noop on 64bit arches or UP kernels.
- * 3) Write side must ensure mutual exclusion or one seqcount update could
- * be lost, thus blocking readers forever.
- * If this synchronization point is not a mutex, but a spinlock or
- * spinlock_bh() or disable_bh() :
- * 3.1) Write side should not sleep.
- * 3.2) Write side should not allow preemption.
- * 3.3) If applicable, interrupts should be disabled.
- *
- * 4) If reader fetches several counters, there is no guarantee the whole values
- * are consistent (remember point 1) : this is a noop on 64bit arches anyway)
- *
- * 5) readers are allowed to sleep or be preempted/interrupted : They perform
- * pure reads. But if they have to fetch many values, it's better to not allow
- * preemptions/interruptions to avoid many retries.
- *
- * 6) If counter might be written by an interrupt, readers should block interrupts.
- * (On UP, there is no seqcount_t protection, a reader allowing interrupts could
- * read partial values)
- *
- * 7) For softirq uses, readers can use u64_stats_fetch_begin_irq() and
- * u64_stats_fetch_retry_irq() helpers
- *
- * Usage :
- *
- * Stats producer (writer) should use following template granted it already got
- * an exclusive access to counters (a lock is already taken, or per cpu
- * data is used [in a non preemptable context])
- *
- * spin_lock_bh(...) or other synchronization to get exclusive access
- * ...
- * u64_stats_update_begin(&stats->syncp);
- * stats->bytes64 += len; // non atomic operation
- * stats->packets64++; // non atomic operation
- * u64_stats_update_end(&stats->syncp);
- *
- * While a consumer (reader) should use following template to get consistent
- * snapshot for each variable (but no guarantee on several ones)
- *
- * u64 tbytes, tpackets;
- * unsigned int start;
- *
- * do {
- * start = u64_stats_fetch_begin(&stats->syncp);
- * tbytes = stats->bytes64; // non atomic operation
- * tpackets = stats->packets64; // non atomic operation
- * } while (u64_stats_fetch_retry(&stats->syncp, start));
- *
- *
- * Example of use in drivers/net/loopback.c, using per_cpu containers,
- * in BH disabled context.
- */
-#include <linux/seqlock.h>
-
-struct u64_stats_sync {
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- seqcount_t seq;
-#endif
-};
-
-static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- write_seqcount_begin(&syncp->seq);
-#endif
-}
-
-static inline void u64_stats_update_end(struct u64_stats_sync *syncp)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- write_seqcount_end(&syncp->seq);
-#endif
-}
-
-static inline unsigned int u64_stats_fetch_begin(const struct u64_stats_sync *syncp)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- return read_seqcount_begin(&syncp->seq);
-#else
-#if BITS_PER_LONG==32
- preempt_disable();
-#endif
- return 0;
-#endif
-}
-
-static inline bool u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
- unsigned int start)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- return read_seqcount_retry(&syncp->seq, start);
-#else
-#if BITS_PER_LONG==32
- preempt_enable();
-#endif
- return false;
-#endif
-}
-
-#endif /* LINUX_VERSION_IS_GEQ(3,6,0) */
-
-#if LINUX_VERSION_IS_LESS(3,15,0) && \
- !(LINUX_VERSION_CODE == KERNEL_VERSION(3,13,11) && UTS_UBUNTU_RELEASE_ABI > 30)
-static inline unsigned int u64_stats_fetch_begin_irq(const struct u64_stats_sync *syncp)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- return read_seqcount_begin(&syncp->seq);
-#else
-#if BITS_PER_LONG==32
- local_irq_disable();
-#endif
- return 0;
-#endif
-}
-
-static inline bool u64_stats_fetch_retry_irq(const struct u64_stats_sync *syncp,
- unsigned int start)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- return read_seqcount_retry(&syncp->seq, start);
-#else
-#if BITS_PER_LONG==32
- local_irq_enable();
-#endif
- return false;
-#endif
-}
-
-#endif /* LINUX_VERSION_IS_GEQ(3,15,0) */
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#if BITS_PER_LONG == 32 && defined(CONFIG_SMP)
-# define u64_stats_init(syncp) seqcount_init(syncp.seq)
-#else
-# define u64_stats_init(syncp) do { } while (0)
-#endif
-#endif /* LINUX_VERSION_IS_LESS(3,13,0) */
-
-#if LINUX_VERSION_IS_LESS(4,16,0) && \
- !LINUX_VERSION_IN_RANGE(4,14,44, 4,15,0) && \
- !(LINUX_VERSION_IS_GEQ(4,15,18) && UTS_UBUNTU_RELEASE_ABI >= 33)
-static inline unsigned long
-u64_stats_update_begin_irqsave(struct u64_stats_sync *syncp)
-{
- unsigned long flags = 0;
-
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- local_irq_save(flags);
- write_seqcount_begin(&syncp->seq);
-#endif
- return flags;
-}
-
-static inline void
-u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp,
- unsigned long flags)
-{
-#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
- write_seqcount_end(&syncp->seq);
- local_irq_restore(flags);
-#endif
-}
-#endif /* < 4.16 */
-
-#endif /* __BACKPORT_LINUX_U64_STATS_SYNC_H */
diff --git a/backport/backport-include/linux/uidgid.h b/backport/backport-include/linux/uidgid.h
deleted file mode 100644
index c2f3faa0..00000000
--- a/backport/backport-include/linux/uidgid.h
+++ /dev/null
@@ -1,221 +0,0 @@
-#if LINUX_VERSION_IS_GEQ(3,5,0)
-#include_next <linux/uidgid.h>
-#else
-
-#ifndef _LINUX_UIDGID_H
-#define _LINUX_UIDGID_H
-
-/*
- * A set of types for the internal kernel types representing uids and gids.
- *
- * The types defined in this header allow distinguishing which uids and gids in
- * the kernel are values used by userspace and which uid and gid values are
- * the internal kernel values. With the addition of user namespaces the values
- * can be different. Using the type system makes it possible for the compiler
- * to detect when we overlook these differences.
- *
- */
-#include <linux/types.h>
-#include <linux/highuid.h>
-
-struct user_namespace;
-extern struct user_namespace init_user_ns;
-
-#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
-
-typedef struct {
- uid_t val;
-} kuid_t;
-
-
-typedef struct {
- gid_t val;
-} kgid_t;
-
-#define KUIDT_INIT(value) (kuid_t){ value }
-#define KGIDT_INIT(value) (kgid_t){ value }
-
-static inline uid_t __kuid_val(kuid_t uid)
-{
- return uid.val;
-}
-
-static inline gid_t __kgid_val(kgid_t gid)
-{
- return gid.val;
-}
-
-#else
-
-typedef uid_t kuid_t;
-typedef gid_t kgid_t;
-
-static inline uid_t __kuid_val(kuid_t uid)
-{
- return uid;
-}
-
-static inline gid_t __kgid_val(kgid_t gid)
-{
- return gid;
-}
-
-#define KUIDT_INIT(value) ((kuid_t) value )
-#define KGIDT_INIT(value) ((kgid_t) value )
-
-#endif
-
-#define GLOBAL_ROOT_UID KUIDT_INIT(0)
-#define GLOBAL_ROOT_GID KGIDT_INIT(0)
-
-#define INVALID_UID KUIDT_INIT(-1)
-#define INVALID_GID KGIDT_INIT(-1)
-
-static inline bool uid_eq(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) == __kuid_val(right);
-}
-
-static inline bool gid_eq(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) == __kgid_val(right);
-}
-
-static inline bool uid_gt(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) > __kuid_val(right);
-}
-
-static inline bool gid_gt(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) > __kgid_val(right);
-}
-
-static inline bool uid_gte(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) >= __kuid_val(right);
-}
-
-static inline bool gid_gte(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) >= __kgid_val(right);
-}
-
-static inline bool uid_lt(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) < __kuid_val(right);
-}
-
-static inline bool gid_lt(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) < __kgid_val(right);
-}
-
-static inline bool uid_lte(kuid_t left, kuid_t right)
-{
- return __kuid_val(left) <= __kuid_val(right);
-}
-
-static inline bool gid_lte(kgid_t left, kgid_t right)
-{
- return __kgid_val(left) <= __kgid_val(right);
-}
-
-static inline bool uid_valid(kuid_t uid)
-{
- return !uid_eq(uid, INVALID_UID);
-}
-
-static inline bool gid_valid(kgid_t gid)
-{
- return !gid_eq(gid, INVALID_GID);
-}
-
-#ifdef CONFIG_USER_NS
-
-#define make_kuid LINUX_BACKPORT(make_kuid)
-extern kuid_t make_kuid(struct user_namespace *from, uid_t uid);
-#define make_kgid LINUX_BACKPORT(make_kgid)
-extern kgid_t make_kgid(struct user_namespace *from, gid_t gid);
-
-#define from_kuid LINUX_BACKPORT(from_kuid)
-extern uid_t from_kuid(struct user_namespace *to, kuid_t uid);
-#define from_kgid LINUX_BACKPORT(from_kgid)
-extern gid_t from_kgid(struct user_namespace *to, kgid_t gid);
-#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged)
-extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid);
-#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged)
-extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid);
-
-#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping)
-static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
-{
- return from_kuid(ns, uid) != (uid_t) -1;
-}
-
-#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping)
-static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
-{
- return from_kgid(ns, gid) != (gid_t) -1;
-}
-
-#else
-
-#define make_kuid LINUX_BACKPORT(make_kuid)
-static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid)
-{
- return KUIDT_INIT(uid);
-}
-
-#define make_kgid LINUX_BACKPORT(make_kgid)
-static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid)
-{
- return KGIDT_INIT(gid);
-}
-
-#define from_kuid LINUX_BACKPORT(from_kuid)
-static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid)
-{
- return __kuid_val(kuid);
-}
-
-#define from_kgid LINUX_BACKPORT(from_kgid)
-static inline gid_t from_kgid(struct user_namespace *to, kgid_t kgid)
-{
- return __kgid_val(kgid);
-}
-
-#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged)
-static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid)
-{
- uid_t uid = from_kuid(to, kuid);
- if (uid == (uid_t)-1)
- uid = overflowuid;
- return uid;
-}
-
-#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged)
-static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid)
-{
- gid_t gid = from_kgid(to, kgid);
- if (gid == (gid_t)-1)
- gid = overflowgid;
- return gid;
-}
-
-#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping)
-static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
-{
- return true;
-}
-
-#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping)
-static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
-{
- return true;
-}
-
-#endif /* CONFIG_USER_NS */
-
-#endif /* _LINUX_UIDGID_H */
-#endif /* LINUX_VERSION_IS_GEQ(3,5,0) */
diff --git a/backport/backport-include/linux/usb.h b/backport/backport-include/linux/usb.h
deleted file mode 100644
index 1873a336..00000000
--- a/backport/backport-include/linux/usb.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef __BACKPORT_USB_H
-#define __BACKPORT_USB_H
-
-#include_next <linux/usb.h>
-#include <linux/version.h>
-
-#ifndef module_usb_driver
-/**
- * module_usb_driver() - Helper macro for registering a USB driver
- * @__usb_driver: usb_driver struct
- *
- * Helper macro for USB drivers which do not do anything special in module
- * init/exit. This eliminates a lot of boilerplate. Each module may only
- * use this macro once, and calling it replaces module_init() and module_exit()
- */
-#define module_usb_driver(__usb_driver) \
- module_driver(__usb_driver, usb_register, \
- usb_deregister)
-#endif
-
-#ifndef USB_VENDOR_AND_INTERFACE_INFO
-/**
- * Backports
- *
- * commit d81a5d1956731c453b85c141458d4ff5d6cc5366
- * Author: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
- * Date: Tue Jul 10 19:10:06 2012 -0300
- *
- * USB: add USB_VENDOR_AND_INTERFACE_INFO() macro
- */
-#define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \
- .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
- | USB_DEVICE_ID_MATCH_VENDOR, \
- .idVendor = (vend), \
- .bInterfaceClass = (cl), \
- .bInterfaceSubClass = (sc), \
- .bInterfaceProtocol = (pr)
-#endif /* USB_VENDOR_AND_INTERFACE_INFO */
-
-#ifndef USB_DEVICE_INTERFACE_NUMBER
-/**
- * USB_DEVICE_INTERFACE_NUMBER - describe a usb device with a specific interface number
- * @vend: the 16 bit USB Vendor ID
- * @prod: the 16 bit USB Product ID
- * @num: bInterfaceNumber value
- *
- * This macro is used to create a struct usb_device_id that matches a
- * specific interface number of devices.
- */
-#define USB_DEVICE_INTERFACE_NUMBER(vend, prod, num) \
- .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
- .idVendor = (vend), \
- .idProduct = (prod)
-#endif /* USB_DEVICE_INTERFACE_NUMBER */
-
-#ifndef USB_DEVICE_INTERFACE_CLASS
-/**
- * USB_DEVICE_INTERFACE_CLASS - describe a usb device with a specific interface class
- * @vend: the 16 bit USB Vendor ID
- * @prod: the 16 bit USB Product ID
- * @cl: bInterfaceClass value
- *
- * This macro is used to create a struct usb_device_id that matches a
- * specific interface class of devices.
- */
-#define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \
- .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
- USB_DEVICE_ID_MATCH_INT_CLASS, \
- .idVendor = (vend), \
- .idProduct = (prod), \
- .bInterfaceClass = (cl)
-#endif /* USB_DEVICE_INTERFACE_CLASS */
-
-#ifndef USB_SUBCLASS_VENDOR_SPEC
-/* this is defined in usb/ch9.h, but we only need it through here */
-#define USB_SUBCLASS_VENDOR_SPEC 0xff
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#define usb_translate_errors LINUX_BACKPORT(usb_translate_errors)
-static inline int usb_translate_errors(int error_code)
-{
- switch (error_code) {
- case 0:
- case -ENOMEM:
- case -ENODEV:
- case -EOPNOTSUPP:
- return error_code;
- default:
- return -EIO;
- }
-}
-#endif /* LINUX_VERSION_IS_LESS(3,2,0) */
-
-#endif /* __BACKPORT_USB_H */
diff --git a/backport/backport-include/linux/usb/cdc.h b/backport/backport-include/linux/usb/cdc.h
deleted file mode 100644
index 5ad31bf1..00000000
--- a/backport/backport-include/linux/usb/cdc.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef __BP_USB_CDC_H
-#define __BP_USB_CDC_H
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_GEQ(4,8,0)
-#include_next <linux/usb/cdc.h>
-#else
-#include <uapi/linux/usb/cdc.h>
-
-/*
- * inofficial magic numbers
- */
-
-#define CDC_PHONET_MAGIC_NUMBER 0xAB
-
-#ifndef USB_CDC_MBIM_EXTENDED_TYPE
-#define USB_CDC_MBIM_EXTENDED_TYPE 0x1c
-
-/* "MBIM Extended Functional Descriptor" from CDC MBIM spec 1.0 errata-1 */
-struct usb_cdc_mbim_extended_desc {
- __u8 bLength;
- __u8 bDescriptorType;
- __u8 bDescriptorSubType;
-
- __le16 bcdMBIMExtendedVersion;
- __u8 bMaxOutstandingCommandMessages;
- __le16 wMTU;
-} __attribute__ ((packed));
-#endif
-
-/*
- * parsing CDC headers
- */
-
-struct usb_cdc_parsed_header {
- struct usb_cdc_union_desc *usb_cdc_union_desc;
- struct usb_cdc_header_desc *usb_cdc_header_desc;
-
- struct usb_cdc_call_mgmt_descriptor *usb_cdc_call_mgmt_descriptor;
- struct usb_cdc_acm_descriptor *usb_cdc_acm_descriptor;
- struct usb_cdc_country_functional_desc *usb_cdc_country_functional_desc;
- struct usb_cdc_network_terminal_desc *usb_cdc_network_terminal_desc;
- struct usb_cdc_ether_desc *usb_cdc_ether_desc;
- struct usb_cdc_dmm_desc *usb_cdc_dmm_desc;
- struct usb_cdc_mdlm_desc *usb_cdc_mdlm_desc;
- struct usb_cdc_mdlm_detail_desc *usb_cdc_mdlm_detail_desc;
- struct usb_cdc_obex_desc *usb_cdc_obex_desc;
- struct usb_cdc_ncm_desc *usb_cdc_ncm_desc;
- struct usb_cdc_mbim_desc *usb_cdc_mbim_desc;
- struct usb_cdc_mbim_extended_desc *usb_cdc_mbim_extended_desc;
-
- bool phonet_magic_present;
-};
-
-#define cdc_parse_cdc_header LINUX_BACKPORT(cdc_parse_cdc_header)
-int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
- struct usb_interface *intf,
- u8 *buffer, int buflen);
-#endif
-
-#endif /* __BP_USB_CDC_H */
diff --git a/backport/backport-include/linux/usb/ch9.h b/backport/backport-include/linux/usb/ch9.h
deleted file mode 100644
index c2f0120c..00000000
--- a/backport/backport-include/linux/usb/ch9.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __BACKPORT__LINUX_USB_CH9_H
-#define __BACKPORT__LINUX_USB_CH9_H
-
-#include <linux/version.h>
-#include_next <linux/usb/ch9.h>
-
-#if LINUX_VERSION_IS_LESS(3,2,0)
-#include <linux/types.h> /* __u8 etc */
-#include <asm/byteorder.h> /* le16_to_cpu */
-
-/**
- * usb_endpoint_maxp - get endpoint's max packet size
- * @epd: endpoint to be checked
- *
- * Returns @epd's max packet
- */
-#define usb_endpoint_maxp LINUX_BACKPORT(usb_endpoint_maxp)
-static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
-{
- return __le16_to_cpu(epd->wMaxPacketSize);
-}
-#endif /* < 3.2 */
-
-#if LINUX_VERSION_IS_LESS(4,6,0)
-#define USB_SPEED_SUPER_PLUS 6
-#endif
-
-#endif /* __BACKPORT__LINUX_USB_CH9_H */
diff --git a/backport/backport-include/linux/uuid.h b/backport/backport-include/linux/uuid.h
deleted file mode 100644
index bc6fbe17..00000000
--- a/backport/backport-include/linux/uuid.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __BACKPORT_LINUX_UUID_H_
-#define __BACKPORT_LINUX_UUID_H_
-#include <linux/version.h>
-#include_next <linux/uuid.h>
-
-#ifndef UUID_STRING_LEN
-/*
- * The length of a UUID string ("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
- * not including trailing NUL.
- */
-#define UUID_STRING_LEN 36
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,13,0)
-#define guid_t uuid_le
-#define uuid_t uuid_be
-
-static inline void guid_gen(guid_t *u)
-{
- return uuid_le_gen(u);
-}
-static inline void uuid_gen(uuid_t *u)
-{
- return uuid_be_gen(u);
-}
-
-static inline void guid_copy(guid_t *dst, const guid_t *src)
-{
- memcpy(dst, src, sizeof(guid_t));
-}
-#endif
-
-#endif /* __BACKPORT_LINUX_UUID_H_ */
diff --git a/backport/backport-include/linux/verification.h b/backport/backport-include/linux/verification.h
deleted file mode 100644
index 5fd0a2d3..00000000
--- a/backport/backport-include/linux/verification.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __BP_VERIFICATION_H
-#define __BP_VERIFICATION_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(4,7,0) && !defined(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION)
-#include_next <linux/verification.h>
-#else
-#include <linux/key.h>
-
-enum key_being_used_for {
- VERIFYING_MODULE_SIGNATURE,
- VERIFYING_FIRMWARE_SIGNATURE,
- VERIFYING_KEXEC_PE_SIGNATURE,
- VERIFYING_KEY_SIGNATURE,
- VERIFYING_KEY_SELF_SIGNATURE,
- VERIFYING_UNSPECIFIED_SIGNATURE,
- NR__KEY_BEING_USED_FOR
-};
-
-extern int verify_pkcs7_signature(const void *data, size_t len,
- const void *raw_pkcs7, size_t pkcs7_len,
- struct key *trusted_keys,
- enum key_being_used_for usage,
- int (*view_content)(void *ctx,
- const void *data, size_t len,
- size_t asn1hdrlen),
- void *ctx);
-#endif /* LINUX_VERSION_IS_GEQ(4,7,0) && !defined(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) */
-#endif /* __BP_VERIFICATION_H */
diff --git a/backport/backport-include/linux/version.h b/backport/backport-include/linux/version.h
deleted file mode 100644
index 2cb601ad..00000000
--- a/backport/backport-include/linux/version.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _BP_LINUX_VERSION_H
-#define _BP_LINUX_VERSION_H
-#include_next <linux/version.h>
-
-#ifndef RHEL_RELEASE_VERSION
-#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))
-#endif
-
-#ifndef RHEL_RELEASE_CODE
-#define RHEL_RELEASE_CODE 0
-#endif
-
-#define LINUX_VERSION_IS_LESS(x1,x2,x3) (LINUX_VERSION_CODE < KERNEL_VERSION(x1,x2,x3))
-#define LINUX_VERSION_IS_GEQ(x1,x2,x3) (LINUX_VERSION_CODE >= KERNEL_VERSION(x1,x2,x3))
-#define LINUX_VERSION_IN_RANGE(x1,x2,x3, y1,y2,y3) \
- (LINUX_VERSION_IS_GEQ(x1,x2,x3) && LINUX_VERSION_IS_LESS(y1,y2,y3))
-#endif /* _BP_LINUX_VERSION_H */
diff --git a/backport/backport-include/linux/wait.h b/backport/backport-include/linux/wait.h
deleted file mode 100644
index 15a674cf..00000000
--- a/backport/backport-include/linux/wait.h
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef __BACKPORT_LINUX_WAIT_H
-#define __BACKPORT_LINUX_WAIT_H
-#include_next <linux/wait.h>
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-extern int bit_wait(void *);
-extern int bit_wait_io(void *);
-
-static inline int
-backport_wait_on_bit(void *word, int bit, unsigned mode)
-{
- return wait_on_bit(word, bit, bit_wait, mode);
-}
-
-static inline int
-backport_wait_on_bit_io(void *word, int bit, unsigned mode)
-{
- return wait_on_bit(word, bit, bit_wait_io, mode);
-}
-
-#define wait_on_bit LINUX_BACKPORT(wait_on_bit)
-#define wait_on_bit_io LINUX_BACKPORT(wait_on_bit_io)
-
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,18,12)
-#define WQ_FLAG_WOKEN 0x02
-
-#define wait_woken LINUX_BACKPORT(wait_woken)
-long wait_woken(wait_queue_t *wait, unsigned mode, long timeout);
-#define wait_woken LINUX_BACKPORT(wait_woken)
-int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key);
-#endif
-
-/**
- * For wait_on_bit_timeout() an extra member in struct wait_bit_key is needed.
- * This was introuced in kernel 3.17 and we are only able to backport this
- * function on these kernel versions.
- */
-#if LINUX_VERSION_IS_GEQ(3,17,0)
-#if LINUX_VERSION_IS_LESS(3,18,0)
-#define out_of_line_wait_on_bit_timeout LINUX_BACKPORT(out_of_line_wait_on_bit_timeout)
-int out_of_line_wait_on_bit_timeout(void *, int, wait_bit_action_f *, unsigned, unsigned long);
-
-#define bit_wait_timeout LINUX_BACKPORT(bit_wait_timeout)
-extern int bit_wait_timeout(struct wait_bit_key *);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,20,0)
-#define wait_on_bit_timeout LINUX_BACKPORT(wait_on_bit_timeout)
-/**
- * wait_on_bit_timeout - wait for a bit to be cleared or a timeout elapses
- * @word: the word being waited on, a kernel virtual address
- * @bit: the bit of the word being waited on
- * @mode: the task state to sleep in
- * @timeout: timeout, in jiffies
- *
- * Use the standard hashed waitqueue table to wait for a bit
- * to be cleared. This is similar to wait_on_bit(), except also takes a
- * timeout parameter.
- *
- * Returned value will be zero if the bit was cleared before the
- * @timeout elapsed, or non-zero if the @timeout elapsed or process
- * received a signal and the mode permitted wakeup on that signal.
- */
-static inline int
-wait_on_bit_timeout(void *word, int bit, unsigned mode, unsigned long timeout)
-{
- might_sleep();
- if (!test_bit(bit, word))
- return 0;
- return out_of_line_wait_on_bit_timeout(word, bit,
- bit_wait_timeout,
- mode, timeout);
-}
-#endif
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,13,0)
-#define wait_queue_entry_t wait_queue_t
-
-#define wait_event_killable_timeout(wq_head, condition, timeout) \
-({ \
- long __ret = timeout; \
- might_sleep(); \
- if (!___wait_cond_timeout(condition)) \
- __ret = __wait_event_killable_timeout(wq_head, \
- condition, timeout); \
- __ret; \
-})
-
-#define __wait_event_killable_timeout(wq_head, condition, timeout) \
- ___wait_event(wq_head, ___wait_cond_timeout(condition), \
- TASK_KILLABLE, 0, timeout, \
- __ret = schedule_timeout(__ret))
-#endif
-
-#endif /* __BACKPORT_LINUX_WAIT_H */
diff --git a/backport/backport-include/linux/watchdog.h b/backport/backport-include/linux/watchdog.h
deleted file mode 100644
index 598c8c48..00000000
--- a/backport/backport-include/linux/watchdog.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __BACKPORT_WATCHDOG_H
-#define __BACKPORT_WATCHDOG_H
-#include_next <linux/watchdog.h>
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define watchdog_device LINUX_BACKPORT(watchdog_device)
-struct watchdog_device {
-};
-#endif
-
-#endif /* __BACKPORT_WATCHDOG_H */
diff --git a/backport/backport-include/linux/workqueue.h b/backport/backport-include/linux/workqueue.h
deleted file mode 100644
index ab68d217..00000000
--- a/backport/backport-include/linux/workqueue.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef __BACKPORT_LINUX_WORKQUEUE_H
-#define __BACKPORT_LINUX_WORKQUEUE_H
-#include_next <linux/workqueue.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define mod_delayed_work LINUX_BACKPORT(mod_delayed_work)
-bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
- unsigned long delay);
-#endif
-
-#ifndef create_freezable_workqueue
-/* note freez_a_ble -> freez_ea_able */
-#define create_freezable_workqueue create_freezeable_workqueue
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#define __WQ_ORDERED 0
-/*
- * commit b196be89cdc14a88cc637cdad845a75c5886c82d
- * Author: Tejun Heo <tj@kernel.org>
- * Date: Tue Jan 10 15:11:35 2012 -0800
- *
- * workqueue: make alloc_workqueue() take printf fmt and args for name
- */
-struct workqueue_struct *
-backport_alloc_workqueue(const char *fmt, unsigned int flags,
- int max_active, struct lock_class_key *key,
- const char *lock_name, ...);
-#undef alloc_workqueue
-#ifdef CONFIG_LOCKDEP
-#define alloc_workqueue(fmt, flags, max_active, args...) \
-({ \
- static struct lock_class_key __key; \
- const char *__lock_name; \
- \
- if (__builtin_constant_p(fmt)) \
- __lock_name = (fmt); \
- else \
- __lock_name = #fmt; \
- \
- backport_alloc_workqueue((fmt), (flags), (max_active), \
- &__key, __lock_name, ##args); \
-})
-#else
-#define alloc_workqueue(fmt, flags, max_active, args...) \
- backport_alloc_workqueue((fmt), (flags), (max_active), \
- NULL, NULL, ##args)
-#endif
-#undef alloc_ordered_workqueue
-#define alloc_ordered_workqueue(fmt, flags, args...) \
- alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
-#define destroy_workqueue backport_destroy_workqueue
-void backport_destroy_workqueue(struct workqueue_struct *wq);
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,11,0)
-/* power efficient workqueues were added in commit 0668106ca386. */
-#define system_power_efficient_wq system_wq
-#define system_freezable_power_efficient_wq system_freezable_wq
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define drain_workqueue(wq) flush_workqueue(wq)
-#endif
-
-#endif /* __BACKPORT_LINUX_WORKQUEUE_H */
diff --git a/backport/backport-include/net/addrconf.h b/backport/backport-include/net/addrconf.h
deleted file mode 100644
index f1e8e627..00000000
--- a/backport/backport-include/net/addrconf.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _BACKPORT_NET_ADDRCONF_H
-#define _BACKPORT_NET_ADDRCONF_H 1
-
-#include_next <net/addrconf.h>
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-static inline bool ipv6_addr_is_solict_mult(const struct in6_addr *addr)
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
- __u64 *p = (__u64 *)addr;
- return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) |
- ((p[1] ^ cpu_to_be64(0x00000001ff000000UL)) &
- cpu_to_be64(0xffffffffff000000UL))) == 0UL;
-#else
- return ((addr->s6_addr32[0] ^ htonl(0xff020000)) |
- addr->s6_addr32[1] |
- (addr->s6_addr32[2] ^ htonl(0x00000001)) |
- (addr->s6_addr[12] ^ 0xff)) == 0;
-#endif
-}
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-#endif /* _BACKPORT_NET_ADDRCONF_H */
diff --git a/backport/backport-include/net/flow_keys.h b/backport/backport-include/net/flow_keys.h
deleted file mode 100644
index 093bc80a..00000000
--- a/backport/backport-include/net/flow_keys.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#if LINUX_VERSION_IS_GEQ(3,3,0)
-#include_next <net/flow_keys.h>
-#else
-
-#ifndef _NET_FLOW_KEYS_H
-#define _NET_FLOW_KEYS_H
-
-struct flow_keys {
- /* (src,dst) must be grouped, in the same way than in IP header */
- __be32 src;
- __be32 dst;
- union {
- __be32 ports;
- __be16 port16[2];
- };
- u8 ip_proto;
-};
-
-extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow);
-#endif
-#endif
diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h
deleted file mode 100644
index 84011e72..00000000
--- a/backport/backport-include/net/genetlink.h
+++ /dev/null
@@ -1,184 +0,0 @@
-#ifndef __BACKPORT_NET_GENETLINK_H
-#define __BACKPORT_NET_GENETLINK_H
-#include_next <net/genetlink.h>
-#include <linux/version.h>
-
-static inline void __bp_genl_info_userhdr_set(struct genl_info *info,
- void *userhdr)
-{
- info->userhdr = userhdr;
-}
-
-static inline void *__bp_genl_info_userhdr(struct genl_info *info)
-{
- return info->userhdr;
-}
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-#define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG(genl_info_extack(info), msg)
-
-static inline int genl_err_attr(struct genl_info *info, int err,
- struct nlattr *attr)
-{
- return err;
-}
-#endif /* < 4.12 */
-
-/* this is for patches we apply */
-static inline struct netlink_ext_ack *genl_info_extack(struct genl_info *info)
-{
-#if LINUX_VERSION_IS_GEQ(4,12,0)
- return info->extack;
-#else
- return info->userhdr;
-#endif
-}
-
-/* this gets put in place of info->userhdr, since we use that above */
-static inline void *genl_info_userhdr(struct genl_info *info)
-{
- return (u8 *)info->genlhdr + GENL_HDRLEN;
-}
-
-/* this is for patches we apply */
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid)
-#else
-#define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,13,0)
-#define __genl_const
-#else /* < 3.13 */
-#define __genl_const const
-#endif /* < 3.13 */
-
-#ifndef GENLMSG_DEFAULT_SIZE
-#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-#define genl_dump_check_consistent(cb, user_hdr) do { } while (0)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,10,0)
-#define __genl_ro_after_init
-#else
-#define __genl_ro_after_init __ro_after_init
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,15,0)
-#define genlmsg_nlhdr LINUX_BACKPORT(genlmsg_nlhdr)
-static inline struct nlmsghdr *genlmsg_nlhdr(void *user_hdr)
-{
- return (struct nlmsghdr *)((char *)user_hdr -
- GENL_HDRLEN -
- NLMSG_HDRLEN);
-}
-
-#ifndef genl_dump_check_consistent
-static inline
-void backport_genl_dump_check_consistent(struct netlink_callback *cb,
- void *user_hdr)
-{
- struct genl_family dummy_family = {
- .hdrsize = 0,
- };
-
- genl_dump_check_consistent(cb, user_hdr, &dummy_family);
-}
-#define genl_dump_check_consistent LINUX_BACKPORT(genl_dump_check_consistent)
-#endif
-#endif /* LINUX_VERSION_IS_LESS(4,15,0) */
-
-#if LINUX_VERSION_IS_LESS(4,20,0)
-static inline int
-__real_backport_genl_register_family(struct genl_family *family)
-{
- return genl_register_family(family);
-}
-static inline int
-__real_backport_genl_unregister_family(struct genl_family *family)
-{
- return genl_unregister_family(family);
-}
-
-struct backport_genl_family {
- struct genl_family family;
- const struct genl_ops * copy_ops;
-
- /* copied */
- int id; /* private */
- unsigned int hdrsize;
- char name[GENL_NAMSIZ];
- unsigned int version;
- unsigned int maxattr;
- bool netnsok;
- bool parallel_ops;
- int (*pre_doit)(__genl_const struct genl_ops *ops,
- struct sk_buff *skb,
- struct genl_info *info);
- void (*post_doit)(__genl_const struct genl_ops *ops,
- struct sk_buff *skb,
- struct genl_info *info);
-/*
- * unsupported!
- int (*mcast_bind)(struct net *net, int group);
- void (*mcast_unbind)(struct net *net, int group);
- */
- struct nlattr ** attrbuf; /* private */
- __genl_const struct genl_ops * ops;
- __genl_const struct genl_multicast_group *mcgrps;
- unsigned int n_ops;
- unsigned int n_mcgrps;
- struct module *module;
-};
-#undef genl_family
-#define genl_family backport_genl_family
-
-#define genl_register_family backport_genl_register_family
-int genl_register_family(struct genl_family *family);
-
-#define genl_unregister_family backport_genl_unregister_family
-int backport_genl_unregister_family(struct genl_family *family);
-
-#define genl_notify LINUX_BACKPORT(genl_notify)
-void genl_notify(const struct genl_family *family, struct sk_buff *skb,
- struct genl_info *info, u32 group, gfp_t flags);
-
-#define genlmsg_put LINUX_BACKPORT(genlmsg_put)
-void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
- const struct genl_family *family, int flags, u8 cmd);
-
-#define genlmsg_put_reply LINUX_BACKPORT(genlmsg_put_reply)
-void *genlmsg_put_reply(struct sk_buff *skb,
- struct genl_info *info,
- const struct genl_family *family,
- int flags, u8 cmd);
-
-#define genlmsg_multicast_netns LINUX_BACKPORT(genlmsg_multicast_netns)
-int genlmsg_multicast_netns(const struct genl_family *family,
- struct net *net, struct sk_buff *skb,
- u32 portid, unsigned int group,
- gfp_t flags);
-
-#define genlmsg_multicast LINUX_BACKPORT(genlmsg_multicast)
-int genlmsg_multicast(const struct genl_family *family,
- struct sk_buff *skb, u32 portid,
- unsigned int group, gfp_t flags);
-
-#define genlmsg_multicast_allns LINUX_BACKPORT(genlmsg_multicast_allns)
-int backport_genlmsg_multicast_allns(const struct genl_family *family,
- struct sk_buff *skb, u32 portid,
- unsigned int group, gfp_t flags);
-
-#define genl_family_attrbuf LINUX_BACKPORT(genl_family_attrbuf)
-static inline struct nlattr **genl_family_attrbuf(struct genl_family *family)
-{
- WARN_ON(family->parallel_ops);
-
- return family->attrbuf;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,20,0) */
-
-#endif /* __BACKPORT_NET_GENETLINK_H */
diff --git a/backport/backport-include/net/inet_frag.h b/backport/backport-include/net/inet_frag.h
deleted file mode 100644
index f37b8a5b..00000000
--- a/backport/backport-include/net/inet_frag.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef __BACKPORT__NET_FRAG_H__
-#define __BACKPORT__NET_FRAG_H__
-#include_next <net/inet_frag.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-/* Memory Tracking Functions. */
-#define frag_mem_limit LINUX_BACKPORT(frag_mem_limit)
-static inline int frag_mem_limit(struct netns_frags *nf)
-{
- return atomic_read(&nf->mem);
-}
-
-#define init_frag_mem_limit LINUX_BACKPORT(init_frag_mem_limit)
-static inline void init_frag_mem_limit(struct netns_frags *nf)
-{
- atomic_set(&nf->mem, 0);
-}
-
-#define sum_frag_mem_limit LINUX_BACKPORT(sum_frag_mem_limit)
-static inline int sum_frag_mem_limit(struct netns_frags *nf)
-{
- return atomic_read(&nf->mem);
-}
-
-#define inet_frag_maybe_warn_overflow LINUX_BACKPORT(inet_frag_maybe_warn_overflow)
-void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
- const char *prefix);
-#endif /* LINUX_VERSION_IS_LESS(3,9,0) */
-
-/* the type of the paramater changed with kernel 4.3 */
-#if LINUX_VERSION_IS_LESS(3,9,0) || LINUX_VERSION_IN_RANGE(3,16,51, 3,17,0)
-#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit)
-static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
-{
- atomic_sub(i, &nf->mem);
-}
-
-#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit)
-static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
-{
- atomic_add(i, &nf->mem);
-}
-#elif LINUX_VERSION_IS_LESS(4,3,0)
-#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit)
-static inline void sub_frag_mem_limit(struct netns_frags *nf, int i)
-{
- __percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
-}
-
-#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit)
-static inline void add_frag_mem_limit(struct netns_frags *nf, int i)
-{
- __percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
-}
-#endif /* LINUX_VERSION_IS_LESS(4,3,0) */
-
-#if LINUX_VERSION_IS_LESS(4,4,0) && \
- LINUX_VERSION_IS_GEQ(3,9,0)
-#define inet_frags_uninit_net LINUX_BACKPORT(inet_frags_uninit_net)
-static inline void inet_frags_uninit_net(struct netns_frags *nf)
-{
- percpu_counter_destroy(&nf->mem);
-}
-#endif /* < 4.4 && >= 3.9 */
-
-#if LINUX_VERSION_IS_LESS(4,4,0)
-static inline int backport_inet_frags_init_net(struct netns_frags *nf)
-{
- inet_frags_init_net(nf);
- return 0;
-}
-#define inet_frags_init_net LINUX_BACKPORT(inet_frags_init_net)
-#endif /* < 4.4 */
-
-#endif /* __BACKPORT__NET_FRAG_H__ */
diff --git a/backport/backport-include/net/ip.h b/backport/backport-include/net/ip.h
deleted file mode 100644
index 6893ba51..00000000
--- a/backport/backport-include/net/ip.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BACKPORT_NET_IP_H
-#define __BACKPORT_NET_IP_H
-#include_next <net/ip.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,1,0)
-/* Backports 56f8a75c */
-static inline bool ip_is_fragment(const struct iphdr *iph)
-{
- return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0;
-}
-#endif
-
-#endif /* __BACKPORT_NET_IP_H */
diff --git a/backport/backport-include/net/ip6_fib.h b/backport/backport-include/net/ip6_fib.h
deleted file mode 100644
index 2f21163d..00000000
--- a/backport/backport-include/net/ip6_fib.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __BACKPORT_NET_IP6_ROUTE_H
-#define __BACKPORT_NET_IP6_ROUTE_H
-#include_next <net/ip6_fib.h>
-#include <net/ip6_route.h>
-#include <linux/route.h>
-#include <linux/version.h>
-
-/*
- * This function is avaliable with one argument since kernel 3.10, but the
- * secound one was added in 4.2.
- */
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define rt6_nexthop LINUX_BACKPORT(rt6_nexthop)
-static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt,
- struct in6_addr *daddr)
-{
- if (rt->rt6i_flags & RTF_GATEWAY)
- return &rt->rt6i_gateway;
- else if (rt->rt6i_flags & RTF_CACHE)
- return &rt->rt6i_dst.addr;
- else
- return daddr;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,2,0) */
-
-#endif /* __BACKPORT_NET_IP6_ROUTE_H */
diff --git a/backport/backport-include/net/ipv6.h b/backport/backport-include/net/ipv6.h
deleted file mode 100644
index 7416d6b0..00000000
--- a/backport/backport-include/net/ipv6.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef __BACKPORT_NET_IPV6_H
-#define __BACKPORT_NET_IPV6_H
-#include_next <net/ipv6.h>
-#include <linux/version.h>
-#include <net/addrconf.h>
-#include <net/inet_frag.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-/*
- * Equivalent of ipv4 struct ip
- */
-struct frag_queue {
- struct inet_frag_queue q;
-
- __be32 id; /* fragment id */
- u32 user;
- struct in6_addr saddr;
- struct in6_addr daddr;
-
- int iif;
- unsigned int csum;
- __u16 nhoffset;
-};
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-
-#if LINUX_VERSION_IS_LESS(3,6,0)
-#define ipv6_addr_hash LINUX_BACKPORT(ipv6_addr_hash)
-static inline u32 ipv6_addr_hash(const struct in6_addr *a)
-{
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
- const unsigned long *ul = (const unsigned long *)a;
- unsigned long x = ul[0] ^ ul[1];
-
- return (u32)(x ^ (x >> 32));
-#else
- return (__force u32)(a->s6_addr32[0] ^ a->s6_addr32[1] ^
- a->s6_addr32[2] ^ a->s6_addr32[3]);
-#endif
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define ipv6_addr_prefix_copy LINUX_BACKPORT(ipv6_addr_prefix_copy)
-static inline void ipv6_addr_prefix_copy(struct in6_addr *addr,
- const struct in6_addr *pfx,
- int plen)
-{
- /* caller must guarantee 0 <= plen <= 128 */
- int o = plen >> 3,
- b = plen & 0x7;
-
- memcpy(addr->s6_addr, pfx, o);
- if (b != 0) {
- addr->s6_addr[o] &= ~(0xff00 >> b);
- addr->s6_addr[o] |= (pfx->s6_addr[o] & (0xff00 >> b));
- }
-}
-#endif
-
-#endif /* __BACKPORT_NET_IPV6_H */
diff --git a/backport/backport-include/net/iw_handler.h b/backport/backport-include/net/iw_handler.h
deleted file mode 100644
index 84d63b30..00000000
--- a/backport/backport-include/net/iw_handler.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __BACKPORT_IW_HANDLER_H
-#define __BACKPORT_IW_HANDLER_H
-#include_next <net/iw_handler.h>
-
-#if LINUX_VERSION_IS_LESS(4,1,0)
-static inline char *
-iwe_stream_add_event_check(struct iw_request_info *info, char *stream,
- char *ends, struct iw_event *iwe, int event_len)
-{
- char *res = iwe_stream_add_event(info, stream, ends, iwe, event_len);
-
- if (res == stream)
- return ERR_PTR(-E2BIG);
- return res;
-}
-
-static inline char *
-iwe_stream_add_point_check(struct iw_request_info *info, char *stream,
- char *ends, struct iw_event *iwe, char *extra)
-{
- char *res = iwe_stream_add_point(info, stream, ends, iwe, extra);
-
- if (res == stream)
- return ERR_PTR(-E2BIG);
- return res;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,1,0) */
-
-/* this was added in v3.2.79, v3.18.30, v4.1.21, v4.4.6 and 4.5 */
-#if !(LINUX_VERSION_IS_GEQ(4,4,6) || \
- (LINUX_VERSION_IS_GEQ(4,1,21) && \
- LINUX_VERSION_IS_LESS(4,2,0)) || \
- (LINUX_VERSION_IS_GEQ(3,18,30) && \
- LINUX_VERSION_IS_LESS(3,19,0)) || \
- (LINUX_VERSION_IS_GEQ(3,2,79) && \
- LINUX_VERSION_IS_LESS(3,3,0)))
-#define wireless_nlevent_flush LINUX_BACKPORT(wireless_nlevent_flush)
-static inline void wireless_nlevent_flush(void) {}
-#endif
-#endif /* __BACKPORT_IW_HANDLER_H */
diff --git a/backport/backport-include/net/net_namespace.h b/backport/backport-include/net/net_namespace.h
deleted file mode 100644
index 1e84297c..00000000
--- a/backport/backport-include/net/net_namespace.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _COMPAT_NET_NET_NAMESPACE_H
-#define _COMPAT_NET_NET_NAMESPACE_H 1
-
-#include_next <net/net_namespace.h>
-
-#if LINUX_VERSION_IS_LESS(3,20,0)
-/*
- * In older kernels we simply fail this function.
- */
-#define get_net_ns_by_fd LINUX_BACKPORT(get_net_ns_by_fd)
-static inline struct net *get_net_ns_by_fd(int fd)
-{
- return ERR_PTR(-EINVAL);
-}
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,1,0)
-typedef struct {
-#ifdef CONFIG_NET_NS
- struct net *net;
-#endif
-} possible_net_t;
-
-static inline void possible_write_pnet(possible_net_t *pnet, struct net *net)
-{
-#ifdef CONFIG_NET_NS
- pnet->net = net;
-#endif
-}
-
-static inline struct net *possible_read_pnet(const possible_net_t *pnet)
-{
-#ifdef CONFIG_NET_NS
- return pnet->net;
-#else
- return &init_net;
-#endif
-}
-#else
-#define possible_write_pnet(pnet, net) write_pnet(pnet, net)
-#define possible_read_pnet(pnet) read_pnet(pnet)
-#endif /* LINUX_VERSION_IS_LESS(4,1,0) */
-
-#endif /* _COMPAT_NET_NET_NAMESPACE_H */
diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
deleted file mode 100644
index 4af73631..00000000
--- a/backport/backport-include/net/netlink.h
+++ /dev/null
@@ -1,551 +0,0 @@
-#ifndef __BACKPORT_NET_NETLINK_H
-#define __BACKPORT_NET_NETLINK_H
-#include_next <net/netlink.h>
-#include <linux/version.h>
-#include <linux/in6.h>
-
-#if LINUX_VERSION_IS_LESS(4,20,0)
-/* can't backport using the enum - need to override */
-#define NLA_UNSPEC 0
-#define NLA_U8 1
-#define NLA_U16 2
-#define NLA_U32 3
-#define NLA_U64 4
-#define NLA_STRING 5
-#define NLA_FLAG 6
-#define NLA_MSECS 7
-#define NLA_NESTED 8
-#define NLA_NESTED_ARRAY 9
-#define NLA_NUL_STRING 10
-#define NLA_BINARY 11
-#define NLA_S8 12
-#define NLA_S16 13
-#define NLA_S32 14
-#define NLA_S64 15
-#define NLA_BITFIELD32 16
-#define NLA_REJECT 17
-#define NLA_EXACT_LEN 18
-#define NLA_EXACT_LEN_WARN 19
-#define __NLA_TYPE_MAX 20
-#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
-
-enum nla_policy_validation {
- NLA_VALIDATE_NONE,
- NLA_VALIDATE_RANGE,
- NLA_VALIDATE_MIN,
- NLA_VALIDATE_MAX,
- NLA_VALIDATE_FUNCTION,
-};
-
-struct backport_nla_policy {
- u8 type;
- u8 validation_type;
- u16 len;
- union {
- const void *validation_data;
- struct {
- s16 min, max;
- };
- int (*validate)(const struct nlattr *attr,
- struct netlink_ext_ack *extack);
- };
-};
-#define nla_policy backport_nla_policy
-
-#define NLA_POLICY_EXACT_LEN(_len) { .type = NLA_EXACT_LEN, .len = _len }
-#define NLA_POLICY_EXACT_LEN_WARN(_len) { .type = NLA_EXACT_LEN_WARN, \
- .len = _len }
-
-#define NLA_POLICY_ETH_ADDR NLA_POLICY_EXACT_LEN(ETH_ALEN)
-#define NLA_POLICY_ETH_ADDR_COMPAT NLA_POLICY_EXACT_LEN_WARN(ETH_ALEN)
-
-#define NLA_POLICY_NESTED(maxattr, policy) \
- { .type = NLA_NESTED, .validation_data = policy, .len = maxattr }
-#define NLA_POLICY_NESTED_ARRAY(maxattr, policy) \
- { .type = NLA_NESTED_ARRAY, .validation_data = policy, .len = maxattr }
-
-#define __NLA_ENSURE(condition) (sizeof(char[1 - 2*!(condition)]) - 1)
-#define NLA_ENSURE_INT_TYPE(tp) \
- (__NLA_ENSURE(tp == NLA_S8 || tp == NLA_U8 || \
- tp == NLA_S16 || tp == NLA_U16 || \
- tp == NLA_S32 || tp == NLA_U32 || \
- tp == NLA_S64 || tp == NLA_U64) + tp)
-#define NLA_ENSURE_NO_VALIDATION_PTR(tp) \
- (__NLA_ENSURE(tp != NLA_BITFIELD32 && \
- tp != NLA_REJECT && \
- tp != NLA_NESTED && \
- tp != NLA_NESTED_ARRAY) + tp)
-
-#define NLA_POLICY_RANGE(tp, _min, _max) { \
- .type = NLA_ENSURE_INT_TYPE(tp), \
- .validation_type = NLA_VALIDATE_RANGE, \
- .min = _min, \
- .max = _max \
-}
-
-#define NLA_POLICY_MIN(tp, _min) { \
- .type = NLA_ENSURE_INT_TYPE(tp), \
- .validation_type = NLA_VALIDATE_MIN, \
- .min = _min, \
-}
-
-#define NLA_POLICY_MAX(tp, _max) { \
- .type = NLA_ENSURE_INT_TYPE(tp), \
- .validation_type = NLA_VALIDATE_MAX, \
- .max = _max, \
-}
-
-#define NLA_POLICY_VALIDATE_FN(tp, fn, ...) { \
- .type = NLA_ENSURE_NO_VALIDATION_PTR(tp), \
- .validation_type = NLA_VALIDATE_FUNCTION, \
- .validate = fn, \
- .len = __VA_ARGS__ + 0, \
-}
-
-#define nla_validate LINUX_BACKPORT(nla_validate)
-int nla_validate(const struct nlattr *head, int len, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack);
-#define nla_parse LINUX_BACKPORT(nla_parse)
-int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
- int len, const struct nla_policy *policy,
- struct netlink_ext_ack *extack);
-#define nla_policy_len LINUX_BACKPORT(nla_policy_len)
-int nla_policy_len(const struct nla_policy *, int);
-
-#define nlmsg_parse LINUX_BACKPORT(nlmsg_parse)
-static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
- struct nlattr *tb[], int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
- return -EINVAL;
-
- return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
- nlmsg_attrlen(nlh, hdrlen), policy, extack);
-}
-
-#define nlmsg_validate LINUX_BACKPORT(nlmsg_validate)
-static inline int nlmsg_validate(const struct nlmsghdr *nlh,
- int hdrlen, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
- return -EINVAL;
-
- return nla_validate(nlmsg_attrdata(nlh, hdrlen),
- nlmsg_attrlen(nlh, hdrlen), maxtype, policy,
- extack);
-}
-
-#define nla_parse_nested LINUX_BACKPORT(nla_parse_nested)
-static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
- const struct nlattr *nla,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy,
- extack);
-}
-
-#define nla_validate_nested LINUX_BACKPORT(nla_validate_nested)
-static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_validate(nla_data(start), nla_len(start), maxtype, policy,
- extack);
-}
-#endif /* < 4.20 */
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-#include <backport/magic.h>
-
-static inline int _nla_validate5(const struct nlattr *head,
- int len, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_validate(head, len, maxtype, policy, extack);
-}
-static inline int _nla_validate4(const struct nlattr *head,
- int len, int maxtype,
- const struct nla_policy *policy)
-{
- return nla_validate(head, len, maxtype, policy, NULL);
-}
-#undef nla_validate
-#define nla_validate(...) \
- macro_dispatcher(_nla_validate, __VA_ARGS__)(__VA_ARGS__)
-
-static inline int _nla_parse6(struct nlattr **tb, int maxtype,
- const struct nlattr *head,
- int len, const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_parse(tb, maxtype, head, len, policy, extack);
-}
-static inline int _nla_parse5(struct nlattr **tb, int maxtype,
- const struct nlattr *head,
- int len, const struct nla_policy *policy)
-{
- return nla_parse(tb, maxtype, head, len, policy, NULL);
-}
-#undef nla_parse
-#define nla_parse(...) \
- macro_dispatcher(_nla_parse, __VA_ARGS__)(__VA_ARGS__)
-
-static inline int _nlmsg_parse6(const struct nlmsghdr *nlh, int hdrlen,
- struct nlattr *tb[], int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nlmsg_parse(nlh, hdrlen, tb, maxtype, policy, extack);
-}
-static inline int _nlmsg_parse5(const struct nlmsghdr *nlh, int hdrlen,
- struct nlattr *tb[], int maxtype,
- const struct nla_policy *policy)
-{
- return nlmsg_parse(nlh, hdrlen, tb, maxtype, policy, NULL);
-}
-#undef nlmsg_parse
-#define nlmsg_parse(...) \
- macro_dispatcher(_nlmsg_parse, __VA_ARGS__)(__VA_ARGS__)
-
-static inline int _nlmsg_validate5(const struct nlmsghdr *nlh,
- int hdrlen, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nlmsg_validate(nlh, hdrlen, maxtype, policy, extack);
-}
-static inline int _nlmsg_validate4(const struct nlmsghdr *nlh,
- int hdrlen, int maxtype,
- const struct nla_policy *policy)
-{
- return nlmsg_validate(nlh, hdrlen, maxtype, policy, NULL);
-}
-#undef nlmsg_validate
-#define nlmsg_validate(...) \
- macro_dispatcher(_nlmsg_validate, __VA_ARGS__)(__VA_ARGS__)
-
-static inline int _nla_parse_nested5(struct nlattr *tb[], int maxtype,
- const struct nlattr *nla,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_parse_nested(tb, maxtype, nla, policy, extack);
-}
-static inline int _nla_parse_nested4(struct nlattr *tb[], int maxtype,
- const struct nlattr *nla,
- const struct nla_policy *policy)
-{
- return nla_parse_nested(tb, maxtype, nla, policy, NULL);
-}
-#undef nla_parse_nested
-#define nla_parse_nested(...) \
- macro_dispatcher(_nla_parse_nested, __VA_ARGS__)(__VA_ARGS__)
-
-static inline int _nla_validate_nested4(const struct nlattr *start, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- return nla_validate_nested(start, maxtype, policy, extack);
-}
-static inline int _nla_validate_nested3(const struct nlattr *start, int maxtype,
- const struct nla_policy *policy)
-{
- return nla_validate_nested(start, maxtype, policy, NULL);
-}
-#undef nla_validate_nested
-#define nla_validate_nested(...) \
- macro_dispatcher(_nla_validate_nested, __VA_ARGS__)(__VA_ARGS__)
-#endif /* LINUX_VERSION_IS_LESS(4,12,0) */
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-/**
- * nla_put_s8 - Add a s8 netlink attribute to a socket buffer
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @value: numeric value
- */
-#define nla_put_s8 LINUX_BACKPORT(nla_put_s8)
-static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value)
-{
- return nla_put(skb, attrtype, sizeof(s8), &value);
-}
-
-/**
- * nla_put_s16 - Add a s16 netlink attribute to a socket buffer
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @value: numeric value
- */
-#define nla_put_s16 LINUX_BACKPORT(nla_put_s16)
-static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value)
-{
- return nla_put(skb, attrtype, sizeof(s16), &value);
-}
-
-/**
- * nla_put_s32 - Add a s32 netlink attribute to a socket buffer
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @value: numeric value
- */
-#define nla_put_s32 LINUX_BACKPORT(nla_put_s32)
-static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value)
-{
- return nla_put(skb, attrtype, sizeof(s32), &value);
-}
-
-/**
- * nla_get_s32 - return payload of s32 attribute
- * @nla: s32 netlink attribute
- */
-#define nla_get_s32 LINUX_BACKPORT(nla_get_s32)
-static inline s32 nla_get_s32(const struct nlattr *nla)
-{
- return *(s32 *) nla_data(nla);
-}
-
-/**
- * nla_get_s16 - return payload of s16 attribute
- * @nla: s16 netlink attribute
- */
-#define nla_get_s16 LINUX_BACKPORT(nla_get_s16)
-static inline s16 nla_get_s16(const struct nlattr *nla)
-{
- return *(s16 *) nla_data(nla);
-}
-
-/**
- * nla_get_s8 - return payload of s8 attribute
- * @nla: s8 netlink attribute
- */
-#define nla_get_s8 LINUX_BACKPORT(nla_get_s8)
-static inline s8 nla_get_s8(const struct nlattr *nla)
-{
- return *(s8 *) nla_data(nla);
-}
-
-/**
- * nla_get_s64 - return payload of s64 attribute
- * @nla: s64 netlink attribute
- */
-#define nla_get_s64 LINUX_BACKPORT(nla_get_s64)
-static inline s64 nla_get_s64(const struct nlattr *nla)
-{
- s64 tmp;
-
- nla_memcpy(&tmp, nla, sizeof(tmp));
-
- return tmp;
-}
-#endif /* < 3.7.0 */
-
-#if LINUX_VERSION_IS_LESS(3,5,0)
-/*
- * This backports:
- * commit 569a8fc38367dfafd87454f27ac646c8e6b54bca
- * Author: David S. Miller <davem@davemloft.net>
- * Date: Thu Mar 29 23:18:53 2012 -0400
- *
- * netlink: Add nla_put_be{16,32,64}() helpers.
- */
-
-#define nla_put_be16 LINUX_BACKPORT(nla_put_be16)
-static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
-{
- return nla_put(skb, attrtype, sizeof(__be16), &value);
-}
-
-#define nla_put_be32 LINUX_BACKPORT(nla_put_be32)
-static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
-{
- return nla_put(skb, attrtype, sizeof(__be32), &value);
-}
-
-#define nla_put_be64 LINUX_BACKPORT(nla_put_be64)
-static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
-{
- return nla_put(skb, attrtype, sizeof(__be64), &value);
-}
-#endif /* < 3.5 */
-
-#if LINUX_VERSION_IS_LESS(3,7,0)
-#define NLA_S8 (NLA_BINARY + 1)
-#define NLA_S16 (NLA_BINARY + 2)
-#define NLA_S32 (NLA_BINARY + 3)
-#define NLA_S64 (NLA_BINARY + 4)
-#define __NLA_TYPE_MAX (NLA_BINARY + 5)
-
-#undef NLA_TYPE_MAX
-#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,1,0)
-#define nla_put_in_addr LINUX_BACKPORT(nla_put_in_addr)
-static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype,
- __be32 addr)
-{
- return nla_put_be32(skb, attrtype, addr);
-}
-
-#define nla_put_in6_addr LINUX_BACKPORT(nla_put_in6_addr)
-static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype,
- const struct in6_addr *addr)
-{
- return nla_put(skb, attrtype, sizeof(*addr), addr);
-}
-
-static inline __be32 nla_get_in_addr(const struct nlattr *nla)
-{
- return *(__be32 *) nla_data(nla);
-}
-
-static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla)
-{
- struct in6_addr tmp;
-
- nla_memcpy(&tmp, nla, sizeof(tmp));
- return tmp;
-}
-#endif /* < 4.1 */
-
-#if LINUX_VERSION_IS_LESS(4,4,0)
-/**
- * nla_get_le32 - return payload of __le32 attribute
- * @nla: __le32 netlink attribute
- */
-#define nla_get_le32 LINUX_BACKPORT(nla_get_le32)
-static inline __le32 nla_get_le32(const struct nlattr *nla)
-{
- return *(__le32 *) nla_data(nla);
-}
-
-/**
- * nla_get_le64 - return payload of __le64 attribute
- * @nla: __le64 netlink attribute
- */
-#define nla_get_le64 LINUX_BACKPORT(nla_get_le64)
-static inline __le64 nla_get_le64(const struct nlattr *nla)
-{
- return *(__le64 *) nla_data(nla);
-}
-#endif /* < 4.4 */
-
-#if LINUX_VERSION_IS_LESS(4,7,0)
-/**
- * nla_need_padding_for_64bit - test 64-bit alignment of the next attribute
- * @skb: socket buffer the message is stored in
- *
- * Return true if padding is needed to align the next attribute (nla_data()) to
- * a 64-bit aligned area.
- */
-#define nla_need_padding_for_64bit LINUX_BACKPORT(nla_need_padding_for_64bit)
-static inline bool nla_need_padding_for_64bit(struct sk_buff *skb)
-{
-#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
- /* The nlattr header is 4 bytes in size, that's why we test
- * if the skb->data _is_ aligned. A NOP attribute, plus
- * nlattr header for next attribute, will make nla_data()
- * 8-byte aligned.
- */
- if (IS_ALIGNED((unsigned long)skb_tail_pointer(skb), 8))
- return true;
-#endif
- return false;
-}
-/**
- * nla_align_64bit - 64-bit align the nla_data() of next attribute
- * @skb: socket buffer the message is stored in
- * @padattr: attribute type for the padding
- *
- * Conditionally emit a padding netlink attribute in order to make
- * the next attribute we emit have a 64-bit aligned nla_data() area.
- * This will only be done in architectures which do not have
- * HAVE_EFFICIENT_UNALIGNED_ACCESS defined.
- *
- * Returns zero on success or a negative error code.
- */
-#define nla_align_64bit LINUX_BACKPORT(nla_align_64bit)
-static inline int nla_align_64bit(struct sk_buff *skb, int padattr)
-{
- if (nla_need_padding_for_64bit(skb) &&
- !nla_reserve(skb, padattr, 0))
- return -EMSGSIZE;
- return 0;
-}
-
-/**
- * nla_total_size_64bit - total length of attribute including padding
- * @payload: length of payload
- */
-#define nla_total_size_64bit LINUX_BACKPORT(nla_total_size_64bit)
-static inline int nla_total_size_64bit(int payload)
-{
- return NLA_ALIGN(nla_attr_size(payload))
-#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
- + NLA_ALIGN(nla_attr_size(0))
-#endif
- ;
-}
-#define __nla_reserve_64bit LINUX_BACKPORT(__nla_reserve_64bit)
-struct nlattr *__nla_reserve_64bit(struct sk_buff *skb, int attrtype,
- int attrlen, int padattr);
-#define nla_reserve_64bit LINUX_BACKPORT(nla_reserve_64bit)
-struct nlattr *nla_reserve_64bit(struct sk_buff *skb, int attrtype,
- int attrlen, int padattr);
-#define __nla_put_64bit LINUX_BACKPORT(__nla_put_64bit)
-void __nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
- const void *data, int padattr);
-#define nla_put_64bit LINUX_BACKPORT(nla_put_64bit)
-int nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
- const void *data, int padattr);
-/**
- * nla_put_u64_64bit - Add a u64 netlink attribute to a skb and align it
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @value: numeric value
- * @padattr: attribute type for the padding
- */
-#define nla_put_u64_64bit LINUX_BACKPORT(nla_put_u64_64bit)
-static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
- u64 value, int padattr)
-{
- return nla_put_64bit(skb, attrtype, sizeof(u64), &value, padattr);
-}
-
-
-/**
- * nla_put_s64 - Add a s64 netlink attribute to a socket buffer and align it
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @value: numeric value
- * @padattr: attribute type for the padding
- */
-#define nla_put_s64 LINUX_BACKPORT(nla_put_s64)
-static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value,
- int padattr)
-{
- return nla_put_64bit(skb, attrtype, sizeof(s64), &value, padattr);
-}
-#endif /* < 4.7 */
-
-#if LINUX_VERSION_IS_LESS(4,10,0)
-/**
- * nla_memdup - duplicate attribute memory (kmemdup)
- * @src: netlink attribute to duplicate from
- * @gfp: GFP mask
- */
-#define nla_memdump LINUX_BACKPORT(nla_memdup)
-static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp)
-{
- return kmemdup(nla_data(src), nla_len(src), gfp);
-}
-#endif /* < 4.9 */
-
-#endif /* __BACKPORT_NET_NETLINK_H */
diff --git a/backport/backport-include/net/sch_generic.h b/backport/backport-include/net/sch_generic.h
deleted file mode 100644
index cabc6012..00000000
--- a/backport/backport-include/net/sch_generic.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __BACKPORT_NET_SCH_GENERIC_H
-#define __BACKPORT_NET_SCH_GENERIC_H
-#include_next <net/sch_generic.h>
-
-#if LINUX_VERSION_IS_LESS(3,3,0)
-#if !((LINUX_VERSION_IS_GEQ(3,2,9) && LINUX_VERSION_IS_LESS(3,3,0)) || (LINUX_VERSION_IS_GEQ(3,0,23) && LINUX_VERSION_IS_LESS(3,1,0)))
-/* mask qdisc_cb_private_validate as RHEL6 backports this */
-#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b)
-static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
-{
- BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct qdisc_skb_cb) + sz);
-}
-#endif
-#endif /* LINUX_VERSION_IS_LESS(3,3,0) */
-
-#ifndef TCQ_F_CAN_BYPASS
-#define TCQ_F_CAN_BYPASS 4
-#endif
-
-#endif /* __BACKPORT_NET_SCH_GENERIC_H */
diff --git a/backport/backport-include/net/sock.h b/backport/backport-include/net/sock.h
deleted file mode 100644
index 39bf0087..00000000
--- a/backport/backport-include/net/sock.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef __BACKPORT_NET_SOCK_H
-#define __BACKPORT_NET_SOCK_H
-#include_next <net/sock.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,9,0)
-#include <backport/magic.h>
-
-#define sk_for_each3(__sk, node, list) \
- hlist_for_each_entry(__sk, node, list, sk_node)
-
-#define sk_for_each_safe4(__sk, node, tmp, list) \
- hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node)
-
-#define sk_for_each2(__sk, list) \
- hlist_for_each_entry(__sk, list, sk_node)
-
-#define sk_for_each_safe3(__sk, tmp, list) \
- hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
-
-#undef sk_for_each
-#define sk_for_each(...) \
- macro_dispatcher(sk_for_each, __VA_ARGS__)(__VA_ARGS__)
-#undef sk_for_each_safe
-#define sk_for_each_safe(...) \
- macro_dispatcher(sk_for_each_safe, __VA_ARGS__)(__VA_ARGS__)
-
-#endif
-
-#if LINUX_VERSION_IS_LESS(3,10,0)
-/*
- * backport SOCK_SELECT_ERR_QUEUE -- see commit
- * "net: add option to enable error queue packets waking select"
- *
- * Adding 14 to SOCK_QUEUE_SHRUNK will reach a bet that can't be
- * set on older kernels, so sock_flag() will always return false.
- */
-#define SOCK_SELECT_ERR_QUEUE (SOCK_QUEUE_SHRUNK + 14)
-#endif
-
-#ifndef sock_skb_cb_check_size
-#define sock_skb_cb_check_size(size) \
- BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb))
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,2,0)
-#define sk_alloc(net, family, priority, prot, kern) sk_alloc(net, family, priority, prot)
-#endif
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define sk_set_bit LINUX_BACKPORT(sk_set_bit)
-static inline void sk_set_bit(int nr, struct sock *sk)
-{
- set_bit(nr, &sk->sk_socket->flags);
-}
-#endif /* < 4.5 */
-
-#if LINUX_VERSION_IS_LESS(4,5,0)
-#define sk_clear_bit LINUX_BACKPORT(sk_clear_bit)
-static inline void sk_clear_bit(int nr, struct sock *sk)
-{
- clear_bit(nr, &sk->sk_socket->flags);
-}
-#endif /* < 4.5 */
-
-#if LINUX_VERSION_IS_LESS(4,16,0)
-#define sk_pacing_shift_update LINUX_BACKPORT(sk_pacing_shift_update)
-static inline void sk_pacing_shift_update(struct sock *sk, int val)
-{
-#if LINUX_VERSION_IS_GEQ(4,15,0)
- if (!sk || !sk_fullsock(sk) || sk->sk_pacing_shift == val)
- return;
- sk->sk_pacing_shift = val;
-#endif /* >= 4.15 */
-}
-#endif /* < 4.16 */
-
-#endif /* __BACKPORT_NET_SOCK_H */
diff --git a/backport/backport-include/net/tso.h b/backport/backport-include/net/tso.h
deleted file mode 100644
index 3a3f50b3..00000000
--- a/backport/backport-include/net/tso.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BACKPORT_TSO_H
-#define BACKPORT_TSO_H
-
-#include <net/ip.h>
-
-#if LINUX_VERSION_IS_LESS(4,4,0)
-
-#define tso_t LINUX_BACKPORT(tso_t)
-struct tso_t {
- int next_frag_idx;
- void *data;
- size_t size;
- u16 ip_id;
- bool ipv6;
- u32 tcp_seq;
-};
-
-#define tso_count_descs LINUX_BACKPORT(tso_count_descs)
-int tso_count_descs(struct sk_buff *skb);
-
-#define tso_build_hdr LINUX_BACKPORT(tso_build_hdr)
-void tso_build_hdr(struct sk_buff *skb, char *hdr, struct tso_t *tso,
- int size, bool is_last);
-#define tso_build_data LINUX_BACKPORT(tso_build_data)
-void tso_build_data(struct sk_buff *skb, struct tso_t *tso, int size);
-#define tso_start LINUX_BACKPORT(tso_start)
-void tso_start(struct sk_buff *skb, struct tso_t *tso);
-
-#else
-#include_next <net/tso.h>
-#endif
-
-#endif /* BACKPORT_TSO_H */
diff --git a/backport/backport-include/pcmcia/device_id.h b/backport/backport-include/pcmcia/device_id.h
deleted file mode 100644
index 908af500..00000000
--- a/backport/backport-include/pcmcia/device_id.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __BACKPORT_PCMCIA_DEVICE_ID_H
-#define __BACKPORT_PCMCIA_DEVICE_ID_H
-#include_next <pcmcia/device_id.h>
-
-#ifndef PCMCIA_DEVICE_MANF_CARD_PROD_ID3
-#define PCMCIA_DEVICE_MANF_CARD_PROD_ID3(manf, card, v3, vh3) { \
- .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \
- PCMCIA_DEV_ID_MATCH_CARD_ID| \
- PCMCIA_DEV_ID_MATCH_PROD_ID3, \
- .manf_id = (manf), \
- .card_id = (card), \
- .prod_id = { NULL, NULL, (v3), NULL }, \
- .prod_id_hash = { 0, 0, (vh3), 0 }, }
-#endif
-
-#ifndef PCMCIA_DEVICE_PROD_ID3
-#define PCMCIA_DEVICE_PROD_ID3(v3, vh3) { \
- .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID3, \
- .prod_id = { NULL, NULL, (v3), NULL }, \
- .prod_id_hash = { 0, 0, (vh3), 0 }, }
-#endif
-
-#endif /* __BACKPORT_PCMCIA_DEVICE_ID_H */
diff --git a/backport/backport-include/pcmcia/ds.h b/backport/backport-include/pcmcia/ds.h
deleted file mode 100644
index 45ab33a6..00000000
--- a/backport/backport-include/pcmcia/ds.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __BACKPORT_PCMCIA_DS_H
-#define __BACKPORT_PCMCIA_DS_H
-#include_next <pcmcia/ds.h>
-
-#ifndef module_pcmcia_driver
-/**
- * backport of:
- *
- * commit 6ed7ffddcf61f668114edb676417e5fb33773b59
- * Author: H Hartley Sweeten <hsweeten@visionengravers.com>
- * Date: Wed Mar 6 11:24:44 2013 -0700
- *
- * pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate
- */
-
-/**
- * module_pcmcia_driver() - Helper macro for registering a pcmcia driver
- * @__pcmcia_driver: pcmcia_driver struct
- *
- * Helper macro for pcmcia drivers which do not do anything special in module
- * init/exit. This eliminates a lot of boilerplate. Each module may only use
- * this macro once, and calling it replaces module_init() and module_exit().
- */
-#define module_pcmcia_driver(__pcmcia_driver) \
- module_driver(__pcmcia_driver, pcmcia_register_driver, \
- pcmcia_unregister_driver)
-#endif
-
-#endif /* __BACKPORT_PCMCIA_DS_H */
diff --git a/backport/backport-include/sound/core.h b/backport/backport-include/sound/core.h
deleted file mode 100644
index 79f8b319..00000000
--- a/backport/backport-include/sound/core.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _BACKPORT_SOUND_CORE_H
-#define _BACKPORT_SOUND_CORE_H
-#include_next <sound/core.h>
-
-#if LINUX_VERSION_IS_LESS(3,15,0)
-#define snd_card_new LINUX_BACKPORT(snd_card_new)
-static inline
-int snd_card_new(struct device *parent, int idx, const char *xid,
- struct module *module, int extra_size,
- struct snd_card **card_ret)
-{
- int ret;
-
- ret = snd_card_create(idx, xid, module, extra_size, card_ret);
- snd_card_set_dev(*card_ret, parent);
- return ret;
-}
-#endif
-
-#endif /* _BACKPORT_SOUND_CORE_H */
diff --git a/backport/backport-include/sound/pcm.h b/backport/backport-include/sound/pcm.h
deleted file mode 100644
index d5794ef9..00000000
--- a/backport/backport-include/sound/pcm.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __BACKPORT_SOUND_PCM_H
-#define __BACKPORT_SOUND_PCM_H
-#include_next <sound/pcm.h>
-#include <linux/version.h>
-
-#if LINUX_VERSION_IS_LESS(3,19,0)
-/**
- * snd_pcm_stop_xrun - stop the running streams as XRUN
- * @substream: the PCM substream instance
- *
- * This stops the given running substream (and all linked substreams) as XRUN.
- * Unlike snd_pcm_stop(), this function takes the substream lock by itself.
- *
- * Return: Zero if successful, or a negative error code.
- */
-static inline int snd_pcm_stop_xrun(struct snd_pcm_substream *substream)
-{
- unsigned long flags;
- int ret = 0;
-
- snd_pcm_stream_lock_irqsave(substream, flags);
- if (snd_pcm_running(substream))
- ret = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
- snd_pcm_stream_unlock_irqrestore(substream, flags);
- return ret;
-}
-#endif /* LINUX_VERSION_IS_LESS(3,19,0) */
-
-#endif /* __BACKPORT_SOUND_PCM_H */
diff --git a/backport/backport-include/trace/ftrace.h b/backport/backport-include/trace/ftrace.h
deleted file mode 100644
index 756ded36..00000000
--- a/backport/backport-include/trace/ftrace.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#undef __print_array
-#define __print_array(array, count, el_size) \
- ({ \
- BUILD_BUG_ON(el_size != 1 && el_size != 2 && \
- el_size != 4 && el_size != 8); \
- ftrace_print_array_seq(p, array, count, el_size); \
- })
-
-#undef __get_dynamic_array_len
-#define __get_dynamic_array_len(field) \
- ((__entry->__data_loc_##field >> 16) & 0xffff)
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-#include_next <trace/ftrace.h>
-#endif
diff --git a/backport/backport-include/uapi/linux/genetlink.h b/backport/backport-include/uapi/linux/genetlink.h
deleted file mode 100644
index 620626ae..00000000
--- a/backport/backport-include/uapi/linux/genetlink.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __BACKPORT_UAPI_LINUX_GENETLINK_H
-#define __BACKPORT_UAPI_LINUX_GENETLINK_H
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(3,7,0)
-#include_next <uapi/linux/genetlink.h>
-#else
-#include_next <linux/genetlink.h>
-#endif
-
-#ifndef GENL_UNS_ADMIN_PERM
-#define GENL_UNS_ADMIN_PERM GENL_ADMIN_PERM
-#endif
-
-#endif /* __BACKPORT_UAPI_LINUX_GENETLINK_H */
diff --git a/backport/backport-include/uapi/linux/sockios.h b/backport/backport-include/uapi/linux/sockios.h
deleted file mode 100644
index 12a7dd6c..00000000
--- a/backport/backport-include/uapi/linux/sockios.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __BACKPORT_LINUX_SOCKIOS_H
-#define __BACKPORT_LINUX_SOCKIOS_H
-#include_next <linux/sockios.h>
-#include <linux/version.h>
-
-/*
- * Kernel backports UAPI note:
- *
- * We carry UAPI headers for backports to enable compilation
- * of kernel / driver code to compile without any changes. If
- * it so happens that a feature is backported it can be added
- * here but notice that if full subsystems are backported you
- * should just include the respective full header onto the
- * copy-list file so that its copied intact. This strategy
- * is used to either backport a specific feature or to just
- * avoid having to do ifdef changes to compile.
- *
- * Userspace is not expected to copy over backports headers
- * to compile userspace programs, userspace programs can
- * and should consider carrying over a respective copy-list
- * of the latest UAPI kernel headers they need in their
- * upstream sources, the kernel the user uses, whether with
- * backports or not should be able to return -EOPNOTSUPP if
- * the feature is not available and let it through if its
- * supported and meats the expected form.
- */
-
-#if LINUX_VERSION_IS_LESS(3,14,0)
-#define SIOCGHWTSTAMP 0x89b1 /* get config */
-#endif /* LINUX_VERSION_IS_LESS(3,14,0) */
-#endif /* __BACKPORT_LINUX_SOCKIOS_H */
diff --git a/backport/compat/.gitignore b/backport/compat/.gitignore
deleted file mode 100644
index 72ff0e99..00000000
--- a/backport/compat/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-oid_registry_data.c
diff --git a/backport/compat/Kconfig b/backport/compat/Kconfig
deleted file mode 100644
index ee8fc84d..00000000
--- a/backport/compat/Kconfig
+++ /dev/null
@@ -1,190 +0,0 @@
-#
-# backport Kconfig
-#
-# Some options are user-selectable ("BPAUTO_USERSEL_*")
-#
-# Most options, however, follow a few different schemes:
-#
-# A) An option that is selected by drivers ("select FOO") will be
-# changed to "select BPAUTO_FOO" (if the option BPAUTO_FOO
-# exists). The option BPAUTO_FOO then controls setting of the
-# BPAUTO_BUILD_FOO option, which is a module, like this:
-#
-# config BPAUTO_BUILD_FOO
-# tristate
-# # or bool
-#
-# # not possible on kernel < X.Y, build will fail if any
-# # drivers are allowed to build on kernels < X.Y
-# depends on KERNEL_X_Y
-#
-# # don't build the backport code if FOO is in the kernel
-# # already, but only if the kernel version is also >= X.Z;
-# # this is an example of backporting where the version of
-# # the FOO subsystem that we need is only available from
-# # kernel version X.Z
-# depends on !FOO || KERNEL_X_Z
-#
-# # build if driver needs it (it selects BPAUTO_FOO)
-# default m if BPAUTO_FOO
-#
-# # or for build-testing (BPAUTO_USERSEL_BUILD_ALL is enabled)
-# default m if BPAUTO_USERSEL_BUILD_ALL
-#
-# config BPAUTO_FOO
-# bool
-#
-# This only works as-is if the kernel code is usable on any version,
-# otherwise the "&& !FOO" part needs to be different.
-#
-#
-# B) An option for code always present on some kernels (e.g. KFIFO).
-# This simply depends on/sets the default based on the version:
-#
-# config BPAUTO_BUILD_KFIFO
-# def_bool y
-# depends on KERNEL_2_6_36
-#
-#
-# C) similarly, a kconfig symbol for an option, e.g.
-# BPAUTO_OPTION_SOME_FIX (no examples provided) check git log
-#
-#
-# Variations are obviously possible.
-#
-
-config BP_MODULES
- option modules
- bool
- default MODULES
-
- help
- This symbol is necessary for the newer kconf tool, it looks
- for the "option modules" to control the 'm' state.
-
-config BPAUTO_BUILD_CORDIC
- tristate
- depends on !CORDIC
- depends on KERNEL_3_1
- default m if BPAUTO_CORDIC
- default m if BPAUTO_USERSEL_BUILD_ALL
- #module-name cordic
- #c-file lib/cordic.c
-
-config BPAUTO_CORDIC
- bool
-
-config BPAUTO_MII
- bool
-
-config BPAUTO_BUILD_LEDS
- bool
- depends on !NEW_LEDS || LEDS_CLASS=n || !LEDS_TRIGGERS
- default y if BPAUTO_NEW_LEDS
- default y if BPAUTO_LEDS_CLASS
- default y if BPAUTO_LEDS_TRIGGERS
-
-config BPAUTO_NEW_LEDS
- bool
-
-config BPAUTO_LEDS_CLASS
- bool
-
-config BPAUTO_LEDS_TRIGGERS
- bool
-
-config BPAUTO_USERSEL_BUILD_ALL
- bool "Build all compat code"
- help
- This option selects all the compat code options
- that would otherwise only be selected by drivers.
-
- It's only really useful for compat testing, so
- you probably shouldn't enable it.
-
-config BPAUTO_WANT_DEV_COREDUMP
- bool
-
-config BPAUTO_BUILD_WANT_DEV_COREDUMP
- bool
- default n if DEV_COREDUMP
- default n if DISABLE_DEV_COREDUMP
- default y if BPAUTO_WANT_DEV_COREDUMP
- #h-file linux/devcoredump.h
- #c-file drivers/base/devcoredump.c
-
-config BPAUTO_RHASHTABLE
- bool
- # current API of rhashtable was introduced in version 4.9
- # (the one including rhltable)
- depends on KERNEL_4_9
- # not very nice - but better than always having it
- default y if BACKPORTED_MAC80211
- #h-file linux/rhashtable.h
- #h-file linux/rhashtable-types.h
- #c-file lib/rhashtable.c
-
-config BPAUTO_BUCKET_LOCKS
- bool
- # the API of bucket_locks that we need was introduced in version 4.16
- depends on KERNEL_4_16
- default y if BPAUTO_RHASHTABLE
- #c-file lib/bucket_locks.c
-
-config BPAUTO_BUILD_HDMI
- bool
- # the hdmi driver got some new apis like hdmi_infoframe_unpack() in
- # kernel 4.0 which are used by some drivers
- depends on KERNEL_4_0
- #h-file linux/hdmi.h
- #c-file drivers/video/hdmi.c
-
-config BPAUTO_HDMI
- bool
- select BPAUTO_BUILD_HDMI if KERNEL_4_0
- # these drivers are using the new features of the hdmi driver.
- default y if BACKPORTED_VIDEO_ADV7511
- default y if BACKPORTED_VIDEO_ADV7604
- default y if BACKPORTED_VIDEO_ADV7842
-
-config BPAUTO_FRAME_VECTOR
- bool
-
-config BPAUTO_BUILD_FRAME_VECTOR
- bool
- default n if FRAME_VECTOR
- default y if BPAUTO_FRAME_VECTOR
- #c-file mm/frame_vector.c
-
-config BPAUTO_REFCOUNT
- bool
- default y
- depends on KERNEL_4_11
- #h-file linux/refcount.h
- #c-file lib/refcount.c
-
-config BPAUTO_SYSTEM_DATA_VERIFICATION
- bool
-
-config BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION
- bool
- default y if BPAUTO_SYSTEM_DATA_VERIFICATION
- depends on KERNEL_4_7 || !SYSTEM_DATA_VERIFICATION
- select BPAUTO_ASN1_DECODER
- select BPAUTO_PUBLIC_KEY
- select BPAUTO_PKCS7
- #h-file linux/oid_registry.h
- #c-file lib/oid_registry.c
-
-config BPAUTO_PUBLIC_KEY
- bool
- #h-file crypto/public_key.h
-
-config BPAUTO_ASN1_DECODER
- bool
- #h-file linux/asn1_decoder.h
- #c-file lib/asn1_decoder.c
-
-config BPAUTO_PKCS7
- bool
- #h-file crypto/pkcs7.h
diff --git a/backport/compat/Makefile b/backport/compat/Makefile
deleted file mode 100644
index 69106de4..00000000
--- a/backport/compat/Makefile
+++ /dev/null
@@ -1,72 +0,0 @@
-ccflags-y += -I$(src) -Wframe-larger-than=1280
-ifeq ($(CONFIG_BACKPORT_INTEGRATE),)
-obj-m += compat.o
-else
-obj-y += compat.o
-endif
-compat-y += main.o
-
-# Kernel backport compatibility code
-compat-$(CPTCFG_KERNEL_3_0) += compat-3.0.o
-compat-$(CPTCFG_KERNEL_3_1) += compat-3.1.o
-compat-$(CPTCFG_KERNEL_3_2) += backport-3.2.o
-compat-$(CPTCFG_KERNEL_3_3) += compat-3.3.o
-compat-$(CPTCFG_KERNEL_3_4) += compat-3.4.o
-compat-$(CPTCFG_KERNEL_3_5) += compat-3.5.o user_namespace.o
-compat-$(CPTCFG_KERNEL_3_6) += compat-3.6.o
-compat-$(CPTCFG_KERNEL_3_7) += compat-3.7.o
-compat-$(CPTCFG_KERNEL_3_8) += compat-3.8.o
-compat-$(CPTCFG_KERNEL_3_9) += compat-3.9.o
-compat-$(CPTCFG_KERNEL_3_10) += backport-3.10.o
-compat-$(CPTCFG_KERNEL_3_11) += backport-3.11.o
-compat-$(CPTCFG_KERNEL_3_12) += backport-3.12.o
-compat-$(CPTCFG_KERNEL_3_13) += backport-3.13.o memneq.o
-compat-$(CPTCFG_KERNEL_3_14) += backport-3.14.o
-compat-$(CPTCFG_KERNEL_3_15) += backport-3.15.o
-compat-$(CPTCFG_KERNEL_3_17) += backport-3.17.o
-compat-$(CPTCFG_KERNEL_3_18) += backport-3.18.o
-compat-$(CPTCFG_KERNEL_3_19) += backport-3.19.o
-compat-$(CPTCFG_KERNEL_4_0) += backport-4.0.o
-compat-$(CPTCFG_KERNEL_4_1) += backport-4.1.o
-compat-$(CPTCFG_KERNEL_4_2) += backport-4.2.o
-compat-$(CPTCFG_KERNEL_4_3) += backport-4.3.o
-compat-$(CPTCFG_KERNEL_4_4) += backport-4.4.o
-compat-$(CPTCFG_KERNEL_4_5) += backport-4.5.o
-compat-$(CPTCFG_KERNEL_4_6) += backport-4.6.o
-compat-$(CPTCFG_KERNEL_4_7) += backport-4.7.o
-compat-$(CPTCFG_KERNEL_4_8) += backport-4.8.o
-compat-$(CPTCFG_KERNEL_4_10) += backport-4.10.o
-compat-$(CPTCFG_KERNEL_4_12) += backport-4.12.o
-compat-$(CPTCFG_KERNEL_4_18) += backport-4.18.o
-compat-$(CPTCFG_KERNEL_4_20) += backport-4.20.o
-
-compat-$(CPTCFG_KERNEL_4_20) += backport-genetlink.o
-
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/verify.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7.asn1.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7_verify.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7_parser.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/x509.asn1.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/x509_akid.asn1.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/x509_cert_parser.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/x509_public_key.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7_trust.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/key.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/public_key.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/rsa.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/bignum.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/md.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/md_wrap.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/sha256.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/oid.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/asn1parse.o
-compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/rsapubkey.asn1.o
-
-$(obj)/lib-oid_registry.o: $(obj)/oid_registry_data.c
-
-$(obj)/oid_registry_data.c: $(src)/../include/linux/backport-oid_registry.h \
- $(src)/build_OID_registry
- $(call cmd,build_OID_registry)
-
-quiet_cmd_build_OID_registry = GEN $@
- cmd_build_OID_registry = perl $(src)/build_OID_registry $< $@
diff --git a/backport/compat/backport-3.10.c b/backport/compat/backport-3.10.c
deleted file mode 100644
index 0c0e2603..00000000
--- a/backport/compat/backport-3.10.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Linux backport symbols for kernels 3.10.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/proc_fs.h>
-#include <linux/random.h>
-#include <linux/tty.h>
-#include <linux/pci.h>
-#include <linux/pci_regs.h>
-#include <linux/of.h>
-#include <linux/mm.h>
-
-void proc_set_size(struct proc_dir_entry *de, loff_t size)
-{
- de->size = size;
-}
-EXPORT_SYMBOL_GPL(proc_set_size);
-
-void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
-{
- de->uid = uid;
- de->gid = gid;
-}
-EXPORT_SYMBOL_GPL(proc_set_user);
-
-/* get_random_int() was not exported for module use until 3.10-rc.
- Implement it here in terms of the more expensive get_random_bytes()
- */
-unsigned int get_random_int(void)
-{
- unsigned int r;
- get_random_bytes(&r, sizeof(r));
-
- return r;
-}
-EXPORT_SYMBOL_GPL(get_random_int);
-
-#ifdef CONFIG_TTY
-/**
- * tty_port_tty_wakeup - helper to wake up a tty
- *
- * @port: tty port
- */
-void tty_port_tty_wakeup(struct tty_port *port)
-{
- struct tty_struct *tty = tty_port_tty_get(port);
-
- if (tty) {
- tty_wakeup(tty);
- tty_kref_put(tty);
- }
-}
-EXPORT_SYMBOL_GPL(tty_port_tty_wakeup);
-
-/**
- * tty_port_tty_hangup - helper to hang up a tty
- *
- * @port: tty port
- * @check_clocal: hang only ttys with CLOCAL unset?
- */
-void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
-{
- struct tty_struct *tty = tty_port_tty_get(port);
-
- if (tty && (!check_clocal || !C_CLOCAL(tty)))
- tty_hangup(tty);
- tty_kref_put(tty);
-}
-EXPORT_SYMBOL_GPL(tty_port_tty_hangup);
-#endif /* CONFIG_TTY */
-
-#ifdef CONFIG_PCI_IOV
-/*
- * pci_vfs_assigned - returns number of VFs are assigned to a guest
- * @dev: the PCI device
- *
- * Returns number of VFs belonging to this device that are assigned to a guest.
- * If device is not a physical function returns -ENODEV.
- */
-int pci_vfs_assigned(struct pci_dev *dev)
-{
- struct pci_dev *vfdev;
- unsigned int vfs_assigned = 0;
- unsigned short dev_id;
-
- /* only search if we are a PF */
- if (!dev->is_physfn)
- return 0;
-
- /*
- * determine the device ID for the VFs, the vendor ID will be the
- * same as the PF so there is no need to check for that one
- */
- pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_VF_DID, &dev_id);
-
- /* loop through all the VFs to see if we own any that are assigned */
- vfdev = pci_get_device(dev->vendor, dev_id, NULL);
- while (vfdev) {
- /*
- * It is considered assigned if it is a virtual function with
- * our dev as the physical function and the assigned bit is set
- */
- if (vfdev->is_virtfn && (vfdev->physfn == dev) &&
- (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED))
- vfs_assigned++;
-
- vfdev = pci_get_device(dev->vendor, dev_id, vfdev);
- }
-
- return vfs_assigned;
-}
-EXPORT_SYMBOL_GPL(pci_vfs_assigned);
-#endif /* CONFIG_PCI_IOV */
-
-#ifdef CONFIG_OF
-/**
- * of_property_read_u32_index - Find and read a u32 from a multi-value property.
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @index: index of the u32 in the list of values
- * @out_value: pointer to return value, modified only if no error.
- *
- * Search for a property in a device node and read nth 32-bit value from
- * it. Returns 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
- *
- * The out_value is modified only if a valid u32 value can be decoded.
- */
-int of_property_read_u32_index(const struct device_node *np,
- const char *propname,
- u32 index, u32 *out_value)
-{
- const u32 *val = of_find_property_value_of_size(np, propname,
- ((index + 1) * sizeof(*out_value)));
-
- if (IS_ERR(val))
- return PTR_ERR(val);
-
- *out_value = be32_to_cpup(((__be32 *)val) + index);
- return 0;
-}
-EXPORT_SYMBOL_GPL(of_property_read_u32_index);
-#endif /* CONFIG_OF */
-
-static inline void set_page_count(struct page *page, int v)
-{
- atomic_set(&page->_count, v);
-}
-
-/*
- * Turn a non-refcounted page (->_count == 0) into refcounted with
- * a count of one.
- */
-static inline void set_page_refcounted(struct page *page)
-{
- VM_BUG_ON(PageTail(page));
- VM_BUG_ON(atomic_read(&page->_count));
- set_page_count(page, 1);
-}
-
-/*
- * split_page takes a non-compound higher-order page, and splits it into
- * n (1<<order) sub-pages: page[0..n]
- * Each sub-page must be freed individually.
- *
- * Note: this is probably too low level an operation for use in drivers.
- * Please consult with lkml before using this in your driver.
- */
-void split_page(struct page *page, unsigned int order)
-{
- int i;
-
- VM_BUG_ON(PageCompound(page));
- VM_BUG_ON(!page_count(page));
-
-#ifdef CONFIG_KMEMCHECK
- /*
- * Split shadow pages too, because free(page[0]) would
- * otherwise free the whole shadow.
- */
- if (kmemcheck_page_is_tracked(page))
- split_page(virt_to_page(page[0].shadow), order);
-#endif
-
- for (i = 1; i < (1 << order); i++)
- set_page_refcounted(page + i);
-}
-EXPORT_SYMBOL_GPL(split_page);
-
-struct action_devres {
- void *data;
- void (*action)(void *);
-};
-
-static void devm_action_release(struct device *dev, void *res)
-{
- struct action_devres *devres = res;
-
- devres->action(devres->data);
-}
-
-/**
- * devm_add_action() - add a custom action to list of managed resources
- * @dev: Device that owns the action
- * @action: Function that should be called
- * @data: Pointer to data passed to @action implementation
- *
- * This adds a custom action to the list of managed resources so that
- * it gets executed as part of standard resource unwinding.
- */
-int devm_add_action(struct device *dev, void (*action)(void *), void *data)
-{
- struct action_devres *devres;
-
- devres = devres_alloc(devm_action_release,
- sizeof(struct action_devres), GFP_KERNEL);
- if (!devres)
- return -ENOMEM;
-
- devres->data = data;
- devres->action = action;
-
- devres_add(dev, devres);
- return 0;
-}
-EXPORT_SYMBOL_GPL(devm_add_action);
diff --git a/backport/compat/backport-3.11.c b/backport/compat/backport-3.11.c
deleted file mode 100644
index 7f9ff341..00000000
--- a/backport/compat/backport-3.11.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Deutschland GmbH
- *
- * Backport functionality introduced in Linux 3.11.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/scatterlist.h>
-
-static bool sg_miter_get_next_page(struct sg_mapping_iter *miter)
-{
- if (!miter->__remaining) {
- struct scatterlist *sg;
- unsigned long pgoffset;
-
- if (!__sg_page_iter_next(&miter->piter))
- return false;
-
- sg = miter->piter.sg;
- pgoffset = miter->piter.sg_pgoffset;
-
- miter->__offset = pgoffset ? 0 : sg->offset;
- miter->__remaining = sg->offset + sg->length -
- (pgoffset << PAGE_SHIFT) - miter->__offset;
- miter->__remaining = min_t(unsigned long, miter->__remaining,
- PAGE_SIZE - miter->__offset);
- }
-
- return true;
-}
-
-/**
- * sg_miter_skip - reposition mapping iterator
- * @miter: sg mapping iter to be skipped
- * @offset: number of bytes to plus the current location
- *
- * Description:
- * Sets the offset of @miter to its current location plus @offset bytes.
- * If mapping iterator @miter has been proceeded by sg_miter_next(), this
- * stops @miter.
- *
- * Context:
- * Don't care if @miter is stopped, or not proceeded yet.
- * Otherwise, preemption disabled if the SG_MITER_ATOMIC is set.
- *
- * Returns:
- * true if @miter contains the valid mapping. false if end of sg
- * list is reached.
- */
-static bool sg_miter_skip(struct sg_mapping_iter *miter, off_t offset)
-{
- sg_miter_stop(miter);
-
- while (offset) {
- off_t consumed;
-
- if (!sg_miter_get_next_page(miter))
- return false;
-
- consumed = min_t(off_t, offset, miter->__remaining);
- miter->__offset += consumed;
- miter->__remaining -= consumed;
- offset -= consumed;
- }
-
- return true;
-}
-
-/**
- * sg_copy_buffer - Copy data between a linear buffer and an SG list
- * @sgl: The SG list
- * @nents: Number of SG entries
- * @buf: Where to copy from
- * @buflen: The number of bytes to copy
- * @skip: Number of bytes to skip before copying
- * @to_buffer: transfer direction (true == from an sg list to a
- * buffer, false == from a buffer to an sg list
- *
- * Returns the number of copied bytes.
- *
- **/
-size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
- size_t buflen, off_t skip, bool to_buffer)
-{
- unsigned int offset = 0;
- struct sg_mapping_iter miter;
- unsigned long flags;
- unsigned int sg_flags = SG_MITER_ATOMIC;
-
- if (to_buffer)
- sg_flags |= SG_MITER_FROM_SG;
- else
- sg_flags |= SG_MITER_TO_SG;
-
- sg_miter_start(&miter, sgl, nents, sg_flags);
-
- if (!sg_miter_skip(&miter, skip))
- return false;
-
- local_irq_save(flags);
-
- while (sg_miter_next(&miter) && offset < buflen) {
- unsigned int len;
-
- len = min(miter.length, buflen - offset);
-
- if (to_buffer)
- memcpy(buf + offset, miter.addr, len);
- else
- memcpy(miter.addr, buf + offset, len);
-
- offset += len;
- }
-
- sg_miter_stop(&miter);
-
- local_irq_restore(flags);
- return offset;
-}
-EXPORT_SYMBOL_GPL(sg_copy_buffer);
diff --git a/backport/compat/backport-3.12.c b/backport/compat/backport-3.12.c
deleted file mode 100644
index c9b21e86..00000000
--- a/backport/compat/backport-3.12.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 3.12.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/export.h>
-#include <linux/hid.h>
-#include <linux/bug.h>
-#include <linux/math64.h>
-
-/*
- * Allocator for buffer that is going to be passed to hid_output_report()
- */
-u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
-{
- /*
- * 7 extra bytes are necessary to achieve proper functionality
- * of implement() working on 8 byte chunks
- */
-
- int len = ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7;
-
- return kmalloc(len, flags);
-}
-EXPORT_SYMBOL_GPL(hid_alloc_report_buf);
-
-#if BITS_PER_LONG == 32
-/**
- * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
- * @dividend: 64bit dividend
- * @divisor: 64bit divisor
- * @remainder: 64bit remainder
- *
- * This implementation is a comparable to algorithm used by div64_u64.
- * But this operation, which includes math for calculating the remainder,
- * is kept distinct to avoid slowing down the div64_u64 operation on 32bit
- * systems.
- */
-#ifndef backports_div64_u64_rem_add
-u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
-{
- u32 high = divisor >> 32;
- u64 quot;
-
- if (high == 0) {
- u32 rem32;
- quot = div_u64_rem(dividend, divisor, &rem32);
- *remainder = rem32;
- } else {
- int n = 1 + fls(high);
- quot = div_u64(dividend >> n, divisor >> n);
-
- if (quot != 0)
- quot--;
-
- *remainder = dividend - quot * divisor;
- if (*remainder >= divisor) {
- quot++;
- *remainder -= divisor;
- }
- }
-
- return quot;
-}
-EXPORT_SYMBOL_GPL(div64_u64_rem);
-#endif /* backports_div64_u64_rem_add */
-#endif /* BITS_PER_LONG */
diff --git a/backport/compat/backport-3.13.c b/backport/compat/backport-3.13.c
deleted file mode 100644
index 2b61711d..00000000
--- a/backport/compat/backport-3.13.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
- * Copyright (c) 2013 Hannes Frederic Sowa <hannes@stressinduktion.org>
- * Copyright (c) 2014 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Backport functionality introduced in Linux 3.13.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/device.h>
-#include <linux/hwmon.h>
-#include <linux/net.h>
-
-#ifdef __BACKPORT_NET_GET_RANDOM_ONCE
-struct __net_random_once_work {
- struct work_struct work;
- struct static_key *key;
-};
-
-static void __net_random_once_deferred(struct work_struct *w)
-{
- struct __net_random_once_work *work =
- container_of(w, struct __net_random_once_work, work);
- if (!static_key_enabled(work->key))
- static_key_slow_inc(work->key);
- kfree(work);
-}
-
-static void __net_random_once_disable_jump(struct static_key *key)
-{
- struct __net_random_once_work *w;
-
- w = kmalloc(sizeof(*w), GFP_ATOMIC);
- if (!w)
- return;
-
- INIT_WORK(&w->work, __net_random_once_deferred);
- w->key = key;
- schedule_work(&w->work);
-}
-
-bool __net_get_random_once(void *buf, int nbytes, bool *done,
- struct static_key *done_key)
-{
- static DEFINE_SPINLOCK(lock);
- unsigned long flags;
-
- spin_lock_irqsave(&lock, flags);
- if (*done) {
- spin_unlock_irqrestore(&lock, flags);
- return false;
- }
-
- get_random_bytes(buf, nbytes);
- *done = true;
- spin_unlock_irqrestore(&lock, flags);
-
- __net_random_once_disable_jump(done_key);
-
- return true;
-}
-EXPORT_SYMBOL_GPL(__net_get_random_once);
-#endif /* __BACKPORT_NET_GET_RANDOM_ONCE */
-
-#ifdef CONFIG_PCI
-#define pci_bus_read_dev_vendor_id LINUX_BACKPORT(pci_bus_read_dev_vendor_id)
-static bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
- int crs_timeout)
-{
- int delay = 1;
-
- if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
- return false;
-
- /* some broken boards return 0 or ~0 if a slot is empty: */
- if (*l == 0xffffffff || *l == 0x00000000 ||
- *l == 0x0000ffff || *l == 0xffff0000)
- return false;
-
- /*
- * Configuration Request Retry Status. Some root ports return the
- * actual device ID instead of the synthetic ID (0xFFFF) required
- * by the PCIe spec. Ignore the device ID and only check for
- * (vendor id == 1).
- */
- while ((*l & 0xffff) == 0x0001) {
- if (!crs_timeout)
- return false;
-
- msleep(delay);
- delay *= 2;
- if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
- return false;
- /* Card hasn't responded in 60 seconds? Must be stuck. */
- if (delay > crs_timeout) {
- printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not responding\n",
- pci_domain_nr(bus), bus->number, PCI_SLOT(devfn),
- PCI_FUNC(devfn));
- return false;
- }
- }
-
- return true;
-}
-
-bool pci_device_is_present(struct pci_dev *pdev)
-{
- u32 v;
-
- return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
-}
-EXPORT_SYMBOL_GPL(pci_device_is_present);
-#endif /* CONFIG_PCI */
-
-#ifdef CONFIG_HWMON
-struct device*
-hwmon_device_register_with_groups(struct device *dev, const char *name,
- void *drvdata,
- const struct attribute_group **groups)
-{
- struct device *hwdev;
-
- hwdev = hwmon_device_register(dev);
- hwdev->groups = groups;
- dev_set_drvdata(hwdev, drvdata);
- return hwdev;
-}
-
-static void devm_hwmon_release(struct device *dev, void *res)
-{
- struct device *hwdev = *(struct device **)res;
-
- hwmon_device_unregister(hwdev);
-}
-
-struct device *
-devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
- void *drvdata,
- const struct attribute_group **groups)
-{
- struct device **ptr, *hwdev;
-
- if (!dev)
- return ERR_PTR(-EINVAL);
-
- ptr = devres_alloc(devm_hwmon_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return ERR_PTR(-ENOMEM);
-
- hwdev = hwmon_device_register_with_groups(dev, name, drvdata, groups);
- if (IS_ERR(hwdev))
- goto error;
-
- *ptr = hwdev;
- devres_add(dev, ptr);
- return hwdev;
-
-error:
- devres_free(ptr);
- return hwdev;
-}
-EXPORT_SYMBOL_GPL(devm_hwmon_device_register_with_groups);
-#endif
diff --git a/backport/compat/backport-3.14.c b/backport/compat/backport-3.14.c
deleted file mode 100644
index aeb30045..00000000
--- a/backport/compat/backport-3.14.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 3.14.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-
-#ifdef CONFIG_PCI_MSI
-/**
- * pci_enable_msi_range - configure device's MSI capability structure
- * @dev: device to configure
- * @minvec: minimal number of interrupts to configure
- * @maxvec: maximum number of interrupts to configure
- *
- * This function tries to allocate a maximum possible number of interrupts in a
- * range between @minvec and @maxvec. It returns a negative errno if an error
- * occurs. If it succeeds, it returns the actual number of interrupts allocated
- * and updates the @dev's irq member to the lowest new interrupt number;
- * the other interrupt numbers allocated to this device are consecutive.
- **/
-int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
-{
- int nvec = maxvec;
- int rc;
-
- if (maxvec < minvec)
- return -ERANGE;
-
- do {
- rc = pci_enable_msi_block(dev, nvec);
- if (rc < 0) {
- return rc;
- } else if (rc > 0) {
- if (rc < minvec)
- return -ENOSPC;
- nvec = rc;
- }
- } while (rc);
-
- return nvec;
-}
-EXPORT_SYMBOL(pci_enable_msi_range);
-#endif
-
-#ifdef CONFIG_PCI_MSI
-/**
- * pci_enable_msix_range - configure device's MSI-X capability structure
- * @dev: pointer to the pci_dev data structure of MSI-X device function
- * @entries: pointer to an array of MSI-X entries
- * @minvec: minimum number of MSI-X irqs requested
- * @maxvec: maximum number of MSI-X irqs requested
- *
- * Setup the MSI-X capability structure of device function with a maximum
- * possible number of interrupts in the range between @minvec and @maxvec
- * upon its software driver call to request for MSI-X mode enabled on its
- * hardware device function. It returns a negative errno if an error occurs.
- * If it succeeds, it returns the actual number of interrupts allocated and
- * indicates the successful configuration of MSI-X capability structure
- * with new allocated MSI-X interrupts.
- **/
-int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
- int minvec, int maxvec)
-{
- int nvec = maxvec;
- int rc;
-
- if (maxvec < minvec)
- return -ERANGE;
-
- do {
- rc = pci_enable_msix(dev, entries, nvec);
- if (rc < 0) {
- return rc;
- } else if (rc > 0) {
- if (rc < minvec)
- return -ENOSPC;
- nvec = rc;
- }
- } while (rc);
-
- return nvec;
-}
-EXPORT_SYMBOL(pci_enable_msix_range);
-#endif
diff --git a/backport/compat/backport-3.15.c b/backport/compat/backport-3.15.c
deleted file mode 100644
index c0023ac1..00000000
--- a/backport/compat/backport-3.15.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2014 Hauke Mehrtens <hauke@hauke-m.de>
- * Copyright (c) 2015 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Backport functionality introduced in Linux 3.15.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/of.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <net/net_namespace.h>
-
-/**
- * devm_kstrdup - Allocate resource managed space and
- * copy an existing string into that.
- * @dev: Device to allocate memory for
- * @s: the string to duplicate
- * @gfp: the GFP mask used in the devm_kmalloc() call when
- * allocating memory
- * RETURNS:
- * Pointer to allocated string on success, NULL on failure.
- */
-char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
-{
- size_t size;
- char *buf;
-
- if (!s)
- return NULL;
-
- size = strlen(s) + 1;
- buf = devm_kmalloc(dev, size, gfp);
- if (buf)
- memcpy(buf, s, size);
- return buf;
-}
-EXPORT_SYMBOL_GPL(devm_kstrdup);
-
-#ifdef CONFIG_OF
-/**
- * of_property_count_elems_of_size - Count the number of elements in a property
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @elem_size: size of the individual element
- *
- * Search for a property in a device node and count the number of elements of
- * size elem_size in it. Returns number of elements on sucess, -EINVAL if the
- * property does not exist or its length does not match a multiple of elem_size
- * and -ENODATA if the property does not have a value.
- */
-int of_property_count_elems_of_size(const struct device_node *np,
- const char *propname, int elem_size)
-{
- struct property *prop = of_find_property(np, propname, NULL);
-
- if (!prop)
- return -EINVAL;
- if (!prop->value)
- return -ENODATA;
-
- if (prop->length % elem_size != 0) {
- pr_err("size of %s in node %s is not a multiple of %d\n",
- propname, np->full_name, elem_size);
- return -EINVAL;
- }
-
- return prop->length / elem_size;
-}
-EXPORT_SYMBOL_GPL(of_property_count_elems_of_size);
-#endif
-
-void kvfree(const void *addr)
-{
- if (is_vmalloc_addr(addr))
- vfree(addr);
- else
- kfree(addr);
-}
-EXPORT_SYMBOL_GPL(kvfree);
diff --git a/backport/compat/backport-3.17.c b/backport/compat/backport-3.17.c
deleted file mode 100644
index 5961e3bc..00000000
--- a/backport/compat/backport-3.17.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2014 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 3.17.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/device.h>
-#include <linux/export.h>
-#include <linux/ktime.h>
-#include <linux/jiffies.h>
-#include <linux/moduleparam.h>
-
-int bit_wait(void *word)
-{
- schedule();
- return 0;
-}
-EXPORT_SYMBOL_GPL(bit_wait);
-
-int bit_wait_io(void *word)
-{
- io_schedule();
- return 0;
-}
-EXPORT_SYMBOL_GPL(bit_wait_io);
-
-/**
- * ktime_get_raw - Returns the raw monotonic time in ktime_t format
- */
-ktime_t ktime_get_raw(void)
-{
- struct timespec ts;
-
- getrawmonotonic(&ts);
- return timespec_to_ktime(ts);
-}
-EXPORT_SYMBOL_GPL(ktime_get_raw);
-
-
-/**
- * nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
- *
- * @n: nsecs in u64
- *
- * Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
- * And this doesn't return MAX_JIFFY_OFFSET since this function is designed
- * for scheduler, not for use in device drivers to calculate timeout value.
- *
- * note:
- * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
- * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
- */
-static u64 backport_nsecs_to_jiffies64(u64 n)
-{
-#if (NSEC_PER_SEC % HZ) == 0
- /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */
- return div_u64(n, NSEC_PER_SEC / HZ);
-#elif (HZ % 512) == 0
- /* overflow after 292 years if HZ = 1024 */
- return div_u64(n * HZ / 512, NSEC_PER_SEC / 512);
-#else
- /*
- * Generic case - optimized for cases where HZ is a multiple of 3.
- * overflow after 64.99 years, exact for HZ = 60, 72, 90, 120 etc.
- */
- return div_u64(n * 9, (9ull * NSEC_PER_SEC + HZ / 2) / HZ);
-#endif
-}
-
-/**
- * nsecs_to_jiffies - Convert nsecs in u64 to jiffies
- *
- * @n: nsecs in u64
- *
- * Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
- * And this doesn't return MAX_JIFFY_OFFSET since this function is designed
- * for scheduler, not for use in device drivers to calculate timeout value.
- *
- * note:
- * NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
- * ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
- */
-unsigned long nsecs_to_jiffies(u64 n)
-{
- return (unsigned long)backport_nsecs_to_jiffies64(n);
-}
-EXPORT_SYMBOL_GPL(nsecs_to_jiffies);
-
-/**
- * devm_kvasprintf - Allocate resource managed space
- * for the formatted string.
- * @dev: Device to allocate memory for
- * @gfp: the GFP mask used in the devm_kmalloc() call when
- * allocating memory
- * @fmt: the formatted string to duplicate
- * @ap: the list of tokens to be placed in the formatted string
- * RETURNS:
- * Pointer to allocated string on success, NULL on failure.
- */
-char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
- va_list ap)
-{
- unsigned int len;
- char *p;
- va_list aq;
-
- va_copy(aq, ap);
- len = vsnprintf(NULL, 0, fmt, aq);
- va_end(aq);
-
- p = devm_kmalloc(dev, len+1, gfp);
- if (!p)
- return NULL;
-
- vsnprintf(p, len+1, fmt, ap);
-
- return p;
-}
-EXPORT_SYMBOL_GPL(devm_kvasprintf);
-
-/**
- * devm_kasprintf - Allocate resource managed space
- * and copy an existing formatted string into that
- * @dev: Device to allocate memory for
- * @gfp: the GFP mask used in the devm_kmalloc() call when
- * allocating memory
- * @fmt: the string to duplicate
- * RETURNS:
- * Pointer to allocated string on success, NULL on failure.
- */
-char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
-{
- va_list ap;
- char *p;
-
- va_start(ap, fmt);
- p = devm_kvasprintf(dev, gfp, fmt, ap);
- va_end(ap);
-
- return p;
-}
-EXPORT_SYMBOL_GPL(devm_kasprintf);
-
-u64 bp_ktime_divns(const ktime_t kt, s64 div)
-{
- u64 dclc;
- int sft = 0;
-
- dclc = ktime_to_ns(kt);
- /* Make sure the divisor is less than 2^32: */
- while (div >> 32) {
- sft++;
- div >>= 1;
- }
- dclc >>= sft;
- do_div(dclc, (unsigned long) div);
-
- return dclc;
-}
-EXPORT_SYMBOL_GPL(bp_ktime_divns);
-
-#define STANDARD_PARAM_DEF(name, type, format, strtolfn) \
- int param_set_##name(const char *val, const struct kernel_param *kp) \
- { \
- return strtolfn(val, 0, (type *)kp->arg); \
- } \
- int param_get_##name(char *buffer, const struct kernel_param *kp) \
- { \
- return scnprintf(buffer, PAGE_SIZE, format, \
- *((type *)kp->arg)); \
- } \
- struct kernel_param_ops param_ops_##name = { \
- .set = param_set_##name, \
- .get = param_get_##name, \
- }; \
- EXPORT_SYMBOL(param_set_##name); \
- EXPORT_SYMBOL(param_get_##name); \
- EXPORT_SYMBOL(param_ops_##name)
-STANDARD_PARAM_DEF(ullong, unsigned long long, "%llu", kstrtoull);
diff --git a/backport/compat/backport-3.18.c b/backport/compat/backport-3.18.c
deleted file mode 100644
index d2eceef7..00000000
--- a/backport/compat/backport-3.18.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (c) 2014 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 3.18.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/if_ether.h>
-#include <linux/if_vlan.h>
-#include <linux/ip.h>
-#include <linux/ipv6.h>
-#include <scsi/fc/fc_fcoe.h>
-#include <linux/skbuff.h>
-#include <linux/errqueue.h>
-#include <linux/wait.h>
-#include <linux/of.h>
-#include <linux/string.h>
-
-/**
- * eth_get_headlen - determine the the length of header for an ethernet frame
- * @data: pointer to start of frame
- * @len: total length of frame
- *
- * Make a best effort attempt to pull the length for all of the headers for
- * a given frame in a linear buffer.
- */
-int eth_get_headlen(unsigned char *data, unsigned int max_len)
-{
- union {
- unsigned char *network;
- /* l2 headers */
- struct ethhdr *eth;
- struct vlan_hdr *vlan;
- /* l3 headers */
- struct iphdr *ipv4;
- struct ipv6hdr *ipv6;
- } hdr;
- __be16 protocol;
- u8 nexthdr = 0; /* default to not TCP */
- u8 hlen;
-
- /* this should never happen, but better safe than sorry */
- if (max_len < ETH_HLEN)
- return max_len;
-
- /* initialize network frame pointer */
- hdr.network = data;
-
- /* set first protocol and move network header forward */
- protocol = hdr.eth->h_proto;
- hdr.network += ETH_HLEN;
-
- /* handle any vlan tag if present */
- if (protocol == htons(ETH_P_8021Q)) {
- if ((hdr.network - data) > (max_len - VLAN_HLEN))
- return max_len;
-
- protocol = hdr.vlan->h_vlan_encapsulated_proto;
- hdr.network += VLAN_HLEN;
- }
-
- /* handle L3 protocols */
- if (protocol == htons(ETH_P_IP)) {
- if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))
- return max_len;
-
- /* access ihl as a u8 to avoid unaligned access on ia64 */
- hlen = (hdr.network[0] & 0x0F) << 2;
-
- /* verify hlen meets minimum size requirements */
- if (hlen < sizeof(struct iphdr))
- return hdr.network - data;
-
- /* record next protocol if header is present */
- if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))
- nexthdr = hdr.ipv4->protocol;
- } else if (protocol == htons(ETH_P_IPV6)) {
- if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))
- return max_len;
-
- /* record next protocol */
- nexthdr = hdr.ipv6->nexthdr;
- hlen = sizeof(struct ipv6hdr);
- } else if (protocol == htons(ETH_P_FCOE)) {
- if ((hdr.network - data) > (max_len - FCOE_HEADER_LEN))
- return max_len;
- hlen = FCOE_HEADER_LEN;
- } else {
- return hdr.network - data;
- }
-
- /* relocate pointer to start of L4 header */
- hdr.network += hlen;
-
- /* finally sort out TCP/UDP */
- if (nexthdr == IPPROTO_TCP) {
- if ((hdr.network - data) > (max_len - sizeof(struct tcphdr)))
- return max_len;
-
- /* access doff as a u8 to avoid unaligned access on ia64 */
- hlen = (hdr.network[12] & 0xF0) >> 2;
-
- /* verify hlen meets minimum size requirements */
- if (hlen < sizeof(struct tcphdr))
- return hdr.network - data;
-
- hdr.network += hlen;
- } else if (nexthdr == IPPROTO_UDP) {
- if ((hdr.network - data) > (max_len - sizeof(struct udphdr)))
- return max_len;
-
- hdr.network += sizeof(struct udphdr);
- }
-
- /*
- * If everything has gone correctly hdr.network should be the
- * data section of the packet and will be the end of the header.
- * If not then it probably represents the end of the last recognized
- * header.
- */
- if ((hdr.network - data) < max_len)
- return hdr.network - data;
- else
- return max_len;
-}
-EXPORT_SYMBOL_GPL(eth_get_headlen);
-
-#define sock_efree LINUX_BACKPORT(sock_efree)
-static void sock_efree(struct sk_buff *skb)
-{
- sock_put(skb->sk);
-}
-
-/**
- * skb_clone_sk - create clone of skb, and take reference to socket
- * @skb: the skb to clone
- *
- * This function creates a clone of a buffer that holds a reference on
- * sk_refcnt. Buffers created via this function are meant to be
- * returned using sock_queue_err_skb, or free via kfree_skb.
- *
- * When passing buffers allocated with this function to sock_queue_err_skb
- * it is necessary to wrap the call with sock_hold/sock_put in order to
- * prevent the socket from being released prior to being enqueued on
- * the sk_error_queue.
- */
-struct sk_buff *skb_clone_sk(struct sk_buff *skb)
-{
- struct sock *sk = skb->sk;
- struct sk_buff *clone;
-
- if (!sk || !atomic_inc_not_zero(&sk->sk_refcnt))
- return NULL;
-
- clone = skb_clone(skb, GFP_ATOMIC);
- if (!clone) {
- sock_put(sk);
- return NULL;
- }
-
- clone->sk = sk;
- clone->destructor = sock_efree;
-
- return clone;
-}
-EXPORT_SYMBOL_GPL(skb_clone_sk);
-
-#if LINUX_VERSION_IS_GEQ(3,3,0)
-/*
- * skb_complete_wifi_ack() needs to get backported, because the version from
- * 3.18 added the sock_hold() and sock_put() calles missing in older versions.
- */
-void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
-{
- struct sock *sk = skb->sk;
- struct sock_exterr_skb *serr;
- int err;
-
- skb->wifi_acked_valid = 1;
- skb->wifi_acked = acked;
-
- serr = SKB_EXT_ERR(skb);
- memset(serr, 0, sizeof(*serr));
- serr->ee.ee_errno = ENOMSG;
- serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS;
-
- /* take a reference to prevent skb_orphan() from freeing the socket */
- sock_hold(sk);
-
- err = sock_queue_err_skb(sk, skb);
- if (err)
- kfree_skb(skb);
-
- sock_put(sk);
-}
-EXPORT_SYMBOL_GPL(skb_complete_wifi_ack);
-#endif
-
-#if LINUX_VERSION_IS_GEQ(3,17,0)
-int __sched out_of_line_wait_on_bit_timeout(
- void *word, int bit, wait_bit_action_f *action,
- unsigned mode, unsigned long timeout)
-{
- wait_queue_head_t *wq = bit_waitqueue(word, bit);
- DEFINE_WAIT_BIT(wait, word, bit);
-
- wait.key.private = jiffies + timeout;
- return __wait_on_bit(wq, &wait, action, mode);
-}
-EXPORT_SYMBOL_GPL(out_of_line_wait_on_bit_timeout);
-
-__sched int bit_wait_timeout(struct wait_bit_key *word)
-{
- unsigned long now = ACCESS_ONCE(jiffies);
- if (signal_pending_state(current->state, current))
- return 1;
- if (time_after_eq(now, word->private))
- return -EAGAIN;
- schedule_timeout(word->private - now);
- return 0;
-}
-EXPORT_SYMBOL_GPL(bit_wait_timeout);
-#endif
-
-#ifdef CONFIG_OF
-/**
- * of_find_property_value_of_size
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @len: requested length of property value
- *
- * Search for a property in a device node and valid the requested size.
- * Returns the property value on success, -EINVAL if the property does not
- * exist, -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
- *
- */
-void *of_find_property_value_of_size(const struct device_node *np,
- const char *propname, u32 len)
-{
- struct property *prop = of_find_property(np, propname, NULL);
-
- if (!prop)
- return ERR_PTR(-EINVAL);
- if (!prop->value)
- return ERR_PTR(-ENODATA);
- if (len > prop->length)
- return ERR_PTR(-EOVERFLOW);
-
- return prop->value;
-}
-
-/**
- * of_property_read_u64_array - Find and read an array of 64 bit integers
- * from a property.
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @out_values: pointer to return value, modified only if return value is 0.
- * @sz: number of array elements to read
- *
- * Search for a property in a device node and read 64-bit value(s) from
- * it. Returns 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
- *
- * The out_values is modified only if a valid u64 value can be decoded.
- */
-int of_property_read_u64_array(const struct device_node *np,
- const char *propname, u64 *out_values,
- size_t sz)
-{
- const __be32 *val = of_find_property_value_of_size(np, propname,
- (sz * sizeof(*out_values)));
-
- if (IS_ERR(val))
- return PTR_ERR(val);
-
- while (sz--) {
- *out_values++ = of_read_number(val, 2);
- val += 2;
- }
- return 0;
-}
-EXPORT_SYMBOL_GPL(of_property_read_u64_array);
-#endif /* CONFIG_OF */
-
-#if !(LINUX_VERSION_IS_GEQ(3,17,3) || \
- (LINUX_VERSION_IS_GEQ(3,14,24) && \
- LINUX_VERSION_IS_LESS(3,15,0)) || \
- (LINUX_VERSION_IS_GEQ(3,12,33) && \
- LINUX_VERSION_IS_LESS(3,13,0)) || \
- (LINUX_VERSION_IS_GEQ(3,10,60) && \
- LINUX_VERSION_IS_LESS(3,11,0)) || \
- (LINUX_VERSION_IS_GEQ(3,4,106) && \
- LINUX_VERSION_IS_LESS(3,5,0)) || \
- (LINUX_VERSION_IS_GEQ(3,2,65) && \
- LINUX_VERSION_IS_LESS(3,3,0)))
-/**
- * memzero_explicit - Fill a region of memory (e.g. sensitive
- * keying data) with 0s.
- * @s: Pointer to the start of the area.
- * @count: The size of the area.
- *
- * Note: usually using memset() is just fine (!), but in cases
- * where clearing out _local_ data at the end of a scope is
- * necessary, memzero_explicit() should be used instead in
- * order to prevent the compiler from optimising away zeroing.
- *
- * memzero_explicit() doesn't need an arch-specific version as
- * it just invokes the one of memset() implicitly.
- */
-void memzero_explicit(void *s, size_t count)
-{
- memset(s, 0, count);
- barrier_data(s);
-}
-EXPORT_SYMBOL_GPL(memzero_explicit);
-#endif
-
-char *bin2hex(char *dst, const void *src, size_t count)
-{
- const unsigned char *_src = src;
-
- while (count--)
- dst = hex_byte_pack(dst, *_src++);
- return dst;
-}
-EXPORT_SYMBOL(bin2hex);
diff --git a/backport/compat/backport-3.19.c b/backport/compat/backport-3.19.c
deleted file mode 100644
index 019644df..00000000
--- a/backport/compat/backport-3.19.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2014 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 3.19.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include <linux/export.h>
-#include <linux/net.h>
-#include <linux/netdevice.h>
-#include <linux/skbuff.h>
-#include <linux/debugfs.h>
-
-#if LINUX_VERSION_IS_LESS(3,18,12)
-static inline bool is_kthread_should_stop(void)
-{
- return (current->flags & PF_KTHREAD) && kthread_should_stop();
-}
-
-/*
- * DEFINE_WAIT_FUNC(wait, woken_wake_func);
- *
- * add_wait_queue(&wq, &wait);
- * for (;;) {
- * if (condition)
- * break;
- *
- * p->state = mode; condition = true;
- * smp_mb(); // A smp_wmb(); // C
- * if (!wait->flags & WQ_FLAG_WOKEN) wait->flags |= WQ_FLAG_WOKEN;
- * schedule() try_to_wake_up();
- * p->state = TASK_RUNNING; ~~~~~~~~~~~~~~~~~~
- * wait->flags &= ~WQ_FLAG_WOKEN; condition = true;
- * smp_mb() // B smp_wmb(); // C
- * wait->flags |= WQ_FLAG_WOKEN;
- * }
- * remove_wait_queue(&wq, &wait);
- *
- */
-long wait_woken(wait_queue_t *wait, unsigned mode, long timeout)
-{
- set_current_state(mode); /* A */
- /*
- * The above implies an smp_mb(), which matches with the smp_wmb() from
- * woken_wake_function() such that if we observe WQ_FLAG_WOKEN we must
- * also observe all state before the wakeup.
- */
- if (!(wait->flags & WQ_FLAG_WOKEN) && !is_kthread_should_stop())
- timeout = schedule_timeout(timeout);
- __set_current_state(TASK_RUNNING);
-
- /*
- * The below implies an smp_mb(), it too pairs with the smp_wmb() from
- * woken_wake_function() such that we must either observe the wait
- * condition being true _OR_ WQ_FLAG_WOKEN such that we will not miss
- * an event.
- */
- set_mb(wait->flags, wait->flags & ~WQ_FLAG_WOKEN); /* B */
-
- return timeout;
-}
-EXPORT_SYMBOL(wait_woken);
-
-int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
-{
- /*
- * Although this function is called under waitqueue lock, LOCK
- * doesn't imply write barrier and the users expects write
- * barrier semantics on wakeup functions. The following
- * smp_wmb() is equivalent to smp_wmb() in try_to_wake_up()
- * and is paired with set_mb() in wait_woken().
- */
- smp_wmb(); /* C */
- wait->flags |= WQ_FLAG_WOKEN;
-
- return default_wake_function(wait, mode, sync, key);
-}
-EXPORT_SYMBOL(woken_wake_function);
-#endif
-
-static u8 netdev_rss_key[NETDEV_RSS_KEY_LEN];
-
-void netdev_rss_key_fill(void *buffer, size_t len)
-{
- BUG_ON(len > sizeof(netdev_rss_key));
-#ifdef __BACKPORT_NET_GET_RANDOM_ONCE
- net_get_random_once(netdev_rss_key, sizeof(netdev_rss_key));
- memcpy(buffer, netdev_rss_key, len);
-#else
- get_random_bytes(buffer, len);
-#endif
-}
-EXPORT_SYMBOL_GPL(netdev_rss_key_fill);
-
-#if defined(CONFIG_DEBUG_FS)
-struct debugfs_devm_entry {
- int (*read)(struct seq_file *seq, void *data);
- struct device *dev;
-};
-
-static int debugfs_devm_entry_open(struct inode *inode, struct file *f)
-{
- struct debugfs_devm_entry *entry = inode->i_private;
-
- return single_open(f, entry->read, entry->dev);
-}
-
-static const struct file_operations debugfs_devm_entry_ops = {
- .owner = THIS_MODULE,
- .open = debugfs_devm_entry_open,
- .release = single_release,
- .read = seq_read,
- .llseek = seq_lseek
-};
-
-/**
- * debugfs_create_devm_seqfile - create a debugfs file that is bound to device.
- *
- * @dev: device related to this debugfs file.
- * @name: name of the debugfs file.
- * @parent: a pointer to the parent dentry for this file. This should be a
- * directory dentry if set. If this parameter is %NULL, then the
- * file will be created in the root of the debugfs filesystem.
- * @read_fn: function pointer called to print the seq_file content.
- */
-struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
- struct dentry *parent,
- int (*read_fn)(struct seq_file *s,
- void *data))
-{
- struct debugfs_devm_entry *entry;
-
- if (IS_ERR(parent))
- return ERR_PTR(-ENOENT);
-
- entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
- if (!entry)
- return ERR_PTR(-ENOMEM);
-
- entry->read = read_fn;
- entry->dev = dev;
-
- return debugfs_create_file(name, S_IRUGO, parent, entry,
- &debugfs_devm_entry_ops);
-}
-EXPORT_SYMBOL_GPL(debugfs_create_devm_seqfile);
-
-#endif /* CONFIG_DEBUG_FS */
-
-int skb_ensure_writable(struct sk_buff *skb, int write_len)
-{
- if (!pskb_may_pull(skb, write_len))
- return -ENOMEM;
-
- if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
- return 0;
-
- return pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
-}
-EXPORT_SYMBOL_GPL(skb_ensure_writable);
diff --git a/backport/compat/backport-3.2.c b/backport/compat/backport-3.2.c
deleted file mode 100644
index 601a1682..00000000
--- a/backport/compat/backport-3.2.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Linux backport symbols for kernels 3.2.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/export.h>
-
-int hex2bin(u8 *dst, const char *src, size_t count)
-{
- while (count--) {
- int hi = hex_to_bin(*src++);
- int lo = hex_to_bin(*src++);
-
- if ((hi < 0) || (lo < 0))
- return -1;
-
- *dst++ = (hi << 4) | lo;
- }
- return 0;
-}
-EXPORT_SYMBOL_GPL(hex2bin);
diff --git a/backport/compat/backport-4.0.c b/backport/compat/backport-4.0.c
deleted file mode 100644
index 84a4c6bf..00000000
--- a/backport/compat/backport-4.0.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.0.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/ctype.h>
-#include <linux/printk.h>
-#include <linux/export.h>
-#include <linux/trace_seq.h>
-#include <asm/unaligned.h>
-
-/**
- * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
- * @buf: data blob to dump
- * @len: number of bytes in the @buf
- * @rowsize: number of bytes to print per line; must be 16 or 32
- * @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
- * @linebuf: where to put the converted data
- * @linebuflen: total size of @linebuf, including space for terminating NUL
- * @ascii: include ASCII after the hex output
- *
- * hex_dump_to_buffer() works on one "line" of output at a time, i.e.,
- * 16 or 32 bytes of input data converted to hex + ASCII output.
- *
- * Given a buffer of u8 data, hex_dump_to_buffer() converts the input data
- * to a hex + ASCII dump at the supplied memory location.
- * The converted output is always NUL-terminated.
- *
- * E.g.:
- * hex_dump_to_buffer(frame->data, frame->len, 16, 1,
- * linebuf, sizeof(linebuf), true);
- *
- * example output buffer:
- * 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO
- *
- * Return:
- * The amount of bytes placed in the buffer without terminating NUL. If the
- * output was truncated, then the return value is the number of bytes
- * (excluding the terminating NUL) which would have been written to the final
- * string if enough space had been available.
- */
-int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize,
- char *linebuf, size_t linebuflen, bool ascii)
-{
- const u8 *ptr = buf;
- int ngroups;
- u8 ch;
- int j, lx = 0;
- int ascii_column;
- int ret;
-
- if (rowsize != 16 && rowsize != 32)
- rowsize = 16;
-
- if (len > rowsize) /* limit to one line at a time */
- len = rowsize;
- if (!is_power_of_2(groupsize) || groupsize > 8)
- groupsize = 1;
- if ((len % groupsize) != 0) /* no mixed size output */
- groupsize = 1;
-
- ngroups = len / groupsize;
- ascii_column = rowsize * 2 + rowsize / groupsize + 1;
-
- if (!linebuflen)
- goto overflow1;
-
- if (!len)
- goto nil;
-
- if (groupsize == 8) {
- const u64 *ptr8 = buf;
-
- for (j = 0; j < ngroups; j++) {
- ret = snprintf(linebuf + lx, linebuflen - lx,
- "%s%16.16llx", j ? " " : "",
- get_unaligned(ptr8 + j));
- if (ret >= linebuflen - lx)
- goto overflow1;
- lx += ret;
- }
- } else if (groupsize == 4) {
- const u32 *ptr4 = buf;
-
- for (j = 0; j < ngroups; j++) {
- ret = snprintf(linebuf + lx, linebuflen - lx,
- "%s%8.8x", j ? " " : "",
- get_unaligned(ptr4 + j));
- if (ret >= linebuflen - lx)
- goto overflow1;
- lx += ret;
- }
- } else if (groupsize == 2) {
- const u16 *ptr2 = buf;
-
- for (j = 0; j < ngroups; j++) {
- ret = snprintf(linebuf + lx, linebuflen - lx,
- "%s%4.4x", j ? " " : "",
- get_unaligned(ptr2 + j));
- if (ret >= linebuflen - lx)
- goto overflow1;
- lx += ret;
- }
- } else {
- for (j = 0; j < len; j++) {
- if (linebuflen < lx + 3)
- goto overflow2;
- ch = ptr[j];
- linebuf[lx++] = hex_asc_hi(ch);
- linebuf[lx++] = hex_asc_lo(ch);
- linebuf[lx++] = ' ';
- }
- if (j)
- lx--;
- }
- if (!ascii)
- goto nil;
-
- while (lx < ascii_column) {
- if (linebuflen < lx + 2)
- goto overflow2;
- linebuf[lx++] = ' ';
- }
- for (j = 0; j < len; j++) {
- if (linebuflen < lx + 2)
- goto overflow2;
- ch = ptr[j];
- linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.';
- }
-nil:
- linebuf[lx] = '\0';
- return lx;
-overflow2:
- linebuf[lx++] = '\0';
-overflow1:
- return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1;
-}
-EXPORT_SYMBOL_GPL(hex_dump_to_buffer);
-
-#if LINUX_VERSION_IS_LESS(3,17,0)
-static inline unsigned char *
-trace_seq_buffer_ptr(struct trace_seq *s)
-{
- return s->buffer + s->len;
-}
-#endif
-
-const char *
-ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len,
- size_t el_size)
-{
- const char *ret = trace_seq_buffer_ptr(p);
- const char *prefix = "";
- void *ptr = (void *)buf;
-
- trace_seq_putc(p, '{');
-
- while (ptr < buf + buf_len) {
- switch (el_size) {
- case 1:
- trace_seq_printf(p, "%s0x%x", prefix,
- *(u8 *)ptr);
- break;
- case 2:
- trace_seq_printf(p, "%s0x%x", prefix,
- *(u16 *)ptr);
- break;
- case 4:
- trace_seq_printf(p, "%s0x%x", prefix,
- *(u32 *)ptr);
- break;
- case 8:
- trace_seq_printf(p, "%s0x%llx", prefix,
- *(u64 *)ptr);
- break;
- default:
- trace_seq_printf(p, "BAD SIZE:%zu 0x%x", el_size,
- *(u8 *)ptr);
- el_size = 1;
- }
- prefix = ",";
- ptr += el_size;
- }
-
- trace_seq_putc(p, '}');
- trace_seq_putc(p, 0);
-
- return ret;
-}
-EXPORT_SYMBOL(ftrace_print_array_seq);
diff --git a/backport/compat/backport-4.1.c b/backport/compat/backport-4.1.c
deleted file mode 100644
index e0a3ec63..00000000
--- a/backport/compat/backport-4.1.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2015 Stefan Assmann <sassmann@kpanic.de>
- * Copyright (c) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.1.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/netdevice.h>
-#include <linux/tty.h>
-
-netdev_features_t passthru_features_check(struct sk_buff *skb,
- struct net_device *dev,
- netdev_features_t features)
-{
- return features;
-}
-EXPORT_SYMBOL_GPL(passthru_features_check);
-
-#ifdef CONFIG_TTY
-#if LINUX_VERSION_IS_GEQ(4,0,0)
-static void unset_locked_termios(struct ktermios *termios,
- struct ktermios *old,
- struct ktermios *locked)
-{
- int i;
-
-#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z)))
-
- if (!locked) {
- printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n");
- return;
- }
-
- NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag);
- NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag);
- NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag);
- NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag);
- termios->c_line = locked->c_line ? old->c_line : termios->c_line;
- for (i = 0; i < NCCS; i++)
- termios->c_cc[i] = locked->c_cc[i] ?
- old->c_cc[i] : termios->c_cc[i];
- /* FIXME: What should we do for i/ospeed */
-}
-
-int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
-{
- struct ktermios old_termios;
- struct tty_ldisc *ld;
-
- WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY &&
- tty->driver->subtype == PTY_TYPE_MASTER);
- /*
- * Perform the actual termios internal changes under lock.
- */
-
-
- /* FIXME: we need to decide on some locking/ordering semantics
- for the set_termios notification eventually */
- down_write(&tty->termios_rwsem);
- old_termios = tty->termios;
- tty->termios = *new_termios;
- unset_locked_termios(&tty->termios, &old_termios, &tty->termios_locked);
-
- if (tty->ops->set_termios)
- tty->ops->set_termios(tty, &old_termios);
- else
- tty_termios_copy_hw(&tty->termios, &old_termios);
-
- ld = tty_ldisc_ref(tty);
- if (ld != NULL) {
- if (ld->ops->set_termios)
- ld->ops->set_termios(tty, &old_termios);
- tty_ldisc_deref(ld);
- }
- up_write(&tty->termios_rwsem);
- return 0;
-}
-EXPORT_SYMBOL_GPL(tty_set_termios);
-#endif /* LINUX_VERSION_IS_GEQ(4,0,0) */
-#endif /* CONFIG_TTY */
diff --git a/backport/compat/backport-4.10.c b/backport/compat/backport-4.10.c
deleted file mode 100644
index a35c699e..00000000
--- a/backport/compat/backport-4.10.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright(c) 2017 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.10.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/ethtool.h>
-#include <linux/mii.h>
-#include <linux/page_ref.h>
-#include <linux/gfp.h>
-
-#if LINUX_VERSION_IS_GEQ(4,6,0)
-#if LINUX_VERSION_IS_LESS(4,7,0)
-static bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
- const unsigned long *src)
-{
- bool retval = true;
-
- /* TODO: following test will soon always be true */
- if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) {
- __ETHTOOL_DECLARE_LINK_MODE_MASK(ext);
-
- bitmap_zero(ext, __ETHTOOL_LINK_MODE_MASK_NBITS);
- bitmap_fill(ext, 32);
- bitmap_complement(ext, ext, __ETHTOOL_LINK_MODE_MASK_NBITS);
- if (bitmap_intersects(ext, src,
- __ETHTOOL_LINK_MODE_MASK_NBITS)) {
- /* src mask goes beyond bit 31 */
- retval = false;
- }
- }
- *legacy_u32 = src[0];
- return retval;
-}
-
-static void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
- u32 legacy_u32)
-{
- bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS);
- dst[0] = legacy_u32;
-}
-#endif
-
-static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
-{
- int advert;
-
- advert = mii->mdio_read(mii->dev, mii->phy_id, addr);
-
- return mii_lpa_to_ethtool_lpa_t(advert);
-}
-
-/**
- * mii_ethtool_set_link_ksettings - set settings that are specified in @cmd
- * @mii: MII interfaces
- * @cmd: requested ethtool_link_ksettings
- *
- * Returns 0 for success, negative on error.
- */
-int mii_ethtool_set_link_ksettings(struct mii_if_info *mii,
- const struct ethtool_link_ksettings *cmd)
-{
- struct net_device *dev = mii->dev;
- u32 speed = cmd->base.speed;
-
- if (speed != SPEED_10 &&
- speed != SPEED_100 &&
- speed != SPEED_1000)
- return -EINVAL;
- if (cmd->base.duplex != DUPLEX_HALF && cmd->base.duplex != DUPLEX_FULL)
- return -EINVAL;
- if (cmd->base.port != PORT_MII)
- return -EINVAL;
- if (cmd->base.phy_address != mii->phy_id)
- return -EINVAL;
- if (cmd->base.autoneg != AUTONEG_DISABLE &&
- cmd->base.autoneg != AUTONEG_ENABLE)
- return -EINVAL;
- if ((speed == SPEED_1000) && (!mii->supports_gmii))
- return -EINVAL;
-
- /* ignore supported, maxtxpkt, maxrxpkt */
-
- if (cmd->base.autoneg == AUTONEG_ENABLE) {
- u32 bmcr, advert, tmp;
- u32 advert2 = 0, tmp2 = 0;
- u32 advertising;
-
- ethtool_convert_link_mode_to_legacy_u32(
- &advertising, cmd->link_modes.advertising);
-
- if ((advertising & (ADVERTISED_10baseT_Half |
- ADVERTISED_10baseT_Full |
- ADVERTISED_100baseT_Half |
- ADVERTISED_100baseT_Full |
- ADVERTISED_1000baseT_Half |
- ADVERTISED_1000baseT_Full)) == 0)
- return -EINVAL;
-
- /* advertise only what has been requested */
- advert = mii->mdio_read(dev, mii->phy_id, MII_ADVERTISE);
- tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
- if (mii->supports_gmii) {
- advert2 = mii->mdio_read(dev, mii->phy_id,
- MII_CTRL1000);
- tmp2 = advert2 &
- ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
- }
- tmp |= ethtool_adv_to_mii_adv_t(advertising);
-
- if (mii->supports_gmii)
- tmp2 |= ethtool_adv_to_mii_ctrl1000_t(advertising);
- if (advert != tmp) {
- mii->mdio_write(dev, mii->phy_id, MII_ADVERTISE, tmp);
- mii->advertising = tmp;
- }
- if ((mii->supports_gmii) && (advert2 != tmp2))
- mii->mdio_write(dev, mii->phy_id, MII_CTRL1000, tmp2);
-
- /* turn on autonegotiation, and force a renegotiate */
- bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
- bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
- mii->mdio_write(dev, mii->phy_id, MII_BMCR, bmcr);
-
- mii->force_media = 0;
- } else {
- u32 bmcr, tmp;
-
- /* turn off auto negotiation, set speed and duplexity */
- bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
- tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
- BMCR_SPEED1000 | BMCR_FULLDPLX);
- if (speed == SPEED_1000)
- tmp |= BMCR_SPEED1000;
- else if (speed == SPEED_100)
- tmp |= BMCR_SPEED100;
- if (cmd->base.duplex == DUPLEX_FULL) {
- tmp |= BMCR_FULLDPLX;
- mii->full_duplex = 1;
- } else {
- mii->full_duplex = 0;
- }
- if (bmcr != tmp)
- mii->mdio_write(dev, mii->phy_id, MII_BMCR, tmp);
-
- mii->force_media = 1;
- }
- return 0;
-}
-EXPORT_SYMBOL(mii_ethtool_set_link_ksettings);
-
-
-/**
- * mii_ethtool_get_link_ksettings - get settings that are specified in @cmd
- * @mii: MII interface
- * @cmd: requested ethtool_link_ksettings
- *
- * The @cmd parameter is expected to have been cleared before calling
- * mii_ethtool_get_link_ksettings().
- *
- * Returns 0 for success, negative on error.
- */
-int mii_ethtool_get_link_ksettings(struct mii_if_info *mii,
- struct ethtool_link_ksettings *cmd)
-{
- struct net_device *dev = mii->dev;
- u16 bmcr, bmsr, ctrl1000 = 0, stat1000 = 0;
- u32 nego, supported, advertising, lp_advertising;
-
- supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
- SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
- if (mii->supports_gmii)
- supported |= SUPPORTED_1000baseT_Half |
- SUPPORTED_1000baseT_Full;
-
- /* only supports twisted-pair */
- cmd->base.port = PORT_MII;
-
- /* this isn't fully supported at higher layers */
- cmd->base.phy_address = mii->phy_id;
- cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22;
-
- advertising = ADVERTISED_TP | ADVERTISED_MII;
-
- bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
- bmsr = mii->mdio_read(dev, mii->phy_id, MII_BMSR);
- if (mii->supports_gmii) {
- ctrl1000 = mii->mdio_read(dev, mii->phy_id, MII_CTRL1000);
- stat1000 = mii->mdio_read(dev, mii->phy_id, MII_STAT1000);
- }
- if (bmcr & BMCR_ANENABLE) {
- advertising |= ADVERTISED_Autoneg;
- cmd->base.autoneg = AUTONEG_ENABLE;
-
- advertising |= mii_get_an(mii, MII_ADVERTISE);
- if (mii->supports_gmii)
- advertising |= mii_ctrl1000_to_ethtool_adv_t(ctrl1000);
-
- if (bmsr & BMSR_ANEGCOMPLETE) {
- lp_advertising = mii_get_an(mii, MII_LPA);
- lp_advertising |=
- mii_stat1000_to_ethtool_lpa_t(stat1000);
- } else {
- lp_advertising = 0;
- }
-
- nego = advertising & lp_advertising;
-
- if (nego & (ADVERTISED_1000baseT_Full |
- ADVERTISED_1000baseT_Half)) {
- cmd->base.speed = SPEED_1000;
- cmd->base.duplex = !!(nego & ADVERTISED_1000baseT_Full);
- } else if (nego & (ADVERTISED_100baseT_Full |
- ADVERTISED_100baseT_Half)) {
- cmd->base.speed = SPEED_100;
- cmd->base.duplex = !!(nego & ADVERTISED_100baseT_Full);
- } else {
- cmd->base.speed = SPEED_10;
- cmd->base.duplex = !!(nego & ADVERTISED_10baseT_Full);
- }
- } else {
- cmd->base.autoneg = AUTONEG_DISABLE;
-
- cmd->base.speed = ((bmcr & BMCR_SPEED1000 &&
- (bmcr & BMCR_SPEED100) == 0) ?
- SPEED_1000 :
- ((bmcr & BMCR_SPEED100) ?
- SPEED_100 : SPEED_10));
- cmd->base.duplex = (bmcr & BMCR_FULLDPLX) ?
- DUPLEX_FULL : DUPLEX_HALF;
-
- lp_advertising = 0;
- }
-
- mii->full_duplex = cmd->base.duplex;
-
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
- supported);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
- advertising);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising,
- lp_advertising);
-
- /* ignore maxtxpkt, maxrxpkt for now */
-
- return 0;
-}
-EXPORT_SYMBOL(mii_ethtool_get_link_ksettings);
-#endif /* LINUX_VERSION_IS_GEQ(4,6,0) */
-
-#if LINUX_VERSION_IS_GEQ(4,2,0)
-void __page_frag_cache_drain(struct page *page, unsigned int count)
-{
- VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
-
- if (page_ref_sub_and_test(page, count)) {
- unsigned int order = compound_order(page);
-
- /*
- * __free_pages_ok() is not exported so call
- * __free_pages() which decrements the ref counter
- * and increment the ref counter before.
- */
- page_ref_inc(page);
- __free_pages(page, order);
- }
-}
-EXPORT_SYMBOL_GPL(__page_frag_cache_drain);
-#endif
diff --git a/backport/compat/backport-4.12.c b/backport/compat/backport-4.12.c
deleted file mode 100644
index 4f9de261..00000000
--- a/backport/compat/backport-4.12.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifdef CONFIG_OF
-#include <linux/of_device.h>
-#endif
-
-#ifdef CONFIG_OF
-#if LINUX_VERSION_IS_GEQ(4,4,0)
-/**
- * of_device_modalias - Fill buffer with newline terminated modalias string
- */
-ssize_t bp_of_device_modalias(struct device *dev, char *str, ssize_t len)
-{
- ssize_t sl = of_device_get_modalias(dev, str, len - 2);
- if (sl < 0)
- return sl;
- if (sl > len - 2)
- return -ENOMEM;
-
- str[sl++] = '\n';
- str[sl] = 0;
- return sl;
-}
-EXPORT_SYMBOL_GPL(bp_of_device_modalias);
-#endif
-#endif
diff --git a/backport/compat/backport-4.18.c b/backport/compat/backport-4.18.c
deleted file mode 100644
index c47fabe5..00000000
--- a/backport/compat/backport-4.18.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright (C) 2018 Intel Corporation
- */
-
-#include <linux/hrtimer.h>
-
-time64_t ktime_get_boottime_seconds(void)
-{
- return ktime_divns(ktime_get_boottime(), NSEC_PER_SEC);
-}
-EXPORT_SYMBOL_GPL(ktime_get_boottime_seconds);
diff --git a/backport/compat/backport-4.2.c b/backport/compat/backport-4.2.c
deleted file mode 100644
index b275d349..00000000
--- a/backport/compat/backport-4.2.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.2.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <crypto/scatterwalk.h>
-#include <crypto/aead.h>
-
-static struct scatterlist *scatterwalk_ffwd(struct scatterlist dst[2],
- struct scatterlist *src,
- unsigned int len)
-{
- for (;;) {
- if (!len)
- return src;
-
- if (src->length > len)
- break;
-
- len -= src->length;
- src = sg_next(src);
- }
-
- sg_init_table(dst, 2);
- sg_set_page(dst, sg_page(src), src->length - len, src->offset + len);
- scatterwalk_crypto_chain(dst, sg_next(src), 0, 2);
-
- return dst;
-}
-
-struct aead_old_request {
- struct scatterlist srcbuf[2];
- struct scatterlist dstbuf[2];
- struct aead_request subreq;
-};
-
-unsigned int crypto_aead_reqsize(struct crypto_aead *tfm)
-{
- return crypto_aead_crt(tfm)->reqsize + sizeof(struct aead_old_request);
-}
-EXPORT_SYMBOL_GPL(crypto_aead_reqsize);
-
-struct aead_request *crypto_backport_convert(struct aead_request *req)
-{
- struct aead_old_request *nreq = aead_request_ctx(req);
- struct crypto_aead *aead = crypto_aead_reqtfm(req);
- struct scatterlist *src, *dst;
-
- src = scatterwalk_ffwd(nreq->srcbuf, req->src, req->assoclen);
- dst = req->src == req->dst ?
- src : scatterwalk_ffwd(nreq->dstbuf, req->dst, req->assoclen);
-
- aead_request_set_tfm(&nreq->subreq, aead);
- aead_request_set_callback(&nreq->subreq, aead_request_flags(req),
- req->base.complete, req->base.data);
- aead_request_set_crypt(&nreq->subreq, src, dst, req->cryptlen,
- req->iv);
- aead_request_set_assoc(&nreq->subreq, req->src, req->assoclen);
-
- return &nreq->subreq;
-}
-EXPORT_SYMBOL_GPL(crypto_backport_convert);
-
-char *strreplace(char *s, char old, char new)
-{
- for (; *s; ++s)
- if (*s == old)
- *s = new;
- return s;
-}
-EXPORT_SYMBOL_GPL(strreplace);
diff --git a/backport/compat/backport-4.20.c b/backport/compat/backport-4.20.c
deleted file mode 100644
index e26f3b52..00000000
--- a/backport/compat/backport-4.20.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright (C) 2018 Intel Corporation
- *
- * Backport functionality introduced in Linux 4.20.
- * This is basically upstream lib/nlattr.c.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/kernel.h>
-#include <linux/export.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <net/netlink.h>
-
-static const u8 nla_attr_len[NLA_TYPE_MAX+1] = {
- [NLA_U8] = sizeof(u8),
- [NLA_U16] = sizeof(u16),
- [NLA_U32] = sizeof(u32),
- [NLA_U64] = sizeof(u64),
- [NLA_S8] = sizeof(s8),
- [NLA_S16] = sizeof(s16),
- [NLA_S32] = sizeof(s32),
- [NLA_S64] = sizeof(s64),
-};
-
-static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
- [NLA_U8] = sizeof(u8),
- [NLA_U16] = sizeof(u16),
- [NLA_U32] = sizeof(u32),
- [NLA_U64] = sizeof(u64),
- [NLA_MSECS] = sizeof(u64),
- [NLA_NESTED] = NLA_HDRLEN,
- [NLA_S8] = sizeof(s8),
- [NLA_S16] = sizeof(s16),
- [NLA_S32] = sizeof(s32),
- [NLA_S64] = sizeof(s64),
-};
-
-static int validate_nla_bitfield32(const struct nlattr *nla,
- const u32 *valid_flags_mask)
-{
- const struct nla_bitfield32 *bf = nla_data(nla);
-
- if (!valid_flags_mask)
- return -EINVAL;
-
- /*disallow invalid bit selector */
- if (bf->selector & ~*valid_flags_mask)
- return -EINVAL;
-
- /*disallow invalid bit values */
- if (bf->value & ~*valid_flags_mask)
- return -EINVAL;
-
- /*disallow valid bit values that are not selected*/
- if (bf->value & ~bf->selector)
- return -EINVAL;
-
- return 0;
-}
-
-static int nla_validate_array(const struct nlattr *head, int len, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- const struct nlattr *entry;
- int rem;
-
- nla_for_each_attr(entry, head, len, rem) {
- int ret;
-
- if (nla_len(entry) == 0)
- continue;
-
- if (nla_len(entry) < NLA_HDRLEN) {
- NL_SET_ERR_MSG_ATTR(extack, entry,
- "Array element too short");
- return -ERANGE;
- }
-
- ret = nla_validate(nla_data(entry), nla_len(entry),
- maxtype, policy, extack);
- if (ret < 0)
- return ret;
- }
-
- return 0;
-}
-
-static int nla_validate_int_range(const struct nla_policy *pt,
- const struct nlattr *nla,
- struct netlink_ext_ack *extack)
-{
- bool validate_min, validate_max;
- s64 value;
-
- validate_min = pt->validation_type == NLA_VALIDATE_RANGE ||
- pt->validation_type == NLA_VALIDATE_MIN;
- validate_max = pt->validation_type == NLA_VALIDATE_RANGE ||
- pt->validation_type == NLA_VALIDATE_MAX;
-
- switch (pt->type) {
- case NLA_U8:
- value = nla_get_u8(nla);
- break;
- case NLA_U16:
- value = nla_get_u16(nla);
- break;
- case NLA_U32:
- value = nla_get_u32(nla);
- break;
- case NLA_S8:
- value = nla_get_s8(nla);
- break;
- case NLA_S16:
- value = nla_get_s16(nla);
- break;
- case NLA_S32:
- value = nla_get_s32(nla);
- break;
- case NLA_S64:
- value = nla_get_s64(nla);
- break;
- case NLA_U64:
- /* treat this one specially, since it may not fit into s64 */
- if ((validate_min && nla_get_u64(nla) < pt->min) ||
- (validate_max && nla_get_u64(nla) > pt->max)) {
- NL_SET_ERR_MSG_ATTR(extack, nla,
- "integer out of range");
- return -ERANGE;
- }
- return 0;
- default:
- WARN_ON(1);
- return -EINVAL;
- }
-
- if ((validate_min && value < pt->min) ||
- (validate_max && value > pt->max)) {
- NL_SET_ERR_MSG_ATTR(extack, nla,
- "integer out of range");
- return -ERANGE;
- }
-
- return 0;
-}
-
-static int validate_nla(const struct nlattr *nla, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- const struct nla_policy *pt;
- int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
- int err = -ERANGE;
-
- if (type <= 0 || type > maxtype)
- return 0;
-
- pt = &policy[type];
-
- BUG_ON(pt->type > NLA_TYPE_MAX);
-
- if ((nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) ||
- (pt->type == NLA_EXACT_LEN_WARN && attrlen != pt->len)) {
- pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
- current->comm, type);
- }
-
- switch (pt->type) {
- case NLA_EXACT_LEN:
- if (attrlen != pt->len)
- goto out_err;
- break;
-
- case NLA_REJECT:
- if (extack && pt->validation_data) {
- NL_SET_BAD_ATTR(extack, nla);
- extack->_msg = pt->validation_data;
- return -EINVAL;
- }
- err = -EINVAL;
- goto out_err;
-
- case NLA_FLAG:
- if (attrlen > 0)
- goto out_err;
- break;
-
- case NLA_BITFIELD32:
- if (attrlen != sizeof(struct nla_bitfield32))
- goto out_err;
-
- err = validate_nla_bitfield32(nla, pt->validation_data);
- if (err)
- goto out_err;
- break;
-
- case NLA_NUL_STRING:
- if (pt->len)
- minlen = min_t(int, attrlen, pt->len + 1);
- else
- minlen = attrlen;
-
- if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL) {
- err = -EINVAL;
- goto out_err;
- }
- /* fall through */
-
- case NLA_STRING:
- if (attrlen < 1)
- goto out_err;
-
- if (pt->len) {
- char *buf = nla_data(nla);
-
- if (buf[attrlen - 1] == '\0')
- attrlen--;
-
- if (attrlen > pt->len)
- goto out_err;
- }
- break;
-
- case NLA_BINARY:
- if (pt->len && attrlen > pt->len)
- goto out_err;
- break;
-
- case NLA_NESTED:
- /* a nested attributes is allowed to be empty; if its not,
- * it must have a size of at least NLA_HDRLEN.
- */
- if (attrlen == 0)
- break;
- if (attrlen < NLA_HDRLEN)
- goto out_err;
- if (pt->validation_data) {
- err = nla_validate(nla_data(nla), nla_len(nla), pt->len,
- pt->validation_data, extack);
- if (err < 0) {
- /*
- * return directly to preserve the inner
- * error message/attribute pointer
- */
- return err;
- }
- }
- break;
- case NLA_NESTED_ARRAY:
- /* a nested array attribute is allowed to be empty; if its not,
- * it must have a size of at least NLA_HDRLEN.
- */
- if (attrlen == 0)
- break;
- if (attrlen < NLA_HDRLEN)
- goto out_err;
- if (pt->validation_data) {
- int err;
-
- err = nla_validate_array(nla_data(nla), nla_len(nla),
- pt->len, pt->validation_data,
- extack);
- if (err < 0) {
- /*
- * return directly to preserve the inner
- * error message/attribute pointer
- */
- return err;
- }
- }
- break;
- default:
- if (pt->len)
- minlen = pt->len;
- else if (pt->type != NLA_UNSPEC)
- minlen = nla_attr_minlen[pt->type];
-
- if (attrlen < minlen)
- goto out_err;
- }
-
- /* further validation */
- switch (pt->validation_type) {
- case NLA_VALIDATE_NONE:
- /* nothing to do */
- break;
- case NLA_VALIDATE_RANGE:
- case NLA_VALIDATE_MIN:
- case NLA_VALIDATE_MAX:
- err = nla_validate_int_range(pt, nla, extack);
- if (err)
- return err;
- break;
- case NLA_VALIDATE_FUNCTION:
- if (pt->validate) {
- err = pt->validate(nla, extack);
- if (err)
- return err;
- }
- break;
- }
-
- return 0;
-out_err:
- NL_SET_ERR_MSG_ATTR(extack, nla, "Attribute failed policy validation");
- return err;
-}
-
-int backport_nla_validate(const struct nlattr *head, int len, int maxtype,
- const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- const struct nlattr *nla;
- int rem;
-
- nla_for_each_attr(nla, head, len, rem) {
- int err = validate_nla(nla, maxtype, policy, extack);
-
- if (err < 0)
- return err;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(backport_nla_validate);
-
-int backport_nla_policy_len(const struct nla_policy *p, int n)
-{
- int i, len = 0;
-
- for (i = 0; i < n; i++, p++) {
- if (p->len)
- len += nla_total_size(p->len);
- else if (nla_attr_len[p->type])
- len += nla_total_size(nla_attr_len[p->type]);
- else if (nla_attr_minlen[p->type])
- len += nla_total_size(nla_attr_minlen[p->type]);
- }
-
- return len;
-}
-EXPORT_SYMBOL_GPL(backport_nla_policy_len);
-
-int backport_nla_parse(struct nlattr **tb, int maxtype,
- const struct nlattr *head,
- int len, const struct nla_policy *policy,
- struct netlink_ext_ack *extack)
-{
- const struct nlattr *nla;
- int rem;
-
- memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
-
- nla_for_each_attr(nla, head, len, rem) {
- u16 type = nla_type(nla);
-
- if (type > 0 && type <= maxtype) {
- if (policy) {
- int err = validate_nla(nla, maxtype, policy,
- extack);
-
- if (err < 0)
- return err;
- }
-
- tb[type] = (struct nlattr *)nla;
- }
- }
-
- if (unlikely(rem > 0))
- pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
- rem, current->comm);
-
- return 0;
-}
-EXPORT_SYMBOL(backport_nla_parse);
diff --git a/backport/compat/backport-4.3.c b/backport/compat/backport-4.3.c
deleted file mode 100644
index 04698ad3..00000000
--- a/backport/compat/backport-4.3.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- * Copyright (c) 2015 - 2016 Intel Deutschland GmbH
- *
- * Backport functionality introduced in Linux 4.3.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/version.h>
-#include <linux/seq_file.h>
-#include <linux/export.h>
-#include <linux/printk.h>
-#include <linux/thermal.h>
-#include <linux/slab.h>
-#include <linux/property.h>
-#include <linux/etherdevice.h>
-#include <linux/of.h>
-
-#ifdef CONFIG_THERMAL
-#if LINUX_VERSION_IS_GEQ(3,8,0)
-struct backport_thermal_ops_wrapper {
- old_thermal_zone_device_ops_t ops;
- struct thermal_zone_device_ops *driver_ops;
-};
-
-static int backport_thermal_get_temp(struct thermal_zone_device *dev,
- unsigned long *temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
- int _temp, ret;
-
- ret = wrapper->driver_ops->get_temp(dev, &_temp);
- if (!ret)
- *temp = (unsigned long)_temp;
-
- return ret;
-}
-
-static int backport_thermal_get_trip_temp(struct thermal_zone_device *dev,
- int i, unsigned long *temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
- int _temp, ret;
-
- ret = wrapper->driver_ops->get_trip_temp(dev, i, &_temp);
- if (!ret)
- *temp = (unsigned long)_temp;
-
- return ret;
-}
-
-static int backport_thermal_set_trip_temp(struct thermal_zone_device *dev,
- int i, unsigned long temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
-
- return wrapper->driver_ops->set_trip_temp(dev, i, (int)temp);
-}
-
-static int backport_thermal_get_trip_hyst(struct thermal_zone_device *dev,
- int i, unsigned long *temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
- int _temp, ret;
-
- ret = wrapper->driver_ops->get_trip_hyst(dev, i, &_temp);
- if (!ret)
- *temp = (unsigned long)_temp;
-
- return ret;
-}
-
-static int backport_thermal_set_trip_hyst(struct thermal_zone_device *dev,
- int i, unsigned long temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
-
- return wrapper->driver_ops->set_trip_hyst(dev, i, (int)temp);
-}
-
-static int backport_thermal_get_crit_temp(struct thermal_zone_device *dev,
- unsigned long *temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
- int _temp, ret;
-
- ret = wrapper->driver_ops->get_crit_temp(dev, &_temp);
- if (!ret)
- *temp = (unsigned long)_temp;
-
- return ret;
-}
-
-#if LINUX_VERSION_IS_GEQ(3, 19, 0)
-static int backport_thermal_set_emul_temp(struct thermal_zone_device *dev,
- unsigned long temp)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
-
- return wrapper->driver_ops->set_emul_temp(dev, (int)temp);
-}
-#endif /* LINUX_VERSION_IS_GEQ(3, 19, 0) */
-
-struct thermal_zone_device *backport_thermal_zone_device_register(
- const char *type, int trips, int mask, void *devdata,
- struct thermal_zone_device_ops *ops,
- const struct thermal_zone_params *tzp,
- int passive_delay, int polling_delay)
-{
- struct backport_thermal_ops_wrapper *wrapper = kzalloc(sizeof(*wrapper), GFP_KERNEL);
- struct thermal_zone_device *ret;
-
- if (!wrapper)
- return NULL;
-
- wrapper->driver_ops = ops;
-
-#define copy(_op) \
- wrapper->ops._op = ops->_op
-
- copy(bind);
- copy(unbind);
- copy(get_mode);
- copy(set_mode);
- copy(get_trip_type);
- copy(get_trend);
- copy(notify);
-
- /* Assign the backport ops to the old struct to get the
- * correct types. But only assign if the registrant defined
- * the ops.
- */
-#define assign_ops(_op) \
- if (ops->_op) \
- wrapper->ops._op = backport_thermal_##_op
-
- assign_ops(get_temp);
- assign_ops(get_trip_temp);
- assign_ops(set_trip_temp);
- assign_ops(get_trip_hyst);
- assign_ops(set_trip_hyst);
- assign_ops(get_crit_temp);
-#if LINUX_VERSION_IS_GEQ(3, 19, 0)
- assign_ops(set_emul_temp);
-#endif /* LINUX_VERSION_IS_GEQ(3, 19, 0) */
-#undef assign_ops
-
- ret = old_thermal_zone_device_register(type, trips, mask, devdata,
- &wrapper->ops, tzp, passive_delay,
- polling_delay);
- if (!ret)
- kfree(wrapper);
- return ret;
-}
-EXPORT_SYMBOL_GPL(backport_thermal_zone_device_register);
-
-void backport_thermal_zone_device_unregister(struct thermal_zone_device *dev)
-{
- struct backport_thermal_ops_wrapper *wrapper =
- container_of(dev->ops, struct backport_thermal_ops_wrapper, ops);
-
- old_thermal_zone_device_unregister(dev);
- kfree(wrapper);
-}
-EXPORT_SYMBOL_GPL(backport_thermal_zone_device_unregister);
-
-#endif /* >= 3.8.0 */
-#endif /* CONFIG_THERMAL */
-
-static void seq_set_overflow(struct seq_file *m)
-{
- m->count = m->size;
-}
-
-/* A complete analogue of print_hex_dump() */
-void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
- int rowsize, int groupsize, const void *buf, size_t len,
- bool ascii)
-{
- const u8 *ptr = buf;
- int i, linelen, remaining = len;
- int ret;
-
- if (rowsize != 16 && rowsize != 32)
- rowsize = 16;
-
- for (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {
- linelen = min(remaining, rowsize);
- remaining -= rowsize;
-
- switch (prefix_type) {
- case DUMP_PREFIX_ADDRESS:
- seq_printf(m, "%s%p: ", prefix_str, ptr + i);
- break;
- case DUMP_PREFIX_OFFSET:
- seq_printf(m, "%s%.8x: ", prefix_str, i);
- break;
- default:
- seq_printf(m, "%s", prefix_str);
- break;
- }
-
- ret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
- m->buf + m->count, m->size - m->count,
- ascii);
- if (ret >= m->size - m->count) {
- seq_set_overflow(m);
- } else {
- m->count += ret;
- seq_putc(m, '\n');
- }
- }
-}
-EXPORT_SYMBOL_GPL(seq_hex_dump);
-
-ssize_t strscpy(char *dest, const char *src, size_t count)
-{
- long res = 0;
-
- if (count == 0)
- return -E2BIG;
-
- while (count) {
- char c;
-
- c = src[res];
- dest[res] = c;
- if (!c)
- return res;
- res++;
- count--;
- }
-
- /* Hit buffer length without finding a NUL; force NUL-termination. */
- if (res)
- dest[res-1] = '\0';
-
- return -E2BIG;
-}
-EXPORT_SYMBOL_GPL(strscpy);
-
-static void *device_get_mac_addr(struct device *dev,
- const char *name, char *addr,
- int alen)
-{
-#if LINUX_VERSION_IS_GEQ(3,18,0)
- int ret = device_property_read_u8_array(dev, name, addr, alen);
-#else
- int ret = of_property_read_u8_array(dev->of_node, name, addr, alen);
-#endif
-
- if (ret == 0 && alen == ETH_ALEN && is_valid_ether_addr(addr))
- return addr;
- return NULL;
-}
-
-/**
- * device_get_mac_address - Get the MAC for a given device
- * @dev: Pointer to the device
- * @addr: Address of buffer to store the MAC in
- * @alen: Length of the buffer pointed to by addr, should be ETH_ALEN
- *
- * Search the firmware node for the best MAC address to use. 'mac-address' is
- * checked first, because that is supposed to contain to "most recent" MAC
- * address. If that isn't set, then 'local-mac-address' is checked next,
- * because that is the default address. If that isn't set, then the obsolete
- * 'address' is checked, just in case we're using an old device tree.
- *
- * Note that the 'address' property is supposed to contain a virtual address of
- * the register set, but some DTS files have redefined that property to be the
- * MAC address.
- *
- * All-zero MAC addresses are rejected, because those could be properties that
- * exist in the firmware tables, but were not updated by the firmware. For
- * example, the DTS could define 'mac-address' and 'local-mac-address', with
- * zero MAC addresses. Some older U-Boots only initialized 'local-mac-address'.
- * In this case, the real MAC is in 'local-mac-address', and 'mac-address'
- * exists but is all zeros.
-*/
-void *device_get_mac_address(struct device *dev, char *addr, int alen)
-{
- char *res;
-
- res = device_get_mac_addr(dev, "mac-address", addr, alen);
- if (res)
- return res;
-
- res = device_get_mac_addr(dev, "local-mac-address", addr, alen);
- if (res)
- return res;
-
- return device_get_mac_addr(dev, "address", addr, alen);
-}
-EXPORT_SYMBOL_GPL(device_get_mac_address);
diff --git a/backport/compat/backport-4.4.c b/backport/compat/backport-4.4.c
deleted file mode 100644
index 7966e949..00000000
--- a/backport/compat/backport-4.4.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright(c) 2015 Intel Deutschland GmbH
- *
- * Backport functionality introduced in Linux 4.4.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/debugfs.h>
-#include <linux/export.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-#include <linux/if_vlan.h>
-#include <linux/mm.h>
-#include <linux/skbuff.h>
-#include <linux/tcp.h>
-#include <net/ip.h>
-#include <net/tso.h>
-#include <asm/unaligned.h>
-
-#ifdef CONFIG_DEBUG_FS
-#if LINUX_VERSION_IS_LESS(4,3,0)
-static ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- char buf[3];
- bool *val = file->private_data;
-
- if (*val)
- buf[0] = 'Y';
- else
- buf[0] = 'N';
- buf[1] = '\n';
- buf[2] = 0x00;
- return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
-}
-
-static ssize_t debugfs_write_file_bool(struct file *file,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
-{
- char buf[32];
- size_t buf_size;
- bool bv;
- bool *val = file->private_data;
-
- buf_size = min(count, (sizeof(buf)-1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
- if (strtobool(buf, &bv) == 0)
- *val = bv;
-
- return count;
-}
-#endif /* < 4.3.0 */
-
-static const struct file_operations fops_bool = {
- .read = debugfs_read_file_bool,
- .write = debugfs_write_file_bool,
- .open = simple_open,
- .llseek = default_llseek,
-};
-
-struct dentry *debugfs_create_bool(const char *name, umode_t mode,
- struct dentry *parent, bool *value)
-{
- return debugfs_create_file(name, mode, parent, value, &fops_bool);
-}
-EXPORT_SYMBOL_GPL(debugfs_create_bool);
-#endif /* CONFIG_DEBUG_FS */
-
-/* Calculate expected number of TX descriptors */
-int tso_count_descs(struct sk_buff *skb)
-{
- /* The Marvell Way */
- return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags;
-}
-EXPORT_SYMBOL(tso_count_descs);
-
-void tso_build_hdr(struct sk_buff *skb, char *hdr, struct tso_t *tso,
- int size, bool is_last)
-{
- struct tcphdr *tcph;
- int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
- int mac_hdr_len = skb_network_offset(skb);
-
- memcpy(hdr, skb->data, hdr_len);
- if (!tso->ipv6) {
- struct iphdr *iph = (void *)(hdr + mac_hdr_len);
-
- iph->id = htons(tso->ip_id);
- iph->tot_len = htons(size + hdr_len - mac_hdr_len);
- tso->ip_id++;
- } else {
-#ifdef CONFIG_IPV6
- struct ipv6hdr *iph = (void *)(hdr + mac_hdr_len);
-
- iph->payload_len = htons(size + tcp_hdrlen(skb));
-#else /* CONFIG_IPV6 */
- /* tso->ipv6 should never be set if IPV6 is not enabeld */
- WARN_ON(1);
-#endif /* CONFIG_IPV6 */
- }
- tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb));
- put_unaligned_be32(tso->tcp_seq, &tcph->seq);
-
- if (!is_last) {
- /* Clear all special flags for not last packet */
- tcph->psh = 0;
- tcph->fin = 0;
- tcph->rst = 0;
- }
-}
-EXPORT_SYMBOL(tso_build_hdr);
-
-void tso_build_data(struct sk_buff *skb, struct tso_t *tso, int size)
-{
- tso->tcp_seq += size;
- tso->size -= size;
- tso->data += size;
-
- if ((tso->size == 0) &&
- (tso->next_frag_idx < skb_shinfo(skb)->nr_frags)) {
- skb_frag_t *frag = &skb_shinfo(skb)->frags[tso->next_frag_idx];
-
- /* Move to next segment */
- tso->size = frag->size;
- tso->data = page_address(skb_frag_page(frag)) + frag->page_offset;
- tso->next_frag_idx++;
- }
-}
-EXPORT_SYMBOL(tso_build_data);
-
-void tso_start(struct sk_buff *skb, struct tso_t *tso)
-{
- int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-
- tso->ip_id = ntohs(ip_hdr(skb)->id);
- tso->tcp_seq = ntohl(tcp_hdr(skb)->seq);
- tso->next_frag_idx = 0;
- tso->ipv6 = vlan_get_protocol(skb) == htons(ETH_P_IPV6);
-
- /* Build first data */
- tso->size = skb_headlen(skb) - hdr_len;
- tso->data = skb->data + hdr_len;
- if ((tso->size == 0) &&
- (tso->next_frag_idx < skb_shinfo(skb)->nr_frags)) {
- skb_frag_t *frag = &skb_shinfo(skb)->frags[tso->next_frag_idx];
-
- /* Move to next segment */
- tso->size = frag->size;
- tso->data = page_address(skb_frag_page(frag)) + frag->page_offset;
- tso->next_frag_idx++;
- }
-}
-EXPORT_SYMBOL(tso_start);
diff --git a/backport/compat/backport-4.5.c b/backport/compat/backport-4.5.c
deleted file mode 100644
index 13764dc7..00000000
--- a/backport/compat/backport-4.5.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright(c) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.5.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/device.h>
-#include <linux/export.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/leds.h>
-#include <linux/phy.h>
-#include <linux/printk.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-#if LINUX_VERSION_IS_GEQ(3,19,0)
-int led_set_brightness_sync(struct led_classdev *led_cdev,
- enum led_brightness value)
-{
- if (led_cdev->blink_delay_on || led_cdev->blink_delay_off)
- return -EBUSY;
-
- led_cdev->brightness = min(value, led_cdev->max_brightness);
-
- if (led_cdev->flags & LED_SUSPENDED)
- return 0;
-
- if (led_cdev->brightness_set_sync)
- return led_cdev->brightness_set_sync(led_cdev,
- led_cdev->brightness);
- return -ENOTSUPP;
-}
-EXPORT_SYMBOL_GPL(led_set_brightness_sync);
-#endif /* >= 3.19 */
-
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-/**
- * no_seek_end_llseek - llseek implementation for fixed-sized devices
- * @file: file structure to seek on
- * @offset: file offset to seek to
- * @whence: type of seek
- *
- */
-loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
-{
- switch (whence) {
- case SEEK_SET: case SEEK_CUR:
-#if LINUX_VERSION_IS_GEQ(3,6,0)
- return generic_file_llseek_size(file, offset, whence,
- ~0ULL, 0);
-#else
- return generic_file_llseek_size(file, offset, whence,
- ~0ULL);
-#endif
- default:
- return -EINVAL;
- }
-}
-EXPORT_SYMBOL_GPL(no_seek_end_llseek);
-#endif /* >= 3.2 */
-
-/**
- * memdup_user_nul - duplicate memory region from user space and NUL-terminate
- *
- * @src: source address in user space
- * @len: number of bytes to copy
- *
- * Returns an ERR_PTR() on failure.
- */
-void *memdup_user_nul(const void __user *src, size_t len)
-{
- char *p;
-
- /*
- * Always use GFP_KERNEL, since copy_from_user() can sleep and
- * cause pagefault, which makes it pointless to use GFP_NOFS
- * or GFP_ATOMIC.
- */
- p = kmalloc(len + 1, GFP_KERNEL);
- if (!p)
- return ERR_PTR(-ENOMEM);
-
- if (copy_from_user(p, src, len)) {
- kfree(p);
- return ERR_PTR(-EFAULT);
- }
- p[len] = '\0';
-
- return p;
-}
-EXPORT_SYMBOL_GPL(memdup_user_nul);
-
-void phy_attached_info(struct phy_device *phydev)
-{
- phy_attached_print(phydev, NULL);
-}
-EXPORT_SYMBOL_GPL(phy_attached_info);
-
-#define ATTACHED_FMT "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)"
-void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
-{
- if (!fmt) {
- dev_info(&phydev->dev, ATTACHED_FMT "\n",
- phydev->drv->name, phydev_name(phydev),
- phydev->irq);
- } else {
- va_list ap;
-
- dev_info(&phydev->dev, ATTACHED_FMT,
- phydev->drv->name, phydev_name(phydev),
- phydev->irq);
-
- va_start(ap, fmt);
- vprintk(fmt, ap);
- va_end(ap);
- }
-}
-EXPORT_SYMBOL_GPL(phy_attached_print);
-
-static void devm_led_trigger_release(struct device *dev, void *res)
-{
- led_trigger_unregister(*(struct led_trigger **)res);
-}
-
-int devm_led_trigger_register(struct device *dev,
- struct led_trigger *trig)
-{
- struct led_trigger **dr;
- int rc;
-
- dr = devres_alloc(devm_led_trigger_release, sizeof(*dr),
- GFP_KERNEL);
- if (!dr)
- return -ENOMEM;
-
- *dr = trig;
-
- rc = led_trigger_register(trig);
- if (rc)
- devres_free(dr);
- else
- devres_add(dev, dr);
-
- return rc;
-}
-EXPORT_SYMBOL_GPL(devm_led_trigger_register);
diff --git a/backport/compat/backport-4.6.c b/backport/compat/backport-4.6.c
deleted file mode 100644
index 8d0ecf56..00000000
--- a/backport/compat/backport-4.6.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright(c) 2016 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.6.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/uaccess.h>
-#include <linux/export.h>
-
-/**
- * kstrtobool - convert common user inputs into boolean values
- * @s: input string
- * @res: result
- *
- * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
- * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value
- * pointed to by res is updated upon finding a match.
- */
-int kstrtobool(const char *s, bool *res)
-{
- if (!s)
- return -EINVAL;
-
- switch (s[0]) {
- case 'y':
- case 'Y':
- case '1':
- *res = true;
- return 0;
- case 'n':
- case 'N':
- case '0':
- *res = false;
- return 0;
- case 'o':
- case 'O':
- switch (s[1]) {
- case 'n':
- case 'N':
- *res = true;
- return 0;
- case 'f':
- case 'F':
- *res = false;
- return 0;
- default:
- break;
- }
- default:
- break;
- }
-
- return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(kstrtobool);
-
-/*
- * Since "base" would be a nonsense argument, this open-codes the
- * _from_user helper instead of using the helper macro below.
- */
-int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
-{
- /* Longest string needed to differentiate, newline, terminator */
- char buf[4];
-
- count = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, s, count))
- return -EFAULT;
- buf[count] = '\0';
- return kstrtobool(buf, res);
-}
-EXPORT_SYMBOL_GPL(kstrtobool_from_user);
-
-/**
- * match_string - matches given string in an array
- * @array: array of strings
- * @n: number of strings in the array or -1 for NULL terminated arrays
- * @string: string to match with
- *
- * Return:
- * index of a @string in the @array if matches, or %-EINVAL otherwise.
- */
-int match_string(const char * const *array, size_t n, const char *string)
-{
- int index;
- const char *item;
-
- for (index = 0; index < n; index++) {
- item = array[index];
- if (!item)
- break;
- if (!strcmp(item, string))
- return index;
- }
-
- return -EINVAL;
-}
-EXPORT_SYMBOL(match_string);
diff --git a/backport/compat/backport-4.7.c b/backport/compat/backport-4.7.c
deleted file mode 100644
index 372951b6..00000000
--- a/backport/compat/backport-4.7.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright(c) 2016 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Backport functionality introduced in Linux 4.7.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/export.h>
-#include <linux/list.h>
-#include <linux/rcupdate.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/skbuff.h>
-#include <net/netlink.h>
-
-/**
- * __nla_reserve_64bit - reserve room for attribute on the skb and align it
- * @skb: socket buffer to reserve room on
- * @attrtype: attribute type
- * @attrlen: length of attribute payload
- *
- * Adds a netlink attribute header to a socket buffer and reserves
- * room for the payload but does not copy it. It also ensure that this
- * attribute will be 64-bit aign.
- *
- * The caller is responsible to ensure that the skb provides enough
- * tailroom for the attribute header and payload.
- */
-struct nlattr *__nla_reserve_64bit(struct sk_buff *skb, int attrtype,
- int attrlen, int padattr)
-{
- if (nla_need_padding_for_64bit(skb))
- nla_align_64bit(skb, padattr);
-
- return __nla_reserve(skb, attrtype, attrlen);
-}
-EXPORT_SYMBOL_GPL(__nla_reserve_64bit);
-
-/**
- * nla_reserve_64bit - reserve room for attribute on the skb and align it
- * @skb: socket buffer to reserve room on
- * @attrtype: attribute type
- * @attrlen: length of attribute payload
- *
- * Adds a netlink attribute header to a socket buffer and reserves
- * room for the payload but does not copy it. It also ensure that this
- * attribute will be 64-bit aign.
- *
- * Returns NULL if the tailroom of the skb is insufficient to store
- * the attribute header and payload.
- */
-struct nlattr *nla_reserve_64bit(struct sk_buff *skb, int attrtype, int attrlen,
- int padattr)
-{
- size_t len;
-
- if (nla_need_padding_for_64bit(skb))
- len = nla_total_size_64bit(attrlen);
- else
- len = nla_total_size(attrlen);
- if (unlikely(skb_tailroom(skb) < len))
- return NULL;
-
- return __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
-}
-EXPORT_SYMBOL_GPL(nla_reserve_64bit);
-
-/**
- * __nla_put_64bit - Add a netlink attribute to a socket buffer and align it
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @attrlen: length of attribute payload
- * @data: head of attribute payload
- *
- * The caller is responsible to ensure that the skb provides enough
- * tailroom for the attribute header and payload.
- */
-void __nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
- const void *data, int padattr)
-{
- struct nlattr *nla;
-
- nla = __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
- memcpy(nla_data(nla), data, attrlen);
-}
-EXPORT_SYMBOL_GPL(__nla_put_64bit);
-
-/**
- * nla_put_64bit - Add a netlink attribute to a socket buffer and align it
- * @skb: socket buffer to add attribute to
- * @attrtype: attribute type
- * @attrtype: attribute type
- * @attrlen: length of attribute payload
- * @data: head of attribute payload
- *
- * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
- * the attribute header and payload.
- */
-int nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
- const void *data, int padattr)
-{
- size_t len;
-
- if (nla_need_padding_for_64bit(skb))
- len = nla_total_size_64bit(attrlen);
- else
- len = nla_total_size(attrlen);
- if (unlikely(skb_tailroom(skb) < len))
- return -EMSGSIZE;
-
- __nla_put_64bit(skb, attrtype, attrlen, data, padattr);
- return 0;
-}
-EXPORT_SYMBOL_GPL(nla_put_64bit);
-
-/*
- * Below 3.18 or if the kernel has devcoredump disabled, we copied the
- * entire devcoredump, so no need to define these functions.
- */
-#if LINUX_VERSION_IS_GEQ(3,18,0) && \
- !defined(CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP)
-#include <linux/devcoredump.h>
-#include <linux/scatterlist.h>
-
-static void devcd_free_sgtable(void *data)
-{
- struct scatterlist *table = data;
- int i;
- struct page *page;
- struct scatterlist *iter;
- struct scatterlist *delete_iter;
-
- /* free pages */
- iter = table;
- for_each_sg(table, iter, sg_nents(table), i) {
- page = sg_page(iter);
- if (page)
- __free_page(page);
- }
-
- /* then free all chained tables */
- iter = table;
- delete_iter = table; /* always points on a head of a table */
- while (!sg_is_last(iter)) {
- iter++;
- if (sg_is_chain(iter)) {
- iter = sg_chain_ptr(iter);
- kfree(delete_iter);
- delete_iter = iter;
- }
- }
-
- /* free the last table */
- kfree(delete_iter);
-}
-
-static ssize_t devcd_read_from_sgtable(char *buffer, loff_t offset,
- size_t buf_len, void *data,
- size_t data_len)
-{
- struct scatterlist *table = data;
-
- if (offset > data_len)
- return -EINVAL;
-
- if (offset + buf_len > data_len)
- buf_len = data_len - offset;
- return sg_pcopy_to_buffer(table, sg_nents(table), buffer, buf_len,
- offset);
-}
-
-void dev_coredumpsg(struct device *dev, struct scatterlist *table,
- size_t datalen, gfp_t gfp)
-{
- dev_coredumpm(dev, THIS_MODULE, table, datalen, gfp,
- /* cast away some const problems */
- (void *)devcd_read_from_sgtable,
- (void *)devcd_free_sgtable);
-}
-EXPORT_SYMBOL_GPL(dev_coredumpsg);
-#endif /* >= 3.18.0 */
diff --git a/backport/compat/backport-4.8.c b/backport/compat/backport-4.8.c
deleted file mode 100644
index 11b2e7d7..00000000
--- a/backport/compat/backport-4.8.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright(c) 2017 Intel Deutschland GmbH
- *
- * Backport functionality introduced in Linux 4.8.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/usb.h>
-#include <linux/usb/cdc.h>
-#include <linux/pci.h>
-
-int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
- struct usb_interface *intf,
- u8 *buffer, int buflen)
-{
- /* duplicates are ignored */
- struct usb_cdc_union_desc *union_header = NULL;
-
- /* duplicates are not tolerated */
- struct usb_cdc_header_desc *header = NULL;
- struct usb_cdc_ether_desc *ether = NULL;
- struct usb_cdc_mdlm_detail_desc *detail = NULL;
- struct usb_cdc_mdlm_desc *desc = NULL;
-
- unsigned int elength;
- int cnt = 0;
-
- memset(hdr, 0x00, sizeof(struct usb_cdc_parsed_header));
- hdr->phonet_magic_present = false;
- while (buflen > 0) {
- elength = buffer[0];
- if (!elength) {
- dev_err(&intf->dev, "skipping garbage byte\n");
- elength = 1;
- goto next_desc;
- }
- if (buffer[1] != USB_DT_CS_INTERFACE) {
- dev_err(&intf->dev, "skipping garbage\n");
- goto next_desc;
- }
-
- switch (buffer[2]) {
- case USB_CDC_UNION_TYPE: /* we've found it */
- if (elength < sizeof(struct usb_cdc_union_desc))
- goto next_desc;
- if (union_header) {
- dev_err(&intf->dev, "More than one union descriptor, skipping ...\n");
- goto next_desc;
- }
- union_header = (struct usb_cdc_union_desc *)buffer;
- break;
- case USB_CDC_COUNTRY_TYPE:
- if (elength < sizeof(struct usb_cdc_country_functional_desc))
- goto next_desc;
- hdr->usb_cdc_country_functional_desc =
- (struct usb_cdc_country_functional_desc *)buffer;
- break;
- case USB_CDC_HEADER_TYPE:
- if (elength != sizeof(struct usb_cdc_header_desc))
- goto next_desc;
- if (header)
- return -EINVAL;
- header = (struct usb_cdc_header_desc *)buffer;
- break;
- case USB_CDC_ACM_TYPE:
- if (elength < sizeof(struct usb_cdc_acm_descriptor))
- goto next_desc;
- hdr->usb_cdc_acm_descriptor =
- (struct usb_cdc_acm_descriptor *)buffer;
- break;
- case USB_CDC_ETHERNET_TYPE:
- if (elength != sizeof(struct usb_cdc_ether_desc))
- goto next_desc;
- if (ether)
- return -EINVAL;
- ether = (struct usb_cdc_ether_desc *)buffer;
- break;
- case USB_CDC_CALL_MANAGEMENT_TYPE:
- if (elength < sizeof(struct usb_cdc_call_mgmt_descriptor))
- goto next_desc;
- hdr->usb_cdc_call_mgmt_descriptor =
- (struct usb_cdc_call_mgmt_descriptor *)buffer;
- break;
- case USB_CDC_DMM_TYPE:
- if (elength < sizeof(struct usb_cdc_dmm_desc))
- goto next_desc;
- hdr->usb_cdc_dmm_desc =
- (struct usb_cdc_dmm_desc *)buffer;
- break;
- case USB_CDC_MDLM_TYPE:
- if (elength < sizeof(struct usb_cdc_mdlm_desc *))
- goto next_desc;
- if (desc)
- return -EINVAL;
- desc = (struct usb_cdc_mdlm_desc *)buffer;
- break;
- case USB_CDC_MDLM_DETAIL_TYPE:
- if (elength < sizeof(struct usb_cdc_mdlm_detail_desc *))
- goto next_desc;
- if (detail)
- return -EINVAL;
- detail = (struct usb_cdc_mdlm_detail_desc *)buffer;
- break;
- case USB_CDC_NCM_TYPE:
- if (elength < sizeof(struct usb_cdc_ncm_desc))
- goto next_desc;
- hdr->usb_cdc_ncm_desc = (struct usb_cdc_ncm_desc *)buffer;
- break;
- case USB_CDC_MBIM_TYPE:
- if (elength < sizeof(struct usb_cdc_mbim_desc))
- goto next_desc;
-
- hdr->usb_cdc_mbim_desc = (struct usb_cdc_mbim_desc *)buffer;
- break;
- case USB_CDC_MBIM_EXTENDED_TYPE:
- if (elength < sizeof(struct usb_cdc_mbim_extended_desc))
- break;
- hdr->usb_cdc_mbim_extended_desc =
- (struct usb_cdc_mbim_extended_desc *)buffer;
- break;
- case CDC_PHONET_MAGIC_NUMBER:
- hdr->phonet_magic_present = true;
- break;
- default:
- /*
- * there are LOTS more CDC descriptors that
- * could legitimately be found here.
- */
- dev_dbg(&intf->dev, "Ignoring descriptor: type %02x, length %ud\n",
- buffer[2], elength);
- goto next_desc;
- }
- cnt++;
-next_desc:
- buflen -= elength;
- buffer += elength;
- }
- hdr->usb_cdc_union_desc = union_header;
- hdr->usb_cdc_header_desc = header;
- hdr->usb_cdc_mdlm_detail_desc = detail;
- hdr->usb_cdc_mdlm_desc = desc;
- hdr->usb_cdc_ether_desc = ether;
- return cnt;
-}
-EXPORT_SYMBOL_GPL(cdc_parse_cdc_header);
-
-#ifdef CONFIG_PCI
-#ifdef CONFIG_PCI_MSI
-
-/**
- * pci_alloc_irq_vectors - allocate multiple IRQs for a device
- * @dev: PCI device to operate on
- * @min_vecs: minimum number of vectors required (must be >= 1)
- * @max_vecs: maximum (desired) number of vectors
- * @flags: flags or quirks for the allocation
- *
- * Allocate up to @max_vecs interrupt vectors for @dev, using MSI-X or MSI
- * vectors if available, and fall back to a single legacy vector
- * if neither is available. Return the number of vectors allocated,
- * (which might be smaller than @max_vecs) if successful, or a negative
- * error code on error. If less than @min_vecs interrupt vectors are
- * available for @dev the function will fail with -ENOSPC.
- *
- * To get the Linux IRQ number used for a vector that can be passed to
- * request_irq() use the pci_irq_vector() helper.
- */
-int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
- unsigned int max_vecs, unsigned int flags)
-{
- int vecs = -ENOSPC;
-
- if (flags & PCI_IRQ_MSIX) {
- vecs = pci_enable_msix_range(dev, NULL, min_vecs, max_vecs);
- if (vecs > 0)
- return vecs;
- }
-
- if (flags & PCI_IRQ_MSI) {
- vecs = pci_enable_msi_range(dev, min_vecs, max_vecs);
- if (vecs > 0)
- return vecs;
- }
-
- /* use legacy irq if allowed */
- if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1) {
- pci_intx(dev, 1);
- return 1;
- }
-
- return vecs;
-}
-EXPORT_SYMBOL_GPL(pci_alloc_irq_vectors);
-#endif /* CONFIG_PCI_MSI */
-#endif /* CONFIG_PCI */
diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
deleted file mode 100644
index 71bf45ad..00000000
--- a/backport/compat/backport-genetlink.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
- *
- * Backport functionality introduced in Linux 4.20.
- * Much of this is based on upstream lib/nlattr.c.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/kernel.h>
-#include <linux/export.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <net/genetlink.h>
-#include <net/netlink.h>
-#include <net/sock.h>
-
-static const struct genl_family *find_family_real_ops(__genl_const struct genl_ops **ops)
-{
- const struct genl_family *family;
- const struct genl_ops *tmp_ops = *ops;
-
- /* find the family ... */
- while (tmp_ops->doit || tmp_ops->dumpit)
- tmp_ops++;
- family = (void *)tmp_ops->done;
-
- /* cast to suppress const warning */
- *ops = (void *)(family->ops + (*ops - family->copy_ops));
-
- return family;
-}
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-enum nlmsgerr_attrs {
- NLMSGERR_ATTR_UNUSED,
- NLMSGERR_ATTR_MSG,
- NLMSGERR_ATTR_OFFS,
- NLMSGERR_ATTR_COOKIE,
- __NLMSGERR_ATTR_MAX,
- NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
-};
-
-#define NLM_F_CAPPED 0x100 /* request was capped */
-#define NLM_F_ACK_TLVS 0x200 /* extended ACK TVLs were included */
-
-static void extack_netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh,
- int err, const struct netlink_ext_ack *extack)
-{
- struct sk_buff *skb;
- struct nlmsghdr *rep;
- struct nlmsgerr *errmsg;
- size_t payload = sizeof(*errmsg);
- size_t tlvlen = 0;
- unsigned int flags = 0;
- /* backports assumes everyone supports this - libnl does so it's true */
- bool nlk_has_extack = true;
-
- /* Error messages get the original request appened, unless the user
- * requests to cap the error message, and get extra error data if
- * requested.
- * (ignored in backports)
- */
- if (nlk_has_extack && extack && extack->_msg)
- tlvlen += nla_total_size(strlen(extack->_msg) + 1);
-
- if (err) {
- if (1)
- payload += nlmsg_len(nlh);
- else
- flags |= NLM_F_CAPPED;
- if (nlk_has_extack && extack && extack->bad_attr)
- tlvlen += nla_total_size(sizeof(u32));
- } else {
- flags |= NLM_F_CAPPED;
-
- if (nlk_has_extack && extack && extack->cookie_len)
- tlvlen += nla_total_size(extack->cookie_len);
- }
-
- if (tlvlen)
- flags |= NLM_F_ACK_TLVS;
-
- skb = nlmsg_new(payload + tlvlen, GFP_KERNEL);
- if (!skb) {
- NETLINK_CB(in_skb).sk->sk_err = ENOBUFS;
- NETLINK_CB(in_skb).sk->sk_error_report(NETLINK_CB(in_skb).sk);
- return;
- }
-
- rep = __nlmsg_put(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
- NLMSG_ERROR, payload, flags);
- errmsg = nlmsg_data(rep);
- errmsg->error = err;
- memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
-
- if (nlk_has_extack && extack) {
- if (extack->_msg) {
- WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,
- extack->_msg));
- }
- if (err) {
- if (extack->bad_attr &&
- !WARN_ON((u8 *)extack->bad_attr < in_skb->data ||
- (u8 *)extack->bad_attr >= in_skb->data +
- in_skb->len))
- WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,
- (u8 *)extack->bad_attr -
- in_skb->data));
- } else {
- if (extack->cookie_len)
- WARN_ON(nla_put(skb, NLMSGERR_ATTR_COOKIE,
- extack->cookie_len,
- extack->cookie));
- }
- }
-
- nlmsg_end(skb, rep);
-
- netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid, MSG_DONTWAIT);
-}
-
-static int extack_doit(struct sk_buff *skb, struct genl_info *info)
-{
- int (*doit)(struct sk_buff *, struct genl_info *);
- int err;
-
- doit = genl_info_extack(info)->__bp_doit;
-
- /* signal from our pre_doit to not do anything */
- if (!doit)
- return 0;
-
- err = doit(skb, info);
-
- if (err == -EINTR)
- return err;
-
- if (info->nlhdr->nlmsg_flags & NLM_F_ACK || err)
- extack_netlink_ack(skb, info->nlhdr, err,
- genl_info_extack(info));
-
- /* suppress sending ACK from normal netlink code */
- info->nlhdr->nlmsg_flags &= ~NLM_F_ACK;
- return 0;
-}
-#endif /* LINUX_VERSION_IS_LESS(4,12,0) */
-
-static int backport_pre_doit(__genl_const struct genl_ops *ops,
- struct sk_buff *skb,
- struct genl_info *info)
-{
- const struct genl_family *family = find_family_real_ops(&ops);
- int err;
-#if LINUX_VERSION_IS_LESS(4,12,0)
- struct netlink_ext_ack *extack = kzalloc(sizeof(*extack), GFP_KERNEL);
-
- __bp_genl_info_userhdr_set(info, extack);
-
- if (!extack) {
- err = -ENOMEM;
- goto err;
- }
-
- extack->__bp_doit = ops->doit;
-#else
- struct netlink_ext_ack *extack = info->extack;
-#endif
-
- err = nlmsg_validate(info->nlhdr, GENL_HDRLEN + family->hdrsize,
- family->maxattr, ops->policy, extack);
- if (!err && family->pre_doit)
- err = family->pre_doit(ops, skb, info);
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
-err:
- if (err) {
- /* signal to do nothing */
- extack->__bp_doit = NULL;
-
- extack_netlink_ack(skb, info->nlhdr, err, extack);
-
- /* suppress sending ACK from normal netlink code */
- info->nlhdr->nlmsg_flags &= ~NLM_F_ACK;
-
- /* extack will be freed in post_doit as usual */
-
- return 0;
- }
-#endif
-
- return err;
-}
-
-static void backport_post_doit(__genl_const struct genl_ops *ops,
- struct sk_buff *skb,
- struct genl_info *info)
-{
- const struct genl_family *family = find_family_real_ops(&ops);
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
- if (genl_info_extack(info)->__bp_doit)
-#else
- if (1)
-#endif
- if (family->post_doit)
- family->post_doit(ops, skb, info);
-
-#if LINUX_VERSION_IS_LESS(4,12,0)
- kfree(__bp_genl_info_userhdr(info));
-#endif
-}
-
-int backport_genl_register_family(struct genl_family *family)
-{
- struct genl_ops *ops;
- int err, i;
-
-#define COPY(memb) family->family.memb = family->memb
-#define BACK(memb) family->memb = family->family.memb
-
- /* we append one entry to the ops to find our family pointer ... */
- ops = kzalloc(sizeof(*ops) * (family->n_ops + 1), GFP_KERNEL);
- memcpy(ops, family->ops, sizeof(*ops) * family->n_ops);
- /*
- * Remove policy to skip validation as the struct nla_policy
- * memory layout isn't compatible with the old version
- */
- for (i = 0; i < family->n_ops; i++) {
- ops[i].policy = NULL;
-#if LINUX_VERSION_IS_LESS(4,12,0)
- if (ops[i].doit)
- ops[i].doit = extack_doit;
-#endif
- }
- /* keep doit/dumpit NULL - that's invalid */
- ops[family->n_ops].done = (void *)family;
-
- COPY(id);
- memcpy(family->family.name, family->name, sizeof(family->name));
- COPY(hdrsize);
- COPY(version);
- COPY(maxattr);
- COPY(netnsok);
-#if LINUX_VERSION_IS_GEQ(3,10,0)
- COPY(parallel_ops);
-#endif
- family->family.pre_doit = backport_pre_doit;
- family->family.post_doit = backport_post_doit;
- /* attrbuf is output only */
- family->copy_ops = ops;
-#if LINUX_VERSION_IS_GEQ(3,13,0)
- family->family.ops = ops;
- COPY(mcgrps);
- COPY(n_ops);
- COPY(n_mcgrps);
-#endif
-#if LINUX_VERSION_IS_GEQ(3,11,0)
- COPY(module);
-#endif
-
- err = __real_backport_genl_register_family(&family->family);
-
- BACK(id);
- BACK(attrbuf);
-
- if (err)
- return err;
-
-#if LINUX_VERSION_IS_GEQ(3,13,0) || RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,0)
- return 0;
-#else
- for (i = 0; i < family->n_ops; i++) {
- err = genl_register_ops(&family->family, ops + i);
- if (err < 0)
- goto error;
- }
-
- for (i = 0; i < family->n_mcgrps; i++) {
- err = genl_register_mc_group(&family->family,
- &family->mcgrps[i]);
- if (err)
- goto error;
- }
-
- return 0;
- error:
- genl_unregister_family(family);
- return err;
-#endif /* LINUX_VERSION_IS_GEQ(3,13,0) || RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(7,0) */
-}
-EXPORT_SYMBOL_GPL(backport_genl_register_family);
-
-int backport_genl_unregister_family(struct genl_family *family)
-{
- return __real_backport_genl_unregister_family(&family->family);
-}
-EXPORT_SYMBOL_GPL(backport_genl_unregister_family);
-
-#define INVALID_GROUP 0xffffffff
-
-static u32 __backport_genl_group(const struct genl_family *family,
- u32 group)
-{
- if (WARN_ON_ONCE(group >= family->n_mcgrps))
- return INVALID_GROUP;
-#if LINUX_VERSION_IS_LESS(3,13,0)
- return family->mcgrps[group].id;
-#else
- return family->family.mcgrp_offset + group;
-#endif
-}
-
-void genl_notify(const struct genl_family *family, struct sk_buff *skb,
- struct genl_info *info, u32 group, gfp_t flags)
-{
- struct net *net = genl_info_net(info);
- struct sock *sk = net->genl_sock;
- int report = 0;
-
- if (info->nlhdr)
- report = nlmsg_report(info->nlhdr);
-
- group = __backport_genl_group(family, group);
- if (group == INVALID_GROUP)
- return;
- nlmsg_notify(sk, skb, info->snd_portid, group, report, flags);
-}
-EXPORT_SYMBOL_GPL(genl_notify);
-
-void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
- const struct genl_family *family, int flags, u8 cmd)
-{
- struct nlmsghdr *nlh;
- struct genlmsghdr *hdr;
-
- nlh = nlmsg_put(skb, portid, seq, family->id, GENL_HDRLEN +
- family->hdrsize, flags);
- if (nlh == NULL)
- return NULL;
-
- hdr = nlmsg_data(nlh);
- hdr->cmd = cmd;
- hdr->version = family->version;
- hdr->reserved = 0;
-
- return (char *) hdr + GENL_HDRLEN;
-}
-EXPORT_SYMBOL_GPL(genlmsg_put);
-
-void *genlmsg_put_reply(struct sk_buff *skb,
- struct genl_info *info,
- const struct genl_family *family,
- int flags, u8 cmd)
-{
- return genlmsg_put(skb, info->snd_portid, info->snd_seq, family,
- flags, cmd);
-}
-EXPORT_SYMBOL_GPL(genlmsg_put_reply);
-
-int genlmsg_multicast_netns(const struct genl_family *family,
- struct net *net, struct sk_buff *skb,
- u32 portid, unsigned int group,
- gfp_t flags)
-{
- group = __backport_genl_group(family, group);
- if (group == INVALID_GROUP)
- return -EINVAL;
- return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
-}
-EXPORT_SYMBOL_GPL(genlmsg_multicast_netns);
-
-int genlmsg_multicast(const struct genl_family *family,
- struct sk_buff *skb, u32 portid,
- unsigned int group, gfp_t flags)
-{
- return genlmsg_multicast_netns(family, &init_net, skb,
- portid, group, flags);
-}
-EXPORT_SYMBOL_GPL(genlmsg_multicast);
-
-static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
- gfp_t flags)
-{
- struct sk_buff *tmp;
- struct net *net, *prev = NULL;
- bool delivered = false;
- int err;
-
- for_each_net_rcu(net) {
- if (prev) {
- tmp = skb_clone(skb, flags);
- if (!tmp) {
- err = -ENOMEM;
- goto error;
- }
- err = nlmsg_multicast(prev->genl_sock, tmp,
- portid, group, flags);
- if (!err)
- delivered = true;
- else if (err != -ESRCH)
- goto error;
- }
-
- prev = net;
- }
-
- err = nlmsg_multicast(prev->genl_sock, skb, portid, group, flags);
- if (!err)
- delivered = true;
- else if (err != -ESRCH)
- return err;
- return delivered ? 0 : -ESRCH;
- error:
- kfree_skb(skb);
- return err;
-}
-
-int backport_genlmsg_multicast_allns(const struct genl_family *family,
- struct sk_buff *skb, u32 portid,
- unsigned int group, gfp_t flags)
-{
- group = __backport_genl_group(family, group);
- if (group == INVALID_GROUP)
- return -EINVAL;
- return genlmsg_mcast(skb, portid, group, flags);
-}
-EXPORT_SYMBOL_GPL(backport_genlmsg_multicast_allns);
diff --git a/backport/compat/backports.h b/backport/compat/backports.h
deleted file mode 100644
index 53848888..00000000
--- a/backport/compat/backports.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef LINUX_BACKPORTS_PRIVATE_H
-#define LINUX_BACKPORTS_PRIVATE_H
-
-#include <linux/version.h>
-
-#ifdef CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP
-int devcoredump_init(void);
-void devcoredump_exit(void);
-#else
-static inline int devcoredump_init(void)
-{ return 0; }
-static inline void devcoredump_exit(void)
-{}
-#endif
-
-#endif /* LINUX_BACKPORTS_PRIVATE_H */
diff --git a/backport/compat/compat-3.0.c b/backport/compat/compat-3.0.c
deleted file mode 100644
index 1bed6a6a..00000000
--- a/backport/compat/compat-3.0.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
- * Copyright 2011 Alexey Dobriyan <adobriyan@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.0.
- */
-
-#include <linux/compat.h>
-#include <linux/if_ether.h>
-
-int mac_pton(const char *s, u8 *mac)
-{
- int i;
-
- /* XX:XX:XX:XX:XX:XX */
- if (strlen(s) < 3 * ETH_ALEN - 1)
- return 0;
-
- /* Don't dirty result unless string is valid MAC. */
- for (i = 0; i < ETH_ALEN; i++) {
- if (!strchr("0123456789abcdefABCDEF", s[i * 3]))
- return 0;
- if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1]))
- return 0;
- if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
- return 0;
- }
- for (i = 0; i < ETH_ALEN; i++) {
- mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
- }
- return 1;
-}
-EXPORT_SYMBOL_GPL(mac_pton);
-
-#define kstrto_from_user(f, g, type) \
-int f(const char __user *s, size_t count, unsigned int base, type *res) \
-{ \
- /* sign, base 2 representation, newline, terminator */ \
- char buf[1 + sizeof(type) * 8 + 1 + 1]; \
- \
- count = min(count, sizeof(buf) - 1); \
- if (copy_from_user(buf, s, count)) \
- return -EFAULT; \
- buf[count] = '\0'; \
- return g(buf, base, res); \
-} \
-EXPORT_SYMBOL_GPL(f)
-
-kstrto_from_user(kstrtoull_from_user, kstrtoull, unsigned long long);
-kstrto_from_user(kstrtoll_from_user, kstrtoll, long long);
-kstrto_from_user(kstrtoul_from_user, kstrtoul, unsigned long);
-kstrto_from_user(kstrtol_from_user, kstrtol, long);
-kstrto_from_user(kstrtouint_from_user, kstrtouint, unsigned int);
-kstrto_from_user(kstrtoint_from_user, kstrtoint, int);
-kstrto_from_user(kstrtou16_from_user, kstrtou16, u16);
-kstrto_from_user(kstrtos16_from_user, kstrtos16, s16);
-kstrto_from_user(kstrtou8_from_user, kstrtou8, u8);
-kstrto_from_user(kstrtos8_from_user, kstrtos8, s8);
-
-/**
- * strtobool - convert common user inputs into boolean values
- * @s: input string
- * @res: result
- *
- * This routine returns 0 iff the first character is one of 'Yy1Nn0'.
- * Otherwise it will return -EINVAL. Value pointed to by res is
- * updated upon finding a match.
- */
-int strtobool(const char *s, bool *res)
-{
- switch (s[0]) {
- case 'y':
- case 'Y':
- case '1':
- *res = true;
- break;
- case 'n':
- case 'N':
- case '0':
- *res = false;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-EXPORT_SYMBOL_GPL(strtobool);
diff --git a/backport/compat/compat-3.1.c b/backport/compat/compat-3.1.c
deleted file mode 100644
index 26187809..00000000
--- a/backport/compat/compat-3.1.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.1.
- */
-
-#include <linux/idr.h>
-#include <linux/cpufreq.h>
-#include <linux/of.h>
-
-static DEFINE_SPINLOCK(compat_simple_ida_lock);
-
-/**
- * ida_simple_get - get a new id.
- * @ida: the (initialized) ida.
- * @start: the minimum id (inclusive, < 0x8000000)
- * @end: the maximum id (exclusive, < 0x8000000 or 0)
- * @gfp_mask: memory allocation flags
- *
- * Allocates an id in the range start <= id < end, or returns -ENOSPC.
- * On memory allocation failure, returns -ENOMEM.
- *
- * Use ida_simple_remove() to get rid of an id.
- */
-int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
- gfp_t gfp_mask)
-{
- int ret, id;
- unsigned int max;
- unsigned long flags;
-
- BUG_ON((int)start < 0);
- BUG_ON((int)end < 0);
-
- if (end == 0)
- max = 0x80000000;
- else {
- BUG_ON(end < start);
- max = end - 1;
- }
-
-again:
- if (!ida_pre_get(ida, gfp_mask))
- return -ENOMEM;
-
- spin_lock_irqsave(&compat_simple_ida_lock, flags);
- ret = ida_get_new_above(ida, start, &id);
- if (!ret) {
- if (id > max) {
- ida_remove(ida, id);
- ret = -ENOSPC;
- } else {
- ret = id;
- }
- }
- spin_unlock_irqrestore(&compat_simple_ida_lock, flags);
-
- if (unlikely(ret == -EAGAIN))
- goto again;
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(ida_simple_get);
-
-/**
- * ida_simple_remove - remove an allocated id.
- * @ida: the (initialized) ida.
- * @id: the id returned by ida_simple_get.
- */
-void ida_simple_remove(struct ida *ida, unsigned int id)
-{
- unsigned long flags;
-
- BUG_ON((int)id < 0);
- spin_lock_irqsave(&compat_simple_ida_lock, flags);
- ida_remove(ida, id);
- spin_unlock_irqrestore(&compat_simple_ida_lock, flags);
-}
-EXPORT_SYMBOL_GPL(ida_simple_remove);
-/* source lib/idr.c */
-
-#ifdef CONFIG_OF
-/**
- * of_property_read_u32_array - Find and read an array of 32 bit integers
- * from a property.
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @out_values: pointer to return value, modified only if return value is 0.
- * @sz: number of array elements to read
- *
- * Search for a property in a device node and read 32-bit value(s) from
- * it. Returns 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
- *
- * The out_values is modified only if a valid u32 value can be decoded.
- */
-int of_property_read_u32_array(const struct device_node *np,
- const char *propname, u32 *out_values,
- size_t sz)
-{
- const __be32 *val = of_find_property_value_of_size(np, propname,
- (sz * sizeof(*out_values)));
-
- if (IS_ERR(val))
- return PTR_ERR(val);
-
- while (sz--)
- *out_values++ = be32_to_cpup(val++);
- return 0;
-}
-EXPORT_SYMBOL_GPL(of_property_read_u32_array);
-#endif
diff --git a/backport/compat/compat-3.3.c b/backport/compat/compat-3.3.c
deleted file mode 100644
index 1185a5d2..00000000
--- a/backport/compat/compat-3.3.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.3.
- */
-
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <linux/skbuff.h>
-#include <linux/module.h>
-#include <linux/workqueue.h>
-#include <net/dst.h>
-#include <net/xfrm.h>
-
-static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
-{
- new->tstamp = old->tstamp;
- new->dev = old->dev;
- new->transport_header = old->transport_header;
- new->network_header = old->network_header;
- new->mac_header = old->mac_header;
- skb_dst_copy(new, old);
- new->rxhash = old->rxhash;
-#if LINUX_VERSION_IS_GEQ(3,1,0)
- new->ooo_okay = old->ooo_okay;
-#endif
-#if LINUX_VERSION_IS_GEQ(3,2,0)
- new->l4_rxhash = old->l4_rxhash;
-#endif
-#ifdef CONFIG_XFRM
- new->sp = secpath_get(old->sp);
-#endif
- memcpy(new->cb, old->cb, sizeof(old->cb));
- new->csum = old->csum;
- new->local_df = old->local_df;
- new->pkt_type = old->pkt_type;
- new->ip_summed = old->ip_summed;
- skb_copy_queue_mapping(new, old);
- new->priority = old->priority;
-#if IS_ENABLED(CONFIG_IP_VS)
- new->ipvs_property = old->ipvs_property;
-#endif
- new->protocol = old->protocol;
- new->mark = old->mark;
- new->skb_iif = old->skb_iif;
- __nf_copy(new, old);
-#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
- new->nf_trace = old->nf_trace;
-#endif
-#ifdef CONFIG_NET_SCHED
- new->tc_index = old->tc_index;
-#ifdef CONFIG_NET_CLS_ACT
- new->tc_verd = old->tc_verd;
-#endif
-#endif
- new->vlan_tci = old->vlan_tci;
-
- skb_copy_secmark(new, old);
-}
-
-static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
-{
-#ifndef NET_SKBUFF_DATA_USES_OFFSET
- /*
- * Shift between the two data areas in bytes
- */
- unsigned long offset = new->data - old->data;
-#endif
-
- __copy_skb_header(new, old);
-
-#ifndef NET_SKBUFF_DATA_USES_OFFSET
- /* {transport,network,mac}_header are relative to skb->head */
- new->transport_header += offset;
- new->network_header += offset;
- if (skb_mac_header_was_set(new))
- new->mac_header += offset;
-#endif
- skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
- skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
- skb_shinfo(new)->gso_type = skb_shinfo(old)->gso_type;
-}
-
-static void skb_clone_fraglist(struct sk_buff *skb)
-{
- struct sk_buff *list;
-
- skb_walk_frags(skb, list)
- skb_get(list);
-}
-
-
-/**
- * __pskb_copy - create copy of an sk_buff with private head.
- * @skb: buffer to copy
- * @headroom: headroom of new skb
- * @gfp_mask: allocation priority
- *
- * Make a copy of both an &sk_buff and part of its data, located
- * in header. Fragmented data remain shared. This is used when
- * the caller wishes to modify only header of &sk_buff and needs
- * private copy of the header to alter. Returns %NULL on failure
- * or the pointer to the buffer on success.
- * The returned buffer has a reference count of 1.
- */
-
-struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask)
-{
- unsigned int size = skb_headlen(skb) + headroom;
- struct sk_buff *n = alloc_skb(size, gfp_mask);
-
- if (!n)
- goto out;
-
- /* Set the data pointer */
- skb_reserve(n, headroom);
- /* Set the tail pointer and length */
- skb_put(n, skb_headlen(skb));
- /* Copy the bytes */
- skb_copy_from_linear_data(skb, n->data, n->len);
-
- n->truesize += skb->data_len;
- n->data_len = skb->data_len;
- n->len = skb->len;
-
- if (skb_shinfo(skb)->nr_frags) {
- int i;
-
-/*
- * SKBTX_DEV_ZEROCOPY was added on 3.1 as well but requires ubuf
- * stuff added to the skb which we do not have
- */
-#if 0
- if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
- if (skb_copy_ubufs(skb, gfp_mask)) {
- kfree_skb(n);
- n = NULL;
- goto out;
- }
- }
-#endif
- for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
- skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i];
-#if LINUX_VERSION_IS_GEQ(3,2,0)
- skb_frag_ref(skb, i);
-#else
- get_page(skb_shinfo(skb)->frags[i].page);
-#endif
- }
- skb_shinfo(n)->nr_frags = i;
- }
-
- if (skb_has_frag_list(skb)) {
- skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list;
- skb_clone_fraglist(n);
- }
-
- copy_skb_header(n, skb);
-out:
- return n;
-}
-EXPORT_SYMBOL_GPL(__pskb_copy);
-
-static DEFINE_SPINLOCK(wq_name_lock);
-static LIST_HEAD(wq_name_list);
-
-struct wq_name {
- struct list_head list;
- struct workqueue_struct *wq;
- char name[24];
-};
-
-struct workqueue_struct *
-backport_alloc_workqueue(const char *fmt, unsigned int flags,
- int max_active, struct lock_class_key *key,
- const char *lock_name, ...)
-{
- struct workqueue_struct *wq;
- struct wq_name *n = kzalloc(sizeof(*n), GFP_KERNEL);
- va_list args;
-
- if (!n)
- return NULL;
-
- va_start(args, lock_name);
- vsnprintf(n->name, sizeof(n->name), fmt, args);
- va_end(args);
-
- wq = __alloc_workqueue_key(n->name, flags, max_active, key, lock_name);
- if (!wq) {
- kfree(n);
- return NULL;
- }
-
- n->wq = wq;
- spin_lock(&wq_name_lock);
- list_add(&n->list, &wq_name_list);
- spin_unlock(&wq_name_lock);
-
- return wq;
-}
-EXPORT_SYMBOL_GPL(backport_alloc_workqueue);
-
-void backport_destroy_workqueue(struct workqueue_struct *wq)
-{
- struct wq_name *n, *tmp;
-
- /* call original */
-#undef destroy_workqueue
- destroy_workqueue(wq);
-
- spin_lock(&wq_name_lock);
- list_for_each_entry_safe(n, tmp, &wq_name_list, list) {
- if (n->wq == wq) {
- list_del(&n->list);
- kfree(n);
- break;
- }
- }
- spin_unlock(&wq_name_lock);
-}
-EXPORT_SYMBOL_GPL(backport_destroy_workqueue);
diff --git a/backport/compat/compat-3.4.c b/backport/compat/compat-3.4.c
deleted file mode 100644
index 52753725..00000000
--- a/backport/compat/compat-3.4.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.4.
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <linux/compat.h>
-#include <asm/uaccess.h>
-
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-#include <linux/regmap.h>
-#include <linux/i2c.h>
-#include <linux/spi/spi.h>
-#endif /* LINUX_VERSION_IS_GEQ(3,2,0) */
-
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-
-#if defined(CONFIG_REGMAP)
-static void devm_regmap_release(struct device *dev, void *res)
-{
- regmap_exit(*(struct regmap **)res);
-}
-
-#if defined(CONFIG_REGMAP_I2C)
-static int regmap_i2c_write(
- struct device *dev,
- const void *data,
- size_t count)
-{
- struct i2c_client *i2c = to_i2c_client(dev);
- int ret;
-
- ret = i2c_master_send(i2c, data, count);
- if (ret == count)
- return 0;
- else if (ret < 0)
- return ret;
- else
- return -EIO;
-}
-
-static int regmap_i2c_gather_write(
- struct device *dev,
- const void *reg, size_t reg_size,
- const void *val, size_t val_size)
-{
- struct i2c_client *i2c = to_i2c_client(dev);
- struct i2c_msg xfer[2];
- int ret;
-
- /* If the I2C controller can't do a gather tell the core, it
- * will substitute in a linear write for us.
- */
- if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_NOSTART))
- return -ENOTSUPP;
-
- xfer[0].addr = i2c->addr;
- xfer[0].flags = 0;
- xfer[0].len = reg_size;
- xfer[0].buf = (void *)reg;
-
- xfer[1].addr = i2c->addr;
- xfer[1].flags = I2C_M_NOSTART;
- xfer[1].len = val_size;
- xfer[1].buf = (void *)val;
-
- ret = i2c_transfer(i2c->adapter, xfer, 2);
- if (ret == 2)
- return 0;
- if (ret < 0)
- return ret;
- else
- return -EIO;
-}
-
-static int regmap_i2c_read(
- struct device *dev,
- const void *reg, size_t reg_size,
- void *val, size_t val_size)
-{
- struct i2c_client *i2c = to_i2c_client(dev);
- struct i2c_msg xfer[2];
- int ret;
-
- xfer[0].addr = i2c->addr;
- xfer[0].flags = 0;
- xfer[0].len = reg_size;
- xfer[0].buf = (void *)reg;
-
- xfer[1].addr = i2c->addr;
- xfer[1].flags = I2C_M_RD;
- xfer[1].len = val_size;
- xfer[1].buf = val;
-
- ret = i2c_transfer(i2c->adapter, xfer, 2);
- if (ret == 2)
- return 0;
- else if (ret < 0)
- return ret;
- else
- return -EIO;
-}
-
-static struct regmap_bus regmap_i2c = {
- .write = regmap_i2c_write,
- .gather_write = regmap_i2c_gather_write,
- .read = regmap_i2c_read,
-};
-#endif /* defined(CONFIG_REGMAP_I2C) */
-
-/**
- * devm_regmap_init(): Initialise managed register map
- *
- * @dev: Device that will be interacted with
- * @bus: Bus-specific callbacks to use with device
- * @bus_context: Data passed to bus-specific callbacks
- * @config: Configuration for register map
- *
- * The return value will be an ERR_PTR() on error or a valid pointer
- * to a struct regmap. This function should generally not be called
- * directly, it should be called by bus-specific init functions. The
- * map will be automatically freed by the device management code.
- */
-struct regmap *devm_regmap_init(struct device *dev,
- const struct regmap_bus *bus,
- const struct regmap_config *config)
-{
- struct regmap **ptr, *regmap;
-
- ptr = devres_alloc(devm_regmap_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return ERR_PTR(-ENOMEM);
-
- regmap = regmap_init(dev,
- bus,
- config);
- if (!IS_ERR(regmap)) {
- *ptr = regmap;
- devres_add(dev, ptr);
- } else {
- devres_free(ptr);
- }
-
- return regmap;
-}
-EXPORT_SYMBOL_GPL(devm_regmap_init);
-
-#if defined(CONFIG_REGMAP_I2C)
-/**
- * devm_regmap_init_i2c(): Initialise managed register map
- *
- * @i2c: Device that will be interacted with
- * @config: Configuration for register map
- *
- * The return value will be an ERR_PTR() on error or a valid pointer
- * to a struct regmap. The regmap will be automatically freed by the
- * device management code.
- */
-struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
- const struct regmap_config *config)
-{
- return devm_regmap_init(&i2c->dev, &regmap_i2c, config);
-}
-EXPORT_SYMBOL_GPL(devm_regmap_init_i2c);
-#endif /* defined(CONFIG_REGMAP_I2C) */
-
-#endif /* defined(CONFIG_REGMAP) */
-#endif /* LINUX_VERSION_IS_GEQ(3,2,0) */
-
-int simple_open(struct inode *inode, struct file *file)
-{
- if (inode->i_private)
- file->private_data = inode->i_private;
- return 0;
-}
-EXPORT_SYMBOL_GPL(simple_open);
-
-#ifdef CONFIG_COMPAT
-static int __compat_put_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
-{
- return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) ||
- __put_user(ts->tv_sec, &cts->tv_sec) ||
- __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
-}
-
-int compat_put_timespec(const struct timespec *ts, void __user *uts)
-{
- if (COMPAT_USE_64BIT_TIME)
- return copy_to_user(uts, ts, sizeof *ts) ? -EFAULT : 0;
- else
- return __compat_put_timespec(ts, uts);
-}
-EXPORT_SYMBOL_GPL(compat_put_timespec);
-#endif
diff --git a/backport/compat/compat-3.5.c b/backport/compat/compat-3.5.c
deleted file mode 100644
index 721ec0e3..00000000
--- a/backport/compat/compat-3.5.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2012-2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.5.
- */
-
-#include <linux/module.h>
-#include <linux/highuid.h>
-#include <linux/ktime.h>
-#include <linux/hrtimer.h>
-#include <linux/gpio.h>
-#include <linux/ptp_clock_kernel.h>
-
-#if LINUX_VERSION_IS_GEQ(3,2,0)
-#include <linux/device.h>
-
-/**
- * devres_release - Find a device resource and destroy it, calling release
- * @dev: Device to find resource from
- * @release: Look for resources associated with this release function
- * @match: Match function (optional)
- * @match_data: Data for the match function
- *
- * Find the latest devres of @dev associated with @release and for
- * which @match returns 1. If @match is NULL, it's considered to
- * match all. If found, the resource is removed atomically, the
- * release function called and the resource freed.
- *
- * RETURNS:
- * 0 if devres is found and freed, -ENOENT if not found.
- */
-int devres_release(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data)
-{
- void *res;
-
- res = devres_remove(dev, release, match, match_data);
- if (unlikely(!res))
- return -ENOENT;
-
- (*release)(dev, res);
- devres_free(res);
- return 0;
-}
-EXPORT_SYMBOL_GPL(devres_release);
-#endif /* LINUX_VERSION_IS_GEQ(3,2,0) */
-
-/*
- * Commit 7a4e7408c5cadb240e068a662251754a562355e3
- * exported overflowuid and overflowgid for all
- * kernel configurations, prior to that we only
- * had it exported when CONFIG_UID16 was enabled.
- * We are technically redefining it here but
- * nothing seems to be changing it, except
- * kernel/ code does epose it via sysctl and
- * proc... if required later we can add that here.
- */
-#ifndef CONFIG_UID16
-int overflowuid = DEFAULT_OVERFLOWUID;
-int overflowgid = DEFAULT_OVERFLOWGID;
-
-EXPORT_SYMBOL_GPL(overflowuid);
-EXPORT_SYMBOL_GPL(overflowgid);
-#endif
-
-/* #if IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
-/* backported to all of our kernels */
-#if 0
-int ptp_clock_index(struct ptp_clock *ptp)
-{
- return ptp->index;
-}
-EXPORT_SYMBOL(ptp_clock_index);
-#endif /* CONFIG_PTP_1588_CLOCK */
-
-#ifdef CONFIG_GPIOLIB
-static void devm_gpio_release(struct device *dev, void *res)
-{
- unsigned *gpio = res;
-
- gpio_free(*gpio);
-}
-
-/**
- * devm_gpio_request - request a GPIO for a managed device
- * @dev: device to request the GPIO for
- * @gpio: GPIO to allocate
- * @label: the name of the requested GPIO
- *
- * Except for the extra @dev argument, this function takes the
- * same arguments and performs the same function as
- * gpio_request(). GPIOs requested with this function will be
- * automatically freed on driver detach.
- *
- * If an GPIO allocated with this function needs to be freed
- * separately, devm_gpio_free() must be used.
- */
-
-int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
-{
- unsigned *dr;
- int rc;
-
- dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
- if (!dr)
- return -ENOMEM;
-
- rc = gpio_request(gpio, label);
- if (rc) {
- devres_free(dr);
- return rc;
- }
-
- *dr = gpio;
- devres_add(dev, dr);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(devm_gpio_request);
-
-/**
- * devm_gpio_request_one - request a single GPIO with initial setup
- * @dev: device to request for
- * @gpio: the GPIO number
- * @flags: GPIO configuration as specified by GPIOF_*
- * @label: a literal description string of this GPIO
- */
-int devm_gpio_request_one(struct device *dev, unsigned gpio,
- unsigned long flags, const char *label)
-{
- unsigned *dr;
- int rc;
-
- dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
- if (!dr)
- return -ENOMEM;
-
- rc = gpio_request_one(gpio, flags, label);
- if (rc) {
- devres_free(dr);
- return rc;
- }
-
- *dr = gpio;
- devres_add(dev, dr);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(devm_gpio_request_one);
-
-static int devm_gpio_match(struct device *dev, void *res, void *data)
-{
- unsigned *this = res, *gpio = data;
-
- return *this == *gpio;
-}
-
-void devm_gpio_free(struct device *dev, unsigned int gpio)
-{
- WARN_ON(devres_destroy(dev, devm_gpio_release, devm_gpio_match,
- &gpio));
- gpio_free(gpio);
-}
-EXPORT_SYMBOL_GPL(devm_gpio_free);
-#endif /* CONFIG_GPIOLIB */
diff --git a/backport/compat/compat-3.6.c b/backport/compat/compat-3.6.c
deleted file mode 100644
index 9e593f5c..00000000
--- a/backport/compat/compat-3.6.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Backport compatibility file for Linux for kernels 3.6.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/export.h>
-#include <linux/clk.h>
-
-/* whoopsie ! */
-#ifndef CONFIG_COMMON_CLK
-#ifndef CONFIG_ARCH_TEGRA
-int clk_enable(struct clk *clk)
-{
- return 0;
-}
-EXPORT_SYMBOL_GPL(clk_enable);
-
-void clk_disable(struct clk *clk)
-{
-}
-EXPORT_SYMBOL_GPL(clk_disable);
-#endif
-#endif
diff --git a/backport/compat/compat-3.7.c b/backport/compat/compat-3.7.c
deleted file mode 100644
index 528d7ec9..00000000
--- a/backport/compat/compat-3.7.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux 3.7.
- */
-
-#include <linux/workqueue.h>
-#include <linux/export.h>
-#include <linux/pci.h>
-#include <linux/pci_regs.h>
-#include <linux/of.h>
-#include <linux/scatterlist.h>
-
-bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
- unsigned long delay)
-{
- cancel_delayed_work(dwork);
- queue_delayed_work(wq, dwork, delay);
- return false;
-}
-EXPORT_SYMBOL_GPL(mod_delayed_work);
-
-#ifdef CONFIG_PCI
-/*
- * Kernels >= 3.7 get their PCI-E Capabilities Register cached
- * via the pci_dev->pcie_flags_reg so for older kernels we have
- * no other option but to read this every single time we need
- * it accessed. If we really cared to improve the efficiency
- * of this we could try to find an unused u16 varible on the
- * pci_dev but if we found it we likely would remove it from
- * the kernel anyway right? Bite me.
- */
-static inline u16 pcie_flags_reg(struct pci_dev *dev)
-{
- int pos;
- u16 reg16;
-
- pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
- if (!pos)
- return 0;
-
- pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
-
- return reg16;
-}
-
-#define pci_pcie_type LINUX_BACKPORT(pci_pcie_type)
-int pci_pcie_type(struct pci_dev *dev)
-{
- return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
-}
-EXPORT_SYMBOL_GPL(pci_pcie_type);
-
-#define pcie_cap_version LINUX_BACKPORT(pcie_cap_version)
-static inline int pcie_cap_version(struct pci_dev *dev)
-{
- return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS;
-}
-
-static inline bool pcie_cap_has_lnkctl(struct pci_dev *dev)
-{
- int type = pci_pcie_type(dev);
-
- return pcie_cap_version(dev) > 1 ||
- type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_ENDPOINT ||
- type == PCI_EXP_TYPE_LEG_END;
-}
-
-static inline bool pcie_cap_has_sltctl(struct pci_dev *dev)
-{
- int type = pci_pcie_type(dev);
-
- return pcie_cap_version(dev) > 1 ||
- type == PCI_EXP_TYPE_ROOT_PORT ||
- (type == PCI_EXP_TYPE_DOWNSTREAM &&
- pcie_flags_reg(dev) & PCI_EXP_FLAGS_SLOT);
-}
-
-static inline bool pcie_cap_has_rtctl(struct pci_dev *dev)
-{
- int type = pci_pcie_type(dev);
-
- return pcie_cap_version(dev) > 1 ||
- type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_RC_EC;
-}
-
-static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
-{
- if (!pci_is_pcie(dev))
- return false;
-
- switch (pos) {
- case PCI_EXP_FLAGS_TYPE:
- return true;
- case PCI_EXP_DEVCAP:
- case PCI_EXP_DEVCTL:
- case PCI_EXP_DEVSTA:
- return true;
- case PCI_EXP_LNKCAP:
- case PCI_EXP_LNKCTL:
- case PCI_EXP_LNKSTA:
- return pcie_cap_has_lnkctl(dev);
- case PCI_EXP_SLTCAP:
- case PCI_EXP_SLTCTL:
- case PCI_EXP_SLTSTA:
- return pcie_cap_has_sltctl(dev);
- case PCI_EXP_RTCTL:
- case PCI_EXP_RTCAP:
- case PCI_EXP_RTSTA:
- return pcie_cap_has_rtctl(dev);
- case PCI_EXP_DEVCAP2:
- case PCI_EXP_DEVCTL2:
- case PCI_EXP_LNKCAP2:
- case PCI_EXP_LNKCTL2:
- case PCI_EXP_LNKSTA2:
- return pcie_cap_version(dev) > 1;
- default:
- return false;
- }
-}
-
-/*
- * Note that these accessor functions are only for the "PCI Express
- * Capability" (see PCIe spec r3.0, sec 7.8). They do not apply to the
- * other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.)
- */
-int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val)
-{
- int ret;
-
- *val = 0;
- if (pos & 1)
- return -EINVAL;
-
- if (pcie_capability_reg_implemented(dev, pos)) {
- ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val);
- /*
- * Reset *val to 0 if pci_read_config_word() fails, it may
- * have been written as 0xFFFF if hardware error happens
- * during pci_read_config_word().
- */
- if (ret)
- *val = 0;
- return ret;
- }
-
- /*
- * For Functions that do not implement the Slot Capabilities,
- * Slot Status, and Slot Control registers, these spaces must
- * be hardwired to 0b, with the exception of the Presence Detect
- * State bit in the Slot Status register of Downstream Ports,
- * which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8)
- */
- if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA &&
- pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
- *val = PCI_EXP_SLTSTA_PDS;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(pcie_capability_read_word);
-
-int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val)
-{
- int ret;
-
- *val = 0;
- if (pos & 3)
- return -EINVAL;
-
- if (pcie_capability_reg_implemented(dev, pos)) {
- ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val);
- /*
- * Reset *val to 0 if pci_read_config_dword() fails, it may
- * have been written as 0xFFFFFFFF if hardware error happens
- * during pci_read_config_dword().
- */
- if (ret)
- *val = 0;
- return ret;
- }
-
- if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL &&
- pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) {
- *val = PCI_EXP_SLTSTA_PDS;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(pcie_capability_read_dword);
-
-int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
-{
- if (pos & 1)
- return -EINVAL;
-
- if (!pcie_capability_reg_implemented(dev, pos))
- return 0;
-
- return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
-}
-EXPORT_SYMBOL_GPL(pcie_capability_write_word);
-
-int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val)
-{
- if (pos & 3)
- return -EINVAL;
-
- if (!pcie_capability_reg_implemented(dev, pos))
- return 0;
-
- return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val);
-}
-EXPORT_SYMBOL_GPL(pcie_capability_write_dword);
-
-int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
- u16 clear, u16 set)
-{
- int ret;
- u16 val;
-
- ret = pcie_capability_read_word(dev, pos, &val);
- if (!ret) {
- val &= ~clear;
- val |= set;
- ret = pcie_capability_write_word(dev, pos, val);
- }
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(pcie_capability_clear_and_set_word);
-
-int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
- u32 clear, u32 set)
-{
- int ret;
- u32 val;
-
- ret = pcie_capability_read_dword(dev, pos, &val);
- if (!ret) {
- val &= ~clear;
- val |= set;
- ret = pcie_capability_write_dword(dev, pos, val);
- }
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(pcie_capability_clear_and_set_dword);
-#endif
-
-#ifdef CONFIG_OF
-#if LINUX_VERSION_IS_LESS(3,7,0)
-/**
- * of_get_child_by_name - Find the child node by name for a given parent
- * @node: parent node
- * @name: child name to look for.
- *
- * This function looks for child node for given matching name
- *
- * Returns a node pointer if found, with refcount incremented, use
- * of_node_put() on it when done.
- * Returns NULL if node is not found.
- */
-struct device_node *of_get_child_by_name(const struct device_node *node,
- const char *name)
-{
- struct device_node *child;
-
- for_each_child_of_node(node, child)
- if (child->name && (of_node_cmp(child->name, name) == 0))
- break;
- return child;
-}
-EXPORT_SYMBOL_GPL(of_get_child_by_name);
-#endif /* LINUX_VERSION_IS_LESS(3,7,0) */
-#endif /* CONFIG_OF */
-
-int sg_nents(struct scatterlist *sg)
-{
- int nents;
- for (nents = 0; sg; sg = sg_next(sg))
- nents++;
- return nents;
-}
-EXPORT_SYMBOL_GPL(sg_nents);
diff --git a/backport/compat/compat-3.8.c b/backport/compat/compat-3.8.c
deleted file mode 100644
index 21686cc3..00000000
--- a/backport/compat/compat-3.8.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Copyright (c) 1999 Andreas Gal
- * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
- * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
- * Copyright (c) 2006-2012 Jiri Kosina
- * Copyright (c) 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Backport functionality introduced in Linux 3.8.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/hid.h>
-#include <linux/module.h>
-#include "hid-ids.h"
-#include <linux/netdevice.h>
-#include <linux/random.h>
-#include <linux/of.h>
-#include <linux/mm.h>
-#include <linux/pci.h>
-#include <linux/pci_regs.h>
-
-#if LINUX_VERSION_IS_LESS(3,7,8)
-void netdev_set_default_ethtool_ops(struct net_device *dev,
- const struct ethtool_ops *ops)
-{
- if (!dev->ethtool_ops)
- dev->ethtool_ops = ops;
-}
-EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops);
-#endif
-
-/* a list of devices that shouldn't be handled by HID core at all */
-static const struct hid_device_id hid_ignore_list[] = {
- { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
- { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
- { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
- { HID_USB_DEVICE(USB_VENDOR_ID_AXENTIA, USB_DEVICE_ID_AXENTIA_FM_RADIO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) },
- { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) },
- { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) },
- { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
- { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
- { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
- { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
- { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) },
- { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_RADIOSHARK) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
- { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
- { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
- { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
- { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
- { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
- { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
- { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) },
- { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
- { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) },
- { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) },
- { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) },
- { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) },
- { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) },
- { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) },
- { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
- { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
-#if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE)
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_INT_TP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_CPAD) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_STICK) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_COMP_TP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) },
-#endif
- { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
- { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
- { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) },
- { }
-};
-
-/**
- * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer
- *
- * There are composite devices for which we want to ignore only a certain
- * interface. This is a list of devices for which only the mouse interface will
- * be ignored. This allows a dedicated driver to take care of the interface.
- */
-static const struct hid_device_id hid_mouse_ignore_list[] = {
- /* appletouch driver */
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
- { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
- { }
-};
-
-static bool hid_match_one_id(struct hid_device *hdev,
- const struct hid_device_id *id)
-{
- return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) &&
-#if LINUX_VERSION_IS_GEQ(3,8,0)
- (id->group == HID_GROUP_ANY || id->group == hdev->group) &&
-#endif
- (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
- (id->product == HID_ANY_ID || id->product == hdev->product);
-}
-
-#define hid_match_id LINUX_BACKPORT(hid_match_id)
-static const struct hid_device_id *
-hid_match_id(struct hid_device *hdev, const struct hid_device_id *id)
-{
- for (; id->bus; id++)
- if (hid_match_one_id(hdev, id))
- return id;
-
- return NULL;
-}
-
-bool hid_ignore(struct hid_device *hdev)
-{
- if (hdev->quirks & HID_QUIRK_NO_IGNORE)
- return false;
- if (hdev->quirks & HID_QUIRK_IGNORE)
- return true;
-
- switch (hdev->vendor) {
- case USB_VENDOR_ID_CODEMERCS:
- /* ignore all Code Mercenaries IOWarrior devices */
- if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST &&
- hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST)
- return true;
- break;
- case USB_VENDOR_ID_LOGITECH:
- if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
- hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
- return true;
- /*
- * The Keene FM transmitter USB device has the same USB ID as
- * the Logitech AudioHub Speaker, but it should ignore the hid.
- * Check if the name is that of the Keene device.
- * For reference: the name of the AudioHub is
- * "HOLTEK AudioHub Speaker".
- */
- if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
- !strcmp(hdev->name, "HOLTEK B-LINK USB Audio "))
- return true;
- break;
- case USB_VENDOR_ID_SOUNDGRAPH:
- if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
- hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
- return true;
- break;
- case USB_VENDOR_ID_HANWANG:
- if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
- hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
- return true;
- break;
- case USB_VENDOR_ID_JESS:
- if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
- hdev->type == HID_TYPE_USBNONE)
- return true;
- break;
- case USB_VENDOR_ID_DWAV:
- /* These are handled by usbtouchscreen. hdev->type is probably
- * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match
- * usbtouchscreen. */
- if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER ||
- hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) &&
- hdev->type != HID_TYPE_USBMOUSE)
- return true;
- break;
- }
-
- if (hdev->type == HID_TYPE_USBMOUSE &&
- hid_match_id(hdev, hid_mouse_ignore_list))
- return true;
-
- return !!hid_match_id(hdev, hid_ignore_list);
-}
-EXPORT_SYMBOL_GPL(hid_ignore);
-
-/* backported to our kernel */
-#if 0
-/**
- * prandom_bytes - get the requested number of pseudo-random bytes
- * @buf: where to copy the pseudo-random bytes to
- * @bytes: the requested number of bytes
- */
-void prandom_bytes(void *buf, int bytes)
-{
- unsigned char *p = buf;
- int i;
-
- for (i = 0; i < round_down(bytes, sizeof(u32)); i += sizeof(u32)) {
- u32 random = random32();
- int j;
-
- for (j = 0; j < sizeof(u32); j++) {
- p[i + j] = random;
- random >>= BITS_PER_BYTE;
- }
- }
-
- if (i < bytes) {
- u32 random = random32();
-
- for (; i < bytes; i++) {
- p[i] = random;
- random >>= BITS_PER_BYTE;
- }
- }
-}
-EXPORT_SYMBOL_GPL(prandom_bytes);
-#endif
-
-#ifdef CONFIG_OF
-/**
- * of_property_read_u8_array - Find and read an array of u8 from a property.
- *
- * @np: device node from which the property value is to be read.
- * @propname: name of the property to be searched.
- * @out_values: pointer to return value, modified only if return value is 0.
- * @sz: number of array elements to read
- *
- * Search for a property in a device node and read 8-bit value(s) from
- * it. Returns 0 on success, -EINVAL if the property does not exist,
- * -ENODATA if property does not have a value, and -EOVERFLOW if the
- * property data isn't large enough.
- *
- * dts entry of array should be like:
- * property = /bits/ 8 <0x50 0x60 0x70>;
- *
- * The out_values is modified only if a valid u8 value can be decoded.
- */
-int of_property_read_u8_array(const struct device_node *np,
- const char *propname, u8 *out_values, size_t sz)
-{
- const u8 *val = of_find_property_value_of_size(np, propname,
- (sz * sizeof(*out_values)));
-
- if (IS_ERR(val))
- return PTR_ERR(val);
-
- while (sz--)
- *out_values++ = *val++;
- return 0;
-}
-EXPORT_SYMBOL_GPL(of_property_read_u8_array);
-#endif /* CONFIG_OF */
-
-#ifdef CONFIG_PCI_IOV
-/**
- * pci_sriov_set_totalvfs -- reduce the TotalVFs available
- * @dev: the PCI PF device
- * @numvfs: number that should be used for TotalVFs supported
- *
- * Should be called from PF driver's probe routine with
- * device's mutex held.
- *
- * Returns 0 if PF is an SRIOV-capable device and
- * value of numvfs valid. If not a PF return -ENOSYS;
- * if numvfs is invalid return -EINVAL;
- * if VFs already enabled, return -EBUSY.
- */
-int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
-{
- if (!dev->is_physfn)
- return -ENOSYS;
- if (numvfs > dev->sriov->total_VFs)
- return -EINVAL;
-
- /* Shouldn't change if VFs already enabled */
- if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE)
- return -EBUSY;
- else
- dev->sriov->driver_max_VFs = numvfs;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs);
-#endif /* CONFIG_PCI_IOV */
diff --git a/backport/compat/compat-3.9.c b/backport/compat/compat-3.9.c
deleted file mode 100644
index 93889b55..00000000
--- a/backport/compat/compat-3.9.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * Backport functionality introduced in Linux 3.9.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/netdevice.h>
-#include <linux/if.h>
-#include <linux/if_ether.h>
-#include <linux/etherdevice.h>
-#include <linux/scatterlist.h>
-#include <linux/highmem.h>
-#include <net/inet_frag.h>
-#include <net/sock.h>
-
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
-{
- void __iomem *dest_ptr;
-
- dest_ptr = devm_ioremap_resource(dev, res);
- if (!dest_ptr)
- return (void __iomem *)ERR_PTR(-ENOMEM);
- return dest_ptr;
-}
-EXPORT_SYMBOL_GPL(devm_ioremap_resource);
-
-/**
- * eth_prepare_mac_addr_change - prepare for mac change
- * @dev: network device
- * @p: socket address
- */
-int eth_prepare_mac_addr_change(struct net_device *dev, void *p)
-{
- struct sockaddr *addr = p;
-
- if (!(dev->priv_flags & IFF_LIVE_ADDR_CHANGE) && netif_running(dev))
- return -EBUSY;
- if (!is_valid_ether_addr(addr->sa_data))
- return -EADDRNOTAVAIL;
- return 0;
-}
-EXPORT_SYMBOL_GPL(eth_prepare_mac_addr_change);
-
-/**
- * eth_commit_mac_addr_change - commit mac change
- * @dev: network device
- * @p: socket address
- */
-void eth_commit_mac_addr_change(struct net_device *dev, void *p)
-{
- struct sockaddr *addr = p;
-
- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
-}
-EXPORT_SYMBOL_GPL(eth_commit_mac_addr_change);
-
-void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
- const char *prefix)
-{
- static const char msg[] = "inet_frag_find: Fragment hash bucket"
- " list length grew over limit " __stringify(INETFRAGS_MAXDEPTH)
- ". Dropping fragment.\n";
-
- if (PTR_ERR(q) == -ENOBUFS)
- LIMIT_NETDEBUG(KERN_WARNING "%s%s", prefix, msg);
-}
-EXPORT_SYMBOL_GPL(inet_frag_maybe_warn_overflow);
-
-void __sg_page_iter_start(struct sg_page_iter *piter,
- struct scatterlist *sglist, unsigned int nents,
- unsigned long pgoffset)
-{
- piter->__pg_advance = 0;
- piter->__nents = nents;
-
- piter->page = NULL;
- piter->sg = sglist;
- piter->sg_pgoffset = pgoffset;
-}
-EXPORT_SYMBOL_GPL(__sg_page_iter_start);
-
-static int sg_page_count(struct scatterlist *sg)
-{
- return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT;
-}
-
-bool __sg_page_iter_next(struct sg_page_iter *piter)
-{
- if (!piter->__nents || !piter->sg)
- return false;
-
- piter->sg_pgoffset += piter->__pg_advance;
- piter->__pg_advance = 1;
-
- while (piter->sg_pgoffset >= sg_page_count(piter->sg)) {
- piter->sg_pgoffset -= sg_page_count(piter->sg);
- piter->sg = sg_next(piter->sg);
- if (!--piter->__nents || !piter->sg)
- return false;
- }
- piter->page = nth_page(sg_page(piter->sg), piter->sg_pgoffset);
-
- return true;
-}
-EXPORT_SYMBOL_GPL(__sg_page_iter_next);
-
-static bool sg_miter_get_next_page(struct sg_mapping_iter *miter)
-{
- if (!miter->__remaining) {
- struct scatterlist *sg;
- unsigned long pgoffset;
-
- if (!__sg_page_iter_next(&miter->piter))
- return false;
-
- sg = miter->piter.sg;
- pgoffset = miter->piter.sg_pgoffset;
-
- miter->__offset = pgoffset ? 0 : sg->offset;
- miter->__remaining = sg->offset + sg->length -
- (pgoffset << PAGE_SHIFT) - miter->__offset;
- miter->__remaining = min_t(unsigned long, miter->__remaining,
- PAGE_SIZE - miter->__offset);
- }
-
- return true;
-}
-
-/**
- * sg_miter_start - start mapping iteration over a sg list
- * @miter: sg mapping iter to be started
- * @sgl: sg list to iterate over
- * @nents: number of sg entries
- *
- * Description:
- * Starts mapping iterator @miter.
- *
- * Context:
- * Don't care.
- */
-void backport_sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl,
- unsigned int nents, unsigned int flags)
-{
- memset(miter, 0, sizeof(struct sg_mapping_iter));
-
- __sg_page_iter_start(&miter->piter, sgl, nents, 0);
- WARN_ON(!(flags & (SG_MITER_TO_SG | SG_MITER_FROM_SG)));
- miter->__flags = flags;
-}
-EXPORT_SYMBOL_GPL(backport_sg_miter_start);
-
-/**
- * sg_miter_next - proceed mapping iterator to the next mapping
- * @miter: sg mapping iter to proceed
- *
- * Description:
- * Proceeds @miter to the next mapping. @miter should have been started
- * using sg_miter_start(). On successful return, @miter->page,
- * @miter->addr and @miter->length point to the current mapping.
- *
- * Context:
- * Preemption disabled if SG_MITER_ATOMIC. Preemption must stay disabled
- * till @miter is stopped. May sleep if !SG_MITER_ATOMIC.
- *
- * Returns:
- * true if @miter contains the next mapping. false if end of sg
- * list is reached.
- */
-bool backport_sg_miter_next(struct sg_mapping_iter *miter)
-{
- sg_miter_stop(miter);
-
- /*
- * Get to the next page if necessary.
- * __remaining, __offset is adjusted by sg_miter_stop
- */
- if (!sg_miter_get_next_page(miter))
- return false;
-
- miter->page = sg_page_iter_page(&miter->piter);
- miter->consumed = miter->length = miter->__remaining;
-
- if (miter->__flags & SG_MITER_ATOMIC)
- miter->addr = kmap_atomic(miter->page) + miter->__offset;
- else
- miter->addr = kmap(miter->page) + miter->__offset;
-
- return true;
-}
-EXPORT_SYMBOL_GPL(backport_sg_miter_next);
-
-/**
- * sg_miter_stop - stop mapping iteration
- * @miter: sg mapping iter to be stopped
- *
- * Description:
- * Stops mapping iterator @miter. @miter should have been started
- * using sg_miter_start(). A stopped iteration can be resumed by
- * calling sg_miter_next() on it. This is useful when resources (kmap)
- * need to be released during iteration.
- *
- * Context:
- * Preemption disabled if the SG_MITER_ATOMIC is set. Don't care
- * otherwise.
- */
-void backport_sg_miter_stop(struct sg_mapping_iter *miter)
-{
- WARN_ON(miter->consumed > miter->length);
-
- /* drop resources from the last iteration */
- if (miter->addr) {
- miter->__offset += miter->consumed;
- miter->__remaining -= miter->consumed;
-
- if ((miter->__flags & SG_MITER_TO_SG) &&
- !PageSlab(miter->page))
- flush_kernel_dcache_page(miter->page);
-
- if (miter->__flags & SG_MITER_ATOMIC) {
- WARN_ON_ONCE(preemptible());
- kunmap_atomic(miter->addr);
- } else
- kunmap(miter->page);
-
- miter->page = NULL;
- miter->addr = NULL;
- miter->length = 0;
- miter->consumed = 0;
- }
-}
-EXPORT_SYMBOL_GPL(backport_sg_miter_stop);
diff --git a/backport/compat/hid-ids.h b/backport/compat/hid-ids.h
deleted file mode 100644
index c147dc06..00000000
--- a/backport/compat/hid-ids.h
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * USB HID quirks support for Linux
- *
- * Copyright (c) 1999 Andreas Gal
- * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
- * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
- * Copyright (c) 2006-2007 Jiri Kosina
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-
-#ifndef HID_IDS_H_FILE
-#define HID_IDS_H_FILE
-
-#define USB_VENDOR_ID_3M 0x0596
-#define USB_DEVICE_ID_3M1968 0x0500
-#define USB_DEVICE_ID_3M2256 0x0502
-#define USB_DEVICE_ID_3M3266 0x0506
-
-#define USB_VENDOR_ID_A4TECH 0x09da
-#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
-#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a
-#define USB_DEVICE_ID_A4TECH_RP_649 0x001a
-
-#define USB_VENDOR_ID_AASHIMA 0x06d6
-#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
-#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026
-
-#define USB_VENDOR_ID_ACECAD 0x0460
-#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004
-#define USB_DEVICE_ID_ACECAD_302 0x0008
-
-#define USB_VENDOR_ID_ACRUX 0x1a34
-
-#define USB_VENDOR_ID_ACTIONSTAR 0x2101
-#define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011
-
-#define USB_VENDOR_ID_ADS_TECH 0x06e1
-#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
-
-#define USB_VENDOR_ID_AFATECH 0x15a4
-#define USB_DEVICE_ID_AFATECH_AF9016 0x9016
-
-#define USB_VENDOR_ID_AIPTEK 0x08ca
-#define USB_DEVICE_ID_AIPTEK_01 0x0001
-#define USB_DEVICE_ID_AIPTEK_10 0x0010
-#define USB_DEVICE_ID_AIPTEK_20 0x0020
-#define USB_DEVICE_ID_AIPTEK_21 0x0021
-#define USB_DEVICE_ID_AIPTEK_22 0x0022
-#define USB_DEVICE_ID_AIPTEK_23 0x0023
-#define USB_DEVICE_ID_AIPTEK_24 0x0024
-
-#define USB_VENDOR_ID_AIRCABLE 0x16CA
-#define USB_DEVICE_ID_AIRCABLE1 0x1502
-
-#define USB_VENDOR_ID_AIREN 0x1a2c
-#define USB_DEVICE_ID_AIREN_SLIMPLUS 0x0002
-
-#define USB_VENDOR_ID_ALCOR 0x058f
-#define USB_DEVICE_ID_ALCOR_USBRS232 0x9720
-
-#define USB_VENDOR_ID_ALPS 0x0433
-#define USB_DEVICE_ID_IBM_GAMEPAD 0x1101
-
-#define USB_VENDOR_ID_APPLE 0x05ac
-#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
-#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d
-#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e
-#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
-#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
-#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
-#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
-#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
-#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
-#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
-#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
-#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
-#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
-#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
-#define USB_DEVICE_ID_APPLE_ALU_MINI_ANSI 0x021d
-#define USB_DEVICE_ID_APPLE_ALU_MINI_ISO 0x021e
-#define USB_DEVICE_ID_APPLE_ALU_MINI_JIS 0x021f
-#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
-#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
-#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
-#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
-#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
-#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
-#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
-#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
-#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
-#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
-#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
-#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
-#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
-#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
-#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238
-#define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f
-#define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240
-#define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241
-#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
-#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243
-#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244
-#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
-#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
-#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
-#define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI 0x024f
-#define USB_DEVICE_ID_APPLE_ALU_REVB_ISO 0x0250
-#define USB_DEVICE_ID_APPLE_ALU_REVB_JIS 0x0251
-#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
-#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
-#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
-#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259
-#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a
-#define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b
-#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
-#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
-#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
-#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
-#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
-#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
-#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
-#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
-#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255
-#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
-#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
-#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
-#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241
-#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
-
-#define USB_VENDOR_ID_ASUS 0x0486
-#define USB_DEVICE_ID_ASUS_T91MT 0x0185
-#define USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO 0x0186
-
-#define USB_VENDOR_ID_ASUSTEK 0x0b05
-#define USB_DEVICE_ID_ASUSTEK_LCM 0x1726
-#define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b
-
-#define USB_VENDOR_ID_ATEN 0x0557
-#define USB_DEVICE_ID_ATEN_UC100KM 0x2004
-#define USB_DEVICE_ID_ATEN_CS124U 0x2202
-#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204
-#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205
-#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208
-
-#define USB_VENDOR_ID_ATMEL 0x03eb
-#define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c
-#define USB_DEVICE_ID_ATMEL_MXT_DIGITIZER 0x2118
-
-#define USB_VENDOR_ID_AUREAL 0x0755
-#define USB_DEVICE_ID_AUREAL_W01RN 0x2626
-
-#define USB_VENDOR_ID_AVERMEDIA 0x07ca
-#define USB_DEVICE_ID_AVER_FM_MR800 0xb800
-
-#define USB_VENDOR_ID_AXENTIA 0x12cf
-#define USB_DEVICE_ID_AXENTIA_FM_RADIO 0x7111
-
-#define USB_VENDOR_ID_BAANTO 0x2453
-#define USB_DEVICE_ID_BAANTO_MT_190W2 0x0100
-
-#define USB_VENDOR_ID_BELKIN 0x050d
-#define USB_DEVICE_ID_FLIP_KVM 0x3201
-
-#define USB_VENDOR_ID_BERKSHIRE 0x0c98
-#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
-
-#define USB_VENDOR_ID_BTC 0x046e
-#define USB_DEVICE_ID_BTC_EMPREX_REMOTE 0x5578
-#define USB_DEVICE_ID_BTC_EMPREX_REMOTE_2 0x5577
-
-#define USB_VENDOR_ID_CANDO 0x2087
-#define USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH 0x0703
-#define USB_DEVICE_ID_CANDO_MULTI_TOUCH 0x0a01
-#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1 0x0a02
-#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6 0x0b03
-#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6 0x0f01
-
-#define USB_VENDOR_ID_CH 0x068e
-#define USB_DEVICE_ID_CH_PRO_THROTTLE 0x00f1
-#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2
-#define USB_DEVICE_ID_CH_FIGHTERSTICK 0x00f3
-#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4
-#define USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE 0x0051
-#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff
-#define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK 0x00d3
-#define USB_DEVICE_ID_CH_AXIS_295 0x001c
-
-#define USB_VENDOR_ID_CHERRY 0x046a
-#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
-#define USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR 0x0027
-
-#define USB_VENDOR_ID_CHIC 0x05fe
-#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014
-
-#define USB_VENDOR_ID_CHICONY 0x04f2
-#define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
-#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d
-#define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618
-#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123
-#define USB_DEVICE_ID_CHICONY_AK1D 0x1125
-
-#define USB_VENDOR_ID_CHUNGHWAT 0x2247
-#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001
-
-#define USB_VENDOR_ID_CIDC 0x1677
-
-#define USB_VENDOR_ID_CMEDIA 0x0d8c
-#define USB_DEVICE_ID_CM109 0x000e
-
-#define USB_VENDOR_ID_CODEMERCS 0x07c0
-#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500
-#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff
-
-#define USB_VENDOR_ID_CREATIVELABS 0x041e
-#define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801
-
-#define USB_VENDOR_ID_CVTOUCH 0x1ff7
-#define USB_DEVICE_ID_CVTOUCH_SCREEN 0x0013
-
-#define USB_VENDOR_ID_CYGNAL 0x10c4
-#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a
-
-#define USB_VENDOR_ID_CYPRESS 0x04b4
-#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
-#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
-#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
-#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
-#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
-#define USB_DEVICE_ID_CYPRESS_BARCODE_3 0xbca1
-#define USB_DEVICE_ID_CYPRESS_BARCODE_4 0xed81
-#define USB_DEVICE_ID_CYPRESS_TRUETOUCH 0xc001
-
-#define USB_VENDOR_ID_DEALEXTREAME 0x10c5
-#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a
-
-#define USB_VENDOR_ID_DELORME 0x1163
-#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
-#define USB_DEVICE_ID_DELORME_EM_LT20 0x0200
-
-#define USB_VENDOR_ID_DMI 0x0c0b
-#define USB_DEVICE_ID_DMI_ENC 0x5fab
-
-#define USB_VENDOR_ID_DRAGONRISE 0x0079
-
-#define USB_VENDOR_ID_DWAV 0x0eef
-#define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001
-#define USB_DEVICE_ID_DWAV_TOUCHCONTROLLER 0x0002
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207 0x7207
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C 0x720c
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224 0x7224
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A 0x722A
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E 0x725e
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262 0x7262
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B 0x726b
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA 0x72aa
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1 0x72a1
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA 0x72fa
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302 0x7302
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349 0x7349
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7 0x73f7
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224 0x7224
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0 0x72d0
-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4 0x72c4
-
-#define USB_VENDOR_ID_ELECOM 0x056e
-#define USB_DEVICE_ID_ELECOM_BM084 0x0061
-
-#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34
-
-#define USB_VENDOR_ID_ELO 0x04E7
-#define USB_DEVICE_ID_ELO_TS2515 0x0022
-#define USB_DEVICE_ID_ELO_TS2700 0x0020
-
-#define USB_VENDOR_ID_EMS 0x2006
-#define USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II 0x0118
-
-#define USB_VENDOR_ID_FLATFROG 0x25b5
-#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002
-
-#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f
-#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100
-
-#define USB_VENDOR_ID_ETT 0x0664
-#define USB_DEVICE_ID_TC5UH 0x0309
-#define USB_DEVICE_ID_TC4UM 0x0306
-
-#define USB_VENDOR_ID_ETURBOTOUCH 0x22b9
-#define USB_DEVICE_ID_ETURBOTOUCH 0x0006
-
-#define USB_VENDOR_ID_EZKEY 0x0518
-#define USB_DEVICE_ID_BTC_8193 0x0002
-
-#define USB_VENDOR_ID_FREESCALE 0x15A2
-#define USB_DEVICE_ID_FREESCALE_MX28 0x004F
-
-#define USB_VENDOR_ID_FRUCTEL 0x25B6
-#define USB_DEVICE_ID_GAMETEL_MT_MODE 0x0002
-
-#define USB_VENDOR_ID_GAMERON 0x0810
-#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001
-#define USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR 0x0002
-
-#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
-#define USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS 0x0003
-#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS 0x0100
-
-#define USB_VENDOR_ID_GLAB 0x06c2
-#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
-#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
-#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040
-#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044
-#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
-#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051
-#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053
-#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058
-
-#define USB_VENDOR_ID_GOODTOUCH 0x1aad
-#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f
-
-#define USB_VENDOR_ID_GOTOP 0x08f2
-#define USB_DEVICE_ID_SUPER_Q2 0x007f
-#define USB_DEVICE_ID_GOGOPEN 0x00ce
-#define USB_DEVICE_ID_PENPOWER 0x00f4
-
-#define USB_VENDOR_ID_GREENASIA 0x0e8f
-#define USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD 0x3013
-
-#define USB_VENDOR_ID_GRETAGMACBETH 0x0971
-#define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005
-
-#define USB_VENDOR_ID_GRIFFIN 0x077d
-#define USB_DEVICE_ID_POWERMATE 0x0410
-#define USB_DEVICE_ID_SOUNDKNOB 0x04AA
-#define USB_DEVICE_ID_RADIOSHARK 0x627a
-
-#define USB_VENDOR_ID_GTCO 0x078c
-#define USB_DEVICE_ID_GTCO_90 0x0090
-#define USB_DEVICE_ID_GTCO_100 0x0100
-#define USB_DEVICE_ID_GTCO_101 0x0101
-#define USB_DEVICE_ID_GTCO_103 0x0103
-#define USB_DEVICE_ID_GTCO_104 0x0104
-#define USB_DEVICE_ID_GTCO_105 0x0105
-#define USB_DEVICE_ID_GTCO_106 0x0106
-#define USB_DEVICE_ID_GTCO_107 0x0107
-#define USB_DEVICE_ID_GTCO_108 0x0108
-#define USB_DEVICE_ID_GTCO_200 0x0200
-#define USB_DEVICE_ID_GTCO_201 0x0201
-#define USB_DEVICE_ID_GTCO_202 0x0202
-#define USB_DEVICE_ID_GTCO_203 0x0203
-#define USB_DEVICE_ID_GTCO_204 0x0204
-#define USB_DEVICE_ID_GTCO_205 0x0205
-#define USB_DEVICE_ID_GTCO_206 0x0206
-#define USB_DEVICE_ID_GTCO_207 0x0207
-#define USB_DEVICE_ID_GTCO_300 0x0300
-#define USB_DEVICE_ID_GTCO_301 0x0301
-#define USB_DEVICE_ID_GTCO_302 0x0302
-#define USB_DEVICE_ID_GTCO_303 0x0303
-#define USB_DEVICE_ID_GTCO_304 0x0304
-#define USB_DEVICE_ID_GTCO_305 0x0305
-#define USB_DEVICE_ID_GTCO_306 0x0306
-#define USB_DEVICE_ID_GTCO_307 0x0307
-#define USB_DEVICE_ID_GTCO_308 0x0308
-#define USB_DEVICE_ID_GTCO_309 0x0309
-#define USB_DEVICE_ID_GTCO_400 0x0400
-#define USB_DEVICE_ID_GTCO_401 0x0401
-#define USB_DEVICE_ID_GTCO_402 0x0402
-#define USB_DEVICE_ID_GTCO_403 0x0403
-#define USB_DEVICE_ID_GTCO_404 0x0404
-#define USB_DEVICE_ID_GTCO_405 0x0405
-#define USB_DEVICE_ID_GTCO_500 0x0500
-#define USB_DEVICE_ID_GTCO_501 0x0501
-#define USB_DEVICE_ID_GTCO_502 0x0502
-#define USB_DEVICE_ID_GTCO_503 0x0503
-#define USB_DEVICE_ID_GTCO_504 0x0504
-#define USB_DEVICE_ID_GTCO_1000 0x1000
-#define USB_DEVICE_ID_GTCO_1001 0x1001
-#define USB_DEVICE_ID_GTCO_1002 0x1002
-#define USB_DEVICE_ID_GTCO_1003 0x1003
-#define USB_DEVICE_ID_GTCO_1004 0x1004
-#define USB_DEVICE_ID_GTCO_1005 0x1005
-#define USB_DEVICE_ID_GTCO_1006 0x1006
-#define USB_DEVICE_ID_GTCO_1007 0x1007
-
-#define USB_VENDOR_ID_GYRATION 0x0c16
-#define USB_DEVICE_ID_GYRATION_REMOTE 0x0002
-#define USB_DEVICE_ID_GYRATION_REMOTE_2 0x0003
-#define USB_DEVICE_ID_GYRATION_REMOTE_3 0x0008
-
-#define USB_VENDOR_ID_HANWANG 0x0b57
-#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000
-#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff
-
-#define USB_VENDOR_ID_HANVON 0x20b3
-#define USB_DEVICE_ID_HANVON_MULTITOUCH 0x0a18
-
-#define USB_VENDOR_ID_HANVON_ALT 0x22ed
-#define USB_DEVICE_ID_HANVON_ALT_MULTITOUCH 0x1010
-
-#define USB_VENDOR_ID_HAPP 0x078b
-#define USB_DEVICE_ID_UGCI_DRIVING 0x0010
-#define USB_DEVICE_ID_UGCI_FLYING 0x0020
-#define USB_DEVICE_ID_UGCI_FIGHTING 0x0030
-
-#define USB_VENDOR_ID_IDEACOM 0x1cb6
-#define USB_DEVICE_ID_IDEACOM_IDC6650 0x6650
-#define USB_DEVICE_ID_IDEACOM_IDC6651 0x6651
-
-#define USB_VENDOR_ID_ILITEK 0x222a
-#define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001
-
-#define USB_VENDOR_ID_ION 0x15e4
-#define USB_DEVICE_ID_ICADE 0x0132
-
-#define USB_VENDOR_ID_HOLTEK 0x1241
-#define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015
-
-#define USB_VENDOR_ID_HOLTEK_ALT 0x04d9
-#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055
-
-#define USB_VENDOR_ID_IMATION 0x0718
-#define USB_DEVICE_ID_DISC_STAKKA 0xd000
-
-#define USB_VENDOR_ID_INTEL_8086 0x8086
-#define USB_VENDOR_ID_INTEL_8087 0x8087
-#define USB_DEVICE_ID_SENSOR_HUB_1020 0x1020
-#define USB_DEVICE_ID_SENSOR_HUB_09FA 0x09FA
-
-#define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615
-#define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070
-
-#define USB_VENDOR_ID_JESS 0x0c45
-#define USB_DEVICE_ID_JESS_YUREX 0x1010
-
-#define USB_VENDOR_ID_KBGEAR 0x084e
-#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
-
-#define USB_VENDOR_ID_KENSINGTON 0x047d
-#define USB_DEVICE_ID_KS_SLIMBLADE 0x2041
-
-#define USB_VENDOR_ID_KWORLD 0x1b80
-#define USB_DEVICE_ID_KWORLD_RADIO_FM700 0xd700
-
-#define USB_VENDOR_ID_KEYTOUCH 0x0926
-#define USB_DEVICE_ID_KEYTOUCH_IEC 0x3333
-
-#define USB_VENDOR_ID_KYE 0x0458
-#define USB_DEVICE_ID_KYE_ERGO_525V 0x0087
-#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
-#define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010
-#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011
-#define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013
-
-#define USB_VENDOR_ID_LABTEC 0x1020
-#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
-
-#define USB_VENDOR_ID_LCPOWER 0x1241
-#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
-
-#define USB_VENDOR_ID_LD 0x0f11
-#define USB_DEVICE_ID_LD_CASSY 0x1000
-#define USB_DEVICE_ID_LD_CASSY2 0x1001
-#define USB_DEVICE_ID_LD_POCKETCASSY 0x1010
-#define USB_DEVICE_ID_LD_POCKETCASSY2 0x1011
-#define USB_DEVICE_ID_LD_MOBILECASSY 0x1020
-#define USB_DEVICE_ID_LD_MOBILECASSY2 0x1021
-#define USB_DEVICE_ID_LD_MICROCASSYVOLTAGE 0x1031
-#define USB_DEVICE_ID_LD_MICROCASSYCURRENT 0x1032
-#define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033
-#define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035
-#define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038
-#define USB_DEVICE_ID_LD_JWM 0x1080
-#define USB_DEVICE_ID_LD_DMMP 0x1081
-#define USB_DEVICE_ID_LD_UMIP 0x1090
-#define USB_DEVICE_ID_LD_UMIC 0x10A0
-#define USB_DEVICE_ID_LD_UMIB 0x10B0
-#define USB_DEVICE_ID_LD_XRAY 0x1100
-#define USB_DEVICE_ID_LD_XRAY2 0x1101
-#define USB_DEVICE_ID_LD_XRAYCT 0x1110
-#define USB_DEVICE_ID_LD_VIDEOCOM 0x1200
-#define USB_DEVICE_ID_LD_MOTOR 0x1210
-#define USB_DEVICE_ID_LD_COM3LAB 0x2000
-#define USB_DEVICE_ID_LD_TELEPORT 0x2010
-#define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020
-#define USB_DEVICE_ID_LD_POWERCONTROL 0x2030
-#define USB_DEVICE_ID_LD_MACHINETEST 0x2040
-#define USB_DEVICE_ID_LD_MOSTANALYSER 0x2050
-#define USB_DEVICE_ID_LD_MOSTANALYSER2 0x2051
-#define USB_DEVICE_ID_LD_ABSESP 0x2060
-#define USB_DEVICE_ID_LD_AUTODATABUS 0x2070
-#define USB_DEVICE_ID_LD_MCT 0x2080
-#define USB_DEVICE_ID_LD_HYBRID 0x2090
-#define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0
-
-#define USB_VENDOR_ID_LENOVO 0x17ef
-#define USB_DEVICE_ID_LENOVO_TPKBD 0x6009
-
-#define USB_VENDOR_ID_LG 0x1fd2
-#define USB_DEVICE_ID_LG_MULTITOUCH 0x0064
-
-#define USB_VENDOR_ID_LOGITECH 0x046d
-#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
-#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
-#define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
-#define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
-#define USB_DEVICE_ID_LOGITECH_HARMONY_PS3 0x0306
-#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a
-#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211
-#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215
-#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218
-#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219
-#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
-#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286
-#define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287
-#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
-#define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293
-#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295
-#define USB_DEVICE_ID_LOGITECH_DFP_WHEEL 0xc298
-#define USB_DEVICE_ID_LOGITECH_G25_WHEEL 0xc299
-#define USB_DEVICE_ID_LOGITECH_DFGT_WHEEL 0xc29a
-#define USB_DEVICE_ID_LOGITECH_G27_WHEEL 0xc29b
-#define USB_DEVICE_ID_LOGITECH_WII_WHEEL 0xc29c
-#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
-#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
-#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
-#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
-#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
-#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER 0xc52b
-#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2 0xc532
-#define USB_DEVICE_ID_SPACETRAVELLER 0xc623
-#define USB_DEVICE_ID_SPACENAVIGATOR 0xc626
-#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704
-#define USB_DEVICE_ID_DINOVO_EDGE 0xc714
-#define USB_DEVICE_ID_DINOVO_MINI 0xc71f
-#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2 0xca03
-
-#define USB_VENDOR_ID_LUMIO 0x202e
-#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006
-#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007
-
-#define USB_VENDOR_ID_MADCATZ 0x0738
-#define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540
-
-#define USB_VENDOR_ID_MCC 0x09db
-#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
-#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a
-
-#define USB_VENDOR_ID_MGE 0x0463
-#define USB_DEVICE_ID_MGE_UPS 0xffff
-#define USB_DEVICE_ID_MGE_UPS1 0x0001
-
-#define USB_VENDOR_ID_MICROCHIP 0x04d8
-#define USB_DEVICE_ID_PICKIT1 0x0032
-#define USB_DEVICE_ID_PICKIT2 0x0033
-#define USB_DEVICE_ID_PICOLCD 0xc002
-#define USB_DEVICE_ID_PICOLCD_BOOTLOADER 0xf002
-
-#define USB_VENDOR_ID_MICROSOFT 0x045e
-#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
-#define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d
-#define USB_DEVICE_ID_MS_NE4K 0x00db
-#define USB_DEVICE_ID_MS_LK6K 0x00f9
-#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701
-#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
-#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730
-#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
-
-#define USB_VENDOR_ID_MOJO 0x8282
-#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201
-
-#define USB_VENDOR_ID_MONTEREY 0x0566
-#define USB_DEVICE_ID_GENIUS_KB29E 0x3004
-
-#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400
-#define USB_DEVICE_ID_N_S_HARMONY 0xc359
-
-#define USB_VENDOR_ID_NATSU 0x08b7
-#define USB_DEVICE_ID_NATSU_GAMEPAD 0x0001
-
-#define USB_VENDOR_ID_NCR 0x0404
-#define USB_DEVICE_ID_NCR_FIRST 0x0300
-#define USB_DEVICE_ID_NCR_LAST 0x03ff
-
-#define USB_VENDOR_ID_NEC 0x073e
-#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
-
-#define USB_VENDOR_ID_NEXTWINDOW 0x1926
-#define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003
-
-#define USB_VENDOR_ID_NINTENDO 0x057e
-#define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306
-
-#define USB_VENDOR_ID_NOVATEK 0x0603
-#define USB_DEVICE_ID_NOVATEK_PCT 0x0600
-
-#define USB_VENDOR_ID_NTRIG 0x1b96
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2 0x0004
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3 0x0005
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4 0x0006
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5 0x0007
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6 0x0008
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7 0x0009
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8 0x000A
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9 0x000B
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10 0x000C
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11 0x000D
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12 0x000E
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13 0x000F
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14 0x0010
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15 0x0011
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16 0x0012
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17 0x0013
-#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014
-
-#define USB_VENDOR_ID_ONTRAK 0x0a07
-#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
-
-#define USB_VENDOR_ID_ORTEK 0x05a4
-#define USB_DEVICE_ID_ORTEK_PKB1700 0x1700
-#define USB_DEVICE_ID_ORTEK_WKB2000 0x2000
-
-#define USB_VENDOR_ID_PANASONIC 0x04da
-#define USB_DEVICE_ID_PANABOARD_UBT780 0x1044
-#define USB_DEVICE_ID_PANABOARD_UBT880 0x104d
-
-#define USB_VENDOR_ID_PANJIT 0x134c
-
-#define USB_VENDOR_ID_PANTHERLORD 0x0810
-#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001
-
-#define USB_VENDOR_ID_PENMOUNT 0x14e1
-#define USB_DEVICE_ID_PENMOUNT_PCI 0x3500
-
-#define USB_VENDOR_ID_PETALYNX 0x18b1
-#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037
-
-#define USB_VENDOR_ID_PHILIPS 0x0471
-#define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617
-
-#define USB_VENDOR_ID_PI_ENGINEERING 0x05f3
-#define USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL 0xff
-
-#define USB_VENDOR_ID_PIXART 0x093a
-#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN 0x8001
-#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1 0x8002
-#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2 0x8003
-
-#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43
-#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003
-
-#define USB_VENDOR_ID_POWERCOM 0x0d9f
-#define USB_DEVICE_ID_POWERCOM_UPS 0x0002
-
-#define USB_VENDOR_ID_PRODIGE 0x05af
-#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062
-
-#define USB_VENDOR_ID_QUANTA 0x0408
-#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000
-#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001
-#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008
-
-#define USB_VENDOR_ID_ROCCAT 0x1e7d
-#define USB_DEVICE_ID_ROCCAT_ARVO 0x30d4
-#define USB_DEVICE_ID_ROCCAT_ISKU 0x319c
-#define USB_DEVICE_ID_ROCCAT_KONE 0x2ced
-#define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51
-#define USB_DEVICE_ID_ROCCAT_KONEXTD 0x2e22
-#define USB_DEVICE_ID_ROCCAT_KOVAPLUS 0x2d50
-#define USB_DEVICE_ID_ROCCAT_LUA 0x2c2e
-#define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24
-#define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6
-#define USB_DEVICE_ID_ROCCAT_SAVU 0x2d5a
-
-#define USB_VENDOR_ID_SAITEK 0x06a3
-#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
-#define USB_DEVICE_ID_SAITEK_PS1000 0x0621
-
-#define USB_VENDOR_ID_SAMSUNG 0x0419
-#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
-#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
-
-#define USB_VENDOR_ID_SENNHEISER 0x1395
-#define USB_DEVICE_ID_SENNHEISER_BTD500USB 0x002c
-
-#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
-#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
-
-#define USB_VENDOR_ID_SIGMATEL 0x066F
-#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
-
-#define USB_VENDOR_ID_SKYCABLE 0x1223
-#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07
-
-#define USB_VENDOR_ID_SONY 0x054c
-#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
-#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306
-#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
-#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f
-
-#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2
-#define USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST 0x0034
-#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST 0x0046
-
-#define USB_VENDOR_ID_STANTUM 0x1f87
-#define USB_DEVICE_ID_MTP 0x0002
-
-#define USB_VENDOR_ID_STANTUM_STM 0x0483
-#define USB_DEVICE_ID_MTP_STM 0x3261
-#define USB_DEVICE_ID_SENSOR_HUB_7014 0x7014
-
-#define USB_VENDOR_ID_STANTUM_SITRONIX 0x1403
-#define USB_DEVICE_ID_MTP_SITRONIX 0x5001
-
-#define USB_VENDOR_ID_SUN 0x0430
-#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab
-
-#define USB_VENDOR_ID_SUNPLUS 0x04fc
-#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8
-
-#define USB_VENDOR_ID_SYMBOL 0x05e0
-#define USB_DEVICE_ID_SYMBOL_SCANNER_1 0x0800
-#define USB_DEVICE_ID_SYMBOL_SCANNER_2 0x1300
-
-#define USB_VENDOR_ID_SYNAPTICS 0x06cb
-#define USB_DEVICE_ID_SYNAPTICS_TP 0x0001
-#define USB_DEVICE_ID_SYNAPTICS_INT_TP 0x0002
-#define USB_DEVICE_ID_SYNAPTICS_CPAD 0x0003
-#define USB_DEVICE_ID_SYNAPTICS_TS 0x0006
-#define USB_DEVICE_ID_SYNAPTICS_STICK 0x0007
-#define USB_DEVICE_ID_SYNAPTICS_WP 0x0008
-#define USB_DEVICE_ID_SYNAPTICS_COMP_TP 0x0009
-#define USB_DEVICE_ID_SYNAPTICS_WTP 0x0010
-#define USB_DEVICE_ID_SYNAPTICS_DPAD 0x0013
-
-#define USB_VENDOR_ID_THRUSTMASTER 0x044f
-
-#define USB_VENDOR_ID_TIVO 0x150a
-#define USB_DEVICE_ID_TIVO_SLIDE_BT 0x1200
-#define USB_DEVICE_ID_TIVO_SLIDE 0x1201
-
-#define USB_VENDOR_ID_TOPSEED 0x0766
-#define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204
-
-#define USB_VENDOR_ID_TOPSEED2 0x1784
-#define USB_DEVICE_ID_TOPSEED2_RF_COMBO 0x0004
-#define USB_DEVICE_ID_TOPSEED2_PERIPAD_701 0x0016
-
-#define USB_VENDOR_ID_TOPMAX 0x0663
-#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
-
-#define USB_VENDOR_ID_TOUCH_INTL 0x1e5e
-#define USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH 0x0313
-
-#define USB_VENDOR_ID_TOUCHPACK 0x1bfd
-#define USB_DEVICE_ID_TOUCHPACK_RTS 0x1688
-
-#define USB_VENDOR_ID_TPV 0x25aa
-#define USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN 0x8883
-
-#define USB_VENDOR_ID_TURBOX 0x062a
-#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
-#define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100
-
-#define USB_VENDOR_ID_TWINHAN 0x6253
-#define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100
-
-#define USB_VENDOR_ID_UCLOGIC 0x5543
-#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042
-#define USB_DEVICE_ID_UCLOGIC_TABLET_KNA5 0x6001
-#define USB_DEVICE_ID_UCLOGIC_TABLET_TWA60 0x0064
-#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003
-#define USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U 0x0004
-#define USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U 0x0005
-#define USB_DEVICE_ID_UCLOGIC_TABLET_WP1062 0x0064
-#define USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850 0x0522
-#define USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60 0x0781
-
-#define USB_VENDOR_ID_UNITEC 0x227d
-#define USB_DEVICE_ID_UNITEC_USB_TOUCH_0709 0x0709
-#define USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19 0x0a19
-
-#define USB_VENDOR_ID_VERNIER 0x08f7
-#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
-#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
-#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
-#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
-#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
-
-#define USB_VENDOR_ID_WACOM 0x056a
-#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81
-#define USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH 0x00BD
-
-#define USB_VENDOR_ID_WALTOP 0x172f
-#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH 0x0032
-#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH 0x0034
-#define USB_DEVICE_ID_WALTOP_Q_PAD 0x0037
-#define USB_DEVICE_ID_WALTOP_PID_0038 0x0038
-#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH 0x0501
-#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH 0x0500
-#define USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET 0x0502
-
-#define USB_VENDOR_ID_WISEGROUP 0x0925
-#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005
-#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
-#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
-#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
-#define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888
-#define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800
-#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
-
-#define USB_VENDOR_ID_WISEGROUP_LTD 0x6666
-#define USB_VENDOR_ID_WISEGROUP_LTD2 0x6677
-#define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802
-#define USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO 0x8801
-#define USB_DEVICE_ID_SUPER_DUAL_BOX_PRO 0x8802
-#define USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO 0x8804
-
-#define USB_VENDOR_ID_X_TENSIONS 0x1ae7
-#define USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE 0x9001
-
-#define USB_VENDOR_ID_XAT 0x2505
-#define USB_DEVICE_ID_XAT_CSR 0x0220
-
-#define USB_VENDOR_ID_XIROKU 0x1477
-#define USB_DEVICE_ID_XIROKU_SPX 0x1006
-#define USB_DEVICE_ID_XIROKU_MPX 0x1007
-#define USB_DEVICE_ID_XIROKU_CSR 0x100e
-#define USB_DEVICE_ID_XIROKU_SPX1 0x1021
-#define USB_DEVICE_ID_XIROKU_CSR1 0x1022
-#define USB_DEVICE_ID_XIROKU_MPX1 0x1023
-#define USB_DEVICE_ID_XIROKU_SPX2 0x1024
-#define USB_DEVICE_ID_XIROKU_CSR2 0x1025
-#define USB_DEVICE_ID_XIROKU_MPX2 0x1026
-
-#define USB_VENDOR_ID_YEALINK 0x6993
-#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001
-
-#define USB_VENDOR_ID_ZEROPLUS 0x0c12
-
-#define USB_VENDOR_ID_ZYDACRON 0x13EC
-#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006
-
-#define USB_VENDOR_ID_ZYTRONIC 0x14c8
-#define USB_DEVICE_ID_ZYTRONIC_ZXY100 0x0005
-
-#define USB_VENDOR_ID_PRIMAX 0x0461
-#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05
-
-#endif
diff --git a/backport/compat/main.c b/backport/compat/main.c
deleted file mode 100644
index 0bf04201..00000000
--- a/backport/compat/main.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pm_qos.h>
-#include <linux/workqueue.h>
-#include "backports.h"
-
-MODULE_AUTHOR("Luis R. Rodriguez");
-MODULE_DESCRIPTION("Kernel backport module");
-MODULE_LICENSE("GPL");
-
-#ifndef CPTCFG_KERNEL_NAME
-#error "You need a CPTCFG_KERNEL_NAME"
-#endif
-
-#ifndef CPTCFG_KERNEL_VERSION
-#error "You need a CPTCFG_KERNEL_VERSION"
-#endif
-
-#ifndef CPTCFG_VERSION
-#error "You need a CPTCFG_VERSION"
-#endif
-
-static char *backported_kernel_name = CPTCFG_KERNEL_NAME;
-
-module_param(backported_kernel_name, charp, 0400);
-MODULE_PARM_DESC(backported_kernel_name,
- "The kernel tree name that was used for this backport (" CPTCFG_KERNEL_NAME ")");
-
-#ifdef BACKPORTS_GIT_TRACKED
-static char *backports_tracker_id = BACKPORTS_GIT_TRACKED;
-module_param(backports_tracker_id, charp, 0400);
-MODULE_PARM_DESC(backports_tracker_id,
- "The version of the tree containing this backport (" BACKPORTS_GIT_TRACKED ")");
-#else
-static char *backported_kernel_version = CPTCFG_KERNEL_VERSION;
-static char *backports_version = CPTCFG_VERSION;
-
-module_param(backported_kernel_version, charp, 0400);
-MODULE_PARM_DESC(backported_kernel_version,
- "The kernel version that was used for this backport (" CPTCFG_KERNEL_VERSION ")");
-
-module_param(backports_version, charp, 0400);
-MODULE_PARM_DESC(backports_version,
- "The git version of the backports tree used to generate this backport (" CPTCFG_VERSION ")");
-
-#endif
-
-void backport_dependency_symbol(void)
-{
-}
-EXPORT_SYMBOL_GPL(backport_dependency_symbol);
-
-
-static int __init backport_init(void)
-{
- int ret = devcoredump_init();
- if (ret)
- return ret;
-
- printk(KERN_INFO "Loading modules backported from " CPTCFG_KERNEL_NAME
-#ifndef BACKPORTS_GIT_TRACKED
- " version " CPTCFG_KERNEL_VERSION
-#endif
- "\n");
-#ifdef BACKPORTS_GIT_TRACKED
- printk(KERN_INFO BACKPORTS_GIT_TRACKED "\n");
-#else
-
-#ifdef CONFIG_BACKPORT_INTEGRATE
- printk(KERN_INFO "Backport integrated by backports.git " CPTCFG_VERSION "\n");
-#else
- printk(KERN_INFO "Backport generated by backports.git " CPTCFG_VERSION "\n");
-#endif /* CONFIG_BACKPORT_INTEGRATE */
-
-#endif /* BACKPORTS_GIT_TRACKED */
-
- return 0;
-}
-subsys_initcall(backport_init);
-
-static void __exit backport_exit(void)
-{
- devcoredump_exit();
-}
-module_exit(backport_exit);
diff --git a/backport/compat/user_namespace.c b/backport/compat/user_namespace.c
deleted file mode 100644
index 6d014040..00000000
--- a/backport/compat/user_namespace.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Backport functionality introduced in Linux user_namespace.c
- */
-
-#include <linux/module.h>
-#include <linux/highuid.h>
-#include <linux/uidgid.h>
-#include <linux/user_namespace.h>
-
-#ifdef CONFIG_USER_NS
-
-kuid_t make_kuid(struct user_namespace *ns, uid_t uid)
-{
- /* Map the uid to a global kernel uid */
- return KUIDT_INIT(uid);
-}
-EXPORT_SYMBOL_GPL(make_kuid);
-
-uid_t from_kuid(struct user_namespace *targ, kuid_t kuid)
-{
- /* Map the uid from a global kernel uid */
- return __kuid_val(kuid);
-}
-EXPORT_SYMBOL_GPL(from_kuid);
-
-uid_t from_kuid_munged(struct user_namespace *targ, kuid_t kuid)
-{
- uid_t uid;
- uid = from_kuid(targ, kuid);
-
- if (uid == (uid_t) -1)
- uid = overflowuid;
- return uid;
-}
-EXPORT_SYMBOL_GPL(from_kuid_munged);
-
-kgid_t make_kgid(struct user_namespace *ns, gid_t gid)
-{
- /* Map the gid to a global kernel gid */
- return KGIDT_INIT(gid);
-}
-EXPORT_SYMBOL_GPL(make_kgid);
-
-gid_t from_kgid(struct user_namespace *targ, kgid_t kgid)
-{
- /* Map the gid from a global kernel gid */
- return __kgid_val(kgid);
-}
-EXPORT_SYMBOL_GPL(from_kgid);
-
-gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid)
-{
- gid_t gid;
- gid = from_kgid(targ, kgid);
-
- if (gid == (gid_t) -1)
- gid = overflowgid;
- return gid;
-}
-EXPORT_SYMBOL_GPL(from_kgid_munged);
-
-#endif /* CONFIG_USER_NS */
diff --git a/backport/compat/verification/asn1parse.c b/backport/compat/verification/asn1parse.c
deleted file mode 100644
index e81713c7..00000000
--- a/backport/compat/verification/asn1parse.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Generic ASN.1 parsing
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_ASN1_PARSE_C)
-
-#include "mbedtls/asn1.h"
-
-#if defined(MBEDTLS_BIGNUM_C)
-#include "mbedtls/bignum.h"
-#endif
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdlib.h>
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
-
-/* Implementation that should never be optimized out by the compiler */
-static void mbedtls_zeroize( void *v, size_t n ) {
- volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
-}
-
-/*
- * ASN.1 DER decoding routines
- */
-int mbedtls_asn1_get_len( unsigned char **p,
- const unsigned char *end,
- size_t *len )
-{
- if( ( end - *p ) < 1 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- if( ( **p & 0x80 ) == 0 )
- *len = *(*p)++;
- else
- {
- switch( **p & 0x7F )
- {
- case 1:
- if( ( end - *p ) < 2 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- *len = (*p)[1];
- (*p) += 2;
- break;
-
- case 2:
- if( ( end - *p ) < 3 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- *len = ( (size_t)(*p)[1] << 8 ) | (*p)[2];
- (*p) += 3;
- break;
-
- case 3:
- if( ( end - *p ) < 4 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- *len = ( (size_t)(*p)[1] << 16 ) |
- ( (size_t)(*p)[2] << 8 ) | (*p)[3];
- (*p) += 4;
- break;
-
- case 4:
- if( ( end - *p ) < 5 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- *len = ( (size_t)(*p)[1] << 24 ) | ( (size_t)(*p)[2] << 16 ) |
- ( (size_t)(*p)[3] << 8 ) | (*p)[4];
- (*p) += 5;
- break;
-
- default:
- return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
- }
- }
-
- if( *len > (size_t) ( end - *p ) )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- return( 0 );
-}
-
-int mbedtls_asn1_get_tag( unsigned char **p,
- const unsigned char *end,
- size_t *len, int tag )
-{
- if( ( end - *p ) < 1 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- if( **p != tag )
- return( MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
-
- (*p)++;
-
- return( mbedtls_asn1_get_len( p, end, len ) );
-}
-
-int mbedtls_asn1_get_bool( unsigned char **p,
- const unsigned char *end,
- int *val )
-{
- int ret;
- size_t len;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_BOOLEAN ) ) != 0 )
- return( ret );
-
- if( len != 1 )
- return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
-
- *val = ( **p != 0 ) ? 1 : 0;
- (*p)++;
-
- return( 0 );
-}
-
-int mbedtls_asn1_get_int( unsigned char **p,
- const unsigned char *end,
- int *val )
-{
- int ret;
- size_t len;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 )
- return( ret );
-
- if( len == 0 || len > sizeof( int ) || ( **p & 0x80 ) != 0 )
- return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
-
- *val = 0;
-
- while( len-- > 0 )
- {
- *val = ( *val << 8 ) | **p;
- (*p)++;
- }
-
- return( 0 );
-}
-
-#if defined(MBEDTLS_BIGNUM_C)
-int mbedtls_asn1_get_mpi( unsigned char **p,
- const unsigned char *end,
- mbedtls_mpi *X )
-{
- int ret;
- size_t len;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 )
- return( ret );
-
- ret = mbedtls_mpi_read_binary( X, *p, len );
-
- *p += len;
-
- return( ret );
-}
-#endif /* MBEDTLS_BIGNUM_C */
-
-int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end,
- mbedtls_asn1_bitstring *bs)
-{
- int ret;
-
- /* Certificate type is a single byte bitstring */
- if( ( ret = mbedtls_asn1_get_tag( p, end, &bs->len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 )
- return( ret );
-
- /* Check length, subtract one for actual bit string length */
- if( bs->len < 1 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
- bs->len -= 1;
-
- /* Get number of unused bits, ensure unused bits <= 7 */
- bs->unused_bits = **p;
- if( bs->unused_bits > 7 )
- return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
- (*p)++;
-
- /* Get actual bitstring */
- bs->p = *p;
- *p += bs->len;
-
- if( *p != end )
- return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
-
- return( 0 );
-}
-
-/*
- * Get a bit string without unused bits
- */
-int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end,
- size_t *len )
-{
- int ret;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, len, MBEDTLS_ASN1_BIT_STRING ) ) != 0 )
- return( ret );
-
- if( (*len)-- < 2 || *(*p)++ != 0 )
- return( MBEDTLS_ERR_ASN1_INVALID_DATA );
-
- return( 0 );
-}
-
-
-
-/*
- * Parses and splits an ASN.1 "SEQUENCE OF <tag>"
- */
-int mbedtls_asn1_get_sequence_of( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_sequence *cur,
- int tag)
-{
- int ret;
- size_t len;
- mbedtls_asn1_buf *buf;
-
- /* Get main sequence tag */
- if( ( ret = mbedtls_asn1_get_tag( p, end, &len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( ret );
-
- if( *p + len != end )
- return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
-
- while( *p < end )
- {
- buf = &(cur->buf);
- buf->tag = **p;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &buf->len, tag ) ) != 0 )
- return( ret );
-
- buf->p = *p;
- *p += buf->len;
-
- /* Allocate and assign next pointer */
- if( *p < end )
- {
- cur->next = (mbedtls_asn1_sequence*)mbedtls_calloc( 1,
- sizeof( mbedtls_asn1_sequence ) );
-
- if( cur->next == NULL )
- return( MBEDTLS_ERR_ASN1_ALLOC_FAILED );
-
- cur = cur->next;
- }
- }
-
- /* Set final sequence entry's next pointer to NULL */
- cur->next = NULL;
-
- if( *p != end )
- return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
-
- return( 0 );
-}
-
-int mbedtls_asn1_get_alg( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params )
-{
- int ret;
- size_t len;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( ret );
-
- if( ( end - *p ) < 1 )
- return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
-
- alg->tag = **p;
- end = *p + len;
-
- if( ( ret = mbedtls_asn1_get_tag( p, end, &alg->len, MBEDTLS_ASN1_OID ) ) != 0 )
- return( ret );
-
- alg->p = *p;
- *p += alg->len;
-
- if( *p == end )
- {
- mbedtls_zeroize( params, sizeof(mbedtls_asn1_buf) );
- return( 0 );
- }
-
- params->tag = **p;
- (*p)++;
-
- if( ( ret = mbedtls_asn1_get_len( p, end, &params->len ) ) != 0 )
- return( ret );
-
- params->p = *p;
- *p += params->len;
-
- if( *p != end )
- return( MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
-
- return( 0 );
-}
-
-int mbedtls_asn1_get_alg_null( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_buf *alg )
-{
- int ret;
- mbedtls_asn1_buf params;
-
- memset( &params, 0, sizeof(mbedtls_asn1_buf) );
-
- if( ( ret = mbedtls_asn1_get_alg( p, end, alg, &params ) ) != 0 )
- return( ret );
-
- if( ( params.tag != MBEDTLS_ASN1_NULL && params.tag != 0 ) || params.len != 0 )
- return( MBEDTLS_ERR_ASN1_INVALID_DATA );
-
- return( 0 );
-}
-
-void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *cur )
-{
- if( cur == NULL )
- return;
-
- mbedtls_free( cur->oid.p );
- mbedtls_free( cur->val.p );
-
- mbedtls_zeroize( cur, sizeof( mbedtls_asn1_named_data ) );
-}
-
-void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head )
-{
- mbedtls_asn1_named_data *cur;
-
- while( ( cur = *head ) != NULL )
- {
- *head = cur->next;
- mbedtls_asn1_free_named_data( cur );
- mbedtls_free( cur );
- }
-}
-
-mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list,
- const char *oid, size_t len )
-{
- while( list != NULL )
- {
- if( list->oid.len == len &&
- memcmp( list->oid.p, oid, len ) == 0 )
- {
- break;
- }
-
- list = list->next;
- }
-
- return( list );
-}
-
-#endif /* MBEDTLS_ASN1_PARSE_C */
diff --git a/backport/compat/verification/bignum.c b/backport/compat/verification/bignum.c
deleted file mode 100644
index b8f65285..00000000
--- a/backport/compat/verification/bignum.c
+++ /dev/null
@@ -1,2458 +0,0 @@
-/*
- * Multi-precision integer library
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-/*
- * The following sources were referenced in the design of this Multi-precision
- * Integer library:
- *
- * [1] Handbook of Applied Cryptography - 1997
- * Menezes, van Oorschot and Vanstone
- *
- * [2] Multi-Precision Math
- * Tom St Denis
- * https://github.com/libtom/libtommath/blob/develop/tommath.pdf
- *
- * [3] GNU Multi-Precision Arithmetic Library
- * https://gmplib.org/manual/index.html
- *
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_BIGNUM_C)
-
-#include "mbedtls/bignum.h"
-#include "mbedtls/bn_mul.h"
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#define mbedtls_printf printf
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
-
-/* Implementation that should never be optimized out by the compiler */
-static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) {
- volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0;
-}
-
-#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
-#define biL (ciL << 3) /* bits in limb */
-#define biH (ciL << 2) /* half limb size */
-
-#define MPI_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
-
-/*
- * Convert between bits/chars and number of limbs
- * Divide first in order to avoid potential overflows
- */
-#define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) )
-#define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) )
-
-/*
- * Initialize one MPI
- */
-void mbedtls_mpi_init( mbedtls_mpi *X )
-{
- if( X == NULL )
- return;
-
- X->s = 1;
- X->n = 0;
- X->p = NULL;
-}
-
-/*
- * Unallocate one MPI
- */
-void mbedtls_mpi_free( mbedtls_mpi *X )
-{
- if( X == NULL )
- return;
-
- if( X->p != NULL )
- {
- mbedtls_mpi_zeroize( X->p, X->n );
- mbedtls_free( X->p );
- }
-
- X->s = 1;
- X->n = 0;
- X->p = NULL;
-}
-
-/*
- * Enlarge to the specified number of limbs
- */
-int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs )
-{
- mbedtls_mpi_uint *p;
-
- if( nblimbs > MBEDTLS_MPI_MAX_LIMBS )
- return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
-
- if( X->n < nblimbs )
- {
- if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( nblimbs, ciL ) ) == NULL )
- return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
-
- if( X->p != NULL )
- {
- memcpy( p, X->p, X->n * ciL );
- mbedtls_mpi_zeroize( X->p, X->n );
- mbedtls_free( X->p );
- }
-
- X->n = nblimbs;
- X->p = p;
- }
-
- return( 0 );
-}
-
-/*
- * Resize down as much as possible,
- * while keeping at least the specified number of limbs
- */
-int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs )
-{
- mbedtls_mpi_uint *p;
- size_t i;
-
- /* Actually resize up in this case */
- if( X->n <= nblimbs )
- return( mbedtls_mpi_grow( X, nblimbs ) );
-
- for( i = X->n - 1; i > 0; i-- )
- if( X->p[i] != 0 )
- break;
- i++;
-
- if( i < nblimbs )
- i = nblimbs;
-
- if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( i, ciL ) ) == NULL )
- return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
-
- if( X->p != NULL )
- {
- memcpy( p, X->p, i * ciL );
- mbedtls_mpi_zeroize( X->p, X->n );
- mbedtls_free( X->p );
- }
-
- X->n = i;
- X->p = p;
-
- return( 0 );
-}
-
-/*
- * Copy the contents of Y into X
- */
-int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y )
-{
- int ret;
- size_t i;
-
- if( X == Y )
- return( 0 );
-
- if( Y->p == NULL )
- {
- mbedtls_mpi_free( X );
- return( 0 );
- }
-
- for( i = Y->n - 1; i > 0; i-- )
- if( Y->p[i] != 0 )
- break;
- i++;
-
- X->s = Y->s;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) );
-
- memset( X->p, 0, X->n * ciL );
- memcpy( X->p, Y->p, i * ciL );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Swap the contents of X and Y
- */
-void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y )
-{
- mbedtls_mpi T;
-
- memcpy( &T, X, sizeof( mbedtls_mpi ) );
- memcpy( X, Y, sizeof( mbedtls_mpi ) );
- memcpy( Y, &T, sizeof( mbedtls_mpi ) );
-}
-
-/*
- * Conditionally assign X = Y, without leaking information
- * about whether the assignment was made or not.
- * (Leaking information about the respective sizes of X and Y is ok however.)
- */
-int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign )
-{
- int ret = 0;
- size_t i;
-
- /* make sure assign is 0 or 1 in a time-constant manner */
- assign = (assign | (unsigned char)-assign) >> 7;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) );
-
- X->s = X->s * ( 1 - assign ) + Y->s * assign;
-
- for( i = 0; i < Y->n; i++ )
- X->p[i] = X->p[i] * ( 1 - assign ) + Y->p[i] * assign;
-
- for( ; i < X->n; i++ )
- X->p[i] *= ( 1 - assign );
-
-cleanup:
- return( ret );
-}
-
-/*
- * Conditionally swap X and Y, without leaking information
- * about whether the swap was made or not.
- * Here it is not ok to simply swap the pointers, which whould lead to
- * different memory access patterns when X and Y are used afterwards.
- */
-int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char swap )
-{
- int ret, s;
- size_t i;
- mbedtls_mpi_uint tmp;
-
- if( X == Y )
- return( 0 );
-
- /* make sure swap is 0 or 1 in a time-constant manner */
- swap = (swap | (unsigned char)-swap) >> 7;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, Y->n ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( Y, X->n ) );
-
- s = X->s;
- X->s = X->s * ( 1 - swap ) + Y->s * swap;
- Y->s = Y->s * ( 1 - swap ) + s * swap;
-
-
- for( i = 0; i < X->n; i++ )
- {
- tmp = X->p[i];
- X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap;
- Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap;
- }
-
-cleanup:
- return( ret );
-}
-
-/*
- * Set value from integer
- */
-int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z )
-{
- int ret;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, 1 ) );
- memset( X->p, 0, X->n * ciL );
-
- X->p[0] = ( z < 0 ) ? -z : z;
- X->s = ( z < 0 ) ? -1 : 1;
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Get a specific bit
- */
-int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos )
-{
- if( X->n * biL <= pos )
- return( 0 );
-
- return( ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01 );
-}
-
-/*
- * Set a bit to a specific value of 0 or 1
- */
-int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val )
-{
- int ret = 0;
- size_t off = pos / biL;
- size_t idx = pos % biL;
-
- if( val != 0 && val != 1 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- if( X->n * biL <= pos )
- {
- if( val == 0 )
- return( 0 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, off + 1 ) );
- }
-
- X->p[off] &= ~( (mbedtls_mpi_uint) 0x01 << idx );
- X->p[off] |= (mbedtls_mpi_uint) val << idx;
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Return the number of less significant zero-bits
- */
-size_t mbedtls_mpi_lsb( const mbedtls_mpi *X )
-{
- size_t i, j, count = 0;
-
- for( i = 0; i < X->n; i++ )
- for( j = 0; j < biL; j++, count++ )
- if( ( ( X->p[i] >> j ) & 1 ) != 0 )
- return( count );
-
- return( 0 );
-}
-
-/*
- * Count leading zero bits in a given integer
- */
-static size_t mbedtls_clz( const mbedtls_mpi_uint x )
-{
- size_t j;
- mbedtls_mpi_uint mask = (mbedtls_mpi_uint) 1 << (biL - 1);
-
- for( j = 0; j < biL; j++ )
- {
- if( x & mask ) break;
-
- mask >>= 1;
- }
-
- return j;
-}
-
-/*
- * Return the number of bits
- */
-size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X )
-{
- size_t i, j;
-
- if( X->n == 0 )
- return( 0 );
-
- for( i = X->n - 1; i > 0; i-- )
- if( X->p[i] != 0 )
- break;
-
- j = biL - mbedtls_clz( X->p[i] );
-
- return( ( i * biL ) + j );
-}
-
-/*
- * Return the total size in bytes
- */
-size_t mbedtls_mpi_size( const mbedtls_mpi *X )
-{
- return( ( mbedtls_mpi_bitlen( X ) + 7 ) >> 3 );
-}
-
-/*
- * Convert an ASCII character to digit value
- */
-static int mpi_get_digit( mbedtls_mpi_uint *d, int radix, char c )
-{
- *d = 255;
-
- if( c >= 0x30 && c <= 0x39 ) *d = c - 0x30;
- if( c >= 0x41 && c <= 0x46 ) *d = c - 0x37;
- if( c >= 0x61 && c <= 0x66 ) *d = c - 0x57;
-
- if( *d >= (mbedtls_mpi_uint) radix )
- return( MBEDTLS_ERR_MPI_INVALID_CHARACTER );
-
- return( 0 );
-}
-
-/*
- * Import from an ASCII string
- */
-int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s )
-{
- int ret;
- size_t i, j, slen, n;
- mbedtls_mpi_uint d;
- mbedtls_mpi T;
-
- if( radix < 2 || radix > 16 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- mbedtls_mpi_init( &T );
-
- slen = strlen( s );
-
- if( radix == 16 )
- {
- if( slen > MPI_SIZE_T_MAX >> 2 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- n = BITS_TO_LIMBS( slen << 2 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, n ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) );
-
- for( i = slen, j = 0; i > 0; i--, j++ )
- {
- if( i == 1 && s[i - 1] == '-' )
- {
- X->s = -1;
- break;
- }
-
- MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) );
- X->p[j / ( 2 * ciL )] |= d << ( ( j % ( 2 * ciL ) ) << 2 );
- }
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) );
-
- for( i = 0; i < slen; i++ )
- {
- if( i == 0 && s[i] == '-' )
- {
- X->s = -1;
- continue;
- }
-
- MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i] ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T, X, radix ) );
-
- if( X->s == 1 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, &T, d ) );
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( X, &T, d ) );
- }
- }
- }
-
-cleanup:
-
- mbedtls_mpi_free( &T );
-
- return( ret );
-}
-
-/*
- * Helper to write the digits high-order first
- */
-static int mpi_write_hlp( mbedtls_mpi *X, int radix, char **p )
-{
- int ret;
- mbedtls_mpi_uint r;
-
- if( radix < 2 || radix > 16 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, radix ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_div_int( X, NULL, X, radix ) );
-
- if( mbedtls_mpi_cmp_int( X, 0 ) != 0 )
- MBEDTLS_MPI_CHK( mpi_write_hlp( X, radix, p ) );
-
- if( r < 10 )
- *(*p)++ = (char)( r + 0x30 );
- else
- *(*p)++ = (char)( r + 0x37 );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Export into an ASCII string
- */
-int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
- char *buf, size_t buflen, size_t *olen )
-{
- int ret = 0;
- size_t n;
- char *p;
- mbedtls_mpi T;
-
- if( radix < 2 || radix > 16 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- n = mbedtls_mpi_bitlen( X );
- if( radix >= 4 ) n >>= 1;
- if( radix >= 16 ) n >>= 1;
- /*
- * Round up the buffer length to an even value to ensure that there is
- * enough room for hexadecimal values that can be represented in an odd
- * number of digits.
- */
- n += 3 + ( ( n + 1 ) & 1 );
-
- if( buflen < n )
- {
- *olen = n;
- return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
- }
-
- p = buf;
- mbedtls_mpi_init( &T );
-
- if( X->s == -1 )
- *p++ = '-';
-
- if( radix == 16 )
- {
- int c;
- size_t i, j, k;
-
- for( i = X->n, k = 0; i > 0; i-- )
- {
- for( j = ciL; j > 0; j-- )
- {
- c = ( X->p[i - 1] >> ( ( j - 1 ) << 3) ) & 0xFF;
-
- if( c == 0 && k == 0 && ( i + j ) != 2 )
- continue;
-
- *(p++) = "0123456789ABCDEF" [c / 16];
- *(p++) = "0123456789ABCDEF" [c % 16];
- k = 1;
- }
- }
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &T, X ) );
-
- if( T.s == -1 )
- T.s = 1;
-
- MBEDTLS_MPI_CHK( mpi_write_hlp( &T, radix, &p ) );
- }
-
- *p++ = '\0';
- *olen = p - buf;
-
-cleanup:
-
- mbedtls_mpi_free( &T );
-
- return( ret );
-}
-
-#if defined(MBEDTLS_FS_IO)
-/*
- * Read X from an opened file
- */
-int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin )
-{
- mbedtls_mpi_uint d;
- size_t slen;
- char *p;
- /*
- * Buffer should have space for (short) label and decimal formatted MPI,
- * newline characters and '\0'
- */
- char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ];
-
- memset( s, 0, sizeof( s ) );
- if( fgets( s, sizeof( s ) - 1, fin ) == NULL )
- return( MBEDTLS_ERR_MPI_FILE_IO_ERROR );
-
- slen = strlen( s );
- if( slen == sizeof( s ) - 2 )
- return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
-
- if( slen > 0 && s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
- if( slen > 0 && s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
-
- p = s + slen;
- while( p-- > s )
- if( mpi_get_digit( &d, radix, *p ) != 0 )
- break;
-
- return( mbedtls_mpi_read_string( X, radix, p + 1 ) );
-}
-
-/*
- * Write X into an opened file (or stdout if fout == NULL)
- */
-int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout )
-{
- int ret;
- size_t n, slen, plen;
- /*
- * Buffer should have space for (short) label and decimal formatted MPI,
- * newline characters and '\0'
- */
- char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ];
-
- memset( s, 0, sizeof( s ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_write_string( X, radix, s, sizeof( s ) - 2, &n ) );
-
- if( p == NULL ) p = "";
-
- plen = strlen( p );
- slen = strlen( s );
- s[slen++] = '\r';
- s[slen++] = '\n';
-
- if( fout != NULL )
- {
- if( fwrite( p, 1, plen, fout ) != plen ||
- fwrite( s, 1, slen, fout ) != slen )
- return( MBEDTLS_ERR_MPI_FILE_IO_ERROR );
- }
- else
- mbedtls_printf( "%s%s", p, s );
-
-cleanup:
-
- return( ret );
-}
-#endif /* MBEDTLS_FS_IO */
-
-/*
- * Import X from unsigned binary data, big endian
- */
-int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen )
-{
- int ret;
- size_t i, j, n;
-
- for( n = 0; n < buflen; n++ )
- if( buf[n] != 0 )
- break;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) );
-
- for( i = buflen, j = 0; i > n; i--, j++ )
- X->p[j / ciL] |= ((mbedtls_mpi_uint) buf[i - 1]) << ((j % ciL) << 3);
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Export X into unsigned binary data, big endian
- */
-int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen )
-{
- size_t i, j, n;
-
- n = mbedtls_mpi_size( X );
-
- if( buflen < n )
- return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
-
- memset( buf, 0, buflen );
-
- for( i = buflen - 1, j = 0; n > 0; i--, j++, n-- )
- buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) );
-
- return( 0 );
-}
-
-/*
- * Left-shift: X <<= count
- */
-int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count )
-{
- int ret;
- size_t i, v0, t1;
- mbedtls_mpi_uint r0 = 0, r1;
-
- v0 = count / (biL );
- t1 = count & (biL - 1);
-
- i = mbedtls_mpi_bitlen( X ) + count;
-
- if( X->n * biL < i )
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, BITS_TO_LIMBS( i ) ) );
-
- ret = 0;
-
- /*
- * shift by count / limb_size
- */
- if( v0 > 0 )
- {
- for( i = X->n; i > v0; i-- )
- X->p[i - 1] = X->p[i - v0 - 1];
-
- for( ; i > 0; i-- )
- X->p[i - 1] = 0;
- }
-
- /*
- * shift by count % limb_size
- */
- if( t1 > 0 )
- {
- for( i = v0; i < X->n; i++ )
- {
- r1 = X->p[i] >> (biL - t1);
- X->p[i] <<= t1;
- X->p[i] |= r0;
- r0 = r1;
- }
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Right-shift: X >>= count
- */
-int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count )
-{
- size_t i, v0, v1;
- mbedtls_mpi_uint r0 = 0, r1;
-
- v0 = count / biL;
- v1 = count & (biL - 1);
-
- if( v0 > X->n || ( v0 == X->n && v1 > 0 ) )
- return mbedtls_mpi_lset( X, 0 );
-
- /*
- * shift by count / limb_size
- */
- if( v0 > 0 )
- {
- for( i = 0; i < X->n - v0; i++ )
- X->p[i] = X->p[i + v0];
-
- for( ; i < X->n; i++ )
- X->p[i] = 0;
- }
-
- /*
- * shift by count % limb_size
- */
- if( v1 > 0 )
- {
- for( i = X->n; i > 0; i-- )
- {
- r1 = X->p[i - 1] << (biL - v1);
- X->p[i - 1] >>= v1;
- X->p[i - 1] |= r0;
- r0 = r1;
- }
- }
-
- return( 0 );
-}
-
-/*
- * Compare unsigned values
- */
-int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y )
-{
- size_t i, j;
-
- for( i = X->n; i > 0; i-- )
- if( X->p[i - 1] != 0 )
- break;
-
- for( j = Y->n; j > 0; j-- )
- if( Y->p[j - 1] != 0 )
- break;
-
- if( i == 0 && j == 0 )
- return( 0 );
-
- if( i > j ) return( 1 );
- if( j > i ) return( -1 );
-
- for( ; i > 0; i-- )
- {
- if( X->p[i - 1] > Y->p[i - 1] ) return( 1 );
- if( X->p[i - 1] < Y->p[i - 1] ) return( -1 );
- }
-
- return( 0 );
-}
-
-/*
- * Compare signed values
- */
-int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y )
-{
- size_t i, j;
-
- for( i = X->n; i > 0; i-- )
- if( X->p[i - 1] != 0 )
- break;
-
- for( j = Y->n; j > 0; j-- )
- if( Y->p[j - 1] != 0 )
- break;
-
- if( i == 0 && j == 0 )
- return( 0 );
-
- if( i > j ) return( X->s );
- if( j > i ) return( -Y->s );
-
- if( X->s > 0 && Y->s < 0 ) return( 1 );
- if( Y->s > 0 && X->s < 0 ) return( -1 );
-
- for( ; i > 0; i-- )
- {
- if( X->p[i - 1] > Y->p[i - 1] ) return( X->s );
- if( X->p[i - 1] < Y->p[i - 1] ) return( -X->s );
- }
-
- return( 0 );
-}
-
-/*
- * Compare signed values
- */
-int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z )
-{
- mbedtls_mpi Y;
- mbedtls_mpi_uint p[1];
-
- *p = ( z < 0 ) ? -z : z;
- Y.s = ( z < 0 ) ? -1 : 1;
- Y.n = 1;
- Y.p = p;
-
- return( mbedtls_mpi_cmp_mpi( X, &Y ) );
-}
-
-/*
- * Unsigned addition: X = |A| + |B| (HAC 14.7)
- */
-int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret;
- size_t i, j;
- mbedtls_mpi_uint *o, *p, c, tmp;
-
- if( X == B )
- {
- const mbedtls_mpi *T = A; A = X; B = T;
- }
-
- if( X != A )
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) );
-
- /*
- * X should always be positive as a result of unsigned additions.
- */
- X->s = 1;
-
- for( j = B->n; j > 0; j-- )
- if( B->p[j - 1] != 0 )
- break;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) );
-
- o = B->p; p = X->p; c = 0;
-
- /*
- * tmp is used because it might happen that p == o
- */
- for( i = 0; i < j; i++, o++, p++ )
- {
- tmp= *o;
- *p += c; c = ( *p < c );
- *p += tmp; c += ( *p < tmp );
- }
-
- while( c != 0 )
- {
- if( i >= X->n )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + 1 ) );
- p = X->p + i;
- }
-
- *p += c; c = ( *p < c ); i++; p++;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Helper for mbedtls_mpi subtraction
- */
-static void mpi_sub_hlp( size_t n, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d )
-{
- size_t i;
- mbedtls_mpi_uint c, z;
-
- for( i = c = 0; i < n; i++, s++, d++ )
- {
- z = ( *d < c ); *d -= c;
- c = ( *d < *s ) + z; *d -= *s;
- }
-
- while( c != 0 )
- {
- z = ( *d < c ); *d -= c;
- c = z; i++; d++;
- }
-}
-
-/*
- * Unsigned subtraction: X = |A| - |B| (HAC 14.9)
- */
-int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- mbedtls_mpi TB;
- int ret;
- size_t n;
-
- if( mbedtls_mpi_cmp_abs( A, B ) < 0 )
- return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE );
-
- mbedtls_mpi_init( &TB );
-
- if( X == B )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) );
- B = &TB;
- }
-
- if( X != A )
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) );
-
- /*
- * X should always be positive as a result of unsigned subtractions.
- */
- X->s = 1;
-
- ret = 0;
-
- for( n = B->n; n > 0; n-- )
- if( B->p[n - 1] != 0 )
- break;
-
- mpi_sub_hlp( n, B->p, X->p );
-
-cleanup:
-
- mbedtls_mpi_free( &TB );
-
- return( ret );
-}
-
-/*
- * Signed addition: X = A + B
- */
-int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret, s = A->s;
-
- if( A->s * B->s < 0 )
- {
- if( mbedtls_mpi_cmp_abs( A, B ) >= 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) );
- X->s = s;
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) );
- X->s = -s;
- }
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) );
- X->s = s;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Signed subtraction: X = A - B
- */
-int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret, s = A->s;
-
- if( A->s * B->s > 0 )
- {
- if( mbedtls_mpi_cmp_abs( A, B ) >= 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) );
- X->s = s;
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) );
- X->s = -s;
- }
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) );
- X->s = s;
- }
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Signed addition: X = A + b
- */
-int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b )
-{
- mbedtls_mpi _B;
- mbedtls_mpi_uint p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mbedtls_mpi_add_mpi( X, A, &_B ) );
-}
-
-/*
- * Signed subtraction: X = A - b
- */
-int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b )
-{
- mbedtls_mpi _B;
- mbedtls_mpi_uint p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mbedtls_mpi_sub_mpi( X, A, &_B ) );
-}
-
-/*
- * Helper for mbedtls_mpi multiplication
- */
-static
-#if defined(__APPLE__) && defined(__arm__)
-/*
- * Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
- * appears to need this to prevent bad ARM code generation at -O3.
- */
-__attribute__ ((noinline))
-#endif
-void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mpi_uint b )
-{
- mbedtls_mpi_uint c = 0, t = 0;
-
-#if defined(MULADDC_HUIT)
- for( ; i >= 8; i -= 8 )
- {
- MULADDC_INIT
- MULADDC_HUIT
- MULADDC_STOP
- }
-
- for( ; i > 0; i-- )
- {
- MULADDC_INIT
- MULADDC_CORE
- MULADDC_STOP
- }
-#else /* MULADDC_HUIT */
- for( ; i >= 16; i -= 16 )
- {
- MULADDC_INIT
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
-
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_STOP
- }
-
- for( ; i >= 8; i -= 8 )
- {
- MULADDC_INIT
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
-
- MULADDC_CORE MULADDC_CORE
- MULADDC_CORE MULADDC_CORE
- MULADDC_STOP
- }
-
- for( ; i > 0; i-- )
- {
- MULADDC_INIT
- MULADDC_CORE
- MULADDC_STOP
- }
-#endif /* MULADDC_HUIT */
-
- t++;
-
- do {
- *d += c; c = ( *d < c ); d++;
- }
- while( c != 0 );
-}
-
-/*
- * Baseline multiplication: X = A * B (HAC 14.12)
- */
-int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret;
- size_t i, j;
- mbedtls_mpi TA, TB;
-
- mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB );
-
- if( X == A ) { MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); A = &TA; }
- if( X == B ) { MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) ); B = &TB; }
-
- for( i = A->n; i > 0; i-- )
- if( A->p[i - 1] != 0 )
- break;
-
- for( j = B->n; j > 0; j-- )
- if( B->p[j - 1] != 0 )
- break;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + j ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) );
-
- for( i++; j > 0; j-- )
- mpi_mul_hlp( i - 1, A->p, X->p + j - 1, B->p[j - 1] );
-
- X->s = A->s * B->s;
-
-cleanup:
-
- mbedtls_mpi_free( &TB ); mbedtls_mpi_free( &TA );
-
- return( ret );
-}
-
-/*
- * Baseline multiplication: X = A * b
- */
-int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b )
-{
- mbedtls_mpi _B;
- mbedtls_mpi_uint p[1];
-
- _B.s = 1;
- _B.n = 1;
- _B.p = p;
- p[0] = b;
-
- return( mbedtls_mpi_mul_mpi( X, A, &_B ) );
-}
-
-/*
- * Unsigned integer divide - double mbedtls_mpi_uint dividend, u1/u0, and
- * mbedtls_mpi_uint divisor, d
- */
-static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1,
- mbedtls_mpi_uint u0, mbedtls_mpi_uint d, mbedtls_mpi_uint *r )
-{
-#if defined(MBEDTLS_HAVE_UDBL)
- mbedtls_t_udbl dividend, quotient;
-#else
- const mbedtls_mpi_uint radix = (mbedtls_mpi_uint) 1 << biH;
- const mbedtls_mpi_uint uint_halfword_mask = ( (mbedtls_mpi_uint) 1 << biH ) - 1;
- mbedtls_mpi_uint d0, d1, q0, q1, rAX, r0, quotient;
- mbedtls_mpi_uint u0_msw, u0_lsw;
- size_t s;
-#endif
-
- /*
- * Check for overflow
- */
- if( 0 == d || u1 >= d )
- {
- if (r != NULL) *r = ~0;
-
- return ( ~0 );
- }
-
-#if defined(MBEDTLS_HAVE_UDBL)
- dividend = (mbedtls_t_udbl) u1 << biL;
- dividend |= (mbedtls_t_udbl) u0;
- quotient = dividend / d;
- if( quotient > ( (mbedtls_t_udbl) 1 << biL ) - 1 )
- quotient = ( (mbedtls_t_udbl) 1 << biL ) - 1;
-
- if( r != NULL )
- *r = (mbedtls_mpi_uint)( dividend - (quotient * d ) );
-
- return (mbedtls_mpi_uint) quotient;
-#else
-
- /*
- * Algorithm D, Section 4.3.1 - The Art of Computer Programming
- * Vol. 2 - Seminumerical Algorithms, Knuth
- */
-
- /*
- * Normalize the divisor, d, and dividend, u0, u1
- */
- s = mbedtls_clz( d );
- d = d << s;
-
- u1 = u1 << s;
- u1 |= ( u0 >> ( biL - s ) ) & ( -(mbedtls_mpi_sint)s >> ( biL - 1 ) );
- u0 = u0 << s;
-
- d1 = d >> biH;
- d0 = d & uint_halfword_mask;
-
- u0_msw = u0 >> biH;
- u0_lsw = u0 & uint_halfword_mask;
-
- /*
- * Find the first quotient and remainder
- */
- q1 = u1 / d1;
- r0 = u1 - d1 * q1;
-
- while( q1 >= radix || ( q1 * d0 > radix * r0 + u0_msw ) )
- {
- q1 -= 1;
- r0 += d1;
-
- if ( r0 >= radix ) break;
- }
-
- rAX = ( u1 * radix ) + ( u0_msw - q1 * d );
- q0 = rAX / d1;
- r0 = rAX - q0 * d1;
-
- while( q0 >= radix || ( q0 * d0 > radix * r0 + u0_lsw ) )
- {
- q0 -= 1;
- r0 += d1;
-
- if ( r0 >= radix ) break;
- }
-
- if (r != NULL)
- *r = ( rAX * radix + u0_lsw - q0 * d ) >> s;
-
- quotient = q1 * radix + q0;
-
- return quotient;
-#endif
-}
-
-/*
- * Division by mbedtls_mpi: A = Q * B + R (HAC 14.20)
- */
-int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret;
- size_t i, n, t, k;
- mbedtls_mpi X, Y, Z, T1, T2;
-
- if( mbedtls_mpi_cmp_int( B, 0 ) == 0 )
- return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO );
-
- mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z );
- mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 );
-
- if( mbedtls_mpi_cmp_abs( A, B ) < 0 )
- {
- if( Q != NULL ) MBEDTLS_MPI_CHK( mbedtls_mpi_lset( Q, 0 ) );
- if( R != NULL ) MBEDTLS_MPI_CHK( mbedtls_mpi_copy( R, A ) );
- return( 0 );
- }
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &X, A ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, B ) );
- X.s = Y.s = 1;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &Z, A->n + 2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &Z, 0 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T1, 2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T2, 3 ) );
-
- k = mbedtls_mpi_bitlen( &Y ) % biL;
- if( k < biL - 1 )
- {
- k = biL - 1 - k;
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &X, k ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &Y, k ) );
- }
- else k = 0;
-
- n = X.n - 1;
- t = Y.n - 1;
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &Y, biL * ( n - t ) ) );
-
- while( mbedtls_mpi_cmp_mpi( &X, &Y ) >= 0 )
- {
- Z.p[n - t]++;
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &Y ) );
- }
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, biL * ( n - t ) ) );
-
- for( i = n; i > t ; i-- )
- {
- if( X.p[i] >= Y.p[t] )
- Z.p[i - t - 1] = ~0;
- else
- {
- Z.p[i - t - 1] = mbedtls_int_div_int( X.p[i], X.p[i - 1],
- Y.p[t], NULL);
- }
-
- Z.p[i - t - 1]++;
- do
- {
- Z.p[i - t - 1]--;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &T1, 0 ) );
- T1.p[0] = ( t < 1 ) ? 0 : Y.p[t - 1];
- T1.p[1] = Y.p[t];
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &T2, 0 ) );
- T2.p[0] = ( i < 2 ) ? 0 : X.p[i - 2];
- T2.p[1] = ( i < 1 ) ? 0 : X.p[i - 1];
- T2.p[2] = X.p[i];
- }
- while( mbedtls_mpi_cmp_mpi( &T1, &T2 ) > 0 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &X, &X, &T1 ) );
-
- if( mbedtls_mpi_cmp_int( &X, 0 ) < 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &T1, &Y ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &X, &X, &T1 ) );
- Z.p[i - t - 1]--;
- }
- }
-
- if( Q != NULL )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( Q, &Z ) );
- Q->s = A->s * B->s;
- }
-
- if( R != NULL )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &X, k ) );
- X.s = A->s;
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( R, &X ) );
-
- if( mbedtls_mpi_cmp_int( R, 0 ) == 0 )
- R->s = 1;
- }
-
-cleanup:
-
- mbedtls_mpi_free( &X ); mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &Z );
- mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 );
-
- return( ret );
-}
-
-/*
- * Division by int: A = Q * b + R
- */
-int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b )
-{
- mbedtls_mpi _B;
- mbedtls_mpi_uint p[1];
-
- p[0] = ( b < 0 ) ? -b : b;
- _B.s = ( b < 0 ) ? -1 : 1;
- _B.n = 1;
- _B.p = p;
-
- return( mbedtls_mpi_div_mpi( Q, R, A, &_B ) );
-}
-
-/*
- * Modulo: R = A mod B
- */
-int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret;
-
- if( mbedtls_mpi_cmp_int( B, 0 ) < 0 )
- return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( NULL, R, A, B ) );
-
- while( mbedtls_mpi_cmp_int( R, 0 ) < 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) );
-
- while( mbedtls_mpi_cmp_mpi( R, B ) >= 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) );
-
-cleanup:
-
- return( ret );
-}
-
-/*
- * Modulo: r = A mod b
- */
-int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b )
-{
- size_t i;
- mbedtls_mpi_uint x, y, z;
-
- if( b == 0 )
- return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO );
-
- if( b < 0 )
- return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE );
-
- /*
- * handle trivial cases
- */
- if( b == 1 )
- {
- *r = 0;
- return( 0 );
- }
-
- if( b == 2 )
- {
- *r = A->p[0] & 1;
- return( 0 );
- }
-
- /*
- * general case
- */
- for( i = A->n, y = 0; i > 0; i-- )
- {
- x = A->p[i - 1];
- y = ( y << biH ) | ( x >> biH );
- z = y / b;
- y -= z * b;
-
- x <<= biH;
- y = ( y << biH ) | ( x >> biH );
- z = y / b;
- y -= z * b;
- }
-
- /*
- * If A is negative, then the current y represents a negative value.
- * Flipping it to the positive side.
- */
- if( A->s < 0 && y != 0 )
- y = b - y;
-
- *r = y;
-
- return( 0 );
-}
-
-/*
- * Fast Montgomery initialization (thanks to Tom St Denis)
- */
-static void mpi_montg_init( mbedtls_mpi_uint *mm, const mbedtls_mpi *N )
-{
- mbedtls_mpi_uint x, m0 = N->p[0];
- unsigned int i;
-
- x = m0;
- x += ( ( m0 + 2 ) & 4 ) << 1;
-
- for( i = biL; i >= 8; i /= 2 )
- x *= ( 2 - ( m0 * x ) );
-
- *mm = ~x + 1;
-}
-
-/*
- * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36)
- */
-static int mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_uint mm,
- const mbedtls_mpi *T )
-{
- size_t i, n, m;
- mbedtls_mpi_uint u0, u1, *d;
-
- if( T->n < N->n + 1 || T->p == NULL )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- memset( T->p, 0, T->n * ciL );
-
- d = T->p;
- n = N->n;
- m = ( B->n < n ) ? B->n : n;
-
- for( i = 0; i < n; i++ )
- {
- /*
- * T = (T + u0*B + u1*N) / 2^biL
- */
- u0 = A->p[i];
- u1 = ( d[0] + u0 * B->p[0] ) * mm;
-
- mpi_mul_hlp( m, B->p, d, u0 );
- mpi_mul_hlp( n, N->p, d, u1 );
-
- *d++ = u0; d[n + 1] = 0;
- }
-
- memcpy( A->p, d, ( n + 1 ) * ciL );
-
- if( mbedtls_mpi_cmp_abs( A, N ) >= 0 )
- mpi_sub_hlp( n, N->p, A->p );
- else
- /* prevent timing attacks */
- mpi_sub_hlp( n, A->p, T->p );
-
- return( 0 );
-}
-
-/*
- * Montgomery reduction: A = A * R^-1 mod N
- */
-static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint mm, const mbedtls_mpi *T )
-{
- mbedtls_mpi_uint z = 1;
- mbedtls_mpi U;
-
- U.n = U.s = (int) z;
- U.p = &z;
-
- return( mpi_montmul( A, &U, N, mm, T ) );
-}
-
-/*
- * Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
- */
-int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR )
-{
- int ret;
- size_t wbits, wsize, one = 1;
- size_t i, j, nblimbs;
- size_t bufsize, nbits;
- mbedtls_mpi_uint ei, mm, state;
- struct {
- mbedtls_mpi RR, T, W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ], Apos;
- } *ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
- int neg;
-
- if (!ctx)
- return -ENOMEM;
-
- if( mbedtls_mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 ) {
- ret = ( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
- goto free_ctx;
- }
-
- if( mbedtls_mpi_cmp_int( E, 0 ) < 0 ) {
- ret = ( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
- goto free_ctx;
- }
-
- /*
- * Init temps and window size
- */
- mpi_montg_init( &mm, N );
- mbedtls_mpi_init( &ctx->RR ); mbedtls_mpi_init( &ctx->T );
- mbedtls_mpi_init( &ctx->Apos );
- memset( ctx->W, 0, sizeof( ctx->W ) );
-
- i = mbedtls_mpi_bitlen( E );
-
- wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 :
- ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1;
-
- if( wsize > MBEDTLS_MPI_WINDOW_SIZE )
- wsize = MBEDTLS_MPI_WINDOW_SIZE;
-
- j = N->n + 1;
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &ctx->W[1], j ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &ctx->T, j * 2 ) );
-
- /*
- * Compensate for negative A (and correct at the end)
- */
- neg = ( A->s == -1 );
- if( neg )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &ctx->Apos, A ) );
- ctx->Apos.s = 1;
- A = &ctx->Apos;
- }
-
- /*
- * If 1st call, pre-compute R^2 mod N
- */
- if( _RR == NULL || _RR->p == NULL )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->RR, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &ctx->RR, N->n * 2 * biL ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->RR, &ctx->RR, N ) );
-
- if( _RR != NULL )
- memcpy( _RR, &ctx->RR, sizeof( mbedtls_mpi ) );
- }
- else
- memcpy( &ctx->RR, _RR, sizeof( mbedtls_mpi ) );
-
- /*
- * W[1] = A * R^2 * R^-1 mod N = A * R mod N
- */
- if( mbedtls_mpi_cmp_mpi( A, N ) >= 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->W[1], A, N ) );
- else
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &ctx->W[1], A ) );
-
- MBEDTLS_MPI_CHK( mpi_montmul( &ctx->W[1], &ctx->RR, N, mm, &ctx->T ) );
-
- /*
- * X = R^2 * R^-1 mod N = R mod N
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, &ctx->RR ) );
- MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &ctx->T ) );
-
- if( wsize > 1 )
- {
- /*
- * W[1 << (wsize - 1)] = W[1] ^ (wsize - 1)
- */
- j = one << ( wsize - 1 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &ctx->W[j], N->n + 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &ctx->W[j], &ctx->W[1] ) );
-
- for( i = 0; i < wsize - 1; i++ )
- MBEDTLS_MPI_CHK( mpi_montmul( &ctx->W[j], &ctx->W[j], N, mm, &ctx->T ) );
-
- /*
- * W[i] = W[i - 1] * W[1]
- */
- for( i = j + 1; i < ( one << wsize ); i++ )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &ctx->W[i], N->n + 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &ctx->W[i], &ctx->W[i - 1] ) );
-
- MBEDTLS_MPI_CHK( mpi_montmul( &ctx->W[i], &ctx->W[1], N, mm, &ctx->T ) );
- }
- }
-
- nblimbs = E->n;
- bufsize = 0;
- nbits = 0;
- wbits = 0;
- state = 0;
-
- while( 1 )
- {
- if( bufsize == 0 )
- {
- if( nblimbs == 0 )
- break;
-
- nblimbs--;
-
- bufsize = sizeof( mbedtls_mpi_uint ) << 3;
- }
-
- bufsize--;
-
- ei = (E->p[nblimbs] >> bufsize) & 1;
-
- /*
- * skip leading 0s
- */
- if( ei == 0 && state == 0 )
- continue;
-
- if( ei == 0 && state == 1 )
- {
- /*
- * out of window, square X
- */
- MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &ctx->T ) );
- continue;
- }
-
- /*
- * add ei to current window
- */
- state = 2;
-
- nbits++;
- wbits |= ( ei << ( wsize - nbits ) );
-
- if( nbits == wsize )
- {
- /*
- * X = X^wsize R^-1 mod N
- */
- for( i = 0; i < wsize; i++ )
- MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &ctx->T ) );
-
- /*
- * X = X * W[wbits] R^-1 mod N
- */
- MBEDTLS_MPI_CHK( mpi_montmul( X, &ctx->W[wbits], N, mm, &ctx->T ) );
-
- state--;
- nbits = 0;
- wbits = 0;
- }
- }
-
- /*
- * process the remaining bits
- */
- for( i = 0; i < nbits; i++ )
- {
- MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &ctx->T ) );
-
- wbits <<= 1;
-
- if( ( wbits & ( one << wsize ) ) != 0 )
- MBEDTLS_MPI_CHK( mpi_montmul( X, &ctx->W[1], N, mm, &ctx->T ) );
- }
-
- /*
- * X = A^E * R * R^-1 mod N = A^E mod N
- */
- MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &ctx->T ) );
-
- if( neg && E->n != 0 && ( E->p[0] & 1 ) != 0 )
- {
- X->s = -1;
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) );
- }
-
-cleanup:
-
- for( i = ( one << ( wsize - 1 ) ); i < ( one << wsize ); i++ )
- mbedtls_mpi_free( &ctx->W[i] );
-
- mbedtls_mpi_free( &ctx->W[1] ); mbedtls_mpi_free( &ctx->T ); mbedtls_mpi_free( &ctx->Apos );
-
- if( _RR == NULL || _RR->p == NULL )
- mbedtls_mpi_free( &ctx->RR );
-free_ctx:
- kfree(ctx);
-
- return( ret );
-}
-
-/*
- * Greatest common divisor: G = gcd(A, B) (HAC 14.54)
- */
-int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B )
-{
- int ret;
- size_t lz, lzt;
- mbedtls_mpi TG, TA, TB;
-
- mbedtls_mpi_init( &TG ); mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) );
-
- lz = mbedtls_mpi_lsb( &TA );
- lzt = mbedtls_mpi_lsb( &TB );
-
- if( lzt < lz )
- lz = lzt;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, lz ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, lz ) );
-
- TA.s = TB.s = 1;
-
- while( mbedtls_mpi_cmp_int( &TA, 0 ) != 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, mbedtls_mpi_lsb( &TA ) ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, mbedtls_mpi_lsb( &TB ) ) );
-
- if( mbedtls_mpi_cmp_mpi( &TA, &TB ) >= 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TA, &TA, &TB ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, 1 ) );
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &TB, &TB, &TA ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, 1 ) );
- }
- }
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &TB, lz ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( G, &TB ) );
-
-cleanup:
-
- mbedtls_mpi_free( &TG ); mbedtls_mpi_free( &TA ); mbedtls_mpi_free( &TB );
-
- return( ret );
-}
-
-/*
- * Fill X with size bytes of random.
- *
- * Use a temporary bytes representation to make sure the result is the same
- * regardless of the platform endianness (useful when f_rng is actually
- * deterministic, eg for tests).
- */
-int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng )
-{
- int ret;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-
- if( size > MBEDTLS_MPI_MAX_SIZE )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- MBEDTLS_MPI_CHK( f_rng( p_rng, buf, size ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) );
-
-cleanup:
- return( ret );
-}
-
-/*
- * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64)
- */
-int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N )
-{
- int ret;
- mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
-
- if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TU ); mbedtls_mpi_init( &U1 ); mbedtls_mpi_init( &U2 );
- mbedtls_mpi_init( &G ); mbedtls_mpi_init( &TB ); mbedtls_mpi_init( &TV );
- mbedtls_mpi_init( &V1 ); mbedtls_mpi_init( &V2 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, A, N ) );
-
- if( mbedtls_mpi_cmp_int( &G, 1 ) != 0 )
- {
- ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE;
- goto cleanup;
- }
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &TA, A, N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TU, &TA ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TV, N ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &U1, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &U2, 0 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &V1, 0 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &V2, 1 ) );
-
- do
- {
- while( ( TU.p[0] & 1 ) == 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TU, 1 ) );
-
- if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &U1, &U1, &TB ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U2, &U2, &TA ) );
- }
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &U1, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &U2, 1 ) );
- }
-
- while( ( TV.p[0] & 1 ) == 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TV, 1 ) );
-
- if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &V1, &V1, &TB ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V2, &V2, &TA ) );
- }
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &V1, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &V2, 1 ) );
- }
-
- if( mbedtls_mpi_cmp_mpi( &TU, &TV ) >= 0 )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &TU, &TU, &TV ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U1, &U1, &V1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &U2, &U2, &V2 ) );
- }
- else
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &TV, &TV, &TU ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V1, &V1, &U1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V2, &V2, &U2 ) );
- }
- }
- while( mbedtls_mpi_cmp_int( &TU, 0 ) != 0 );
-
- while( mbedtls_mpi_cmp_int( &V1, 0 ) < 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &V1, &V1, N ) );
-
- while( mbedtls_mpi_cmp_mpi( &V1, N ) >= 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V1, &V1, N ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, &V1 ) );
-
-cleanup:
-
- mbedtls_mpi_free( &TA ); mbedtls_mpi_free( &TU ); mbedtls_mpi_free( &U1 ); mbedtls_mpi_free( &U2 );
- mbedtls_mpi_free( &G ); mbedtls_mpi_free( &TB ); mbedtls_mpi_free( &TV );
- mbedtls_mpi_free( &V1 ); mbedtls_mpi_free( &V2 );
-
- return( ret );
-}
-
-#if defined(MBEDTLS_GENPRIME)
-
-static const int small_prime[] =
-{
- 3, 5, 7, 11, 13, 17, 19, 23,
- 29, 31, 37, 41, 43, 47, 53, 59,
- 61, 67, 71, 73, 79, 83, 89, 97,
- 101, 103, 107, 109, 113, 127, 131, 137,
- 139, 149, 151, 157, 163, 167, 173, 179,
- 181, 191, 193, 197, 199, 211, 223, 227,
- 229, 233, 239, 241, 251, 257, 263, 269,
- 271, 277, 281, 283, 293, 307, 311, 313,
- 317, 331, 337, 347, 349, 353, 359, 367,
- 373, 379, 383, 389, 397, 401, 409, 419,
- 421, 431, 433, 439, 443, 449, 457, 461,
- 463, 467, 479, 487, 491, 499, 503, 509,
- 521, 523, 541, 547, 557, 563, 569, 571,
- 577, 587, 593, 599, 601, 607, 613, 617,
- 619, 631, 641, 643, 647, 653, 659, 661,
- 673, 677, 683, 691, 701, 709, 719, 727,
- 733, 739, 743, 751, 757, 761, 769, 773,
- 787, 797, 809, 811, 821, 823, 827, 829,
- 839, 853, 857, 859, 863, 877, 881, 883,
- 887, 907, 911, 919, 929, 937, 941, 947,
- 953, 967, 971, 977, 983, 991, 997, -103
-};
-
-/*
- * Small divisors test (X must be positive)
- *
- * Return values:
- * 0: no small factor (possible prime, more tests needed)
- * 1: certain prime
- * MBEDTLS_ERR_MPI_NOT_ACCEPTABLE: certain non-prime
- * other negative: error
- */
-static int mpi_check_small_factors( const mbedtls_mpi *X )
-{
- int ret = 0;
- size_t i;
- mbedtls_mpi_uint r;
-
- if( ( X->p[0] & 1 ) == 0 )
- return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE );
-
- for( i = 0; small_prime[i] > 0; i++ )
- {
- if( mbedtls_mpi_cmp_int( X, small_prime[i] ) <= 0 )
- return( 1 );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, small_prime[i] ) );
-
- if( r == 0 )
- return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE );
- }
-
-cleanup:
- return( ret );
-}
-
-/*
- * Miller-Rabin pseudo-primality test (HAC 4.24)
- */
-static int mpi_miller_rabin( const mbedtls_mpi *X,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng )
-{
- int ret, count;
- size_t i, j, k, n, s;
- mbedtls_mpi W, R, T, A, RR;
-
- mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &A );
- mbedtls_mpi_init( &RR );
-
- /*
- * W = |X| - 1
- * R = W >> lsb( W )
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &W, X, 1 ) );
- s = mbedtls_mpi_lsb( &W );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &R, &W ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &R, s ) );
-
- i = mbedtls_mpi_bitlen( X );
- /*
- * HAC, table 4.4
- */
- n = ( ( i >= 1300 ) ? 2 : ( i >= 850 ) ? 3 :
- ( i >= 650 ) ? 4 : ( i >= 350 ) ? 8 :
- ( i >= 250 ) ? 12 : ( i >= 150 ) ? 18 : 27 );
-
- for( i = 0; i < n; i++ )
- {
- /*
- * pick a random A, 1 < A < |X| - 1
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) );
-
- if( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 )
- {
- j = mbedtls_mpi_bitlen( &A ) - mbedtls_mpi_bitlen( &W );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &A, j + 1 ) );
- }
- A.p[0] |= 3;
-
- count = 0;
- do {
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) );
-
- j = mbedtls_mpi_bitlen( &A );
- k = mbedtls_mpi_bitlen( &W );
- if (j > k) {
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &A, j - k ) );
- }
-
- if (count++ > 30) {
- return MBEDTLS_ERR_MPI_NOT_ACCEPTABLE;
- }
-
- } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 ||
- mbedtls_mpi_cmp_int( &A, 1 ) <= 0 );
-
- /*
- * A = A^R mod |X|
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &A, &A, &R, X, &RR ) );
-
- if( mbedtls_mpi_cmp_mpi( &A, &W ) == 0 ||
- mbedtls_mpi_cmp_int( &A, 1 ) == 0 )
- continue;
-
- j = 1;
- while( j < s && mbedtls_mpi_cmp_mpi( &A, &W ) != 0 )
- {
- /*
- * A = A * A mod |X|
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &A, &A ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &A, &T, X ) );
-
- if( mbedtls_mpi_cmp_int( &A, 1 ) == 0 )
- break;
-
- j++;
- }
-
- /*
- * not prime if A != |X| - 1 or A == 1
- */
- if( mbedtls_mpi_cmp_mpi( &A, &W ) != 0 ||
- mbedtls_mpi_cmp_int( &A, 1 ) == 0 )
- {
- ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE;
- break;
- }
- }
-
-cleanup:
- mbedtls_mpi_free( &W ); mbedtls_mpi_free( &R ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &A );
- mbedtls_mpi_free( &RR );
-
- return( ret );
-}
-
-/*
- * Pseudo-primality test: small factors, then Miller-Rabin
- */
-int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng )
-{
- int ret;
- mbedtls_mpi XX;
-
- XX.s = 1;
- XX.n = X->n;
- XX.p = X->p;
-
- if( mbedtls_mpi_cmp_int( &XX, 0 ) == 0 ||
- mbedtls_mpi_cmp_int( &XX, 1 ) == 0 )
- return( MBEDTLS_ERR_MPI_NOT_ACCEPTABLE );
-
- if( mbedtls_mpi_cmp_int( &XX, 2 ) == 0 )
- return( 0 );
-
- if( ( ret = mpi_check_small_factors( &XX ) ) != 0 )
- {
- if( ret == 1 )
- return( 0 );
-
- return( ret );
- }
-
- return( mpi_miller_rabin( &XX, f_rng, p_rng ) );
-}
-
-/*
- * Prime number generation
- */
-int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng )
-{
- int ret;
- size_t k, n;
- mbedtls_mpi_uint r;
- mbedtls_mpi Y;
-
- if( nbits < 3 || nbits > MBEDTLS_MPI_MAX_BITS )
- return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
-
- mbedtls_mpi_init( &Y );
-
- n = BITS_TO_LIMBS( nbits );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( X, n * ciL, f_rng, p_rng ) );
-
- k = mbedtls_mpi_bitlen( X );
- if( k > nbits ) MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( X, k - nbits + 1 ) );
-
- mbedtls_mpi_set_bit( X, nbits-1, 1 );
-
- X->p[0] |= 1;
-
- if( dh_flag == 0 )
- {
- while( ( ret = mbedtls_mpi_is_prime( X, f_rng, p_rng ) ) != 0 )
- {
- if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE )
- goto cleanup;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 2 ) );
- }
- }
- else
- {
- /*
- * An necessary condition for Y and X = 2Y + 1 to be prime
- * is X = 2 mod 3 (which is equivalent to Y = 2 mod 3).
- * Make sure it is satisfied, while keeping X = 3 mod 4
- */
-
- X->p[0] |= 2;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, 3 ) );
- if( r == 0 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 8 ) );
- else if( r == 1 )
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 4 ) );
-
- /* Set Y = (X-1) / 2, which is X / 2 because X is odd */
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, X ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, 1 ) );
-
- while( 1 )
- {
- /*
- * First, check small factors for X and Y
- * before doing Miller-Rabin on any of them
- */
- if( ( ret = mpi_check_small_factors( X ) ) == 0 &&
- ( ret = mpi_check_small_factors( &Y ) ) == 0 &&
- ( ret = mpi_miller_rabin( X, f_rng, p_rng ) ) == 0 &&
- ( ret = mpi_miller_rabin( &Y, f_rng, p_rng ) ) == 0 )
- {
- break;
- }
-
- if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE )
- goto cleanup;
-
- /*
- * Next candidates. We want to preserve Y = (X-1) / 2 and
- * Y = 1 mod 2 and Y = 2 mod 3 (eq X = 3 mod 4 and X = 2 mod 3)
- * so up Y by 6 and X by 12.
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 12 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &Y, &Y, 6 ) );
- }
- }
-
-cleanup:
-
- mbedtls_mpi_free( &Y );
-
- return( ret );
-}
-
-#endif /* MBEDTLS_GENPRIME */
-
-#if defined(MBEDTLS_SELF_TEST)
-
-#define GCD_PAIR_COUNT 3
-
-static const int gcd_pairs[GCD_PAIR_COUNT][3] =
-{
- { 693, 609, 21 },
- { 1764, 868, 28 },
- { 768454923, 542167814, 1 }
-};
-
-/*
- * Checkup routine
- */
-int mbedtls_mpi_self_test( int verbose )
-{
- int ret, i;
- mbedtls_mpi A, E, N, X, Y, U, V;
-
- mbedtls_mpi_init( &A ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &X );
- mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &U ); mbedtls_mpi_init( &V );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &A, 16,
- "EFE021C2645FD1DC586E69184AF4A31E" \
- "D5F53E93B5F123FA41680867BA110131" \
- "944FE7952E2517337780CB0DB80E61AA" \
- "E7C8DDC6C5C6AADEB34EB38A2F40D5E6" ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &E, 16,
- "B2E7EFD37075B9F03FF989C7C5051C20" \
- "34D2A323810251127E7BF8625A4F49A5" \
- "F3E27F4DA8BD59C47D6DAABA4C8127BD" \
- "5B5C25763222FEFCCFC38B832366C29E" ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &N, 16,
- "0066A198186C18C10B2F5ED9B522752A" \
- "9830B69916E535C8F047518A889A43A5" \
- "94B6BED27A168D31D4A52F88925AA8F5" ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &X, &A, &N ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16,
- "602AB7ECA597A3D6B56FF9829A5E8B85" \
- "9E857EA95A03512E2BAE7391688D264A" \
- "A5663B0341DB9CCFD2C4C5F421FEC814" \
- "8001B72E848A38CAE1C65F78E56ABDEF" \
- "E12D3C039B8A02D6BE593F0BBBDA56F1" \
- "ECF677152EF804370C1A305CAF3B5BF1" \
- "30879B56C61DE584A0F53A2447A51E" ) );
-
- if( verbose != 0 )
- mbedtls_printf( " MPI test #1 (mul_mpi): " );
-
- if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto cleanup;
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &X, &Y, &A, &N ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16,
- "256567336059E52CAE22925474705F39A94" ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &V, 16,
- "6613F26162223DF488E9CD48CC132C7A" \
- "0AC93C701B001B092E4E5B9F73BCD27B" \
- "9EE50D0657C77F374E903CDFA4C642" ) );
-
- if( verbose != 0 )
- mbedtls_printf( " MPI test #2 (div_mpi): " );
-
- if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 ||
- mbedtls_mpi_cmp_mpi( &Y, &V ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto cleanup;
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &X, &A, &E, &N, NULL ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16,
- "36E139AEA55215609D2816998ED020BB" \
- "BD96C37890F65171D948E9BC7CBAA4D9" \
- "325D24D6A3C12710F10A09FA08AB87" ) );
-
- if( verbose != 0 )
- mbedtls_printf( " MPI test #3 (exp_mod): " );
-
- if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto cleanup;
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &X, &A, &N ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &U, 16,
- "003A0AAEDD7E784FC07D8F9EC6E3BFD5" \
- "C3DBA76456363A10869622EAC2DD84EC" \
- "C5B8A74DAC4D09E03B5E0BE779F2DF61" ) );
-
- if( verbose != 0 )
- mbedtls_printf( " MPI test #4 (inv_mod): " );
-
- if( mbedtls_mpi_cmp_mpi( &X, &U ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto cleanup;
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
- if( verbose != 0 )
- mbedtls_printf( " MPI test #5 (simple gcd): " );
-
- for( i = 0; i < GCD_PAIR_COUNT; i++ )
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &X, gcd_pairs[i][0] ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &Y, gcd_pairs[i][1] ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &A, &X, &Y ) );
-
- if( mbedtls_mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed at %d\n", i );
-
- ret = 1;
- goto cleanup;
- }
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
-cleanup:
-
- if( ret != 0 && verbose != 0 )
- mbedtls_printf( "Unexpected error, return code = %08X\n", ret );
-
- mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N ); mbedtls_mpi_free( &X );
- mbedtls_mpi_free( &Y ); mbedtls_mpi_free( &U ); mbedtls_mpi_free( &V );
-
- if( verbose != 0 )
- mbedtls_printf( "\n" );
-
- return( ret );
-}
-
-#endif /* MBEDTLS_SELF_TEST */
-
-#endif /* MBEDTLS_BIGNUM_C */
diff --git a/backport/compat/verification/key.c b/backport/compat/verification/key.c
deleted file mode 100644
index 329f8b22..00000000
--- a/backport/compat/verification/key.c
+++ /dev/null
@@ -1,172 +0,0 @@
-#include <linux/export.h>
-#include <linux/slab.h>
-#include <linux/key.h>
-#include <linux/err.h>
-#include <keys/asymmetric-type.h>
-#include "x509_parser.h"
-
-static void keyring_clear(struct key *keyring)
-{
- struct key *key, *tmp;
-
- if (!keyring->keyring)
- return;
-
- list_for_each_entry_safe(key, tmp, &keyring->list, list) {
- WARN_ON(refcount_read(&key->refcount) > 1);
- key_put(key);
- }
-}
-
-void key_put(struct key *key)
-{
- if (refcount_dec_and_test(&key->refcount)) {
- keyring_clear(key);
- list_del(&key->list);
- kfree(key->description);
- public_key_free(key->public_key);
- public_key_signature_free(key->sig);
- kfree(key->kids.id[0]);
- kfree(key->kids.id[1]);
- kfree(key);
- }
-}
-EXPORT_SYMBOL_GPL(key_put);
-
-static struct key *key_alloc(void)
-{
- struct key *key = kzalloc(sizeof(*key), GFP_KERNEL);
-
- if (!key)
- return NULL;
- refcount_set(&key->refcount, 1);
- INIT_LIST_HEAD(&key->list);
-
- return key;
-}
-
-struct key *bp_keyring_alloc(void)
-{
- struct key *key = key_alloc();
-
- if (!key)
- return NULL;
-
- key->keyring = true;
-
- return key;
-}
-EXPORT_SYMBOL_GPL(bp_keyring_alloc);
-
-key_ref_t bp_key_create_or_update(key_ref_t keyring,
- const char *description,
- const void *payload,
- size_t plen)
-{
- struct key *key = key_alloc();
- struct x509_certificate *cert;
- const char *q;
- size_t srlen, sulen;
- char *desc = NULL, *p;
- int err;
-
- if (!key)
- return NULL;
-
- cert = x509_cert_parse(payload, plen);
- if (IS_ERR(cert)) {
- err = PTR_ERR(cert);
- goto free;
- }
-
- if (cert->unsupported_sig) {
- public_key_signature_free(cert->sig);
- cert->sig = NULL;
- }
-
- sulen = strlen(cert->subject);
- if (cert->raw_skid) {
- srlen = cert->raw_skid_size;
- q = cert->raw_skid;
- } else {
- srlen = cert->raw_serial_size;
- q = cert->raw_serial;
- }
-
- err = -ENOMEM;
- desc = kmalloc(sulen + 2 + srlen * 2 + 1, GFP_KERNEL);
- if (!desc)
- goto free;
- p = memcpy(desc, cert->subject, sulen);
- p += sulen;
- *p++ = ':';
- *p++ = ' ';
- p = bin2hex(p, q, srlen);
- *p = 0;
- key->description = desc;
-
- key->kids.id[0] = cert->id;
- key->kids.id[1] = cert->skid;
- key->public_key = cert->pub;
- key->sig = cert->sig;
-
- cert->id = NULL;
- cert->skid = NULL;
- cert->pub = NULL;
- cert->sig = NULL;
- x509_free_certificate(cert);
-
- refcount_inc(&key->refcount);
- list_add_tail(&key->list, &key_ref_to_ptr(keyring)->list);
-
- return make_key_ref(key, 0);
-free:
- kfree(key);
- return ERR_PTR(err);
-}
-EXPORT_SYMBOL_GPL(bp_key_create_or_update);
-
-struct key *find_asymmetric_key(struct key *keyring,
- const struct asymmetric_key_id *id_0,
- const struct asymmetric_key_id *id_1,
- bool partial)
-{
- struct key *key;
-
- if (WARN_ON(partial))
- return ERR_PTR(-ENOENT);
- if (WARN_ON(!keyring))
- return ERR_PTR(-EINVAL);
-
- list_for_each_entry(key, &keyring->list, list) {
- const struct asymmetric_key_ids *kids = &key->kids;
-
- if (id_0 && (!kids->id[0] ||
- !asymmetric_key_id_same(id_0, kids->id[0])))
- continue;
- if (id_1 && (!kids->id[1] ||
- !asymmetric_key_id_same(id_0, kids->id[1])))
- continue;
-
- refcount_inc(&key->refcount);
- return key;
- }
-
- return ERR_PTR(-ENOKEY);
-}
-
-struct asymmetric_key_id *
-asymmetric_key_generate_id(const void *val_1, size_t len_1,
- const void *val_2, size_t len_2)
-{
- struct asymmetric_key_id *kid;
-
- kid = kmalloc(sizeof(struct asymmetric_key_id) + len_1 + len_2,
- GFP_KERNEL);
- if (!kid)
- return ERR_PTR(-ENOMEM);
- kid->len = len_1 + len_2;
- memcpy(kid->data, val_1, len_1);
- memcpy(kid->data + len_1, val_2, len_2);
- return kid;
-}
diff --git a/backport/compat/verification/mbedtls/asn1.h b/backport/compat/verification/mbedtls/asn1.h
deleted file mode 100644
index 46eb214b..00000000
--- a/backport/compat/verification/mbedtls/asn1.h
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * \file asn1.h
- *
- * \brief Generic ASN.1 parsing
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_ASN1_H
-#define MBEDTLS_ASN1_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_BIGNUM_C)
-#include "bignum.h"
-#endif
-
-/**
- * \addtogroup asn1_module
- * \{
- */
-
-/**
- * \name ASN1 Error codes
- * These error codes are OR'ed to X509 error codes for
- * higher error granularity.
- * ASN1 is a standard to specify data structures.
- * \{
- */
-#define MBEDTLS_ERR_ASN1_OUT_OF_DATA -0x0060 /**< Out of data when parsing an ASN1 data structure. */
-#define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG -0x0062 /**< ASN1 tag was of an unexpected value. */
-#define MBEDTLS_ERR_ASN1_INVALID_LENGTH -0x0064 /**< Error when trying to determine the length or invalid length. */
-#define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH -0x0066 /**< Actual length differs from expected length. */
-#define MBEDTLS_ERR_ASN1_INVALID_DATA -0x0068 /**< Data is invalid. (not used) */
-#define MBEDTLS_ERR_ASN1_ALLOC_FAILED -0x006A /**< Memory allocation failed */
-#define MBEDTLS_ERR_ASN1_BUF_TOO_SMALL -0x006C /**< Buffer too small when writing ASN.1 data structure. */
-
-/* \} name */
-
-/**
- * \name DER constants
- * These constants comply with DER encoded the ANS1 type tags.
- * DER encoding uses hexadecimal representation.
- * An example DER sequence is:\n
- * - 0x02 -- tag indicating INTEGER
- * - 0x01 -- length in octets
- * - 0x05 -- value
- * Such sequences are typically read into \c ::mbedtls_x509_buf.
- * \{
- */
-#define MBEDTLS_ASN1_BOOLEAN 0x01
-#define MBEDTLS_ASN1_INTEGER 0x02
-#define MBEDTLS_ASN1_BIT_STRING 0x03
-#define MBEDTLS_ASN1_OCTET_STRING 0x04
-#define MBEDTLS_ASN1_NULL 0x05
-#define MBEDTLS_ASN1_OID 0x06
-#define MBEDTLS_ASN1_UTF8_STRING 0x0C
-#define MBEDTLS_ASN1_SEQUENCE 0x10
-#define MBEDTLS_ASN1_SET 0x11
-#define MBEDTLS_ASN1_PRINTABLE_STRING 0x13
-#define MBEDTLS_ASN1_T61_STRING 0x14
-#define MBEDTLS_ASN1_IA5_STRING 0x16
-#define MBEDTLS_ASN1_UTC_TIME 0x17
-#define MBEDTLS_ASN1_GENERALIZED_TIME 0x18
-#define MBEDTLS_ASN1_UNIVERSAL_STRING 0x1C
-#define MBEDTLS_ASN1_BMP_STRING 0x1E
-#define MBEDTLS_ASN1_PRIMITIVE 0x00
-#define MBEDTLS_ASN1_CONSTRUCTED 0x20
-#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80
-/* \} name */
-/* \} addtogroup asn1_module */
-
-/** Returns the size of the binary string, without the trailing \\0 */
-#define MBEDTLS_OID_SIZE(x) (sizeof(x) - 1)
-
-/**
- * Compares an mbedtls_asn1_buf structure to a reference OID.
- *
- * Only works for 'defined' oid_str values (MBEDTLS_OID_HMAC_SHA1), you cannot use a
- * 'unsigned char *oid' here!
- */
-#define MBEDTLS_OID_CMP(oid_str, oid_buf) \
- ( ( MBEDTLS_OID_SIZE(oid_str) != (oid_buf)->len ) || \
- memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) != 0 )
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \name Functions to parse ASN.1 data structures
- * \{
- */
-
-/**
- * Type-length-value structure that allows for ASN1 using DER.
- */
-typedef struct mbedtls_asn1_buf
-{
- int tag; /**< ASN1 type, e.g. MBEDTLS_ASN1_UTF8_STRING. */
- size_t len; /**< ASN1 length, in octets. */
- unsigned char *p; /**< ASN1 data, e.g. in ASCII. */
-}
-mbedtls_asn1_buf;
-
-/**
- * Container for ASN1 bit strings.
- */
-typedef struct mbedtls_asn1_bitstring
-{
- size_t len; /**< ASN1 length, in octets. */
- unsigned char unused_bits; /**< Number of unused bits at the end of the string */
- unsigned char *p; /**< Raw ASN1 data for the bit string */
-}
-mbedtls_asn1_bitstring;
-
-/**
- * Container for a sequence of ASN.1 items
- */
-typedef struct mbedtls_asn1_sequence
-{
- mbedtls_asn1_buf buf; /**< Buffer containing the given ASN.1 item. */
- struct mbedtls_asn1_sequence *next; /**< The next entry in the sequence. */
-}
-mbedtls_asn1_sequence;
-
-/**
- * Container for a sequence or list of 'named' ASN.1 data items
- */
-typedef struct mbedtls_asn1_named_data
-{
- mbedtls_asn1_buf oid; /**< The object identifier. */
- mbedtls_asn1_buf val; /**< The named value. */
- struct mbedtls_asn1_named_data *next; /**< The next entry in the sequence. */
- unsigned char next_merged; /**< Merge next item into the current one? */
-}
-mbedtls_asn1_named_data;
-
-/**
- * \brief Get the length of an ASN.1 element.
- * Updates the pointer to immediately behind the length.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param len The variable that will receive the value
- *
- * \return 0 if successful, MBEDTLS_ERR_ASN1_OUT_OF_DATA on reaching
- * end of data, MBEDTLS_ERR_ASN1_INVALID_LENGTH if length is
- * unparseable.
- */
-int mbedtls_asn1_get_len( unsigned char **p,
- const unsigned char *end,
- size_t *len );
-
-/**
- * \brief Get the tag and length of the tag. Check for the requested tag.
- * Updates the pointer to immediately behind the tag and length.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param len The variable that will receive the length
- * \param tag The expected tag
- *
- * \return 0 if successful, MBEDTLS_ERR_ASN1_UNEXPECTED_TAG if tag did
- * not match requested tag, or another specific ASN.1 error code.
- */
-int mbedtls_asn1_get_tag( unsigned char **p,
- const unsigned char *end,
- size_t *len, int tag );
-
-/**
- * \brief Retrieve a boolean ASN.1 tag and its value.
- * Updates the pointer to immediately behind the full tag.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param val The variable that will receive the value
- *
- * \return 0 if successful or a specific ASN.1 error code.
- */
-int mbedtls_asn1_get_bool( unsigned char **p,
- const unsigned char *end,
- int *val );
-
-/**
- * \brief Retrieve an integer ASN.1 tag and its value.
- * Updates the pointer to immediately behind the full tag.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param val The variable that will receive the value
- *
- * \return 0 if successful or a specific ASN.1 error code.
- */
-int mbedtls_asn1_get_int( unsigned char **p,
- const unsigned char *end,
- int *val );
-
-/**
- * \brief Retrieve a bitstring ASN.1 tag and its value.
- * Updates the pointer to immediately behind the full tag.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param bs The variable that will receive the value
- *
- * \return 0 if successful or a specific ASN.1 error code.
- */
-int mbedtls_asn1_get_bitstring( unsigned char **p, const unsigned char *end,
- mbedtls_asn1_bitstring *bs);
-
-/**
- * \brief Retrieve a bitstring ASN.1 tag without unused bits and its
- * value.
- * Updates the pointer to the beginning of the bit/octet string.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param len Length of the actual bit/octect string in bytes
- *
- * \return 0 if successful or a specific ASN.1 error code.
- */
-int mbedtls_asn1_get_bitstring_null( unsigned char **p, const unsigned char *end,
- size_t *len );
-
-/**
- * \brief Parses and splits an ASN.1 "SEQUENCE OF <tag>"
- * Updated the pointer to immediately behind the full sequence tag.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param cur First variable in the chain to fill
- * \param tag Type of sequence
- *
- * \return 0 if successful or a specific ASN.1 error code.
- */
-int mbedtls_asn1_get_sequence_of( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_sequence *cur,
- int tag);
-
-#if defined(MBEDTLS_BIGNUM_C)
-/**
- * \brief Retrieve a MPI value from an integer ASN.1 tag.
- * Updates the pointer to immediately behind the full tag.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param X The MPI that will receive the value
- *
- * \return 0 if successful or a specific ASN.1 or MPI error code.
- */
-int mbedtls_asn1_get_mpi( unsigned char **p,
- const unsigned char *end,
- mbedtls_mpi *X );
-#endif /* MBEDTLS_BIGNUM_C */
-
-/**
- * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence.
- * Updates the pointer to immediately behind the full
- * AlgorithmIdentifier.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param alg The buffer to receive the OID
- * \param params The buffer to receive the params (if any)
- *
- * \return 0 if successful or a specific ASN.1 or MPI error code.
- */
-int mbedtls_asn1_get_alg( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_buf *alg, mbedtls_asn1_buf *params );
-
-/**
- * \brief Retrieve an AlgorithmIdentifier ASN.1 sequence with NULL or no
- * params.
- * Updates the pointer to immediately behind the full
- * AlgorithmIdentifier.
- *
- * \param p The position in the ASN.1 data
- * \param end End of data
- * \param alg The buffer to receive the OID
- *
- * \return 0 if successful or a specific ASN.1 or MPI error code.
- */
-int mbedtls_asn1_get_alg_null( unsigned char **p,
- const unsigned char *end,
- mbedtls_asn1_buf *alg );
-
-/**
- * \brief Find a specific named_data entry in a sequence or list based on
- * the OID.
- *
- * \param list The list to seek through
- * \param oid The OID to look for
- * \param len Size of the OID
- *
- * \return NULL if not found, or a pointer to the existing entry.
- */
-mbedtls_asn1_named_data *mbedtls_asn1_find_named_data( mbedtls_asn1_named_data *list,
- const char *oid, size_t len );
-
-/**
- * \brief Free a mbedtls_asn1_named_data entry
- *
- * \param entry The named data entry to free
- */
-void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *entry );
-
-/**
- * \brief Free all entries in a mbedtls_asn1_named_data list
- * Head will be set to NULL
- *
- * \param head Pointer to the head of the list of named data entries to free
- */
-void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* asn1.h */
diff --git a/backport/compat/verification/mbedtls/bignum.h b/backport/compat/verification/mbedtls/bignum.h
deleted file mode 100644
index 69f8e2d9..00000000
--- a/backport/compat/verification/mbedtls/bignum.h
+++ /dev/null
@@ -1,760 +0,0 @@
-/**
- * \file bignum.h
- *
- * \brief Multi-precision integer library
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_BIGNUM_H
-#define MBEDTLS_BIGNUM_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_FS_IO)
-#include <stdio.h>
-#endif
-
-#define MBEDTLS_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An error occurred while reading from or writing to a file. */
-#define MBEDTLS_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_MPI_INVALID_CHARACTER -0x0006 /**< There is an invalid character in the digit string. */
-#define MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< The buffer is too small to write to. */
-#define MBEDTLS_ERR_MPI_NEGATIVE_VALUE -0x000A /**< The input arguments are negative or result in illegal output. */
-#define MBEDTLS_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< The input argument for division is zero, which is not allowed. */
-#define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */
-#define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */
-
-#define MBEDTLS_MPI_CHK(f) do { if( ( ret = f ) != 0 ) goto cleanup; } while( 0 )
-
-/*
- * Maximum size MPIs are allowed to grow to in number of limbs.
- */
-#define MBEDTLS_MPI_MAX_LIMBS 10000
-
-#if !defined(MBEDTLS_MPI_WINDOW_SIZE)
-/*
- * Maximum window size used for modular exponentiation. Default: 6
- * Minimum value: 1. Maximum value: 6.
- *
- * Result is an array of ( 2 << MBEDTLS_MPI_WINDOW_SIZE ) MPIs used
- * for the sliding window calculation. (So 64 by default)
- *
- * Reduction in size, reduces speed.
- */
-#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */
-#endif /* !MBEDTLS_MPI_WINDOW_SIZE */
-
-#if !defined(MBEDTLS_MPI_MAX_SIZE)
-/*
- * Maximum size of MPIs allowed in bits and bytes for user-MPIs.
- * ( Default: 512 bytes => 4096 bits, Maximum tested: 2048 bytes => 16384 bits )
- *
- * Note: Calculations can results temporarily in larger MPIs. So the number
- * of limbs required (MBEDTLS_MPI_MAX_LIMBS) is higher.
- */
-#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
-#endif /* !MBEDTLS_MPI_MAX_SIZE */
-
-#define MBEDTLS_MPI_MAX_BITS ( 8 * MBEDTLS_MPI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */
-
-/*
- * When reading from files with mbedtls_mpi_read_file() and writing to files with
- * mbedtls_mpi_write_file() the buffer should have space
- * for a (short) label, the MPI (in the provided radix), the newline
- * characters and the '\0'.
- *
- * By default we assume at least a 10 char label, a minimum radix of 10
- * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars).
- * Autosized at compile time for at least a 10 char label, a minimum radix
- * of 10 (decimal) for a number of MBEDTLS_MPI_MAX_BITS size.
- *
- * This used to be statically sized to 1250 for a maximum of 4096 bit
- * numbers (1234 decimal chars).
- *
- * Calculate using the formula:
- * MBEDTLS_MPI_RW_BUFFER_SIZE = ceil(MBEDTLS_MPI_MAX_BITS / ln(10) * ln(2)) +
- * LabelSize + 6
- */
-#define MBEDTLS_MPI_MAX_BITS_SCALE100 ( 100 * MBEDTLS_MPI_MAX_BITS )
-#define MBEDTLS_LN_2_DIV_LN_10_SCALE100 332
-#define MBEDTLS_MPI_RW_BUFFER_SIZE ( ((MBEDTLS_MPI_MAX_BITS_SCALE100 + MBEDTLS_LN_2_DIV_LN_10_SCALE100 - 1) / MBEDTLS_LN_2_DIV_LN_10_SCALE100) + 10 + 6 )
-
-/*
- * Define the base integer type, architecture-wise.
- *
- * 32 or 64-bit integer types can be forced regardless of the underlying
- * architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64
- * respectively and undefining MBEDTLS_HAVE_ASM.
- *
- * Double-width integers (e.g. 128-bit in 64-bit architectures) can be
- * disabled by defining MBEDTLS_NO_UDBL_DIVISION.
- */
-#if !defined(MBEDTLS_HAVE_INT32)
- #if defined(_MSC_VER) && defined(_M_AMD64)
- /* Always choose 64-bit when using MSC */
- #if !defined(MBEDTLS_HAVE_INT64)
- #define MBEDTLS_HAVE_INT64
- #endif /* !MBEDTLS_HAVE_INT64 */
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
- #elif defined(__GNUC__) && ( \
- defined(__amd64__) || defined(__x86_64__) || \
- defined(__ppc64__) || defined(__powerpc64__) || \
- defined(__ia64__) || defined(__alpha__) || \
- ( defined(__sparc__) && defined(__arch64__) ) || \
- defined(__s390x__) || defined(__mips64) )
- #if !defined(MBEDTLS_HAVE_INT64)
- #define MBEDTLS_HAVE_INT64
- #endif /* MBEDTLS_HAVE_INT64 */
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
- #if !defined(MBEDTLS_NO_UDBL_DIVISION)
- /* mbedtls_t_udbl defined as 128-bit unsigned int */
- typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
- #define MBEDTLS_HAVE_UDBL
- #endif /* !MBEDTLS_NO_UDBL_DIVISION */
- #elif defined(__ARMCC_VERSION) && defined(__aarch64__)
- /*
- * __ARMCC_VERSION is defined for both armcc and armclang and
- * __aarch64__ is only defined by armclang when compiling 64-bit code
- */
- #if !defined(MBEDTLS_HAVE_INT64)
- #define MBEDTLS_HAVE_INT64
- #endif /* !MBEDTLS_HAVE_INT64 */
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
- #if !defined(MBEDTLS_NO_UDBL_DIVISION)
- /* mbedtls_t_udbl defined as 128-bit unsigned int */
- typedef __uint128_t mbedtls_t_udbl;
- #define MBEDTLS_HAVE_UDBL
- #endif /* !MBEDTLS_NO_UDBL_DIVISION */
- #elif defined(MBEDTLS_HAVE_INT64)
- /* Force 64-bit integers with unknown compiler */
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
- #endif
-#endif /* !MBEDTLS_HAVE_INT32 */
-
-#if !defined(MBEDTLS_HAVE_INT64)
- /* Default to 32-bit compilation */
- #if !defined(MBEDTLS_HAVE_INT32)
- #define MBEDTLS_HAVE_INT32
- #endif /* !MBEDTLS_HAVE_INT32 */
- typedef int32_t mbedtls_mpi_sint;
- typedef uint32_t mbedtls_mpi_uint;
- #if !defined(MBEDTLS_NO_UDBL_DIVISION)
- typedef uint64_t mbedtls_t_udbl;
- #define MBEDTLS_HAVE_UDBL
- #endif /* !MBEDTLS_NO_UDBL_DIVISION */
-#endif /* !MBEDTLS_HAVE_INT64 */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief MPI structure
- */
-typedef struct
-{
- int s; /*!< integer sign */
- size_t n; /*!< total # of limbs */
- mbedtls_mpi_uint *p; /*!< pointer to limbs */
-}
-mbedtls_mpi;
-
-/**
- * \brief Initialize one MPI (make internal references valid)
- * This just makes it ready to be set or freed,
- * but does not define a value for the MPI.
- *
- * \param X One MPI to initialize.
- */
-void mbedtls_mpi_init( mbedtls_mpi *X );
-
-/**
- * \brief Unallocate one MPI
- *
- * \param X One MPI to unallocate.
- */
-void mbedtls_mpi_free( mbedtls_mpi *X );
-
-/**
- * \brief Enlarge to the specified number of limbs
- *
- * \param X MPI to grow
- * \param nblimbs The target number of limbs
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs );
-
-/**
- * \brief Resize down, keeping at least the specified number of limbs
- *
- * \param X MPI to shrink
- * \param nblimbs The minimum number of limbs to keep
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs );
-
-/**
- * \brief Copy the contents of Y into X
- *
- * \param X Destination MPI
- * \param Y Source MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y );
-
-/**
- * \brief Swap the contents of X and Y
- *
- * \param X First MPI value
- * \param Y Second MPI value
- */
-void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y );
-
-/**
- * \brief Safe conditional assignement X = Y if assign is 1
- *
- * \param X MPI to conditionally assign to
- * \param Y Value to be assigned
- * \param assign 1: perform the assignment, 0: keep X's original value
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- *
- * \note This function is equivalent to
- * if( assign ) mbedtls_mpi_copy( X, Y );
- * except that it avoids leaking any information about whether
- * the assignment was done or not (the above code may leak
- * information through branch prediction and/or memory access
- * patterns analysis).
- */
-int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign );
-
-/**
- * \brief Safe conditional swap X <-> Y if swap is 1
- *
- * \param X First mbedtls_mpi value
- * \param Y Second mbedtls_mpi value
- * \param assign 1: perform the swap, 0: keep X and Y's original values
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- *
- * \note This function is equivalent to
- * if( assign ) mbedtls_mpi_swap( X, Y );
- * except that it avoids leaking any information about whether
- * the assignment was done or not (the above code may leak
- * information through branch prediction and/or memory access
- * patterns analysis).
- */
-int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char assign );
-
-/**
- * \brief Set value from integer
- *
- * \param X MPI to set
- * \param z Value to use
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z );
-
-/**
- * \brief Get a specific bit from X
- *
- * \param X MPI to use
- * \param pos Zero-based index of the bit in X
- *
- * \return Either a 0 or a 1
- */
-int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos );
-
-/**
- * \brief Set a bit of X to a specific value of 0 or 1
- *
- * \note Will grow X if necessary to set a bit to 1 in a not yet
- * existing limb. Will not grow if bit should be set to 0
- *
- * \param X MPI to use
- * \param pos Zero-based index of the bit in X
- * \param val The value to set the bit to (0 or 1)
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1
- */
-int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val );
-
-/**
- * \brief Return the number of zero-bits before the least significant
- * '1' bit
- *
- * Note: Thus also the zero-based index of the least significant '1' bit
- *
- * \param X MPI to use
- */
-size_t mbedtls_mpi_lsb( const mbedtls_mpi *X );
-
-/**
- * \brief Return the number of bits up to and including the most
- * significant '1' bit'
- *
- * Note: Thus also the one-based index of the most significant '1' bit
- *
- * \param X MPI to use
- */
-size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X );
-
-/**
- * \brief Return the total size in bytes
- *
- * \param X MPI to use
- */
-size_t mbedtls_mpi_size( const mbedtls_mpi *X );
-
-/**
- * \brief Import from an ASCII string
- *
- * \param X Destination MPI
- * \param radix Input numeric base
- * \param s Null-terminated string buffer
- *
- * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code
- */
-int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s );
-
-/**
- * \brief Export into an ASCII string
- *
- * \param X Source MPI
- * \param radix Output numeric base
- * \param buf Buffer to write the string to
- * \param buflen Length of buf
- * \param olen Length of the string written, including final NUL byte
- *
- * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code.
- * *olen is always updated to reflect the amount
- * of data that has (or would have) been written.
- *
- * \note Call this function with buflen = 0 to obtain the
- * minimum required buffer size in *olen.
- */
-int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
- char *buf, size_t buflen, size_t *olen );
-
-#if defined(MBEDTLS_FS_IO)
-/**
- * \brief Read MPI from a line in an opened file
- *
- * \param X Destination MPI
- * \param radix Input numeric base
- * \param fin Input file handle
- *
- * \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if
- * the file read buffer is too small or a
- * MBEDTLS_ERR_MPI_XXX error code
- *
- * \note On success, this function advances the file stream
- * to the end of the current line or to EOF.
- *
- * The function returns 0 on an empty line.
- *
- * Leading whitespaces are ignored, as is a
- * '0x' prefix for radix 16.
- *
- */
-int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin );
-
-/**
- * \brief Write X into an opened file, or stdout if fout is NULL
- *
- * \param p Prefix, can be NULL
- * \param X Source MPI
- * \param radix Output numeric base
- * \param fout Output file handle (can be NULL)
- *
- * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code
- *
- * \note Set fout == NULL to print X on the console.
- */
-int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout );
-#endif /* MBEDTLS_FS_IO */
-
-/**
- * \brief Import X from unsigned binary data, big endian
- *
- * \param X Destination MPI
- * \param buf Input buffer
- * \param buflen Input buffer size
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen );
-
-/**
- * \brief Export X into unsigned binary data, big endian.
- * Always fills the whole buffer, which will start with zeros
- * if the number is smaller.
- *
- * \param X Source MPI
- * \param buf Output buffer
- * \param buflen Output buffer size
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough
- */
-int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen );
-
-/**
- * \brief Left-shift: X <<= count
- *
- * \param X MPI to shift
- * \param count Amount to shift
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count );
-
-/**
- * \brief Right-shift: X >>= count
- *
- * \param X MPI to shift
- * \param count Amount to shift
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count );
-
-/**
- * \brief Compare unsigned values
- *
- * \param X Left-hand MPI
- * \param Y Right-hand MPI
- *
- * \return 1 if |X| is greater than |Y|,
- * -1 if |X| is lesser than |Y| or
- * 0 if |X| is equal to |Y|
- */
-int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y );
-
-/**
- * \brief Compare signed values
- *
- * \param X Left-hand MPI
- * \param Y Right-hand MPI
- *
- * \return 1 if X is greater than Y,
- * -1 if X is lesser than Y or
- * 0 if X is equal to Y
- */
-int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y );
-
-/**
- * \brief Compare signed values
- *
- * \param X Left-hand MPI
- * \param z The integer value to compare to
- *
- * \return 1 if X is greater than z,
- * -1 if X is lesser than z or
- * 0 if X is equal to z
- */
-int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z );
-
-/**
- * \brief Unsigned addition: X = |A| + |B|
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Unsigned subtraction: X = |A| - |B|
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B is greater than A
- */
-int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Signed addition: X = A + B
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Signed subtraction: X = A - B
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Signed addition: X = A + b
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param b The integer value to add
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b );
-
-/**
- * \brief Signed subtraction: X = A - b
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param b The integer value to subtract
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b );
-
-/**
- * \brief Baseline multiplication: X = A * B
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Baseline multiplication: X = A * b
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param b The unsigned integer value to multiply with
- *
- * \note b is unsigned
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b );
-
-/**
- * \brief Division by mbedtls_mpi: A = Q * B + R
- *
- * \param Q Destination MPI for the quotient
- * \param R Destination MPI for the rest value
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0
- *
- * \note Either Q or R can be NULL.
- */
-int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Division by int: A = Q * b + R
- *
- * \param Q Destination MPI for the quotient
- * \param R Destination MPI for the rest value
- * \param A Left-hand MPI
- * \param b Integer to divide by
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0
- *
- * \note Either Q or R can be NULL.
- */
-int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b );
-
-/**
- * \brief Modulo: R = A mod B
- *
- * \param R Destination MPI for the rest value
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0,
- * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B < 0
- */
-int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Modulo: r = A mod b
- *
- * \param r Destination mbedtls_mpi_uint
- * \param A Left-hand MPI
- * \param b Integer to divide by
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0,
- * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if b < 0
- */
-int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b );
-
-/**
- * \brief Sliding-window exponentiation: X = A^E mod N
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param E Exponent MPI
- * \param N Modular MPI
- * \param _RR Speed-up MPI used for recalculations
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or even or
- * if E is negative
- *
- * \note _RR is used to avoid re-computing R*R mod N across
- * multiple calls, which speeds up things a bit. It can
- * be set to NULL if the extra performance is unneeded.
- */
-int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR );
-
-/**
- * \brief Fill an MPI X with size bytes of random
- *
- * \param X Destination MPI
- * \param size Size in bytes
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng );
-
-/**
- * \brief Greatest common divisor: G = gcd(A, B)
- *
- * \param G Destination MPI
- * \param A Left-hand MPI
- * \param B Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
- */
-int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B );
-
-/**
- * \brief Modular inverse: X = A^-1 mod N
- *
- * \param X Destination MPI
- * \param A Left-hand MPI
- * \param N Right-hand MPI
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1,
- MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N.
- */
-int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
-
-/**
- * \brief Miller-Rabin primality test
- *
- * \param X MPI to check
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \return 0 if successful (probably prime),
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if X is not prime
- */
-int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng );
-
-/**
- * \brief Prime number generation
- *
- * \param X Destination MPI
- * \param nbits Required size of X in bits
- * ( 3 <= nbits <= MBEDTLS_MPI_MAX_BITS )
- * \param dh_flag If 1, then (X-1)/2 will be prime too
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \return 0 if successful (probably prime),
- * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
- */
-int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int mbedtls_mpi_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* bignum.h */
diff --git a/backport/compat/verification/mbedtls/bn_mul.h b/backport/compat/verification/mbedtls/bn_mul.h
deleted file mode 100644
index 5f59ec64..00000000
--- a/backport/compat/verification/mbedtls/bn_mul.h
+++ /dev/null
@@ -1,887 +0,0 @@
-/**
- * \file bn_mul.h
- *
- * \brief Multi-precision integer library
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-/*
- * Multiply source vector [s] with b, add result
- * to destination vector [d] and set carry c.
- *
- * Currently supports:
- *
- * . IA-32 (386+) . AMD64 / EM64T
- * . IA-32 (SSE2) . Motorola 68000
- * . PowerPC, 32-bit . MicroBlaze
- * . PowerPC, 64-bit . TriCore
- * . SPARC v8 . ARM v3+
- * . Alpha . MIPS32
- * . C, longlong . C, generic
- */
-#ifndef MBEDTLS_BN_MUL_H
-#define MBEDTLS_BN_MUL_H
-
-#include "bignum.h"
-
-#if defined(MBEDTLS_HAVE_ASM)
-
-#ifndef asm
-#define asm __asm
-#endif
-
-/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */
-#if defined(__GNUC__) && \
- ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 )
-#if defined(__i386__)
-
-#define MULADDC_INIT \
- asm( \
- "movl %%ebx, %0 \n\t" \
- "movl %5, %%esi \n\t" \
- "movl %6, %%edi \n\t" \
- "movl %7, %%ecx \n\t" \
- "movl %8, %%ebx \n\t"
-
-#define MULADDC_CORE \
- "lodsl \n\t" \
- "mull %%ebx \n\t" \
- "addl %%ecx, %%eax \n\t" \
- "adcl $0, %%edx \n\t" \
- "addl (%%edi), %%eax \n\t" \
- "adcl $0, %%edx \n\t" \
- "movl %%edx, %%ecx \n\t" \
- "stosl \n\t"
-
-#if defined(MBEDTLS_HAVE_SSE2)
-
-#define MULADDC_HUIT \
- "movd %%ecx, %%mm1 \n\t" \
- "movd %%ebx, %%mm0 \n\t" \
- "movd (%%edi), %%mm3 \n\t" \
- "paddq %%mm3, %%mm1 \n\t" \
- "movd (%%esi), %%mm2 \n\t" \
- "pmuludq %%mm0, %%mm2 \n\t" \
- "movd 4(%%esi), %%mm4 \n\t" \
- "pmuludq %%mm0, %%mm4 \n\t" \
- "movd 8(%%esi), %%mm6 \n\t" \
- "pmuludq %%mm0, %%mm6 \n\t" \
- "movd 12(%%esi), %%mm7 \n\t" \
- "pmuludq %%mm0, %%mm7 \n\t" \
- "paddq %%mm2, %%mm1 \n\t" \
- "movd 4(%%edi), %%mm3 \n\t" \
- "paddq %%mm4, %%mm3 \n\t" \
- "movd 8(%%edi), %%mm5 \n\t" \
- "paddq %%mm6, %%mm5 \n\t" \
- "movd 12(%%edi), %%mm4 \n\t" \
- "paddq %%mm4, %%mm7 \n\t" \
- "movd %%mm1, (%%edi) \n\t" \
- "movd 16(%%esi), %%mm2 \n\t" \
- "pmuludq %%mm0, %%mm2 \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "movd 20(%%esi), %%mm4 \n\t" \
- "pmuludq %%mm0, %%mm4 \n\t" \
- "paddq %%mm3, %%mm1 \n\t" \
- "movd 24(%%esi), %%mm6 \n\t" \
- "pmuludq %%mm0, %%mm6 \n\t" \
- "movd %%mm1, 4(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "movd 28(%%esi), %%mm3 \n\t" \
- "pmuludq %%mm0, %%mm3 \n\t" \
- "paddq %%mm5, %%mm1 \n\t" \
- "movd 16(%%edi), %%mm5 \n\t" \
- "paddq %%mm5, %%mm2 \n\t" \
- "movd %%mm1, 8(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "paddq %%mm7, %%mm1 \n\t" \
- "movd 20(%%edi), %%mm5 \n\t" \
- "paddq %%mm5, %%mm4 \n\t" \
- "movd %%mm1, 12(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "paddq %%mm2, %%mm1 \n\t" \
- "movd 24(%%edi), %%mm5 \n\t" \
- "paddq %%mm5, %%mm6 \n\t" \
- "movd %%mm1, 16(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "paddq %%mm4, %%mm1 \n\t" \
- "movd 28(%%edi), %%mm5 \n\t" \
- "paddq %%mm5, %%mm3 \n\t" \
- "movd %%mm1, 20(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "paddq %%mm6, %%mm1 \n\t" \
- "movd %%mm1, 24(%%edi) \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "paddq %%mm3, %%mm1 \n\t" \
- "movd %%mm1, 28(%%edi) \n\t" \
- "addl $32, %%edi \n\t" \
- "addl $32, %%esi \n\t" \
- "psrlq $32, %%mm1 \n\t" \
- "movd %%mm1, %%ecx \n\t"
-
-#define MULADDC_STOP \
- "emms \n\t" \
- "movl %4, %%ebx \n\t" \
- "movl %%ecx, %1 \n\t" \
- "movl %%edi, %2 \n\t" \
- "movl %%esi, %3 \n\t" \
- : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \
- : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \
- : "eax", "ecx", "edx", "esi", "edi" \
- );
-
-#else
-
-#define MULADDC_STOP \
- "movl %4, %%ebx \n\t" \
- "movl %%ecx, %1 \n\t" \
- "movl %%edi, %2 \n\t" \
- "movl %%esi, %3 \n\t" \
- : "=m" (t), "=m" (c), "=m" (d), "=m" (s) \
- : "m" (t), "m" (s), "m" (d), "m" (c), "m" (b) \
- : "eax", "ecx", "edx", "esi", "edi" \
- );
-#endif /* SSE2 */
-#endif /* i386 */
-
-#if defined(__amd64__) || defined (__x86_64__)
-
-#define MULADDC_INIT \
- asm( \
- "xorq %%r8, %%r8 \n\t"
-
-#define MULADDC_CORE \
- "movq (%%rsi), %%rax \n\t" \
- "mulq %%rbx \n\t" \
- "addq $8, %%rsi \n\t" \
- "addq %%rcx, %%rax \n\t" \
- "movq %%r8, %%rcx \n\t" \
- "adcq $0, %%rdx \n\t" \
- "nop \n\t" \
- "addq %%rax, (%%rdi) \n\t" \
- "adcq %%rdx, %%rcx \n\t" \
- "addq $8, %%rdi \n\t"
-
-#define MULADDC_STOP \
- : "+c" (c), "+D" (d), "+S" (s) \
- : "b" (b) \
- : "rax", "rdx", "r8" \
- );
-
-#endif /* AMD64 */
-
-#if defined(__mc68020__) || defined(__mcpu32__)
-
-#define MULADDC_INIT \
- asm( \
- "movl %3, %%a2 \n\t" \
- "movl %4, %%a3 \n\t" \
- "movl %5, %%d3 \n\t" \
- "movl %6, %%d2 \n\t" \
- "moveq #0, %%d0 \n\t"
-
-#define MULADDC_CORE \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d4:%%d1 \n\t" \
- "addl %%d3, %%d1 \n\t" \
- "addxl %%d0, %%d4 \n\t" \
- "moveq #0, %%d3 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "addxl %%d4, %%d3 \n\t"
-
-#define MULADDC_STOP \
- "movl %%d3, %0 \n\t" \
- "movl %%a3, %1 \n\t" \
- "movl %%a2, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "d0", "d1", "d2", "d3", "d4", "a2", "a3" \
- );
-
-#define MULADDC_HUIT \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d4:%%d1 \n\t" \
- "addxl %%d3, %%d1 \n\t" \
- "addxl %%d0, %%d4 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d3:%%d1 \n\t" \
- "addxl %%d4, %%d1 \n\t" \
- "addxl %%d0, %%d3 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d4:%%d1 \n\t" \
- "addxl %%d3, %%d1 \n\t" \
- "addxl %%d0, %%d4 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d3:%%d1 \n\t" \
- "addxl %%d4, %%d1 \n\t" \
- "addxl %%d0, %%d3 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d4:%%d1 \n\t" \
- "addxl %%d3, %%d1 \n\t" \
- "addxl %%d0, %%d4 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d3:%%d1 \n\t" \
- "addxl %%d4, %%d1 \n\t" \
- "addxl %%d0, %%d3 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d4:%%d1 \n\t" \
- "addxl %%d3, %%d1 \n\t" \
- "addxl %%d0, %%d4 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "movel %%a2@+, %%d1 \n\t" \
- "mulul %%d2, %%d3:%%d1 \n\t" \
- "addxl %%d4, %%d1 \n\t" \
- "addxl %%d0, %%d3 \n\t" \
- "addl %%d1, %%a3@+ \n\t" \
- "addxl %%d0, %%d3 \n\t"
-
-#endif /* MC68000 */
-
-#if defined(__powerpc64__) || defined(__ppc64__)
-
-#if defined(__MACH__) && defined(__APPLE__)
-
-#define MULADDC_INIT \
- asm( \
- "ld r3, %3 \n\t" \
- "ld r4, %4 \n\t" \
- "ld r5, %5 \n\t" \
- "ld r6, %6 \n\t" \
- "addi r3, r3, -8 \n\t" \
- "addi r4, r4, -8 \n\t" \
- "addic r5, r5, 0 \n\t"
-
-#define MULADDC_CORE \
- "ldu r7, 8(r3) \n\t" \
- "mulld r8, r7, r6 \n\t" \
- "mulhdu r9, r7, r6 \n\t" \
- "adde r8, r8, r5 \n\t" \
- "ld r7, 8(r4) \n\t" \
- "addze r5, r9 \n\t" \
- "addc r8, r8, r7 \n\t" \
- "stdu r8, 8(r4) \n\t"
-
-#define MULADDC_STOP \
- "addze r5, r5 \n\t" \
- "addi r4, r4, 8 \n\t" \
- "addi r3, r3, 8 \n\t" \
- "std r5, %0 \n\t" \
- "std r4, %1 \n\t" \
- "std r3, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
- );
-
-
-#else /* __MACH__ && __APPLE__ */
-
-#define MULADDC_INIT \
- asm( \
- "ld %%r3, %3 \n\t" \
- "ld %%r4, %4 \n\t" \
- "ld %%r5, %5 \n\t" \
- "ld %%r6, %6 \n\t" \
- "addi %%r3, %%r3, -8 \n\t" \
- "addi %%r4, %%r4, -8 \n\t" \
- "addic %%r5, %%r5, 0 \n\t"
-
-#define MULADDC_CORE \
- "ldu %%r7, 8(%%r3) \n\t" \
- "mulld %%r8, %%r7, %%r6 \n\t" \
- "mulhdu %%r9, %%r7, %%r6 \n\t" \
- "adde %%r8, %%r8, %%r5 \n\t" \
- "ld %%r7, 8(%%r4) \n\t" \
- "addze %%r5, %%r9 \n\t" \
- "addc %%r8, %%r8, %%r7 \n\t" \
- "stdu %%r8, 8(%%r4) \n\t"
-
-#define MULADDC_STOP \
- "addze %%r5, %%r5 \n\t" \
- "addi %%r4, %%r4, 8 \n\t" \
- "addi %%r3, %%r3, 8 \n\t" \
- "std %%r5, %0 \n\t" \
- "std %%r4, %1 \n\t" \
- "std %%r3, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
- );
-
-#endif /* __MACH__ && __APPLE__ */
-
-#elif defined(__powerpc__) || defined(__ppc__) /* end PPC64/begin PPC32 */
-
-#if defined(__MACH__) && defined(__APPLE__)
-
-#define MULADDC_INIT \
- asm( \
- "lwz r3, %3 \n\t" \
- "lwz r4, %4 \n\t" \
- "lwz r5, %5 \n\t" \
- "lwz r6, %6 \n\t" \
- "addi r3, r3, -4 \n\t" \
- "addi r4, r4, -4 \n\t" \
- "addic r5, r5, 0 \n\t"
-
-#define MULADDC_CORE \
- "lwzu r7, 4(r3) \n\t" \
- "mullw r8, r7, r6 \n\t" \
- "mulhwu r9, r7, r6 \n\t" \
- "adde r8, r8, r5 \n\t" \
- "lwz r7, 4(r4) \n\t" \
- "addze r5, r9 \n\t" \
- "addc r8, r8, r7 \n\t" \
- "stwu r8, 4(r4) \n\t"
-
-#define MULADDC_STOP \
- "addze r5, r5 \n\t" \
- "addi r4, r4, 4 \n\t" \
- "addi r3, r3, 4 \n\t" \
- "stw r5, %0 \n\t" \
- "stw r4, %1 \n\t" \
- "stw r3, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
- );
-
-#else /* __MACH__ && __APPLE__ */
-
-#define MULADDC_INIT \
- asm( \
- "lwz %%r3, %3 \n\t" \
- "lwz %%r4, %4 \n\t" \
- "lwz %%r5, %5 \n\t" \
- "lwz %%r6, %6 \n\t" \
- "addi %%r3, %%r3, -4 \n\t" \
- "addi %%r4, %%r4, -4 \n\t" \
- "addic %%r5, %%r5, 0 \n\t"
-
-#define MULADDC_CORE \
- "lwzu %%r7, 4(%%r3) \n\t" \
- "mullw %%r8, %%r7, %%r6 \n\t" \
- "mulhwu %%r9, %%r7, %%r6 \n\t" \
- "adde %%r8, %%r8, %%r5 \n\t" \
- "lwz %%r7, 4(%%r4) \n\t" \
- "addze %%r5, %%r9 \n\t" \
- "addc %%r8, %%r8, %%r7 \n\t" \
- "stwu %%r8, 4(%%r4) \n\t"
-
-#define MULADDC_STOP \
- "addze %%r5, %%r5 \n\t" \
- "addi %%r4, %%r4, 4 \n\t" \
- "addi %%r3, %%r3, 4 \n\t" \
- "stw %%r5, %0 \n\t" \
- "stw %%r4, %1 \n\t" \
- "stw %%r3, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r3", "r4", "r5", "r6", "r7", "r8", "r9" \
- );
-
-#endif /* __MACH__ && __APPLE__ */
-
-#endif /* PPC32 */
-
-/*
- * The Sparc(64) assembly is reported to be broken.
- * Disable it for now, until we're able to fix it.
- */
-#if 0 && defined(__sparc__)
-#if defined(__sparc64__)
-
-#define MULADDC_INIT \
- asm( \
- "ldx %3, %%o0 \n\t" \
- "ldx %4, %%o1 \n\t" \
- "ld %5, %%o2 \n\t" \
- "ld %6, %%o3 \n\t"
-
-#define MULADDC_CORE \
- "ld [%%o0], %%o4 \n\t" \
- "inc 4, %%o0 \n\t" \
- "ld [%%o1], %%o5 \n\t" \
- "umul %%o3, %%o4, %%o4 \n\t" \
- "addcc %%o4, %%o2, %%o4 \n\t" \
- "rd %%y, %%g1 \n\t" \
- "addx %%g1, 0, %%g1 \n\t" \
- "addcc %%o4, %%o5, %%o4 \n\t" \
- "st %%o4, [%%o1] \n\t" \
- "addx %%g1, 0, %%o2 \n\t" \
- "inc 4, %%o1 \n\t"
-
- #define MULADDC_STOP \
- "st %%o2, %0 \n\t" \
- "stx %%o1, %1 \n\t" \
- "stx %%o0, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "g1", "o0", "o1", "o2", "o3", "o4", \
- "o5" \
- );
-
-#else /* __sparc64__ */
-
-#define MULADDC_INIT \
- asm( \
- "ld %3, %%o0 \n\t" \
- "ld %4, %%o1 \n\t" \
- "ld %5, %%o2 \n\t" \
- "ld %6, %%o3 \n\t"
-
-#define MULADDC_CORE \
- "ld [%%o0], %%o4 \n\t" \
- "inc 4, %%o0 \n\t" \
- "ld [%%o1], %%o5 \n\t" \
- "umul %%o3, %%o4, %%o4 \n\t" \
- "addcc %%o4, %%o2, %%o4 \n\t" \
- "rd %%y, %%g1 \n\t" \
- "addx %%g1, 0, %%g1 \n\t" \
- "addcc %%o4, %%o5, %%o4 \n\t" \
- "st %%o4, [%%o1] \n\t" \
- "addx %%g1, 0, %%o2 \n\t" \
- "inc 4, %%o1 \n\t"
-
-#define MULADDC_STOP \
- "st %%o2, %0 \n\t" \
- "st %%o1, %1 \n\t" \
- "st %%o0, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "g1", "o0", "o1", "o2", "o3", "o4", \
- "o5" \
- );
-
-#endif /* __sparc64__ */
-#endif /* __sparc__ */
-
-#if defined(__microblaze__) || defined(microblaze)
-
-#define MULADDC_INIT \
- asm( \
- "lwi r3, %3 \n\t" \
- "lwi r4, %4 \n\t" \
- "lwi r5, %5 \n\t" \
- "lwi r6, %6 \n\t" \
- "andi r7, r6, 0xffff \n\t" \
- "bsrli r6, r6, 16 \n\t"
-
-#define MULADDC_CORE \
- "lhui r8, r3, 0 \n\t" \
- "addi r3, r3, 2 \n\t" \
- "lhui r9, r3, 0 \n\t" \
- "addi r3, r3, 2 \n\t" \
- "mul r10, r9, r6 \n\t" \
- "mul r11, r8, r7 \n\t" \
- "mul r12, r9, r7 \n\t" \
- "mul r13, r8, r6 \n\t" \
- "bsrli r8, r10, 16 \n\t" \
- "bsrli r9, r11, 16 \n\t" \
- "add r13, r13, r8 \n\t" \
- "add r13, r13, r9 \n\t" \
- "bslli r10, r10, 16 \n\t" \
- "bslli r11, r11, 16 \n\t" \
- "add r12, r12, r10 \n\t" \
- "addc r13, r13, r0 \n\t" \
- "add r12, r12, r11 \n\t" \
- "addc r13, r13, r0 \n\t" \
- "lwi r10, r4, 0 \n\t" \
- "add r12, r12, r10 \n\t" \
- "addc r13, r13, r0 \n\t" \
- "add r12, r12, r5 \n\t" \
- "addc r5, r13, r0 \n\t" \
- "swi r12, r4, 0 \n\t" \
- "addi r4, r4, 4 \n\t"
-
-#define MULADDC_STOP \
- "swi r5, %0 \n\t" \
- "swi r4, %1 \n\t" \
- "swi r3, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r3", "r4" "r5", "r6", "r7", "r8", \
- "r9", "r10", "r11", "r12", "r13" \
- );
-
-#endif /* MicroBlaze */
-
-#if defined(__tricore__)
-
-#define MULADDC_INIT \
- asm( \
- "ld.a %%a2, %3 \n\t" \
- "ld.a %%a3, %4 \n\t" \
- "ld.w %%d4, %5 \n\t" \
- "ld.w %%d1, %6 \n\t" \
- "xor %%d5, %%d5 \n\t"
-
-#define MULADDC_CORE \
- "ld.w %%d0, [%%a2+] \n\t" \
- "madd.u %%e2, %%e4, %%d0, %%d1 \n\t" \
- "ld.w %%d0, [%%a3] \n\t" \
- "addx %%d2, %%d2, %%d0 \n\t" \
- "addc %%d3, %%d3, 0 \n\t" \
- "mov %%d4, %%d3 \n\t" \
- "st.w [%%a3+], %%d2 \n\t"
-
-#define MULADDC_STOP \
- "st.w %0, %%d4 \n\t" \
- "st.a %1, %%a3 \n\t" \
- "st.a %2, %%a2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "d0", "d1", "e2", "d4", "a2", "a3" \
- );
-
-#endif /* TriCore */
-
-/*
- * gcc -O0 by default uses r7 for the frame pointer, so it complains about our
- * use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately,
- * passing that option is not easy when building with yotta.
- *
- * On the other hand, -fomit-frame-pointer is implied by any -Ox options with
- * x !=0, which we can detect using __OPTIMIZE__ (which is also defined by
- * clang and armcc5 under the same conditions).
- *
- * So, only use the optimized assembly below for optimized build, which avoids
- * the build error and is pretty reasonable anyway.
- */
-#if defined(__GNUC__) && !defined(__OPTIMIZE__)
-#define MULADDC_CANNOT_USE_R7
-#endif
-
-#if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7)
-
-#if defined(__thumb__) && !defined(__thumb2__)
-
-#define MULADDC_INIT \
- asm( \
- "ldr r0, %3 \n\t" \
- "ldr r1, %4 \n\t" \
- "ldr r2, %5 \n\t" \
- "ldr r3, %6 \n\t" \
- "lsr r7, r3, #16 \n\t" \
- "mov r9, r7 \n\t" \
- "lsl r7, r3, #16 \n\t" \
- "lsr r7, r7, #16 \n\t" \
- "mov r8, r7 \n\t"
-
-#define MULADDC_CORE \
- "ldmia r0!, {r6} \n\t" \
- "lsr r7, r6, #16 \n\t" \
- "lsl r6, r6, #16 \n\t" \
- "lsr r6, r6, #16 \n\t" \
- "mov r4, r8 \n\t" \
- "mul r4, r6 \n\t" \
- "mov r3, r9 \n\t" \
- "mul r6, r3 \n\t" \
- "mov r5, r9 \n\t" \
- "mul r5, r7 \n\t" \
- "mov r3, r8 \n\t" \
- "mul r7, r3 \n\t" \
- "lsr r3, r6, #16 \n\t" \
- "add r5, r5, r3 \n\t" \
- "lsr r3, r7, #16 \n\t" \
- "add r5, r5, r3 \n\t" \
- "add r4, r4, r2 \n\t" \
- "mov r2, #0 \n\t" \
- "adc r5, r2 \n\t" \
- "lsl r3, r6, #16 \n\t" \
- "add r4, r4, r3 \n\t" \
- "adc r5, r2 \n\t" \
- "lsl r3, r7, #16 \n\t" \
- "add r4, r4, r3 \n\t" \
- "adc r5, r2 \n\t" \
- "ldr r3, [r1] \n\t" \
- "add r4, r4, r3 \n\t" \
- "adc r2, r5 \n\t" \
- "stmia r1!, {r4} \n\t"
-
-#define MULADDC_STOP \
- "str r2, %0 \n\t" \
- "str r1, %1 \n\t" \
- "str r0, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "r8", "r9", "cc" \
- );
-
-#else
-
-#define MULADDC_INIT \
- asm( \
- "ldr r0, %3 \n\t" \
- "ldr r1, %4 \n\t" \
- "ldr r2, %5 \n\t" \
- "ldr r3, %6 \n\t"
-
-#define MULADDC_CORE \
- "ldr r4, [r0], #4 \n\t" \
- "mov r5, #0 \n\t" \
- "ldr r6, [r1] \n\t" \
- "umlal r2, r5, r3, r4 \n\t" \
- "adds r7, r6, r2 \n\t" \
- "adc r2, r5, #0 \n\t" \
- "str r7, [r1], #4 \n\t"
-
-#define MULADDC_STOP \
- "str r2, %0 \n\t" \
- "str r1, %1 \n\t" \
- "str r0, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "r0", "r1", "r2", "r3", "r4", "r5", \
- "r6", "r7", "cc" \
- );
-
-#endif /* Thumb */
-
-#endif /* ARMv3 */
-
-#if defined(__alpha__)
-
-#define MULADDC_INIT \
- asm( \
- "ldq $1, %3 \n\t" \
- "ldq $2, %4 \n\t" \
- "ldq $3, %5 \n\t" \
- "ldq $4, %6 \n\t"
-
-#define MULADDC_CORE \
- "ldq $6, 0($1) \n\t" \
- "addq $1, 8, $1 \n\t" \
- "mulq $6, $4, $7 \n\t" \
- "umulh $6, $4, $6 \n\t" \
- "addq $7, $3, $7 \n\t" \
- "cmpult $7, $3, $3 \n\t" \
- "ldq $5, 0($2) \n\t" \
- "addq $7, $5, $7 \n\t" \
- "cmpult $7, $5, $5 \n\t" \
- "stq $7, 0($2) \n\t" \
- "addq $2, 8, $2 \n\t" \
- "addq $6, $3, $3 \n\t" \
- "addq $5, $3, $3 \n\t"
-
-#define MULADDC_STOP \
- "stq $3, %0 \n\t" \
- "stq $2, %1 \n\t" \
- "stq $1, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "$1", "$2", "$3", "$4", "$5", "$6", "$7" \
- );
-#endif /* Alpha */
-
-#if defined(__mips__) && !defined(__mips64)
-
-#define MULADDC_INIT \
- asm( \
- "lw $10, %3 \n\t" \
- "lw $11, %4 \n\t" \
- "lw $12, %5 \n\t" \
- "lw $13, %6 \n\t"
-
-#define MULADDC_CORE \
- "lw $14, 0($10) \n\t" \
- "multu $13, $14 \n\t" \
- "addi $10, $10, 4 \n\t" \
- "mflo $14 \n\t" \
- "mfhi $9 \n\t" \
- "addu $14, $12, $14 \n\t" \
- "lw $15, 0($11) \n\t" \
- "sltu $12, $14, $12 \n\t" \
- "addu $15, $14, $15 \n\t" \
- "sltu $14, $15, $14 \n\t" \
- "addu $12, $12, $9 \n\t" \
- "sw $15, 0($11) \n\t" \
- "addu $12, $12, $14 \n\t" \
- "addi $11, $11, 4 \n\t"
-
-#define MULADDC_STOP \
- "sw $12, %0 \n\t" \
- "sw $11, %1 \n\t" \
- "sw $10, %2 \n\t" \
- : "=m" (c), "=m" (d), "=m" (s) \
- : "m" (s), "m" (d), "m" (c), "m" (b) \
- : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \
- );
-
-#endif /* MIPS */
-#endif /* GNUC */
-
-#if (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
-
-#define MULADDC_INIT \
- __asm mov esi, s \
- __asm mov edi, d \
- __asm mov ecx, c \
- __asm mov ebx, b
-
-#define MULADDC_CORE \
- __asm lodsd \
- __asm mul ebx \
- __asm add eax, ecx \
- __asm adc edx, 0 \
- __asm add eax, [edi] \
- __asm adc edx, 0 \
- __asm mov ecx, edx \
- __asm stosd
-
-#if defined(MBEDTLS_HAVE_SSE2)
-
-#define EMIT __asm _emit
-
-#define MULADDC_HUIT \
- EMIT 0x0F EMIT 0x6E EMIT 0xC9 \
- EMIT 0x0F EMIT 0x6E EMIT 0xC3 \
- EMIT 0x0F EMIT 0x6E EMIT 0x1F \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x6E EMIT 0x16 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x04 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x08 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
- EMIT 0x0F EMIT 0x6E EMIT 0x7E EMIT 0x0C \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF8 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
- EMIT 0x0F EMIT 0x6E EMIT 0x5F EMIT 0x04 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xDC \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x08 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xEE \
- EMIT 0x0F EMIT 0x6E EMIT 0x67 EMIT 0x0C \
- EMIT 0x0F EMIT 0xD4 EMIT 0xFC \
- EMIT 0x0F EMIT 0x7E EMIT 0x0F \
- EMIT 0x0F EMIT 0x6E EMIT 0x56 EMIT 0x10 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD0 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x6E EMIT 0x66 EMIT 0x14 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xE0 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x6E EMIT 0x76 EMIT 0x18 \
- EMIT 0x0F EMIT 0xF4 EMIT 0xF0 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x04 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x6E EMIT 0x5E EMIT 0x1C \
- EMIT 0x0F EMIT 0xF4 EMIT 0xD8 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCD \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x10 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xD5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x08 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCF \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x14 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xE5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x0C \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCA \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x18 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xF5 \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x10 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCC \
- EMIT 0x0F EMIT 0x6E EMIT 0x6F EMIT 0x1C \
- EMIT 0x0F EMIT 0xD4 EMIT 0xDD \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x14 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCE \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x18 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0xD4 EMIT 0xCB \
- EMIT 0x0F EMIT 0x7E EMIT 0x4F EMIT 0x1C \
- EMIT 0x83 EMIT 0xC7 EMIT 0x20 \
- EMIT 0x83 EMIT 0xC6 EMIT 0x20 \
- EMIT 0x0F EMIT 0x73 EMIT 0xD1 EMIT 0x20 \
- EMIT 0x0F EMIT 0x7E EMIT 0xC9
-
-#define MULADDC_STOP \
- EMIT 0x0F EMIT 0x77 \
- __asm mov c, ecx \
- __asm mov d, edi \
- __asm mov s, esi \
-
-#else
-
-#define MULADDC_STOP \
- __asm mov c, ecx \
- __asm mov d, edi \
- __asm mov s, esi \
-
-#endif /* SSE2 */
-#endif /* MSVC */
-
-#endif /* MBEDTLS_HAVE_ASM */
-
-#if !defined(MULADDC_CORE)
-#if defined(MBEDTLS_HAVE_UDBL)
-
-#define MULADDC_INIT \
-{ \
- mbedtls_t_udbl r; \
- mbedtls_mpi_uint r0, r1;
-
-#define MULADDC_CORE \
- r = *(s++) * (mbedtls_t_udbl) b; \
- r0 = (mbedtls_mpi_uint) r; \
- r1 = (mbedtls_mpi_uint)( r >> biL ); \
- r0 += c; r1 += (r0 < c); \
- r0 += *d; r1 += (r0 < *d); \
- c = r1; *(d++) = r0;
-
-#define MULADDC_STOP \
-}
-
-#else
-#define MULADDC_INIT \
-{ \
- mbedtls_mpi_uint s0, s1, b0, b1; \
- mbedtls_mpi_uint r0, r1, rx, ry; \
- b0 = ( b << biH ) >> biH; \
- b1 = ( b >> biH );
-
-#define MULADDC_CORE \
- s0 = ( *s << biH ) >> biH; \
- s1 = ( *s >> biH ); s++; \
- rx = s0 * b1; r0 = s0 * b0; \
- ry = s1 * b0; r1 = s1 * b1; \
- r1 += ( rx >> biH ); \
- r1 += ( ry >> biH ); \
- rx <<= biH; ry <<= biH; \
- r0 += rx; r1 += (r0 < rx); \
- r0 += ry; r1 += (r0 < ry); \
- r0 += c; r1 += (r0 < c); \
- r0 += *d; r1 += (r0 < *d); \
- c = r1; *(d++) = r0;
-
-#define MULADDC_STOP \
-}
-
-#endif /* C (generic) */
-#endif /* C (longlong) */
-
-#endif /* bn_mul.h */
diff --git a/backport/compat/verification/mbedtls/config.h b/backport/compat/verification/mbedtls/config.h
deleted file mode 100644
index 91d900de..00000000
--- a/backport/compat/verification/mbedtls/config.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __MBEDTLS_CONFIG_H
-#define __MBEDTLS_CONFIG_H
-#define MBEDTLS_RSA_C
-#define MBEDTLS_PKCS1_V15
-#define MBEDTLS_MD_C
-#define __OpenBSD__
-#define MBEDTLS_PLATFORM_C
-#define MBEDTLS_BIGNUM_C
-#define MBEDTLS_OID_C
-#define MBEDTLS_ASN1_PARSE_C
-#define MBEDTLS_NO_UDBL_DIVISION
-#define MBEDTLS_SHA256_C
-#include <linux/types.h>
-#include "platform.h"
-#endif /* __MBEDTLS_CONFIG_H */
diff --git a/backport/compat/verification/mbedtls/md.h b/backport/compat/verification/mbedtls/md.h
deleted file mode 100644
index 5342e4f5..00000000
--- a/backport/compat/verification/mbedtls/md.h
+++ /dev/null
@@ -1,354 +0,0 @@
-/**
- * \file md.h
- *
- * \brief Generic message digest wrapper
- *
- * \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_MD_H
-#define MBEDTLS_MD_H
-
-#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
-#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
-#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- MBEDTLS_MD_NONE=0,
- MBEDTLS_MD_MD2,
- MBEDTLS_MD_MD4,
- MBEDTLS_MD_MD5,
- MBEDTLS_MD_SHA1,
- MBEDTLS_MD_SHA224,
- MBEDTLS_MD_SHA256,
- MBEDTLS_MD_SHA384,
- MBEDTLS_MD_SHA512,
- MBEDTLS_MD_RIPEMD160,
-} mbedtls_md_type_t;
-
-#if defined(MBEDTLS_SHA512_C)
-#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
-#else
-#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
-#endif
-
-/**
- * Opaque struct defined in md_internal.h
- */
-typedef struct mbedtls_md_info_t mbedtls_md_info_t;
-
-/**
- * Generic message digest context.
- */
-typedef struct {
- /** Information about the associated message digest */
- const mbedtls_md_info_t *md_info;
-
- /** Digest-specific context */
- void *md_ctx;
-
- /** HMAC part of the context */
- void *hmac_ctx;
-} mbedtls_md_context_t;
-
-/**
- * \brief Returns the list of digests supported by the generic digest module.
- *
- * \return a statically allocated array of digests, the last entry
- * is 0.
- */
-const int *mbedtls_md_list( void );
-
-/**
- * \brief Returns the message digest information associated with the
- * given digest name.
- *
- * \param md_name Name of the digest to search for.
- *
- * \return The message digest information associated with md_name or
- * NULL if not found.
- */
-const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
-
-/**
- * \brief Returns the message digest information associated with the
- * given digest type.
- *
- * \param md_type type of digest to search for.
- *
- * \return The message digest information associated with md_type or
- * NULL if not found.
- */
-const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
-
-/**
- * \brief Initialize a md_context (as NONE)
- * This should always be called first.
- * Prepares the context for mbedtls_md_setup() or mbedtls_md_free().
- */
-void mbedtls_md_init( mbedtls_md_context_t *ctx );
-
-/**
- * \brief Free and clear the internal structures of ctx.
- * Can be called at any time after mbedtls_md_init().
- * Mandatory once mbedtls_md_setup() has been called.
- */
-void mbedtls_md_free( mbedtls_md_context_t *ctx );
-
-#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
-#if defined(MBEDTLS_DEPRECATED_WARNING)
-#define MBEDTLS_DEPRECATED __attribute__((deprecated))
-#else
-#define MBEDTLS_DEPRECATED
-#endif
-/**
- * \brief Select MD to use and allocate internal structures.
- * Should be called after mbedtls_md_init() or mbedtls_md_free().
- * Makes it necessary to call mbedtls_md_free() later.
- *
- * \deprecated Superseded by mbedtls_md_setup() in 2.0.0
- *
- * \param ctx Context to set up.
- * \param md_info Message digest to use.
- *
- * \returns \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
- * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
- */
-int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED;
-#undef MBEDTLS_DEPRECATED
-#endif /* MBEDTLS_DEPRECATED_REMOVED */
-
-/**
- * \brief Select MD to use and allocate internal structures.
- * Should be called after mbedtls_md_init() or mbedtls_md_free().
- * Makes it necessary to call mbedtls_md_free() later.
- *
- * \param ctx Context to set up.
- * \param md_info Message digest to use.
- * \param hmac 0 to save some memory if HMAC will not be used,
- * non-zero is HMAC is going to be used with this context.
- *
- * \returns \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
- * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
- */
-int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
-
-/**
- * \brief Clone the state of an MD context
- *
- * \note The two contexts must have been setup to the same type
- * (cloning from SHA-256 to SHA-512 make no sense).
- *
- * \warning Only clones the MD state, not the HMAC state! (for now)
- *
- * \param dst The destination context
- * \param src The context to be cloned
- *
- * \return \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.
- */
-int mbedtls_md_clone( mbedtls_md_context_t *dst,
- const mbedtls_md_context_t *src );
-
-/**
- * \brief Returns the size of the message digest output.
- *
- * \param md_info message digest info
- *
- * \return size of the message digest output in bytes.
- */
-unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
-
-/**
- * \brief Returns the type of the message digest output.
- *
- * \param md_info message digest info
- *
- * \return type of the message digest output.
- */
-mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
-
-/**
- * \brief Returns the name of the message digest output.
- *
- * \param md_info message digest info
- *
- * \return name of the message digest output.
- */
-const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
-
-/**
- * \brief Prepare the context to digest a new message.
- * Generally called after mbedtls_md_setup() or mbedtls_md_finish().
- * Followed by mbedtls_md_update().
- *
- * \param ctx generic message digest context.
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_starts( mbedtls_md_context_t *ctx );
-
-/**
- * \brief Generic message digest process buffer
- * Called between mbedtls_md_starts() and mbedtls_md_finish().
- * May be called repeatedly.
- *
- * \param ctx Generic message digest context
- * \param input buffer holding the datal
- * \param ilen length of the input data
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
-
-/**
- * \brief Generic message digest final digest
- * Called after mbedtls_md_update().
- * Usually followed by mbedtls_md_free() or mbedtls_md_starts().
- *
- * \param ctx Generic message digest context
- * \param output Generic message digest checksum result
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
-
-/**
- * \brief Output = message_digest( input buffer )
- *
- * \param md_info message digest info
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output Generic message digest checksum result
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
- unsigned char *output );
-
-#if defined(MBEDTLS_FS_IO)
-/**
- * \brief Output = message_digest( file contents )
- *
- * \param md_info message digest info
- * \param path input file name
- * \param output generic message digest checksum result
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
- * MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
- */
-int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
- unsigned char *output );
-#endif /* MBEDTLS_FS_IO */
-
-/**
- * \brief Set HMAC key and prepare to authenticate a new message.
- * Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish().
- *
- * \param ctx HMAC context
- * \param key HMAC secret key
- * \param keylen length of the HMAC key in bytes
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
- size_t keylen );
-
-/**
- * \brief Generic HMAC process buffer.
- * Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
- * and mbedtls_md_hmac_finish().
- * May be called repeatedly.
- *
- * \param ctx HMAC context
- * \param input buffer holding the data
- * \param ilen length of the input data
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
- size_t ilen );
-
-/**
- * \brief Output HMAC.
- * Called after mbedtls_md_hmac_update().
- * Usually followed by mbedtls_md_hmac_reset(),
- * mbedtls_md_hmac_starts(), or mbedtls_md_free().
- *
- * \param ctx HMAC context
- * \param output Generic HMAC checksum result
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
-
-/**
- * \brief Prepare to authenticate a new message with the same key.
- * Called after mbedtls_md_hmac_finish() and before
- * mbedtls_md_hmac_update().
- *
- * \param ctx HMAC context to be reset
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
-
-/**
- * \brief Output = Generic_HMAC( hmac key, input buffer )
- *
- * \param md_info message digest info
- * \param key HMAC secret key
- * \param keylen length of the HMAC key in bytes
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output Generic HMAC-result
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
- */
-int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
- const unsigned char *input, size_t ilen,
- unsigned char *output );
-
-/* Internal use */
-int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MBEDTLS_MD_H */
diff --git a/backport/compat/verification/mbedtls/md_internal.h b/backport/compat/verification/mbedtls/md_internal.h
deleted file mode 100644
index 0a8600b4..00000000
--- a/backport/compat/verification/mbedtls/md_internal.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * \file md_internal.h
- *
- * \brief Message digest wrappers.
- *
- * \warning This in an internal header. Do not include directly.
- *
- * \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_MD_WRAP_H
-#define MBEDTLS_MD_WRAP_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#include "md.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Message digest information.
- * Allows message digest functions to be called in a generic way.
- */
-struct mbedtls_md_info_t
-{
- /** Digest identifier */
- mbedtls_md_type_t type;
-
- /** Name of the message digest */
- const char * name;
-
- /** Output length of the digest function in bytes */
- int size;
-
- /** Block length of the digest function in bytes */
- int block_size;
-
- /** Digest initialisation function */
- void (*starts_func)( void *ctx );
-
- /** Digest update function */
- void (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
-
- /** Digest finalisation function */
- void (*finish_func)( void *ctx, unsigned char *output );
-
- /** Generic digest function */
- void (*digest_func)( const unsigned char *input, size_t ilen,
- unsigned char *output );
-
- /** Allocate a new context */
- void * (*ctx_alloc_func)( void );
-
- /** Free the given context */
- void (*ctx_free_func)( void *ctx );
-
- /** Clone state from a context */
- void (*clone_func)( void *dst, const void *src );
-
- /** Internal use only */
- void (*process_func)( void *ctx, const unsigned char *input );
-};
-
-#if defined(MBEDTLS_MD2_C)
-extern const mbedtls_md_info_t mbedtls_md2_info;
-#endif
-#if defined(MBEDTLS_MD4_C)
-extern const mbedtls_md_info_t mbedtls_md4_info;
-#endif
-#if defined(MBEDTLS_MD5_C)
-extern const mbedtls_md_info_t mbedtls_md5_info;
-#endif
-#if defined(MBEDTLS_RIPEMD160_C)
-extern const mbedtls_md_info_t mbedtls_ripemd160_info;
-#endif
-#if defined(MBEDTLS_SHA1_C)
-extern const mbedtls_md_info_t mbedtls_sha1_info;
-#endif
-#if defined(MBEDTLS_SHA256_C)
-extern const mbedtls_md_info_t mbedtls_sha224_info;
-extern const mbedtls_md_info_t mbedtls_sha256_info;
-#endif
-#if defined(MBEDTLS_SHA512_C)
-extern const mbedtls_md_info_t mbedtls_sha384_info;
-extern const mbedtls_md_info_t mbedtls_sha512_info;
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MBEDTLS_MD_WRAP_H */
diff --git a/backport/compat/verification/mbedtls/oid.h b/backport/compat/verification/mbedtls/oid.h
deleted file mode 100644
index b2ff0887..00000000
--- a/backport/compat/verification/mbedtls/oid.h
+++ /dev/null
@@ -1,570 +0,0 @@
-/**
- * \file oid.h
- *
- * \brief Object Identifier (OID) database
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_OID_H
-#define MBEDTLS_OID_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#include "asn1.h"
-#include "pk.h"
-
-#if defined(MBEDTLS_CIPHER_C)
-#include "cipher.h"
-#endif
-
-#if defined(MBEDTLS_MD_C)
-#include "md.h"
-#endif
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
-#include "x509.h"
-#endif
-
-#define MBEDTLS_ERR_OID_NOT_FOUND -0x002E /**< OID is not found. */
-#define MBEDTLS_ERR_OID_BUF_TOO_SMALL -0x000B /**< output buffer is too small */
-
-/*
- * Top level OID tuples
- */
-#define MBEDTLS_OID_ISO_MEMBER_BODIES "\x2a" /* {iso(1) member-body(2)} */
-#define MBEDTLS_OID_ISO_IDENTIFIED_ORG "\x2b" /* {iso(1) identified-organization(3)} */
-#define MBEDTLS_OID_ISO_CCITT_DS "\x55" /* {joint-iso-ccitt(2) ds(5)} */
-#define MBEDTLS_OID_ISO_ITU_COUNTRY "\x60" /* {joint-iso-itu-t(2) country(16)} */
-
-/*
- * ISO Member bodies OID parts
- */
-#define MBEDTLS_OID_COUNTRY_US "\x86\x48" /* {us(840)} */
-#define MBEDTLS_OID_ORG_RSA_DATA_SECURITY "\x86\xf7\x0d" /* {rsadsi(113549)} */
-#define MBEDTLS_OID_RSA_COMPANY MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US \
- MBEDTLS_OID_ORG_RSA_DATA_SECURITY /* {iso(1) member-body(2) us(840) rsadsi(113549)} */
-#define MBEDTLS_OID_ORG_ANSI_X9_62 "\xce\x3d" /* ansi-X9-62(10045) */
-#define MBEDTLS_OID_ANSI_X9_62 MBEDTLS_OID_ISO_MEMBER_BODIES MBEDTLS_OID_COUNTRY_US \
- MBEDTLS_OID_ORG_ANSI_X9_62
-
-/*
- * ISO Identified organization OID parts
- */
-#define MBEDTLS_OID_ORG_DOD "\x06" /* {dod(6)} */
-#define MBEDTLS_OID_ORG_OIW "\x0e"
-#define MBEDTLS_OID_OIW_SECSIG MBEDTLS_OID_ORG_OIW "\x03"
-#define MBEDTLS_OID_OIW_SECSIG_ALG MBEDTLS_OID_OIW_SECSIG "\x02"
-#define MBEDTLS_OID_OIW_SECSIG_SHA1 MBEDTLS_OID_OIW_SECSIG_ALG "\x1a"
-#define MBEDTLS_OID_ORG_CERTICOM "\x81\x04" /* certicom(132) */
-#define MBEDTLS_OID_CERTICOM MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_CERTICOM
-#define MBEDTLS_OID_ORG_TELETRUST "\x24" /* teletrust(36) */
-#define MBEDTLS_OID_TELETRUST MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_TELETRUST
-
-/*
- * ISO ITU OID parts
- */
-#define MBEDTLS_OID_ORGANIZATION "\x01" /* {organization(1)} */
-#define MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ISO_ITU_COUNTRY MBEDTLS_OID_COUNTRY_US MBEDTLS_OID_ORGANIZATION /* {joint-iso-itu-t(2) country(16) us(840) organization(1)} */
-
-#define MBEDTLS_OID_ORG_GOV "\x65" /* {gov(101)} */
-#define MBEDTLS_OID_GOV MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ORG_GOV /* {joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101)} */
-
-#define MBEDTLS_OID_ORG_NETSCAPE "\x86\xF8\x42" /* {netscape(113730)} */
-#define MBEDTLS_OID_NETSCAPE MBEDTLS_OID_ISO_ITU_US_ORG MBEDTLS_OID_ORG_NETSCAPE /* Netscape OID {joint-iso-itu-t(2) country(16) us(840) organization(1) netscape(113730)} */
-
-/* ISO arc for standard certificate and CRL extensions */
-#define MBEDTLS_OID_ID_CE MBEDTLS_OID_ISO_CCITT_DS "\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */
-
-/**
- * Private Internet Extensions
- * { iso(1) identified-organization(3) dod(6) internet(1)
- * security(5) mechanisms(5) pkix(7) }
- */
-#define MBEDTLS_OID_PKIX MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_ORG_DOD "\x01\x05\x05\x07"
-
-/*
- * Arc for standard naming attributes
- */
-#define MBEDTLS_OID_AT MBEDTLS_OID_ISO_CCITT_DS "\x04" /**< id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4} */
-#define MBEDTLS_OID_AT_CN MBEDTLS_OID_AT "\x03" /**< id-at-commonName AttributeType:= {id-at 3} */
-#define MBEDTLS_OID_AT_SUR_NAME MBEDTLS_OID_AT "\x04" /**< id-at-surName AttributeType:= {id-at 4} */
-#define MBEDTLS_OID_AT_SERIAL_NUMBER MBEDTLS_OID_AT "\x05" /**< id-at-serialNumber AttributeType:= {id-at 5} */
-#define MBEDTLS_OID_AT_COUNTRY MBEDTLS_OID_AT "\x06" /**< id-at-countryName AttributeType:= {id-at 6} */
-#define MBEDTLS_OID_AT_LOCALITY MBEDTLS_OID_AT "\x07" /**< id-at-locality AttributeType:= {id-at 7} */
-#define MBEDTLS_OID_AT_STATE MBEDTLS_OID_AT "\x08" /**< id-at-state AttributeType:= {id-at 8} */
-#define MBEDTLS_OID_AT_ORGANIZATION MBEDTLS_OID_AT "\x0A" /**< id-at-organizationName AttributeType:= {id-at 10} */
-#define MBEDTLS_OID_AT_ORG_UNIT MBEDTLS_OID_AT "\x0B" /**< id-at-organizationalUnitName AttributeType:= {id-at 11} */
-#define MBEDTLS_OID_AT_TITLE MBEDTLS_OID_AT "\x0C" /**< id-at-title AttributeType:= {id-at 12} */
-#define MBEDTLS_OID_AT_POSTAL_ADDRESS MBEDTLS_OID_AT "\x10" /**< id-at-postalAddress AttributeType:= {id-at 16} */
-#define MBEDTLS_OID_AT_POSTAL_CODE MBEDTLS_OID_AT "\x11" /**< id-at-postalCode AttributeType:= {id-at 17} */
-#define MBEDTLS_OID_AT_GIVEN_NAME MBEDTLS_OID_AT "\x2A" /**< id-at-givenName AttributeType:= {id-at 42} */
-#define MBEDTLS_OID_AT_INITIALS MBEDTLS_OID_AT "\x2B" /**< id-at-initials AttributeType:= {id-at 43} */
-#define MBEDTLS_OID_AT_GENERATION_QUALIFIER MBEDTLS_OID_AT "\x2C" /**< id-at-generationQualifier AttributeType:= {id-at 44} */
-#define MBEDTLS_OID_AT_UNIQUE_IDENTIFIER MBEDTLS_OID_AT "\x2D" /**< id-at-uniqueIdentifier AttributType:= {id-at 45} */
-#define MBEDTLS_OID_AT_DN_QUALIFIER MBEDTLS_OID_AT "\x2E" /**< id-at-dnQualifier AttributeType:= {id-at 46} */
-#define MBEDTLS_OID_AT_PSEUDONYM MBEDTLS_OID_AT "\x41" /**< id-at-pseudonym AttributeType:= {id-at 65} */
-
-#define MBEDTLS_OID_DOMAIN_COMPONENT "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x19" /** id-domainComponent AttributeType:= {itu-t(0) data(9) pss(2342) ucl(19200300) pilot(100) pilotAttributeType(1) domainComponent(25)} */
-
-/*
- * OIDs for standard certificate extensions
- */
-#define MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER MBEDTLS_OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */
-#define MBEDTLS_OID_SUBJECT_KEY_IDENTIFIER MBEDTLS_OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */
-#define MBEDTLS_OID_KEY_USAGE MBEDTLS_OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */
-#define MBEDTLS_OID_CERTIFICATE_POLICIES MBEDTLS_OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */
-#define MBEDTLS_OID_POLICY_MAPPINGS MBEDTLS_OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */
-#define MBEDTLS_OID_SUBJECT_ALT_NAME MBEDTLS_OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */
-#define MBEDTLS_OID_ISSUER_ALT_NAME MBEDTLS_OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */
-#define MBEDTLS_OID_SUBJECT_DIRECTORY_ATTRS MBEDTLS_OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */
-#define MBEDTLS_OID_BASIC_CONSTRAINTS MBEDTLS_OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */
-#define MBEDTLS_OID_NAME_CONSTRAINTS MBEDTLS_OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */
-#define MBEDTLS_OID_POLICY_CONSTRAINTS MBEDTLS_OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */
-#define MBEDTLS_OID_EXTENDED_KEY_USAGE MBEDTLS_OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */
-#define MBEDTLS_OID_CRL_DISTRIBUTION_POINTS MBEDTLS_OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */
-#define MBEDTLS_OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */
-#define MBEDTLS_OID_FRESHEST_CRL MBEDTLS_OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */
-
-/*
- * Netscape certificate extensions
- */
-#define MBEDTLS_OID_NS_CERT MBEDTLS_OID_NETSCAPE "\x01"
-#define MBEDTLS_OID_NS_CERT_TYPE MBEDTLS_OID_NS_CERT "\x01"
-#define MBEDTLS_OID_NS_BASE_URL MBEDTLS_OID_NS_CERT "\x02"
-#define MBEDTLS_OID_NS_REVOCATION_URL MBEDTLS_OID_NS_CERT "\x03"
-#define MBEDTLS_OID_NS_CA_REVOCATION_URL MBEDTLS_OID_NS_CERT "\x04"
-#define MBEDTLS_OID_NS_RENEWAL_URL MBEDTLS_OID_NS_CERT "\x07"
-#define MBEDTLS_OID_NS_CA_POLICY_URL MBEDTLS_OID_NS_CERT "\x08"
-#define MBEDTLS_OID_NS_SSL_SERVER_NAME MBEDTLS_OID_NS_CERT "\x0C"
-#define MBEDTLS_OID_NS_COMMENT MBEDTLS_OID_NS_CERT "\x0D"
-#define MBEDTLS_OID_NS_DATA_TYPE MBEDTLS_OID_NETSCAPE "\x02"
-#define MBEDTLS_OID_NS_CERT_SEQUENCE MBEDTLS_OID_NS_DATA_TYPE "\x05"
-
-/*
- * OIDs for CRL extensions
- */
-#define MBEDTLS_OID_PRIVATE_KEY_USAGE_PERIOD MBEDTLS_OID_ID_CE "\x10"
-#define MBEDTLS_OID_CRL_NUMBER MBEDTLS_OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */
-
-/*
- * X.509 v3 Extended key usage OIDs
- */
-#define MBEDTLS_OID_ANY_EXTENDED_KEY_USAGE MBEDTLS_OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */
-
-#define MBEDTLS_OID_KP MBEDTLS_OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */
-#define MBEDTLS_OID_SERVER_AUTH MBEDTLS_OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */
-#define MBEDTLS_OID_CLIENT_AUTH MBEDTLS_OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */
-#define MBEDTLS_OID_CODE_SIGNING MBEDTLS_OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */
-#define MBEDTLS_OID_EMAIL_PROTECTION MBEDTLS_OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */
-#define MBEDTLS_OID_TIME_STAMPING MBEDTLS_OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */
-#define MBEDTLS_OID_OCSP_SIGNING MBEDTLS_OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */
-
-/*
- * PKCS definition OIDs
- */
-
-#define MBEDTLS_OID_PKCS MBEDTLS_OID_RSA_COMPANY "\x01" /**< pkcs OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) 1 } */
-#define MBEDTLS_OID_PKCS1 MBEDTLS_OID_PKCS "\x01" /**< pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } */
-#define MBEDTLS_OID_PKCS5 MBEDTLS_OID_PKCS "\x05" /**< pkcs-5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 5 } */
-#define MBEDTLS_OID_PKCS9 MBEDTLS_OID_PKCS "\x09" /**< pkcs-9 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 9 } */
-#define MBEDTLS_OID_PKCS12 MBEDTLS_OID_PKCS "\x0c" /**< pkcs-12 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 12 } */
-
-/*
- * PKCS#1 OIDs
- */
-#define MBEDTLS_OID_PKCS1_RSA MBEDTLS_OID_PKCS1 "\x01" /**< rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1 } */
-#define MBEDTLS_OID_PKCS1_MD2 MBEDTLS_OID_PKCS1 "\x02" /**< md2WithRSAEncryption ::= { pkcs-1 2 } */
-#define MBEDTLS_OID_PKCS1_MD4 MBEDTLS_OID_PKCS1 "\x03" /**< md4WithRSAEncryption ::= { pkcs-1 3 } */
-#define MBEDTLS_OID_PKCS1_MD5 MBEDTLS_OID_PKCS1 "\x04" /**< md5WithRSAEncryption ::= { pkcs-1 4 } */
-#define MBEDTLS_OID_PKCS1_SHA1 MBEDTLS_OID_PKCS1 "\x05" /**< sha1WithRSAEncryption ::= { pkcs-1 5 } */
-#define MBEDTLS_OID_PKCS1_SHA224 MBEDTLS_OID_PKCS1 "\x0e" /**< sha224WithRSAEncryption ::= { pkcs-1 14 } */
-#define MBEDTLS_OID_PKCS1_SHA256 MBEDTLS_OID_PKCS1 "\x0b" /**< sha256WithRSAEncryption ::= { pkcs-1 11 } */
-#define MBEDTLS_OID_PKCS1_SHA384 MBEDTLS_OID_PKCS1 "\x0c" /**< sha384WithRSAEncryption ::= { pkcs-1 12 } */
-#define MBEDTLS_OID_PKCS1_SHA512 MBEDTLS_OID_PKCS1 "\x0d" /**< sha512WithRSAEncryption ::= { pkcs-1 13 } */
-
-#define MBEDTLS_OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D"
-
-#define MBEDTLS_OID_PKCS9_EMAIL MBEDTLS_OID_PKCS9 "\x01" /**< emailAddress AttributeType ::= { pkcs-9 1 } */
-
-/* RFC 4055 */
-#define MBEDTLS_OID_RSASSA_PSS MBEDTLS_OID_PKCS1 "\x0a" /**< id-RSASSA-PSS ::= { pkcs-1 10 } */
-#define MBEDTLS_OID_MGF1 MBEDTLS_OID_PKCS1 "\x08" /**< id-mgf1 ::= { pkcs-1 8 } */
-
-/*
- * Digest algorithms
- */
-#define MBEDTLS_OID_DIGEST_ALG_MD2 MBEDTLS_OID_RSA_COMPANY "\x02\x02" /**< id-mbedtls_md2 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 2 } */
-#define MBEDTLS_OID_DIGEST_ALG_MD4 MBEDTLS_OID_RSA_COMPANY "\x02\x04" /**< id-mbedtls_md4 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 4 } */
-#define MBEDTLS_OID_DIGEST_ALG_MD5 MBEDTLS_OID_RSA_COMPANY "\x02\x05" /**< id-mbedtls_md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 } */
-#define MBEDTLS_OID_DIGEST_ALG_SHA1 MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_SHA1 /**< id-mbedtls_sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 } */
-#define MBEDTLS_OID_DIGEST_ALG_SHA224 MBEDTLS_OID_GOV "\x03\x04\x02\x04" /**< id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 4 } */
-#define MBEDTLS_OID_DIGEST_ALG_SHA256 MBEDTLS_OID_GOV "\x03\x04\x02\x01" /**< id-mbedtls_sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 1 } */
-
-#define MBEDTLS_OID_DIGEST_ALG_SHA384 MBEDTLS_OID_GOV "\x03\x04\x02\x02" /**< id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 2 } */
-
-#define MBEDTLS_OID_DIGEST_ALG_SHA512 MBEDTLS_OID_GOV "\x03\x04\x02\x03" /**< id-mbedtls_sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3 } */
-
-#define MBEDTLS_OID_HMAC_SHA1 MBEDTLS_OID_RSA_COMPANY "\x02\x07" /**< id-hmacWithSHA1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 7 } */
-
-/*
- * Encryption algorithms
- */
-#define MBEDTLS_OID_DES_CBC MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_ALG "\x07" /**< desCBC OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 7 } */
-#define MBEDTLS_OID_DES_EDE3_CBC MBEDTLS_OID_RSA_COMPANY "\x03\x07" /**< des-ede3-cbc OBJECT IDENTIFIER ::= { iso(1) member-body(2) -- us(840) rsadsi(113549) encryptionAlgorithm(3) 7 } */
-
-/*
- * PKCS#5 OIDs
- */
-#define MBEDTLS_OID_PKCS5_PBKDF2 MBEDTLS_OID_PKCS5 "\x0c" /**< id-PBKDF2 OBJECT IDENTIFIER ::= {pkcs-5 12} */
-#define MBEDTLS_OID_PKCS5_PBES2 MBEDTLS_OID_PKCS5 "\x0d" /**< id-PBES2 OBJECT IDENTIFIER ::= {pkcs-5 13} */
-#define MBEDTLS_OID_PKCS5_PBMAC1 MBEDTLS_OID_PKCS5 "\x0e" /**< id-PBMAC1 OBJECT IDENTIFIER ::= {pkcs-5 14} */
-
-/*
- * PKCS#5 PBES1 algorithms
- */
-#define MBEDTLS_OID_PKCS5_PBE_MD2_DES_CBC MBEDTLS_OID_PKCS5 "\x01" /**< pbeWithMD2AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 1} */
-#define MBEDTLS_OID_PKCS5_PBE_MD2_RC2_CBC MBEDTLS_OID_PKCS5 "\x04" /**< pbeWithMD2AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 4} */
-#define MBEDTLS_OID_PKCS5_PBE_MD5_DES_CBC MBEDTLS_OID_PKCS5 "\x03" /**< pbeWithMD5AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 3} */
-#define MBEDTLS_OID_PKCS5_PBE_MD5_RC2_CBC MBEDTLS_OID_PKCS5 "\x06" /**< pbeWithMD5AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 6} */
-#define MBEDTLS_OID_PKCS5_PBE_SHA1_DES_CBC MBEDTLS_OID_PKCS5 "\x0a" /**< pbeWithSHA1AndDES-CBC OBJECT IDENTIFIER ::= {pkcs-5 10} */
-#define MBEDTLS_OID_PKCS5_PBE_SHA1_RC2_CBC MBEDTLS_OID_PKCS5 "\x0b" /**< pbeWithSHA1AndRC2-CBC OBJECT IDENTIFIER ::= {pkcs-5 11} */
-
-/*
- * PKCS#8 OIDs
- */
-#define MBEDTLS_OID_PKCS9_CSR_EXT_REQ MBEDTLS_OID_PKCS9 "\x0e" /**< extensionRequest OBJECT IDENTIFIER ::= {pkcs-9 14} */
-
-/*
- * PKCS#12 PBE OIDs
- */
-#define MBEDTLS_OID_PKCS12_PBE MBEDTLS_OID_PKCS12 "\x01" /**< pkcs-12PbeIds OBJECT IDENTIFIER ::= {pkcs-12 1} */
-
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_128 MBEDTLS_OID_PKCS12_PBE "\x01" /**< pbeWithSHAAnd128BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 1} */
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC4_40 MBEDTLS_OID_PKCS12_PBE "\x02" /**< pbeWithSHAAnd40BitRC4 OBJECT IDENTIFIER ::= {pkcs-12PbeIds 2} */
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC MBEDTLS_OID_PKCS12_PBE "\x03" /**< pbeWithSHAAnd3-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 3} */
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC MBEDTLS_OID_PKCS12_PBE "\x04" /**< pbeWithSHAAnd2-KeyTripleDES-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 4} */
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_128_CBC MBEDTLS_OID_PKCS12_PBE "\x05" /**< pbeWithSHAAnd128BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 5} */
-#define MBEDTLS_OID_PKCS12_PBE_SHA1_RC2_40_CBC MBEDTLS_OID_PKCS12_PBE "\x06" /**< pbeWithSHAAnd40BitRC2-CBC OBJECT IDENTIFIER ::= {pkcs-12PbeIds 6} */
-
-/*
- * EC key algorithms from RFC 5480
- */
-
-/* id-ecPublicKey OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 } */
-#define MBEDTLS_OID_EC_ALG_UNRESTRICTED MBEDTLS_OID_ANSI_X9_62 "\x02\01"
-
-/* id-ecDH OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132)
- * schemes(1) ecdh(12) } */
-#define MBEDTLS_OID_EC_ALG_ECDH MBEDTLS_OID_CERTICOM "\x01\x0c"
-
-/*
- * ECParameters namedCurve identifiers, from RFC 5480, RFC 5639, and SEC2
- */
-
-/* secp192r1 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 1 } */
-#define MBEDTLS_OID_EC_GRP_SECP192R1 MBEDTLS_OID_ANSI_X9_62 "\x03\x01\x01"
-
-/* secp224r1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 33 } */
-#define MBEDTLS_OID_EC_GRP_SECP224R1 MBEDTLS_OID_CERTICOM "\x00\x21"
-
-/* secp256r1 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) curves(3) prime(1) 7 } */
-#define MBEDTLS_OID_EC_GRP_SECP256R1 MBEDTLS_OID_ANSI_X9_62 "\x03\x01\x07"
-
-/* secp384r1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 34 } */
-#define MBEDTLS_OID_EC_GRP_SECP384R1 MBEDTLS_OID_CERTICOM "\x00\x22"
-
-/* secp521r1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 35 } */
-#define MBEDTLS_OID_EC_GRP_SECP521R1 MBEDTLS_OID_CERTICOM "\x00\x23"
-
-/* secp192k1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 31 } */
-#define MBEDTLS_OID_EC_GRP_SECP192K1 MBEDTLS_OID_CERTICOM "\x00\x1f"
-
-/* secp224k1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 32 } */
-#define MBEDTLS_OID_EC_GRP_SECP224K1 MBEDTLS_OID_CERTICOM "\x00\x20"
-
-/* secp256k1 OBJECT IDENTIFIER ::= {
- * iso(1) identified-organization(3) certicom(132) curve(0) 10 } */
-#define MBEDTLS_OID_EC_GRP_SECP256K1 MBEDTLS_OID_CERTICOM "\x00\x0a"
-
-/* RFC 5639 4.1
- * ecStdCurvesAndGeneration OBJECT IDENTIFIER::= {iso(1)
- * identified-organization(3) teletrust(36) algorithm(3) signature-
- * algorithm(3) ecSign(2) 8}
- * ellipticCurve OBJECT IDENTIFIER ::= {ecStdCurvesAndGeneration 1}
- * versionOne OBJECT IDENTIFIER ::= {ellipticCurve 1} */
-#define MBEDTLS_OID_EC_BRAINPOOL_V1 MBEDTLS_OID_TELETRUST "\x03\x03\x02\x08\x01\x01"
-
-/* brainpoolP256r1 OBJECT IDENTIFIER ::= {versionOne 7} */
-#define MBEDTLS_OID_EC_GRP_BP256R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x07"
-
-/* brainpoolP384r1 OBJECT IDENTIFIER ::= {versionOne 11} */
-#define MBEDTLS_OID_EC_GRP_BP384R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x0B"
-
-/* brainpoolP512r1 OBJECT IDENTIFIER ::= {versionOne 13} */
-#define MBEDTLS_OID_EC_GRP_BP512R1 MBEDTLS_OID_EC_BRAINPOOL_V1 "\x0D"
-
-/*
- * SEC1 C.1
- *
- * prime-field OBJECT IDENTIFIER ::= { id-fieldType 1 }
- * id-fieldType OBJECT IDENTIFIER ::= { ansi-X9-62 fieldType(1)}
- */
-#define MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE MBEDTLS_OID_ANSI_X9_62 "\x01"
-#define MBEDTLS_OID_ANSI_X9_62_PRIME_FIELD MBEDTLS_OID_ANSI_X9_62_FIELD_TYPE "\x01"
-
-/*
- * ECDSA signature identifiers, from RFC 5480
- */
-#define MBEDTLS_OID_ANSI_X9_62_SIG MBEDTLS_OID_ANSI_X9_62 "\x04" /* signatures(4) */
-#define MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 MBEDTLS_OID_ANSI_X9_62_SIG "\x03" /* ecdsa-with-SHA2(3) */
-
-/* ecdsa-with-SHA1 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4) 1 } */
-#define MBEDTLS_OID_ECDSA_SHA1 MBEDTLS_OID_ANSI_X9_62_SIG "\x01"
-
-/* ecdsa-with-SHA224 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4)
- * ecdsa-with-SHA2(3) 1 } */
-#define MBEDTLS_OID_ECDSA_SHA224 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x01"
-
-/* ecdsa-with-SHA256 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4)
- * ecdsa-with-SHA2(3) 2 } */
-#define MBEDTLS_OID_ECDSA_SHA256 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x02"
-
-/* ecdsa-with-SHA384 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4)
- * ecdsa-with-SHA2(3) 3 } */
-#define MBEDTLS_OID_ECDSA_SHA384 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x03"
-
-/* ecdsa-with-SHA512 OBJECT IDENTIFIER ::= {
- * iso(1) member-body(2) us(840) ansi-X9-62(10045) signatures(4)
- * ecdsa-with-SHA2(3) 4 } */
-#define MBEDTLS_OID_ECDSA_SHA512 MBEDTLS_OID_ANSI_X9_62_SIG_SHA2 "\x04"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Base OID descriptor structure
- */
-typedef struct {
- const char *asn1; /*!< OID ASN.1 representation */
- size_t asn1_len; /*!< length of asn1 */
- const char *name; /*!< official name (e.g. from RFC) */
- const char *description; /*!< human friendly description */
-} mbedtls_oid_descriptor_t;
-
-/**
- * \brief Translate an ASN.1 OID into its numeric representation
- * (e.g. "\x2A\x86\x48\x86\xF7\x0D" into "1.2.840.113549")
- *
- * \param buf buffer to put representation in
- * \param size size of the buffer
- * \param oid OID to translate
- *
- * \return Length of the string written (excluding final NULL) or
- * MBEDTLS_ERR_OID_BUF_TOO_SMALL in case of error
- */
-int mbedtls_oid_get_numeric_string( char *buf, size_t size, const mbedtls_asn1_buf *oid );
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
-/**
- * \brief Translate an X.509 extension OID into local values
- *
- * \param oid OID to use
- * \param ext_type place to store the extension type
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_x509_ext_type( const mbedtls_asn1_buf *oid, int *ext_type );
-#endif
-
-/**
- * \brief Translate an X.509 attribute type OID into the short name
- * (e.g. the OID for an X520 Common Name into "CN")
- *
- * \param oid OID to use
- * \param short_name place to store the string pointer
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_attr_short_name( const mbedtls_asn1_buf *oid, const char **short_name );
-
-/**
- * \brief Translate PublicKeyAlgorithm OID into pk_type
- *
- * \param oid OID to use
- * \param pk_alg place to store public key algorithm
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_pk_alg( const mbedtls_asn1_buf *oid, mbedtls_pk_type_t *pk_alg );
-
-/**
- * \brief Translate pk_type into PublicKeyAlgorithm OID
- *
- * \param pk_alg Public key type to look for
- * \param oid place to store ASN.1 OID string pointer
- * \param olen length of the OID
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_oid_by_pk_alg( mbedtls_pk_type_t pk_alg,
- const char **oid, size_t *olen );
-
-#if defined(MBEDTLS_ECP_C)
-/**
- * \brief Translate NamedCurve OID into an EC group identifier
- *
- * \param oid OID to use
- * \param grp_id place to store group id
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_ec_grp( const mbedtls_asn1_buf *oid, mbedtls_ecp_group_id *grp_id );
-
-/**
- * \brief Translate EC group identifier into NamedCurve OID
- *
- * \param grp_id EC group identifier
- * \param oid place to store ASN.1 OID string pointer
- * \param olen length of the OID
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_oid_by_ec_grp( mbedtls_ecp_group_id grp_id,
- const char **oid, size_t *olen );
-#endif /* MBEDTLS_ECP_C */
-
-#if defined(MBEDTLS_MD_C)
-/**
- * \brief Translate SignatureAlgorithm OID into md_type and pk_type
- *
- * \param oid OID to use
- * \param md_alg place to store message digest algorithm
- * \param pk_alg place to store public key algorithm
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_sig_alg( const mbedtls_asn1_buf *oid,
- mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg );
-
-/**
- * \brief Translate SignatureAlgorithm OID into description
- *
- * \param oid OID to use
- * \param desc place to store string pointer
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_sig_alg_desc( const mbedtls_asn1_buf *oid, const char **desc );
-
-/**
- * \brief Translate md_type and pk_type into SignatureAlgorithm OID
- *
- * \param md_alg message digest algorithm
- * \param pk_alg public key algorithm
- * \param oid place to store ASN.1 OID string pointer
- * \param olen length of the OID
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_oid_by_sig_alg( mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg,
- const char **oid, size_t *olen );
-
-/**
- * \brief Translate hash algorithm OID into md_type
- *
- * \param oid OID to use
- * \param md_alg place to store message digest algorithm
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_md_alg( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg );
-#endif /* MBEDTLS_MD_C */
-
-/**
- * \brief Translate Extended Key Usage OID into description
- *
- * \param oid OID to use
- * \param desc place to store string pointer
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_extended_key_usage( const mbedtls_asn1_buf *oid, const char **desc );
-
-/**
- * \brief Translate md_type into hash algorithm OID
- *
- * \param md_alg message digest algorithm
- * \param oid place to store ASN.1 OID string pointer
- * \param olen length of the OID
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_oid_by_md( mbedtls_md_type_t md_alg, const char **oid, size_t *olen );
-
-#if defined(MBEDTLS_CIPHER_C)
-/**
- * \brief Translate encryption algorithm OID into cipher_type
- *
- * \param oid OID to use
- * \param cipher_alg place to store cipher algorithm
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_cipher_alg( const mbedtls_asn1_buf *oid, mbedtls_cipher_type_t *cipher_alg );
-#endif /* MBEDTLS_CIPHER_C */
-
-#if defined(MBEDTLS_PKCS12_C)
-/**
- * \brief Translate PKCS#12 PBE algorithm OID into md_type and
- * cipher_type
- *
- * \param oid OID to use
- * \param md_alg place to store message digest algorithm
- * \param cipher_alg place to store cipher algorithm
- *
- * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
- */
-int mbedtls_oid_get_pkcs12_pbe_alg( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg,
- mbedtls_cipher_type_t *cipher_alg );
-#endif /* MBEDTLS_PKCS12_C */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* oid.h */
diff --git a/backport/compat/verification/mbedtls/pk.h b/backport/compat/verification/mbedtls/pk.h
deleted file mode 100644
index 9aac7e2a..00000000
--- a/backport/compat/verification/mbedtls/pk.h
+++ /dev/null
@@ -1,618 +0,0 @@
-/**
- * \file pk.h
- *
- * \brief Public Key abstraction layer
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-#ifndef MBEDTLS_PK_H
-#define MBEDTLS_PK_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#include "md.h"
-
-#if defined(MBEDTLS_RSA_C)
-#include "rsa.h"
-#endif
-
-#if defined(MBEDTLS_ECP_C)
-#include "ecp.h"
-#endif
-
-#if defined(MBEDTLS_ECDSA_C)
-#include "ecdsa.h"
-#endif
-
-#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
- !defined(inline) && !defined(__cplusplus)
-#define inline __inline
-#endif
-
-#define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80 /**< Memory allocation failed. */
-#define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00 /**< Type mismatch, eg attempt to encrypt with an ECDSA key */
-#define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80 /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00 /**< Read/write of file failed. */
-#define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80 /**< Unsupported key version */
-#define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00 /**< Invalid key tag or value. */
-#define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80 /**< Key algorithm is unsupported (only RSA and EC are supported). */
-#define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00 /**< Private key password can't be empty. */
-#define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80 /**< Given private key password does not allow for correct decryption. */
-#define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00 /**< The pubkey tag or value is invalid (only RSA and EC are supported). */
-#define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 /**< The algorithm tag or value is invalid. */
-#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */
-#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */
-#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The signature is valid but its length is less than expected. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Public key types
- */
-typedef enum {
- MBEDTLS_PK_NONE=0,
- MBEDTLS_PK_RSA,
- MBEDTLS_PK_ECKEY,
- MBEDTLS_PK_ECKEY_DH,
- MBEDTLS_PK_ECDSA,
- MBEDTLS_PK_RSA_ALT,
- MBEDTLS_PK_RSASSA_PSS,
-} mbedtls_pk_type_t;
-
-/**
- * \brief Options for RSASSA-PSS signature verification.
- * See \c mbedtls_rsa_rsassa_pss_verify_ext()
- */
-typedef struct
-{
- mbedtls_md_type_t mgf1_hash_id;
- int expected_salt_len;
-
-} mbedtls_pk_rsassa_pss_options;
-
-/**
- * \brief Types for interfacing with the debug module
- */
-typedef enum
-{
- MBEDTLS_PK_DEBUG_NONE = 0,
- MBEDTLS_PK_DEBUG_MPI,
- MBEDTLS_PK_DEBUG_ECP,
-} mbedtls_pk_debug_type;
-
-/**
- * \brief Item to send to the debug module
- */
-typedef struct
-{
- mbedtls_pk_debug_type type;
- const char *name;
- void *value;
-} mbedtls_pk_debug_item;
-
-/** Maximum number of item send for debugging, plus 1 */
-#define MBEDTLS_PK_DEBUG_MAX_ITEMS 3
-
-/**
- * \brief Public key information and operations
- */
-typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
-
-/**
- * \brief Public key container
- */
-typedef struct
-{
- const mbedtls_pk_info_t * pk_info; /**< Public key informations */
- void * pk_ctx; /**< Underlying public key context */
-} mbedtls_pk_context;
-
-#if defined(MBEDTLS_RSA_C)
-/**
- * Quick access to an RSA context inside a PK context.
- *
- * \warning You must make sure the PK context actually holds an RSA context
- * before using this function!
- */
-static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk )
-{
- return( (mbedtls_rsa_context *) (pk).pk_ctx );
-}
-#endif /* MBEDTLS_RSA_C */
-
-#if defined(MBEDTLS_ECP_C)
-/**
- * Quick access to an EC context inside a PK context.
- *
- * \warning You must make sure the PK context actually holds an EC context
- * before using this function!
- */
-static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk )
-{
- return( (mbedtls_ecp_keypair *) (pk).pk_ctx );
-}
-#endif /* MBEDTLS_ECP_C */
-
-#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
-/**
- * \brief Types for RSA-alt abstraction
- */
-typedef int (*mbedtls_pk_rsa_alt_decrypt_func)( void *ctx, int mode, size_t *olen,
- const unsigned char *input, unsigned char *output,
- size_t output_max_len );
-typedef int (*mbedtls_pk_rsa_alt_sign_func)( void *ctx,
- int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
- int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
- const unsigned char *hash, unsigned char *sig );
-typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)( void *ctx );
-#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
-
-/**
- * \brief Return information associated with the given PK type
- *
- * \param pk_type PK type to search for.
- *
- * \return The PK info associated with the type or NULL if not found.
- */
-const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type );
-
-/**
- * \brief Initialize a mbedtls_pk_context (as NONE)
- */
-void mbedtls_pk_init( mbedtls_pk_context *ctx );
-
-/**
- * \brief Free a mbedtls_pk_context
- */
-void mbedtls_pk_free( mbedtls_pk_context *ctx );
-
-/**
- * \brief Initialize a PK context with the information given
- * and allocates the type-specific PK subcontext.
- *
- * \param ctx Context to initialize. Must be empty (type NONE).
- * \param info Information to use
- *
- * \return 0 on success,
- * MBEDTLS_ERR_PK_BAD_INPUT_DATA on invalid input,
- * MBEDTLS_ERR_PK_ALLOC_FAILED on allocation failure.
- *
- * \note For contexts holding an RSA-alt key, use
- * \c mbedtls_pk_setup_rsa_alt() instead.
- */
-int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info );
-
-#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
-/**
- * \brief Initialize an RSA-alt context
- *
- * \param ctx Context to initialize. Must be empty (type NONE).
- * \param key RSA key pointer
- * \param decrypt_func Decryption function
- * \param sign_func Signing function
- * \param key_len_func Function returning key length in bytes
- *
- * \return 0 on success, or MBEDTLS_ERR_PK_BAD_INPUT_DATA if the
- * context wasn't already initialized as RSA_ALT.
- *
- * \note This function replaces \c mbedtls_pk_setup() for RSA-alt.
- */
-int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key,
- mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
- mbedtls_pk_rsa_alt_sign_func sign_func,
- mbedtls_pk_rsa_alt_key_len_func key_len_func );
-#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
-
-/**
- * \brief Get the size in bits of the underlying key
- *
- * \param ctx Context to use
- *
- * \return Key size in bits, or 0 on error
- */
-size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx );
-
-/**
- * \brief Get the length in bytes of the underlying key
- * \param ctx Context to use
- *
- * \return Key length in bytes, or 0 on error
- */
-static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx )
-{
- return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 );
-}
-
-/**
- * \brief Tell if a context can do the operation given by type
- *
- * \param ctx Context to test
- * \param type Target type
- *
- * \return 0 if context can't do the operations,
- * 1 otherwise.
- */
-int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type );
-
-/**
- * \brief Verify signature (including padding if relevant).
- *
- * \param ctx PK context to use
- * \param md_alg Hash algorithm used (see notes)
- * \param hash Hash of the message to sign
- * \param hash_len Hash length or 0 (see notes)
- * \param sig Signature to verify
- * \param sig_len Signature length
- *
- * \return 0 on success (signature is valid),
- * MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is
- * valid but its actual length is less than sig_len,
- * or a specific error code.
- *
- * \note For RSA keys, the default padding type is PKCS#1 v1.5.
- * Use \c mbedtls_pk_verify_ext( MBEDTLS_PK_RSASSA_PSS, ... )
- * to verify RSASSA_PSS signatures.
- *
- * \note If hash_len is 0, then the length associated with md_alg
- * is used instead, or an error returned if it is invalid.
- *
- * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0
- */
-int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
- const unsigned char *hash, size_t hash_len,
- const unsigned char *sig, size_t sig_len );
-
-/**
- * \brief Verify signature, with options.
- * (Includes verification of the padding depending on type.)
- *
- * \param type Signature type (inc. possible padding type) to verify
- * \param options Pointer to type-specific options, or NULL
- * \param ctx PK context to use
- * \param md_alg Hash algorithm used (see notes)
- * \param hash Hash of the message to sign
- * \param hash_len Hash length or 0 (see notes)
- * \param sig Signature to verify
- * \param sig_len Signature length
- *
- * \return 0 on success (signature is valid),
- * MBEDTLS_ERR_PK_TYPE_MISMATCH if the PK context can't be
- * used for this type of signatures,
- * MBEDTLS_ERR_PK_SIG_LEN_MISMATCH if the signature is
- * valid but its actual length is less than sig_len,
- * or a specific error code.
- *
- * \note If hash_len is 0, then the length associated with md_alg
- * is used instead, or an error returned if it is invalid.
- *
- * \note md_alg may be MBEDTLS_MD_NONE, only if hash_len != 0
- *
- * \note If type is MBEDTLS_PK_RSASSA_PSS, then options must point
- * to a mbedtls_pk_rsassa_pss_options structure,
- * otherwise it must be NULL.
- */
-int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
- mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
- const unsigned char *hash, size_t hash_len,
- const unsigned char *sig, size_t sig_len );
-
-/**
- * \brief Make signature, including padding if relevant.
- *
- * \param ctx PK context to use - must hold a private key
- * \param md_alg Hash algorithm used (see notes)
- * \param hash Hash of the message to sign
- * \param hash_len Hash length or 0 (see notes)
- * \param sig Place to write the signature
- * \param sig_len Number of bytes written
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \return 0 on success, or a specific error code.
- *
- * \note For RSA keys, the default padding type is PKCS#1 v1.5.
- * There is no interface in the PK module to make RSASSA-PSS
- * signatures yet.
- *
- * \note If hash_len is 0, then the length associated with md_alg
- * is used instead, or an error returned if it is invalid.
- *
- * \note For RSA, md_alg may be MBEDTLS_MD_NONE if hash_len != 0.
- * For ECDSA, md_alg may never be MBEDTLS_MD_NONE.
- */
-int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
- const unsigned char *hash, size_t hash_len,
- unsigned char *sig, size_t *sig_len,
- int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
-
-/**
- * \brief Decrypt message (including padding if relevant).
- *
- * \param ctx PK context to use - must hold a private key
- * \param input Input to decrypt
- * \param ilen Input size
- * \param output Decrypted output
- * \param olen Decrypted message length
- * \param osize Size of the output buffer
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \note For RSA keys, the default padding type is PKCS#1 v1.5.
- *
- * \return 0 on success, or a specific error code.
- */
-int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
- const unsigned char *input, size_t ilen,
- unsigned char *output, size_t *olen, size_t osize,
- int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
-
-/**
- * \brief Encrypt message (including padding if relevant).
- *
- * \param ctx PK context to use
- * \param input Message to encrypt
- * \param ilen Message size
- * \param output Encrypted output
- * \param olen Encrypted output length
- * \param osize Size of the output buffer
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \note For RSA keys, the default padding type is PKCS#1 v1.5.
- *
- * \return 0 on success, or a specific error code.
- */
-int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
- const unsigned char *input, size_t ilen,
- unsigned char *output, size_t *olen, size_t osize,
- int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
-
-/**
- * \brief Check if a public-private pair of keys matches.
- *
- * \param pub Context holding a public key.
- * \param prv Context holding a private (and public) key.
- *
- * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA
- */
-int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv );
-
-/**
- * \brief Export debug information
- *
- * \param ctx Context to use
- * \param items Place to write debug items
- *
- * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA
- */
-int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items );
-
-/**
- * \brief Access the type name
- *
- * \param ctx Context to use
- *
- * \return Type name on success, or "invalid PK"
- */
-const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx );
-
-/**
- * \brief Get the key type
- *
- * \param ctx Context to use
- *
- * \return Type on success, or MBEDTLS_PK_NONE
- */
-mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx );
-
-#if defined(MBEDTLS_PK_PARSE_C)
-/** \ingroup pk_module */
-/**
- * \brief Parse a private key in PEM or DER format
- *
- * \param ctx key to be initialized
- * \param key input buffer
- * \param keylen size of the buffer
- * (including the terminating null byte for PEM data)
- * \param pwd password for decryption (optional)
- * \param pwdlen size of the password
- *
- * \note On entry, ctx must be empty, either freshly initialised
- * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
- * specific key type, check the result with mbedtls_pk_can_do().
- *
- * \note The key is also checked for correctness.
- *
- * \return 0 if successful, or a specific PK or PEM error code
- */
-int mbedtls_pk_parse_key( mbedtls_pk_context *ctx,
- const unsigned char *key, size_t keylen,
- const unsigned char *pwd, size_t pwdlen );
-
-/** \ingroup pk_module */
-/**
- * \brief Parse a public key in PEM or DER format
- *
- * \param ctx key to be initialized
- * \param key input buffer
- * \param keylen size of the buffer
- * (including the terminating null byte for PEM data)
- *
- * \note On entry, ctx must be empty, either freshly initialised
- * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
- * specific key type, check the result with mbedtls_pk_can_do().
- *
- * \note The key is also checked for correctness.
- *
- * \return 0 if successful, or a specific PK or PEM error code
- */
-int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
- const unsigned char *key, size_t keylen );
-
-#if defined(MBEDTLS_FS_IO)
-/** \ingroup pk_module */
-/**
- * \brief Load and parse a private key
- *
- * \param ctx key to be initialized
- * \param path filename to read the private key from
- * \param password password to decrypt the file (can be NULL)
- *
- * \note On entry, ctx must be empty, either freshly initialised
- * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
- * specific key type, check the result with mbedtls_pk_can_do().
- *
- * \note The key is also checked for correctness.
- *
- * \return 0 if successful, or a specific PK or PEM error code
- */
-int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
- const char *path, const char *password );
-
-/** \ingroup pk_module */
-/**
- * \brief Load and parse a public key
- *
- * \param ctx key to be initialized
- * \param path filename to read the public key from
- *
- * \note On entry, ctx must be empty, either freshly initialised
- * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If
- * you need a specific key type, check the result with
- * mbedtls_pk_can_do().
- *
- * \note The key is also checked for correctness.
- *
- * \return 0 if successful, or a specific PK or PEM error code
- */
-int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path );
-#endif /* MBEDTLS_FS_IO */
-#endif /* MBEDTLS_PK_PARSE_C */
-
-#if defined(MBEDTLS_PK_WRITE_C)
-/**
- * \brief Write a private key to a PKCS#1 or SEC1 DER structure
- * Note: data is written at the end of the buffer! Use the
- * return value to determine where you should start
- * using the buffer
- *
- * \param ctx private to write away
- * \param buf buffer to write to
- * \param size size of the buffer
- *
- * \return length of data written if successful, or a specific
- * error code
- */
-int mbedtls_pk_write_key_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
-
-/**
- * \brief Write a public key to a SubjectPublicKeyInfo DER structure
- * Note: data is written at the end of the buffer! Use the
- * return value to determine where you should start
- * using the buffer
- *
- * \param ctx public key to write away
- * \param buf buffer to write to
- * \param size size of the buffer
- *
- * \return length of data written if successful, or a specific
- * error code
- */
-int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
-
-#if defined(MBEDTLS_PEM_WRITE_C)
-/**
- * \brief Write a public key to a PEM string
- *
- * \param ctx public key to write away
- * \param buf buffer to write to
- * \param size size of the buffer
- *
- * \return 0 if successful, or a specific error code
- */
-int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
-
-/**
- * \brief Write a private key to a PKCS#1 or SEC1 PEM string
- *
- * \param ctx private to write away
- * \param buf buffer to write to
- * \param size size of the buffer
- *
- * \return 0 if successful, or a specific error code
- */
-int mbedtls_pk_write_key_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
-#endif /* MBEDTLS_PEM_WRITE_C */
-#endif /* MBEDTLS_PK_WRITE_C */
-
-/*
- * WARNING: Low-level functions. You probably do not want to use these unless
- * you are certain you do ;)
- */
-
-#if defined(MBEDTLS_PK_PARSE_C)
-/**
- * \brief Parse a SubjectPublicKeyInfo DER structure
- *
- * \param p the position in the ASN.1 data
- * \param end end of the buffer
- * \param pk the key to fill
- *
- * \return 0 if successful, or a specific PK error code
- */
-int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end,
- mbedtls_pk_context *pk );
-#endif /* MBEDTLS_PK_PARSE_C */
-
-#if defined(MBEDTLS_PK_WRITE_C)
-/**
- * \brief Write a subjectPublicKey to ASN.1 data
- * Note: function works backwards in data buffer
- *
- * \param p reference to current position pointer
- * \param start start of the buffer (for bounds-checking)
- * \param key public key to write away
- *
- * \return the length written or a negative error code
- */
-int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start,
- const mbedtls_pk_context *key );
-#endif /* MBEDTLS_PK_WRITE_C */
-
-/*
- * Internal module functions. You probably do not want to use these unless you
- * know you do.
- */
-#if defined(MBEDTLS_FS_IO)
-int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n );
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MBEDTLS_PK_H */
diff --git a/backport/compat/verification/mbedtls/platform.h b/backport/compat/verification/mbedtls/platform.h
deleted file mode 100644
index cf5fa56f..00000000
--- a/backport/compat/verification/mbedtls/platform.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __MBEDTLS_PLATFORM_H
-#define __MBEDTLS_PLATFORM_H
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-
-#define mbedtls_printf pr_debug
-#define mbedtls_calloc(a, b) kcalloc(a, b, GFP_KERNEL)
-#define mbedtls_free kfree
-#define mbedtls_snprintf snprintf
-
-#endif /* __MBEDTLS_PLATFORM_H */
diff --git a/backport/compat/verification/mbedtls/rsa.h b/backport/compat/verification/mbedtls/rsa.h
deleted file mode 100644
index 9683520c..00000000
--- a/backport/compat/verification/mbedtls/rsa.h
+++ /dev/null
@@ -1,672 +0,0 @@
-/**
- * \file rsa.h
- *
- * \brief The RSA public-key cryptosystem
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_RSA_H
-#define MBEDTLS_RSA_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#include "bignum.h"
-#include "md.h"
-
-#if defined(MBEDTLS_THREADING_C)
-#include "threading.h"
-#endif
-
-/*
- * RSA Error codes
- */
-#define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */
-#define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */
-#define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the library's validity check. */
-#define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */
-#define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */
-#define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */
-#define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */
-#define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */
-
-/*
- * RSA constants
- */
-#define MBEDTLS_RSA_PUBLIC 0
-#define MBEDTLS_RSA_PRIVATE 1
-
-#define MBEDTLS_RSA_PKCS_V15 0
-#define MBEDTLS_RSA_PKCS_V21 1
-
-#define MBEDTLS_RSA_SIGN 1
-#define MBEDTLS_RSA_CRYPT 2
-
-#define MBEDTLS_RSA_SALT_LEN_ANY -1
-
-/*
- * The above constants may be used even if the RSA module is compile out,
- * eg for alternative (PKCS#11) RSA implemenations in the PK layers.
- */
-#if defined(MBEDTLS_RSA_C)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief RSA context structure
- */
-typedef struct
-{
- int ver; /*!< always 0 */
- size_t len; /*!< size(N) in chars */
-
- mbedtls_mpi N; /*!< public modulus */
- mbedtls_mpi E; /*!< public exponent */
-
- mbedtls_mpi D; /*!< private exponent */
- mbedtls_mpi P; /*!< 1st prime factor */
- mbedtls_mpi Q; /*!< 2nd prime factor */
- mbedtls_mpi DP; /*!< D % (P - 1) */
- mbedtls_mpi DQ; /*!< D % (Q - 1) */
- mbedtls_mpi QP; /*!< 1 / (Q % P) */
-
- mbedtls_mpi RN; /*!< cached R^2 mod N */
- mbedtls_mpi RP; /*!< cached R^2 mod P */
- mbedtls_mpi RQ; /*!< cached R^2 mod Q */
-
- mbedtls_mpi Vi; /*!< cached blinding value */
- mbedtls_mpi Vf; /*!< cached un-blinding value */
-
- int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
- MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
- int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
- specified in the mbedtls_md.h header file
- for the EME-OAEP and EMSA-PSS
- encoding */
-#if defined(MBEDTLS_THREADING_C)
- mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex */
-#endif
-}
-mbedtls_rsa_context;
-
-/**
- * \brief Initialize an RSA context
- *
- * Note: Set padding to MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP
- * encryption scheme and the RSASSA-PSS signature scheme.
- *
- * \param ctx RSA context to be initialized
- * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
- * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
- *
- * \note The hash_id parameter is actually ignored
- * when using MBEDTLS_RSA_PKCS_V15 padding.
- *
- * \note Choice of padding mode is strictly enforced for private key
- * operations, since there might be security concerns in
- * mixing padding modes. For public key operations it's merely
- * a default value, which can be overriden by calling specific
- * rsa_rsaes_xxx or rsa_rsassa_xxx functions.
- *
- * \note The chosen hash is always used for OEAP encryption.
- * For PSS signatures, it's always used for making signatures,
- * but can be overriden (and always is, if set to
- * MBEDTLS_MD_NONE) for verifying them.
- */
-void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
- int padding,
- int hash_id);
-
-/**
- * \brief Set padding for an already initialized RSA context
- * See \c mbedtls_rsa_init() for details.
- *
- * \param ctx RSA context to be set
- * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
- * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
- */
-void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id);
-
-/**
- * \brief Generate an RSA keypair
- *
- * \param ctx RSA context that will hold the key
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- * \param nbits size of the public key in bits
- * \param exponent public exponent (e.g., 65537)
- *
- * \note mbedtls_rsa_init() must be called beforehand to setup
- * the RSA context.
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- */
-int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- unsigned int nbits, int exponent );
-
-/**
- * \brief Check a public RSA key
- *
- * \param ctx RSA context to be checked
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- */
-int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx );
-
-/**
- * \brief Check a private RSA key
- *
- * \param ctx RSA context to be checked
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- */
-int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx );
-
-/**
- * \brief Check a public-private RSA key pair.
- * Check each of the contexts, and make sure they match.
- *
- * \param pub RSA context holding the public key
- * \param prv RSA context holding the private key
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- */
-int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv );
-
-/**
- * \brief Do an RSA public key operation
- *
- * \param ctx RSA context
- * \param input input buffer
- * \param output output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note This function does NOT take care of message
- * padding. Also, be sure to set input[0] = 0 or ensure that
- * input is smaller than N.
- *
- * \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
- const unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Do an RSA private key operation
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for blinding)
- * \param p_rng RNG parameter
- * \param input input buffer
- * \param output output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- const unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Generic wrapper to perform a PKCS#1 encryption using the
- * mode from the context. Add the message padding, then do an
- * RSA operation.
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
- * and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t ilen,
- const unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t ilen,
- const unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
- * and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param label buffer holding the custom label to use
- * \param label_len contains the label length
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- const unsigned char *label, size_t label_len,
- size_t ilen,
- const unsigned char *input,
- unsigned char *output );
-
-/**
- * \brief Generic wrapper to perform a PKCS#1 decryption using the
- * mode from the context. Do an RSA operation, then remove
- * the message padding
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer length \c output_max_len should be
- * as large as the size ctx->len of ctx->N (eg. 128 bytes
- * if RSA-1024 is used) to be able to hold an arbitrary
- * decrypted message. If it is not large enough to hold
- * the decryption of the particular ciphertext provided,
- * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
- *
- * \note The input buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len );
-
-/**
- * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer length \c output_max_len should be
- * as large as the size ctx->len of ctx->N (eg. 128 bytes
- * if RSA-1024 is used) to be able to hold an arbitrary
- * decrypted message. If it is not large enough to hold
- * the decryption of the particular ciphertext provided,
- * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
- *
- * \note The input buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len );
-
-/**
- * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param label buffer holding the custom label to use
- * \param label_len contains the label length
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer length \c output_max_len should be
- * as large as the size ctx->len of ctx->N (eg. 128 bytes
- * if RSA-1024 is used) to be able to hold an arbitrary
- * decrypted message. If it is not large enough to hold
- * the decryption of the particular ciphertext provided,
- * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
- *
- * \note The input buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- const unsigned char *label, size_t label_len,
- size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len );
-
-/**
- * \brief Generic wrapper to perform a PKCS#1 signature using the
- * mode from the context. Do a private RSA operation to sign
- * a message digest
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
- * MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note In case of PKCS#1 v2.1 encoding, see comments on
- * \note \c mbedtls_rsa_rsassa_pss_sign() for details on md_alg and hash_id.
- */
-int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig );
-
-/**
- * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig );
-
-/**
- * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
- * MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is the one used for the
- * encoding. md_alg in the function call is the type of hash
- * that is encoded. According to RFC 3447 it is advised to
- * keep both hashes the same.
- */
-int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig );
-
-/**
- * \brief Generic wrapper to perform a PKCS#1 verification using the
- * mode from the context. Do a public RSA operation and check
- * the message digest
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note In case of PKCS#1 v2.1 encoding, see comments on
- * \c mbedtls_rsa_rsassa_pss_verify() about md_alg and hash_id.
- */
-int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig );
-
-/**
- * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- */
-int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig );
-
-/**
- * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
- * (This is the "simple" version.)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is the one used for the
- * verification. md_alg in the function call is the type of
- * hash that is verified. According to RFC 3447 it is advised to
- * keep both hashes the same. If hash_id in the RSA context is
- * unset, the md_alg from the function call is used.
- */
-int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig );
-
-/**
- * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
- * (This is the version with "full" options.)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param mgf1_hash_id message digest used for mask generation
- * \param expected_salt_len Length of the salt used in padding, use
- * MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is ignored.
- */
-int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- mbedtls_md_type_t mgf1_hash_id,
- int expected_salt_len,
- const unsigned char *sig );
-
-/**
- * \brief Copy the components of an RSA context
- *
- * \param dst Destination context
- * \param src Source context
- *
- * \return 0 on success,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure
- */
-int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src );
-
-/**
- * \brief Free the components of an RSA key
- *
- * \param ctx RSA Context to free
- */
-void mbedtls_rsa_free( mbedtls_rsa_context *ctx );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int mbedtls_rsa_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MBEDTLS_RSA_C */
-
-#endif /* rsa.h */
diff --git a/backport/compat/verification/mbedtls/sha1.h b/backport/compat/verification/mbedtls/sha1.h
deleted file mode 100644
index b8752edd..00000000
--- a/backport/compat/verification/mbedtls/sha1.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * \file sha1.h
- *
- * \brief SHA-1 cryptographic hash function
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_SHA1_H
-#define MBEDTLS_SHA1_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if !defined(MBEDTLS_SHA1_ALT)
-// Regular implementation
-//
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief SHA-1 context structure
- */
-typedef struct
-{
- uint32_t total[2]; /*!< number of bytes processed */
- uint32_t state[5]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
-}
-mbedtls_sha1_context;
-
-/**
- * \brief Initialize SHA-1 context
- *
- * \param ctx SHA-1 context to be initialized
- */
-void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
-
-/**
- * \brief Clear SHA-1 context
- *
- * \param ctx SHA-1 context to be cleared
- */
-void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
-
-/**
- * \brief Clone (the state of) a SHA-1 context
- *
- * \param dst The destination context
- * \param src The context to be cloned
- */
-void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
- const mbedtls_sha1_context *src );
-
-/**
- * \brief SHA-1 context setup
- *
- * \param ctx context to be initialized
- */
-void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
-
-/**
- * \brief SHA-1 process buffer
- *
- * \param ctx SHA-1 context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
-
-/**
- * \brief SHA-1 final digest
- *
- * \param ctx SHA-1 context
- * \param output SHA-1 checksum result
- */
-void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );
-
-/* Internal use */
-void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
-
-#ifdef __cplusplus
-}
-#endif
-
-#else /* MBEDTLS_SHA1_ALT */
-#include "sha1_alt.h"
-#endif /* MBEDTLS_SHA1_ALT */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Output = SHA-1( input buffer )
- *
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-1 checksum result
- */
-void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int mbedtls_sha1_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* mbedtls_sha1.h */
diff --git a/backport/compat/verification/mbedtls/sha256.h b/backport/compat/verification/mbedtls/sha256.h
deleted file mode 100644
index 68223f0b..00000000
--- a/backport/compat/verification/mbedtls/sha256.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * \file sha256.h
- *
- * \brief SHA-224 and SHA-256 cryptographic hash function
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_SHA256_H
-#define MBEDTLS_SHA256_H
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if !defined(MBEDTLS_SHA256_ALT)
-// Regular implementation
-//
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief SHA-256 context structure
- */
-typedef struct
-{
- uint32_t total[2]; /*!< number of bytes processed */
- uint32_t state[8]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
- int is224; /*!< 0 => SHA-256, else SHA-224 */
-}
-mbedtls_sha256_context;
-
-/**
- * \brief Initialize SHA-256 context
- *
- * \param ctx SHA-256 context to be initialized
- */
-void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
-
-/**
- * \brief Clear SHA-256 context
- *
- * \param ctx SHA-256 context to be cleared
- */
-void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
-
-/**
- * \brief Clone (the state of) a SHA-256 context
- *
- * \param dst The destination context
- * \param src The context to be cloned
- */
-void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
- const mbedtls_sha256_context *src );
-
-/**
- * \brief SHA-256 context setup
- *
- * \param ctx context to be initialized
- * \param is224 0 = use SHA256, 1 = use SHA224
- */
-void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );
-
-/**
- * \brief SHA-256 process buffer
- *
- * \param ctx SHA-256 context
- * \param input buffer holding the data
- * \param ilen length of the input data
- */
-void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
- size_t ilen );
-
-/**
- * \brief SHA-256 final digest
- *
- * \param ctx SHA-256 context
- * \param output SHA-224/256 checksum result
- */
-void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] );
-
-/* Internal use */
-void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );
-
-#ifdef __cplusplus
-}
-#endif
-
-#else /* MBEDTLS_SHA256_ALT */
-#include "sha256_alt.h"
-#endif /* MBEDTLS_SHA256_ALT */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Output = SHA-256( input buffer )
- *
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-224/256 checksum result
- * \param is224 0 = use SHA256, 1 = use SHA224
- */
-void mbedtls_sha256( const unsigned char *input, size_t ilen,
- unsigned char output[32], int is224 );
-
-/**
- * \brief Checkup routine
- *
- * \return 0 if successful, or 1 if the test failed
- */
-int mbedtls_sha256_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* mbedtls_sha256.h */
diff --git a/backport/compat/verification/md.c b/backport/compat/verification/md.c
deleted file mode 100644
index cff07534..00000000
--- a/backport/compat/verification/md.c
+++ /dev/null
@@ -1,471 +0,0 @@
-/**
- * \file mbedtls_md.c
- *
- * \brief Generic message digest wrapper for mbed TLS
- *
- * \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_MD_C)
-
-#include "mbedtls/md.h"
-#include "mbedtls/md_internal.h"
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdlib.h>
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
-
-#if defined(MBEDTLS_FS_IO)
-#include <stdio.h>
-#endif
-
-/* Implementation that should never be optimized out by the compiler */
-static void mbedtls_zeroize( void *v, size_t n ) {
- volatile unsigned char *p = v; while( n-- ) *p++ = 0;
-}
-
-/*
- * Reminder: update profiles in x509_crt.c when adding a new hash!
- */
-static const int supported_digests[] = {
-
-#if defined(MBEDTLS_SHA512_C)
- MBEDTLS_MD_SHA512,
- MBEDTLS_MD_SHA384,
-#endif
-
-#if defined(MBEDTLS_SHA256_C)
- MBEDTLS_MD_SHA256,
- MBEDTLS_MD_SHA224,
-#endif
-
-#if defined(MBEDTLS_SHA1_C)
- MBEDTLS_MD_SHA1,
-#endif
-
-#if defined(MBEDTLS_RIPEMD160_C)
- MBEDTLS_MD_RIPEMD160,
-#endif
-
-#if defined(MBEDTLS_MD5_C)
- MBEDTLS_MD_MD5,
-#endif
-
-#if defined(MBEDTLS_MD4_C)
- MBEDTLS_MD_MD4,
-#endif
-
-#if defined(MBEDTLS_MD2_C)
- MBEDTLS_MD_MD2,
-#endif
-
- MBEDTLS_MD_NONE
-};
-
-const int *mbedtls_md_list( void )
-{
- return( supported_digests );
-}
-
-const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name )
-{
- if( NULL == md_name )
- return( NULL );
-
- /* Get the appropriate digest information */
-#if defined(MBEDTLS_MD2_C)
- if( !strcmp( "MD2", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_MD2 );
-#endif
-#if defined(MBEDTLS_MD4_C)
- if( !strcmp( "MD4", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_MD4 );
-#endif
-#if defined(MBEDTLS_MD5_C)
- if( !strcmp( "MD5", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_MD5 );
-#endif
-#if defined(MBEDTLS_RIPEMD160_C)
- if( !strcmp( "RIPEMD160", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_RIPEMD160 );
-#endif
-#if defined(MBEDTLS_SHA1_C)
- if( !strcmp( "SHA1", md_name ) || !strcmp( "SHA", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 );
-#endif
-#if defined(MBEDTLS_SHA256_C)
- if( !strcmp( "SHA224", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_SHA224 );
- if( !strcmp( "SHA256", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 );
-#endif
-#if defined(MBEDTLS_SHA512_C)
- if( !strcmp( "SHA384", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_SHA384 );
- if( !strcmp( "SHA512", md_name ) )
- return mbedtls_md_info_from_type( MBEDTLS_MD_SHA512 );
-#endif
- return( NULL );
-}
-
-const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type )
-{
- switch( md_type )
- {
-#if defined(MBEDTLS_MD2_C)
- case MBEDTLS_MD_MD2:
- return( &mbedtls_md2_info );
-#endif
-#if defined(MBEDTLS_MD4_C)
- case MBEDTLS_MD_MD4:
- return( &mbedtls_md4_info );
-#endif
-#if defined(MBEDTLS_MD5_C)
- case MBEDTLS_MD_MD5:
- return( &mbedtls_md5_info );
-#endif
-#if defined(MBEDTLS_RIPEMD160_C)
- case MBEDTLS_MD_RIPEMD160:
- return( &mbedtls_ripemd160_info );
-#endif
-#if defined(MBEDTLS_SHA1_C)
- case MBEDTLS_MD_SHA1:
- return( &mbedtls_sha1_info );
-#endif
-#if defined(MBEDTLS_SHA256_C)
- case MBEDTLS_MD_SHA224:
- return( &mbedtls_sha224_info );
- case MBEDTLS_MD_SHA256:
- return( &mbedtls_sha256_info );
-#endif
-#if defined(MBEDTLS_SHA512_C)
- case MBEDTLS_MD_SHA384:
- return( &mbedtls_sha384_info );
- case MBEDTLS_MD_SHA512:
- return( &mbedtls_sha512_info );
-#endif
- default:
- return( NULL );
- }
-}
-
-void mbedtls_md_init( mbedtls_md_context_t *ctx )
-{
- memset( ctx, 0, sizeof( mbedtls_md_context_t ) );
-}
-
-void mbedtls_md_free( mbedtls_md_context_t *ctx )
-{
- if( ctx == NULL || ctx->md_info == NULL )
- return;
-
- if( ctx->md_ctx != NULL )
- ctx->md_info->ctx_free_func( ctx->md_ctx );
-
- if( ctx->hmac_ctx != NULL )
- {
- mbedtls_zeroize( ctx->hmac_ctx, 2 * ctx->md_info->block_size );
- mbedtls_free( ctx->hmac_ctx );
- }
-
- mbedtls_zeroize( ctx, sizeof( mbedtls_md_context_t ) );
-}
-
-int mbedtls_md_clone( mbedtls_md_context_t *dst,
- const mbedtls_md_context_t *src )
-{
- if( dst == NULL || dst->md_info == NULL ||
- src == NULL || src->md_info == NULL ||
- dst->md_info != src->md_info )
- {
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- }
-
- dst->md_info->clone_func( dst->md_ctx, src->md_ctx );
-
- return( 0 );
-}
-
-#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
-int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info )
-{
- return mbedtls_md_setup( ctx, md_info, 1 );
-}
-#endif
-
-int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac )
-{
- if( md_info == NULL || ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL )
- return( MBEDTLS_ERR_MD_ALLOC_FAILED );
-
- if( hmac != 0 )
- {
- ctx->hmac_ctx = mbedtls_calloc( 2, md_info->block_size );
- if( ctx->hmac_ctx == NULL )
- {
- md_info->ctx_free_func( ctx->md_ctx );
- return( MBEDTLS_ERR_MD_ALLOC_FAILED );
- }
- }
-
- ctx->md_info = md_info;
-
- return( 0 );
-}
-
-int mbedtls_md_starts( mbedtls_md_context_t *ctx )
-{
- if( ctx == NULL || ctx->md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ctx->md_info->starts_func( ctx->md_ctx );
-
- return( 0 );
-}
-
-int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
-{
- if( ctx == NULL || ctx->md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ctx->md_info->update_func( ctx->md_ctx, input, ilen );
-
- return( 0 );
-}
-
-int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
-{
- if( ctx == NULL || ctx->md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ctx->md_info->finish_func( ctx->md_ctx, output );
-
- return( 0 );
-}
-
-int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- if( md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- md_info->digest_func( input, ilen, output );
-
- return( 0 );
-}
-
-#if defined(MBEDTLS_FS_IO)
-int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigned char *output )
-{
- int ret;
- FILE *f;
- size_t n;
- mbedtls_md_context_t ctx;
- unsigned char buf[1024];
-
- if( md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- if( ( f = fopen( path, "rb" ) ) == NULL )
- return( MBEDTLS_ERR_MD_FILE_IO_ERROR );
-
- mbedtls_md_init( &ctx );
-
- if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 )
- goto cleanup;
-
- md_info->starts_func( ctx.md_ctx );
-
- while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
- md_info->update_func( ctx.md_ctx, buf, n );
-
- if( ferror( f ) != 0 )
- {
- ret = MBEDTLS_ERR_MD_FILE_IO_ERROR;
- goto cleanup;
- }
-
- md_info->finish_func( ctx.md_ctx, output );
-
-cleanup:
- fclose( f );
- mbedtls_md_free( &ctx );
-
- return( ret );
-}
-#endif /* MBEDTLS_FS_IO */
-
-int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen )
-{
- unsigned char sum[MBEDTLS_MD_MAX_SIZE];
- unsigned char *ipad, *opad;
- size_t i;
-
- if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- if( keylen > (size_t) ctx->md_info->block_size )
- {
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, key, keylen );
- ctx->md_info->finish_func( ctx->md_ctx, sum );
-
- keylen = ctx->md_info->size;
- key = sum;
- }
-
- ipad = (unsigned char *) ctx->hmac_ctx;
- opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
-
- memset( ipad, 0x36, ctx->md_info->block_size );
- memset( opad, 0x5C, ctx->md_info->block_size );
-
- for( i = 0; i < keylen; i++ )
- {
- ipad[i] = (unsigned char)( ipad[i] ^ key[i] );
- opad[i] = (unsigned char)( opad[i] ^ key[i] );
- }
-
- mbedtls_zeroize( sum, sizeof( sum ) );
-
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size );
-
- return( 0 );
-}
-
-int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
-{
- if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ctx->md_info->update_func( ctx->md_ctx, input, ilen );
-
- return( 0 );
-}
-
-int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output )
-{
- unsigned char tmp[MBEDTLS_MD_MAX_SIZE];
- unsigned char *opad;
-
- if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
-
- ctx->md_info->finish_func( ctx->md_ctx, tmp );
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, opad, ctx->md_info->block_size );
- ctx->md_info->update_func( ctx->md_ctx, tmp, ctx->md_info->size );
- ctx->md_info->finish_func( ctx->md_ctx, output );
-
- return( 0 );
-}
-
-int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx )
-{
- unsigned char *ipad;
-
- if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ipad = (unsigned char *) ctx->hmac_ctx;
-
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size );
-
- return( 0 );
-}
-
-int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
- const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- mbedtls_md_context_t ctx;
- int ret;
-
- if( md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- mbedtls_md_init( &ctx );
-
- if( ( ret = mbedtls_md_setup( &ctx, md_info, 1 ) ) != 0 )
- return( ret );
-
- mbedtls_md_hmac_starts( &ctx, key, keylen );
- mbedtls_md_hmac_update( &ctx, input, ilen );
- mbedtls_md_hmac_finish( &ctx, output );
-
- mbedtls_md_free( &ctx );
-
- return( 0 );
-}
-
-int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data )
-{
- if( ctx == NULL || ctx->md_info == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- ctx->md_info->process_func( ctx->md_ctx, data );
-
- return( 0 );
-}
-
-unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info )
-{
- if( md_info == NULL )
- return( 0 );
-
- return md_info->size;
-}
-
-mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info )
-{
- if( md_info == NULL )
- return( MBEDTLS_MD_NONE );
-
- return md_info->type;
-}
-
-const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info )
-{
- if( md_info == NULL )
- return( NULL );
-
- return md_info->name;
-}
-
-#endif /* MBEDTLS_MD_C */
diff --git a/backport/compat/verification/md_wrap.c b/backport/compat/verification/md_wrap.c
deleted file mode 100644
index 49c47d69..00000000
--- a/backport/compat/verification/md_wrap.c
+++ /dev/null
@@ -1,577 +0,0 @@
-/**
- * \file md_wrap.c
- *
- * \brief Generic message digest wrapper for mbed TLS
- *
- * \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_MD_C)
-
-#include "mbedtls/md_internal.h"
-
-#if defined(MBEDTLS_MD2_C)
-#include "mbedtls/md2.h"
-#endif
-
-#if defined(MBEDTLS_MD4_C)
-#include "mbedtls/md4.h"
-#endif
-
-#if defined(MBEDTLS_MD5_C)
-#include "mbedtls/md5.h"
-#endif
-
-#if defined(MBEDTLS_RIPEMD160_C)
-#include "mbedtls/ripemd160.h"
-#endif
-
-#if defined(MBEDTLS_SHA1_C)
-#include "mbedtls/sha1.h"
-#endif
-
-#if defined(MBEDTLS_SHA256_C)
-#include "mbedtls/sha256.h"
-#endif
-
-#if defined(MBEDTLS_SHA512_C)
-#include "mbedtls/sha512.h"
-#endif
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdlib.h>
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
-
-#if defined(MBEDTLS_MD2_C)
-
-static void md2_starts_wrap( void *ctx )
-{
- mbedtls_md2_starts( (mbedtls_md2_context *) ctx );
-}
-
-static void md2_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_md2_update( (mbedtls_md2_context *) ctx, input, ilen );
-}
-
-static void md2_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_md2_finish( (mbedtls_md2_context *) ctx, output );
-}
-
-static void *md2_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md2_context ) );
-
- if( ctx != NULL )
- mbedtls_md2_init( (mbedtls_md2_context *) ctx );
-
- return( ctx );
-}
-
-static void md2_ctx_free( void *ctx )
-{
- mbedtls_md2_free( (mbedtls_md2_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void md2_clone_wrap( void *dst, const void *src )
-{
- mbedtls_md2_clone( (mbedtls_md2_context *) dst,
- (const mbedtls_md2_context *) src );
-}
-
-static void md2_process_wrap( void *ctx, const unsigned char *data )
-{
- ((void) data);
-
- mbedtls_md2_process( (mbedtls_md2_context *) ctx );
-}
-
-const mbedtls_md_info_t mbedtls_md2_info = {
- MBEDTLS_MD_MD2,
- "MD2",
- 16,
- 16,
- md2_starts_wrap,
- md2_update_wrap,
- md2_finish_wrap,
- mbedtls_md2,
- md2_ctx_alloc,
- md2_ctx_free,
- md2_clone_wrap,
- md2_process_wrap,
-};
-
-#endif /* MBEDTLS_MD2_C */
-
-#if defined(MBEDTLS_MD4_C)
-
-static void md4_starts_wrap( void *ctx )
-{
- mbedtls_md4_starts( (mbedtls_md4_context *) ctx );
-}
-
-static void md4_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_md4_update( (mbedtls_md4_context *) ctx, input, ilen );
-}
-
-static void md4_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_md4_finish( (mbedtls_md4_context *) ctx, output );
-}
-
-static void *md4_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md4_context ) );
-
- if( ctx != NULL )
- mbedtls_md4_init( (mbedtls_md4_context *) ctx );
-
- return( ctx );
-}
-
-static void md4_ctx_free( void *ctx )
-{
- mbedtls_md4_free( (mbedtls_md4_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void md4_clone_wrap( void *dst, const void *src )
-{
- mbedtls_md4_clone( (mbedtls_md4_context *) dst,
- (const mbedtls_md4_context *) src );
-}
-
-static void md4_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_md4_process( (mbedtls_md4_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_md4_info = {
- MBEDTLS_MD_MD4,
- "MD4",
- 16,
- 64,
- md4_starts_wrap,
- md4_update_wrap,
- md4_finish_wrap,
- mbedtls_md4,
- md4_ctx_alloc,
- md4_ctx_free,
- md4_clone_wrap,
- md4_process_wrap,
-};
-
-#endif /* MBEDTLS_MD4_C */
-
-#if defined(MBEDTLS_MD5_C)
-
-static void md5_starts_wrap( void *ctx )
-{
- mbedtls_md5_starts( (mbedtls_md5_context *) ctx );
-}
-
-static void md5_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_md5_update( (mbedtls_md5_context *) ctx, input, ilen );
-}
-
-static void md5_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_md5_finish( (mbedtls_md5_context *) ctx, output );
-}
-
-static void *md5_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_md5_context ) );
-
- if( ctx != NULL )
- mbedtls_md5_init( (mbedtls_md5_context *) ctx );
-
- return( ctx );
-}
-
-static void md5_ctx_free( void *ctx )
-{
- mbedtls_md5_free( (mbedtls_md5_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void md5_clone_wrap( void *dst, const void *src )
-{
- mbedtls_md5_clone( (mbedtls_md5_context *) dst,
- (const mbedtls_md5_context *) src );
-}
-
-static void md5_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_md5_process( (mbedtls_md5_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_md5_info = {
- MBEDTLS_MD_MD5,
- "MD5",
- 16,
- 64,
- md5_starts_wrap,
- md5_update_wrap,
- md5_finish_wrap,
- mbedtls_md5,
- md5_ctx_alloc,
- md5_ctx_free,
- md5_clone_wrap,
- md5_process_wrap,
-};
-
-#endif /* MBEDTLS_MD5_C */
-
-#if defined(MBEDTLS_RIPEMD160_C)
-
-static void ripemd160_starts_wrap( void *ctx )
-{
- mbedtls_ripemd160_starts( (mbedtls_ripemd160_context *) ctx );
-}
-
-static void ripemd160_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_ripemd160_update( (mbedtls_ripemd160_context *) ctx, input, ilen );
-}
-
-static void ripemd160_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_ripemd160_finish( (mbedtls_ripemd160_context *) ctx, output );
-}
-
-static void *ripemd160_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ripemd160_context ) );
-
- if( ctx != NULL )
- mbedtls_ripemd160_init( (mbedtls_ripemd160_context *) ctx );
-
- return( ctx );
-}
-
-static void ripemd160_ctx_free( void *ctx )
-{
- mbedtls_ripemd160_free( (mbedtls_ripemd160_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void ripemd160_clone_wrap( void *dst, const void *src )
-{
- mbedtls_ripemd160_clone( (mbedtls_ripemd160_context *) dst,
- (const mbedtls_ripemd160_context *) src );
-}
-
-static void ripemd160_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_ripemd160_process( (mbedtls_ripemd160_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_ripemd160_info = {
- MBEDTLS_MD_RIPEMD160,
- "RIPEMD160",
- 20,
- 64,
- ripemd160_starts_wrap,
- ripemd160_update_wrap,
- ripemd160_finish_wrap,
- mbedtls_ripemd160,
- ripemd160_ctx_alloc,
- ripemd160_ctx_free,
- ripemd160_clone_wrap,
- ripemd160_process_wrap,
-};
-
-#endif /* MBEDTLS_RIPEMD160_C */
-
-#if defined(MBEDTLS_SHA1_C)
-
-static void sha1_starts_wrap( void *ctx )
-{
- mbedtls_sha1_starts( (mbedtls_sha1_context *) ctx );
-}
-
-static void sha1_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_sha1_update( (mbedtls_sha1_context *) ctx, input, ilen );
-}
-
-static void sha1_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_sha1_finish( (mbedtls_sha1_context *) ctx, output );
-}
-
-static void *sha1_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha1_context ) );
-
- if( ctx != NULL )
- mbedtls_sha1_init( (mbedtls_sha1_context *) ctx );
-
- return( ctx );
-}
-
-static void sha1_clone_wrap( void *dst, const void *src )
-{
- mbedtls_sha1_clone( (mbedtls_sha1_context *) dst,
- (const mbedtls_sha1_context *) src );
-}
-
-static void sha1_ctx_free( void *ctx )
-{
- mbedtls_sha1_free( (mbedtls_sha1_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void sha1_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_sha1_process( (mbedtls_sha1_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_sha1_info = {
- MBEDTLS_MD_SHA1,
- "SHA1",
- 20,
- 64,
- sha1_starts_wrap,
- sha1_update_wrap,
- sha1_finish_wrap,
- mbedtls_sha1,
- sha1_ctx_alloc,
- sha1_ctx_free,
- sha1_clone_wrap,
- sha1_process_wrap,
-};
-
-#endif /* MBEDTLS_SHA1_C */
-
-/*
- * Wrappers for generic message digests
- */
-#if defined(MBEDTLS_SHA256_C)
-
-static void sha224_starts_wrap( void *ctx )
-{
- mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 1 );
-}
-
-static void sha224_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_sha256_update( (mbedtls_sha256_context *) ctx, input, ilen );
-}
-
-static void sha224_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_sha256_finish( (mbedtls_sha256_context *) ctx, output );
-}
-
-static void sha224_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- mbedtls_sha256( input, ilen, output, 1 );
-}
-
-static void *sha224_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha256_context ) );
-
- if( ctx != NULL )
- mbedtls_sha256_init( (mbedtls_sha256_context *) ctx );
-
- return( ctx );
-}
-
-static void sha224_ctx_free( void *ctx )
-{
- mbedtls_sha256_free( (mbedtls_sha256_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void sha224_clone_wrap( void *dst, const void *src )
-{
- mbedtls_sha256_clone( (mbedtls_sha256_context *) dst,
- (const mbedtls_sha256_context *) src );
-}
-
-static void sha224_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_sha256_process( (mbedtls_sha256_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_sha224_info = {
- MBEDTLS_MD_SHA224,
- "SHA224",
- 28,
- 64,
- sha224_starts_wrap,
- sha224_update_wrap,
- sha224_finish_wrap,
- sha224_wrap,
- sha224_ctx_alloc,
- sha224_ctx_free,
- sha224_clone_wrap,
- sha224_process_wrap,
-};
-
-static void sha256_starts_wrap( void *ctx )
-{
- mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 0 );
-}
-
-static void sha256_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- mbedtls_sha256( input, ilen, output, 0 );
-}
-
-const mbedtls_md_info_t mbedtls_sha256_info = {
- MBEDTLS_MD_SHA256,
- "SHA256",
- 32,
- 64,
- sha256_starts_wrap,
- sha224_update_wrap,
- sha224_finish_wrap,
- sha256_wrap,
- sha224_ctx_alloc,
- sha224_ctx_free,
- sha224_clone_wrap,
- sha224_process_wrap,
-};
-
-#endif /* MBEDTLS_SHA256_C */
-
-#if defined(MBEDTLS_SHA512_C)
-
-static void sha384_starts_wrap( void *ctx )
-{
- mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 1 );
-}
-
-static void sha384_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
-{
- mbedtls_sha512_update( (mbedtls_sha512_context *) ctx, input, ilen );
-}
-
-static void sha384_finish_wrap( void *ctx, unsigned char *output )
-{
- mbedtls_sha512_finish( (mbedtls_sha512_context *) ctx, output );
-}
-
-static void sha384_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- mbedtls_sha512( input, ilen, output, 1 );
-}
-
-static void *sha384_ctx_alloc( void )
-{
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_sha512_context ) );
-
- if( ctx != NULL )
- mbedtls_sha512_init( (mbedtls_sha512_context *) ctx );
-
- return( ctx );
-}
-
-static void sha384_ctx_free( void *ctx )
-{
- mbedtls_sha512_free( (mbedtls_sha512_context *) ctx );
- mbedtls_free( ctx );
-}
-
-static void sha384_clone_wrap( void *dst, const void *src )
-{
- mbedtls_sha512_clone( (mbedtls_sha512_context *) dst,
- (const mbedtls_sha512_context *) src );
-}
-
-static void sha384_process_wrap( void *ctx, const unsigned char *data )
-{
- mbedtls_sha512_process( (mbedtls_sha512_context *) ctx, data );
-}
-
-const mbedtls_md_info_t mbedtls_sha384_info = {
- MBEDTLS_MD_SHA384,
- "SHA384",
- 48,
- 128,
- sha384_starts_wrap,
- sha384_update_wrap,
- sha384_finish_wrap,
- sha384_wrap,
- sha384_ctx_alloc,
- sha384_ctx_free,
- sha384_clone_wrap,
- sha384_process_wrap,
-};
-
-static void sha512_starts_wrap( void *ctx )
-{
- mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 0 );
-}
-
-static void sha512_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
-{
- mbedtls_sha512( input, ilen, output, 0 );
-}
-
-const mbedtls_md_info_t mbedtls_sha512_info = {
- MBEDTLS_MD_SHA512,
- "SHA512",
- 64,
- 128,
- sha512_starts_wrap,
- sha384_update_wrap,
- sha384_finish_wrap,
- sha512_wrap,
- sha384_ctx_alloc,
- sha384_ctx_free,
- sha384_clone_wrap,
- sha384_process_wrap,
-};
-
-#endif /* MBEDTLS_SHA512_C */
-
-#endif /* MBEDTLS_MD_C */
diff --git a/backport/compat/verification/oid.c b/backport/compat/verification/oid.c
deleted file mode 100644
index 64753690..00000000
--- a/backport/compat/verification/oid.c
+++ /dev/null
@@ -1,709 +0,0 @@
-/**
- * \file oid.c
- *
- * \brief Object Identifier (OID) database
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_OID_C)
-
-#include "mbedtls/oid.h"
-#include "mbedtls/rsa.h"
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#define mbedtls_snprintf snprintf
-#endif
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
-#include "mbedtls/x509.h"
-#endif
-
-/*
- * Macro to automatically add the size of #define'd OIDs
- */
-#define ADD_LEN(s) s, MBEDTLS_OID_SIZE(s)
-
-/*
- * Macro to generate an internal function for oid_XXX_from_asn1() (used by
- * the other functions)
- */
-#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \
-static const TYPE_T * oid_ ## NAME ## _from_asn1( const mbedtls_asn1_buf *oid ) \
-{ \
- const TYPE_T *p = LIST; \
- const mbedtls_oid_descriptor_t *cur = (const mbedtls_oid_descriptor_t *) p; \
- if( p == NULL || oid == NULL ) return( NULL ); \
- while( cur->asn1 != NULL ) { \
- if( cur->asn1_len == oid->len && \
- memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \
- return( p ); \
- } \
- p++; \
- cur = (const mbedtls_oid_descriptor_t *) p; \
- } \
- return( NULL ); \
-}
-
-/*
- * Macro to generate a function for retrieving a single attribute from the
- * descriptor of an mbedtls_oid_descriptor_t wrapper.
- */
-#define FN_OID_GET_DESCRIPTOR_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
-int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
-{ \
- const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
- *ATTR1 = data->descriptor.ATTR1; \
- return( 0 ); \
-}
-
-/*
- * Macro to generate a function for retrieving a single attribute from an
- * mbedtls_oid_descriptor_t wrapper.
- */
-#define FN_OID_GET_ATTR1(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1) \
-int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) \
-{ \
- const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
- *ATTR1 = data->ATTR1; \
- return( 0 ); \
-}
-
-/*
- * Macro to generate a function for retrieving two attributes from an
- * mbedtls_oid_descriptor_t wrapper.
- */
-#define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \
- ATTR2_TYPE, ATTR2) \
-int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \
-{ \
- const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \
- if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \
- *ATTR1 = data->ATTR1; \
- *ATTR2 = data->ATTR2; \
- return( 0 ); \
-}
-
-/*
- * Macro to generate a function for retrieving the OID based on a single
- * attribute from a mbedtls_oid_descriptor_t wrapper.
- */
-#define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) \
-int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \
-{ \
- const TYPE_T *cur = LIST; \
- while( cur->descriptor.asn1 != NULL ) { \
- if( cur->ATTR1 == ATTR1 ) { \
- *oid = cur->descriptor.asn1; \
- *olen = cur->descriptor.asn1_len; \
- return( 0 ); \
- } \
- cur++; \
- } \
- return( MBEDTLS_ERR_OID_NOT_FOUND ); \
-}
-
-/*
- * Macro to generate a function for retrieving the OID based on two
- * attributes from a mbedtls_oid_descriptor_t wrapper.
- */
-#define FN_OID_GET_OID_BY_ATTR2(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1, \
- ATTR2_TYPE, ATTR2) \
-int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \
- size_t *olen ) \
-{ \
- const TYPE_T *cur = LIST; \
- while( cur->descriptor.asn1 != NULL ) { \
- if( cur->ATTR1 == ATTR1 && cur->ATTR2 == ATTR2 ) { \
- *oid = cur->descriptor.asn1; \
- *olen = cur->descriptor.asn1_len; \
- return( 0 ); \
- } \
- cur++; \
- } \
- return( MBEDTLS_ERR_OID_NOT_FOUND ); \
-}
-
-#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
-/*
- * For X520 attribute types
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- const char *short_name;
-} oid_x520_attr_t;
-
-static const oid_x520_attr_t oid_x520_attr_type[] =
-{
- {
- { ADD_LEN( MBEDTLS_OID_AT_CN ), "id-at-commonName", "Common Name" },
- "CN",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_COUNTRY ), "id-at-countryName", "Country" },
- "C",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_LOCALITY ), "id-at-locality", "Locality" },
- "L",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_STATE ), "id-at-state", "State" },
- "ST",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_ORGANIZATION ),"id-at-organizationName", "Organization" },
- "O",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_ORG_UNIT ), "id-at-organizationalUnitName", "Org Unit" },
- "OU",
- },
- {
- { ADD_LEN( MBEDTLS_OID_PKCS9_EMAIL ), "emailAddress", "E-mail address" },
- "emailAddress",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_SERIAL_NUMBER ),"id-at-serialNumber", "Serial number" },
- "serialNumber",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_POSTAL_ADDRESS ),"id-at-postalAddress", "Postal address" },
- "postalAddress",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_POSTAL_CODE ), "id-at-postalCode", "Postal code" },
- "postalCode",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_SUR_NAME ), "id-at-surName", "Surname" },
- "SN",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_GIVEN_NAME ), "id-at-givenName", "Given name" },
- "GN",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_INITIALS ), "id-at-initials", "Initials" },
- "initials",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_GENERATION_QUALIFIER ), "id-at-generationQualifier", "Generation qualifier" },
- "generationQualifier",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_TITLE ), "id-at-title", "Title" },
- "title",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_DN_QUALIFIER ),"id-at-dnQualifier", "Distinguished Name qualifier" },
- "dnQualifier",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_PSEUDONYM ), "id-at-pseudonym", "Pseudonym" },
- "pseudonym",
- },
- {
- { ADD_LEN( MBEDTLS_OID_DOMAIN_COMPONENT ), "id-domainComponent", "Domain component" },
- "DC",
- },
- {
- { ADD_LEN( MBEDTLS_OID_AT_UNIQUE_IDENTIFIER ), "id-at-uniqueIdentifier", "Unique Identifier" },
- "uniqueIdentifier",
- },
- {
- { NULL, 0, NULL, NULL },
- NULL,
- }
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type)
-FN_OID_GET_ATTR1(mbedtls_oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char *, short_name)
-
-/*
- * For X509 extensions
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- int ext_type;
-} oid_x509_ext_t;
-
-static const oid_x509_ext_t oid_x509_ext[] =
-{
- {
- { ADD_LEN( MBEDTLS_OID_BASIC_CONSTRAINTS ), "id-ce-basicConstraints", "Basic Constraints" },
- MBEDTLS_X509_EXT_BASIC_CONSTRAINTS,
- },
- {
- { ADD_LEN( MBEDTLS_OID_KEY_USAGE ), "id-ce-keyUsage", "Key Usage" },
- MBEDTLS_X509_EXT_KEY_USAGE,
- },
- {
- { ADD_LEN( MBEDTLS_OID_EXTENDED_KEY_USAGE ), "id-ce-extKeyUsage", "Extended Key Usage" },
- MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE,
- },
- {
- { ADD_LEN( MBEDTLS_OID_SUBJECT_ALT_NAME ), "id-ce-subjectAltName", "Subject Alt Name" },
- MBEDTLS_X509_EXT_SUBJECT_ALT_NAME,
- },
- {
- { ADD_LEN( MBEDTLS_OID_NS_CERT_TYPE ), "id-netscape-certtype", "Netscape Certificate Type" },
- MBEDTLS_X509_EXT_NS_CERT_TYPE,
- },
- {
- { NULL, 0, NULL, NULL },
- 0,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_x509_ext_t, x509_ext, oid_x509_ext)
-FN_OID_GET_ATTR1(mbedtls_oid_get_x509_ext_type, oid_x509_ext_t, x509_ext, int, ext_type)
-
-static const mbedtls_oid_descriptor_t oid_ext_key_usage[] =
-{
- { ADD_LEN( MBEDTLS_OID_SERVER_AUTH ), "id-kp-serverAuth", "TLS Web Server Authentication" },
- { ADD_LEN( MBEDTLS_OID_CLIENT_AUTH ), "id-kp-clientAuth", "TLS Web Client Authentication" },
- { ADD_LEN( MBEDTLS_OID_CODE_SIGNING ), "id-kp-codeSigning", "Code Signing" },
- { ADD_LEN( MBEDTLS_OID_EMAIL_PROTECTION ), "id-kp-emailProtection", "E-mail Protection" },
- { ADD_LEN( MBEDTLS_OID_TIME_STAMPING ), "id-kp-timeStamping", "Time Stamping" },
- { ADD_LEN( MBEDTLS_OID_OCSP_SIGNING ), "id-kp-OCSPSigning", "OCSP Signing" },
- { NULL, 0, NULL, NULL },
-};
-
-FN_OID_TYPED_FROM_ASN1(mbedtls_oid_descriptor_t, ext_key_usage, oid_ext_key_usage)
-FN_OID_GET_ATTR1(mbedtls_oid_get_extended_key_usage, mbedtls_oid_descriptor_t, ext_key_usage, const char *, description)
-#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
-
-#if defined(MBEDTLS_MD_C)
-/*
- * For SignatureAlgorithmIdentifier
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_md_type_t md_alg;
- mbedtls_pk_type_t pk_alg;
-} oid_sig_alg_t;
-
-static const oid_sig_alg_t oid_sig_alg[] =
-{
-#if defined(MBEDTLS_RSA_C)
-#if defined(MBEDTLS_MD2_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_MD2 ), "md2WithRSAEncryption", "RSA with MD2" },
- MBEDTLS_MD_MD2, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_MD2_C */
-#if defined(MBEDTLS_MD4_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_MD4 ), "md4WithRSAEncryption", "RSA with MD4" },
- MBEDTLS_MD_MD4, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_MD4_C */
-#if defined(MBEDTLS_MD5_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_MD5 ), "md5WithRSAEncryption", "RSA with MD5" },
- MBEDTLS_MD_MD5, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_MD5_C */
-#if defined(MBEDTLS_SHA1_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_SHA1 ), "sha-1WithRSAEncryption", "RSA with SHA1" },
- MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_SHA1_C */
-#if defined(MBEDTLS_SHA256_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_SHA224 ), "sha224WithRSAEncryption", "RSA with SHA-224" },
- MBEDTLS_MD_SHA224, MBEDTLS_PK_RSA,
- },
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_SHA256 ), "sha256WithRSAEncryption", "RSA with SHA-256" },
- MBEDTLS_MD_SHA256, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_SHA256_C */
-#if defined(MBEDTLS_SHA512_C)
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_SHA384 ), "sha384WithRSAEncryption", "RSA with SHA-384" },
- MBEDTLS_MD_SHA384, MBEDTLS_PK_RSA,
- },
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_SHA512 ), "sha512WithRSAEncryption", "RSA with SHA-512" },
- MBEDTLS_MD_SHA512, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_SHA512_C */
-#if defined(MBEDTLS_SHA1_C)
- {
- { ADD_LEN( MBEDTLS_OID_RSA_SHA_OBS ), "sha-1WithRSAEncryption", "RSA with SHA1" },
- MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
- },
-#endif /* MBEDTLS_SHA1_C */
-#endif /* MBEDTLS_RSA_C */
-#if defined(MBEDTLS_ECDSA_C)
-#if defined(MBEDTLS_SHA1_C)
- {
- { ADD_LEN( MBEDTLS_OID_ECDSA_SHA1 ), "ecdsa-with-SHA1", "ECDSA with SHA1" },
- MBEDTLS_MD_SHA1, MBEDTLS_PK_ECDSA,
- },
-#endif /* MBEDTLS_SHA1_C */
-#if defined(MBEDTLS_SHA256_C)
- {
- { ADD_LEN( MBEDTLS_OID_ECDSA_SHA224 ), "ecdsa-with-SHA224", "ECDSA with SHA224" },
- MBEDTLS_MD_SHA224, MBEDTLS_PK_ECDSA,
- },
- {
- { ADD_LEN( MBEDTLS_OID_ECDSA_SHA256 ), "ecdsa-with-SHA256", "ECDSA with SHA256" },
- MBEDTLS_MD_SHA256, MBEDTLS_PK_ECDSA,
- },
-#endif /* MBEDTLS_SHA256_C */
-#if defined(MBEDTLS_SHA512_C)
- {
- { ADD_LEN( MBEDTLS_OID_ECDSA_SHA384 ), "ecdsa-with-SHA384", "ECDSA with SHA384" },
- MBEDTLS_MD_SHA384, MBEDTLS_PK_ECDSA,
- },
- {
- { ADD_LEN( MBEDTLS_OID_ECDSA_SHA512 ), "ecdsa-with-SHA512", "ECDSA with SHA512" },
- MBEDTLS_MD_SHA512, MBEDTLS_PK_ECDSA,
- },
-#endif /* MBEDTLS_SHA512_C */
-#endif /* MBEDTLS_ECDSA_C */
-#if defined(MBEDTLS_RSA_C)
- {
- { ADD_LEN( MBEDTLS_OID_RSASSA_PSS ), "RSASSA-PSS", "RSASSA-PSS" },
- MBEDTLS_MD_NONE, MBEDTLS_PK_RSASSA_PSS,
- },
-#endif /* MBEDTLS_RSA_C */
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_MD_NONE, MBEDTLS_PK_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_sig_alg_t, sig_alg, oid_sig_alg)
-FN_OID_GET_DESCRIPTOR_ATTR1(mbedtls_oid_get_sig_alg_desc, oid_sig_alg_t, sig_alg, const char *, description)
-FN_OID_GET_ATTR2(mbedtls_oid_get_sig_alg, oid_sig_alg_t, sig_alg, mbedtls_md_type_t, md_alg, mbedtls_pk_type_t, pk_alg)
-FN_OID_GET_OID_BY_ATTR2(mbedtls_oid_get_oid_by_sig_alg, oid_sig_alg_t, oid_sig_alg, mbedtls_pk_type_t, pk_alg, mbedtls_md_type_t, md_alg)
-#endif /* MBEDTLS_MD_C */
-
-/*
- * For PublicKeyInfo (PKCS1, RFC 5480)
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_pk_type_t pk_alg;
-} oid_pk_alg_t;
-
-static const oid_pk_alg_t oid_pk_alg[] =
-{
- {
- { ADD_LEN( MBEDTLS_OID_PKCS1_RSA ), "rsaEncryption", "RSA" },
- MBEDTLS_PK_RSA,
- },
- {
- { ADD_LEN( MBEDTLS_OID_EC_ALG_UNRESTRICTED ), "id-ecPublicKey", "Generic EC key" },
- MBEDTLS_PK_ECKEY,
- },
- {
- { ADD_LEN( MBEDTLS_OID_EC_ALG_ECDH ), "id-ecDH", "EC key for ECDH" },
- MBEDTLS_PK_ECKEY_DH,
- },
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_PK_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_pk_alg_t, pk_alg, oid_pk_alg)
-FN_OID_GET_ATTR1(mbedtls_oid_get_pk_alg, oid_pk_alg_t, pk_alg, mbedtls_pk_type_t, pk_alg)
-FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_pk_alg, oid_pk_alg_t, oid_pk_alg, mbedtls_pk_type_t, pk_alg)
-
-#if defined(MBEDTLS_ECP_C)
-/*
- * For namedCurve (RFC 5480)
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_ecp_group_id grp_id;
-} oid_ecp_grp_t;
-
-static const oid_ecp_grp_t oid_ecp_grp[] =
-{
-#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192R1 ), "secp192r1", "secp192r1" },
- MBEDTLS_ECP_DP_SECP192R1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224R1 ), "secp224r1", "secp224r1" },
- MBEDTLS_ECP_DP_SECP224R1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256R1 ), "secp256r1", "secp256r1" },
- MBEDTLS_ECP_DP_SECP256R1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP384R1 ), "secp384r1", "secp384r1" },
- MBEDTLS_ECP_DP_SECP384R1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" },
- MBEDTLS_ECP_DP_SECP521R1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192K1 ), "secp192k1", "secp192k1" },
- MBEDTLS_ECP_DP_SECP192K1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224K1 ), "secp224k1", "secp224k1" },
- MBEDTLS_ECP_DP_SECP224K1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256K1 ), "secp256k1", "secp256k1" },
- MBEDTLS_ECP_DP_SECP256K1,
- },
-#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" },
- MBEDTLS_ECP_DP_BP256R1,
- },
-#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" },
- MBEDTLS_ECP_DP_BP384R1,
- },
-#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
-#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
- {
- { ADD_LEN( MBEDTLS_OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" },
- MBEDTLS_ECP_DP_BP512R1,
- },
-#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_ECP_DP_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_ecp_grp_t, grp_id, oid_ecp_grp)
-FN_OID_GET_ATTR1(mbedtls_oid_get_ec_grp, oid_ecp_grp_t, grp_id, mbedtls_ecp_group_id, grp_id)
-FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_ec_grp, oid_ecp_grp_t, oid_ecp_grp, mbedtls_ecp_group_id, grp_id)
-#endif /* MBEDTLS_ECP_C */
-
-#if defined(MBEDTLS_CIPHER_C)
-/*
- * For PKCS#5 PBES2 encryption algorithm
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_cipher_type_t cipher_alg;
-} oid_cipher_alg_t;
-
-static const oid_cipher_alg_t oid_cipher_alg[] =
-{
- {
- { ADD_LEN( MBEDTLS_OID_DES_CBC ), "desCBC", "DES-CBC" },
- MBEDTLS_CIPHER_DES_CBC,
- },
- {
- { ADD_LEN( MBEDTLS_OID_DES_EDE3_CBC ), "des-ede3-cbc", "DES-EDE3-CBC" },
- MBEDTLS_CIPHER_DES_EDE3_CBC,
- },
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_CIPHER_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_cipher_alg_t, cipher_alg, oid_cipher_alg)
-FN_OID_GET_ATTR1(mbedtls_oid_get_cipher_alg, oid_cipher_alg_t, cipher_alg, mbedtls_cipher_type_t, cipher_alg)
-#endif /* MBEDTLS_CIPHER_C */
-
-#if defined(MBEDTLS_MD_C)
-/*
- * For digestAlgorithm
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_md_type_t md_alg;
-} oid_md_alg_t;
-
-static const oid_md_alg_t oid_md_alg[] =
-{
-#if defined(MBEDTLS_MD2_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD2 ), "id-md2", "MD2" },
- MBEDTLS_MD_MD2,
- },
-#endif /* MBEDTLS_MD2_C */
-#if defined(MBEDTLS_MD4_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD4 ), "id-md4", "MD4" },
- MBEDTLS_MD_MD4,
- },
-#endif /* MBEDTLS_MD4_C */
-#if defined(MBEDTLS_MD5_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD5 ), "id-md5", "MD5" },
- MBEDTLS_MD_MD5,
- },
-#endif /* MBEDTLS_MD5_C */
-#if defined(MBEDTLS_SHA1_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" },
- MBEDTLS_MD_SHA1,
- },
-#endif /* MBEDTLS_SHA1_C */
-#if defined(MBEDTLS_SHA256_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA224 ), "id-sha224", "SHA-224" },
- MBEDTLS_MD_SHA224,
- },
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA256 ), "id-sha256", "SHA-256" },
- MBEDTLS_MD_SHA256,
- },
-#endif /* MBEDTLS_SHA256_C */
-#if defined(MBEDTLS_SHA512_C)
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA384 ), "id-sha384", "SHA-384" },
- MBEDTLS_MD_SHA384,
- },
- {
- { ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA512 ), "id-sha512", "SHA-512" },
- MBEDTLS_MD_SHA512,
- },
-#endif /* MBEDTLS_SHA512_C */
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_MD_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg)
-FN_OID_GET_ATTR1(mbedtls_oid_get_md_alg, oid_md_alg_t, md_alg, mbedtls_md_type_t, md_alg)
-FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_md, oid_md_alg_t, oid_md_alg, mbedtls_md_type_t, md_alg)
-#endif /* MBEDTLS_MD_C */
-
-#if defined(MBEDTLS_PKCS12_C)
-/*
- * For PKCS#12 PBEs
- */
-typedef struct {
- mbedtls_oid_descriptor_t descriptor;
- mbedtls_md_type_t md_alg;
- mbedtls_cipher_type_t cipher_alg;
-} oid_pkcs12_pbe_alg_t;
-
-static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] =
-{
- {
- { ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES3_EDE_CBC ), "pbeWithSHAAnd3-KeyTripleDES-CBC", "PBE with SHA1 and 3-Key 3DES" },
- MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE3_CBC,
- },
- {
- { ADD_LEN( MBEDTLS_OID_PKCS12_PBE_SHA1_DES2_EDE_CBC ), "pbeWithSHAAnd2-KeyTripleDES-CBC", "PBE with SHA1 and 2-Key 3DES" },
- MBEDTLS_MD_SHA1, MBEDTLS_CIPHER_DES_EDE_CBC,
- },
- {
- { NULL, 0, NULL, NULL },
- MBEDTLS_MD_NONE, MBEDTLS_CIPHER_NONE,
- },
-};
-
-FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg)
-FN_OID_GET_ATTR2(mbedtls_oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, mbedtls_md_type_t, md_alg, mbedtls_cipher_type_t, cipher_alg)
-#endif /* MBEDTLS_PKCS12_C */
-
-#define OID_SAFE_SNPRINTF \
- do { \
- if( ret < 0 || (size_t) ret >= n ) \
- return( MBEDTLS_ERR_OID_BUF_TOO_SMALL ); \
- \
- n -= (size_t) ret; \
- p += (size_t) ret; \
- } while( 0 )
-
-/* Return the x.y.z.... style numeric string for the given OID */
-int mbedtls_oid_get_numeric_string( char *buf, size_t size,
- const mbedtls_asn1_buf *oid )
-{
- int ret;
- size_t i, n;
- unsigned int value;
- char *p;
-
- p = buf;
- n = size;
-
- /* First byte contains first two dots */
- if( oid->len > 0 )
- {
- ret = mbedtls_snprintf( p, n, "%d.%d", oid->p[0] / 40, oid->p[0] % 40 );
- OID_SAFE_SNPRINTF;
- }
-
- value = 0;
- for( i = 1; i < oid->len; i++ )
- {
- /* Prevent overflow in value. */
- if( ( ( value << 7 ) >> 7 ) != value )
- return( MBEDTLS_ERR_OID_BUF_TOO_SMALL );
-
- value <<= 7;
- value += oid->p[i] & 0x7F;
-
- if( !( oid->p[i] & 0x80 ) )
- {
- /* Last byte */
- ret = mbedtls_snprintf( p, n, ".%d", value );
- OID_SAFE_SNPRINTF;
- value = 0;
- }
- }
-
- return( (int) ( size - n ) );
-}
-
-#endif /* MBEDTLS_OID_C */
diff --git a/backport/compat/verification/pkcs7.asn1.c b/backport/compat/verification/pkcs7.asn1.c
deleted file mode 100644
index d8c91f5b..00000000
--- a/backport/compat/verification/pkcs7.asn1.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for pkcs7
- */
-#include <linux/asn1_ber_bytecode.h>
-#include "pkcs7.asn1.h"
-
-enum pkcs7_actions {
- ACT_pkcs7_check_content_type = 0,
- ACT_pkcs7_extract_cert = 1,
- ACT_pkcs7_note_OID = 2,
- ACT_pkcs7_note_certificate_list = 3,
- ACT_pkcs7_note_content = 4,
- ACT_pkcs7_note_data = 5,
- ACT_pkcs7_note_signed_info = 6,
- ACT_pkcs7_note_signeddata_version = 7,
- ACT_pkcs7_note_signerinfo_version = 8,
- ACT_pkcs7_sig_note_authenticated_attr = 9,
- ACT_pkcs7_sig_note_digest_algo = 10,
- ACT_pkcs7_sig_note_issuer = 11,
- ACT_pkcs7_sig_note_pkey_algo = 12,
- ACT_pkcs7_sig_note_serial = 13,
- ACT_pkcs7_sig_note_set_of_authattrs = 14,
- ACT_pkcs7_sig_note_signature = 15,
- ACT_pkcs7_sig_note_skid = 16,
- NR__pkcs7_actions = 17
-};
-
-static const asn1_action_t pkcs7_action_table[NR__pkcs7_actions] = {
- [ 0] = pkcs7_check_content_type,
- [ 1] = pkcs7_extract_cert,
- [ 2] = pkcs7_note_OID,
- [ 3] = pkcs7_note_certificate_list,
- [ 4] = pkcs7_note_content,
- [ 5] = pkcs7_note_data,
- [ 6] = pkcs7_note_signed_info,
- [ 7] = pkcs7_note_signeddata_version,
- [ 8] = pkcs7_note_signerinfo_version,
- [ 9] = pkcs7_sig_note_authenticated_attr,
- [ 10] = pkcs7_sig_note_digest_algo,
- [ 11] = pkcs7_sig_note_issuer,
- [ 12] = pkcs7_sig_note_pkey_algo,
- [ 13] = pkcs7_sig_note_serial,
- [ 14] = pkcs7_sig_note_set_of_authattrs,
- [ 15] = pkcs7_sig_note_signature,
- [ 16] = pkcs7_sig_note_skid,
-};
-
-static const unsigned char pkcs7_machine[] = {
- // PKCS7ContentInfo
- [ 0] = ASN1_OP_MATCH,
- [ 1] = _tag(UNIV, CONS, SEQ),
- // ContentType
- [ 2] = ASN1_OP_MATCH_ACT,
- [ 3] = _tag(UNIV, PRIM, OID),
- [ 4] = _action(ACT_pkcs7_note_OID),
- [ 5] = ASN1_OP_ACT,
- [ 6] = _action(ACT_pkcs7_check_content_type),
- [ 7] = ASN1_OP_MATCH_JUMP_OR_SKIP, // content
- [ 8] = _tagn(CONT, CONS, 0),
- [ 9] = _jump_target(12),
- [ 10] = ASN1_OP_END_SEQ,
- [ 11] = ASN1_OP_COMPLETE,
-
- // SignedData
- [ 12] = ASN1_OP_MATCH,
- [ 13] = _tag(UNIV, CONS, SEQ),
- [ 14] = ASN1_OP_MATCH_ACT, // version
- [ 15] = _tag(UNIV, PRIM, INT),
- [ 16] = _action(ACT_pkcs7_note_signeddata_version),
- // DigestAlgorithmIdentifiers
- [ 17] = ASN1_OP_MATCH_JUMP_OR_SKIP, // daSet
- [ 18] = _tag(UNIV, CONS, SET),
- [ 19] = _jump_target(61),
- [ 20] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // daSequence
- [ 21] = _tag(UNIV, CONS, SEQ),
- [ 22] = _jump_target(67),
- [ 23] = ASN1_OP_COND_FAIL,
- // ContentInfo
- [ 24] = ASN1_OP_MATCH,
- [ 25] = _tag(UNIV, CONS, SEQ),
- // ContentType
- [ 26] = ASN1_OP_MATCH_ACT,
- [ 27] = _tag(UNIV, PRIM, OID),
- [ 28] = _action(ACT_pkcs7_note_OID),
- [ 29] = ASN1_OP_ACT,
- [ 30] = _action(ACT_pkcs7_note_OID),
- [ 31] = ASN1_OP_MATCH_JUMP_OR_SKIP, // content
- [ 32] = _tagn(CONT, CONS, 0),
- [ 33] = _jump_target(73),
- [ 34] = ASN1_OP_END_SEQ,
- [ 35] = ASN1_OP_ACT,
- [ 36] = _action(ACT_pkcs7_note_content),
- // ExtendedCertificatesAndCertificates
- [ 37] = ASN1_OP_MATCH_JUMP_OR_SKIP, // certSet
- [ 38] = _tagn(CONT, CONS, 0),
- [ 39] = _jump_target(77), // --> ExtendedCertificatesAndCertificates
- // Certificates
- [ 40] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // certSequence
- [ 41] = _tagn(CONT, CONS, 2),
- [ 42] = _jump_target(85), // --> Certificates
- [ 43] = ASN1_OP_ACT,
- [ 44] = _action(ACT_pkcs7_note_certificate_list),
- // CertificateRevocationLists
- [ 45] = ASN1_OP_MATCH_JUMP_OR_SKIP, // crlSet
- [ 46] = _tagn(CONT, CONS, 1),
- [ 47] = _jump_target(90), // --> CertificateRevocationLists
- // CRLSequence
- [ 48] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // crlSequence
- [ 49] = _tagn(CONT, CONS, 3),
- [ 50] = _jump_target(96), // --> CRLSequence
- // SignerInfos
- [ 51] = ASN1_OP_MATCH_JUMP_OR_SKIP, // siSet
- [ 52] = _tag(UNIV, CONS, SET),
- [ 53] = _jump_target(102),
- [ 54] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // siSequence
- [ 55] = _tag(UNIV, CONS, SEQ),
- [ 56] = _jump_target(108),
- [ 57] = ASN1_OP_COND_FAIL,
- [ 58] = ASN1_OP_END_SEQ,
- [ 59] = ASN1_OP_END_SEQ,
- [ 60] = ASN1_OP_RETURN,
-
- // DigestAlgorithmIdentifier
- [ 61] = ASN1_OP_MATCH_JUMP,
- [ 62] = _tag(UNIV, CONS, SEQ),
- [ 63] = _jump_target(114), // --> DigestAlgorithmIdentifier
- [ 64] = ASN1_OP_END_SET_OF,
- [ 65] = _jump_target(61),
- [ 66] = ASN1_OP_RETURN,
-
- // DigestAlgorithmIdentifier
- [ 67] = ASN1_OP_MATCH_JUMP,
- [ 68] = _tag(UNIV, CONS, SEQ),
- [ 69] = _jump_target(114), // --> DigestAlgorithmIdentifier
- [ 70] = ASN1_OP_END_SEQ_OF,
- [ 71] = _jump_target(67),
- [ 72] = ASN1_OP_RETURN,
-
- // Data
- [ 73] = ASN1_OP_MATCH_ANY_ACT,
- [ 74] = _action(ACT_pkcs7_note_data),
- [ 75] = ASN1_OP_END_SEQ,
- [ 76] = ASN1_OP_RETURN,
-
- // ExtendedCertificateOrCertificate
- // Certificate
- [ 77] = ASN1_OP_MATCH_ANY_ACT_OR_SKIP,
- [ 78] = _action(ACT_pkcs7_extract_cert),
- // ExtendedCertificate
- // Certificate
- [ 79] = ASN1_OP_COND_MATCH_ANY_ACT_OR_SKIP,
- [ 80] = _action(ACT_pkcs7_extract_cert),
- [ 81] = ASN1_OP_COND_FAIL,
- [ 82] = ASN1_OP_END_SET_OF,
- [ 83] = _jump_target(77),
- [ 84] = ASN1_OP_RETURN,
-
- // Certificate
- [ 85] = ASN1_OP_MATCH_ANY_ACT,
- [ 86] = _action(ACT_pkcs7_extract_cert),
- [ 87] = ASN1_OP_END_SEQ_OF,
- [ 88] = _jump_target(85),
- [ 89] = ASN1_OP_RETURN,
-
- // CertificateList
- [ 90] = ASN1_OP_MATCH_JUMP,
- [ 91] = _tag(UNIV, CONS, SEQ),
- [ 92] = _jump_target(120), // --> CertificateList
- [ 93] = ASN1_OP_END_SET_OF,
- [ 94] = _jump_target(90),
- [ 95] = ASN1_OP_RETURN,
-
- // CertificateList
- [ 96] = ASN1_OP_MATCH_JUMP,
- [ 97] = _tag(UNIV, CONS, SEQ),
- [ 98] = _jump_target(120), // --> CertificateList
- [ 99] = ASN1_OP_END_SEQ_OF,
- [ 100] = _jump_target(96),
- [ 101] = ASN1_OP_RETURN,
-
- // SignerInfo
- [ 102] = ASN1_OP_MATCH_JUMP,
- [ 103] = _tag(UNIV, CONS, SEQ),
- [ 104] = _jump_target(125), // --> SignerInfo
- [ 105] = ASN1_OP_END_SET_OF,
- [ 106] = _jump_target(102),
- [ 107] = ASN1_OP_RETURN,
-
- // SignerInfo
- [ 108] = ASN1_OP_MATCH_JUMP,
- [ 109] = _tag(UNIV, CONS, SEQ),
- [ 110] = _jump_target(125), // --> SignerInfo
- [ 111] = ASN1_OP_END_SEQ_OF,
- [ 112] = _jump_target(108),
- [ 113] = ASN1_OP_RETURN,
-
- [ 114] = ASN1_OP_MATCH_ACT, // algorithm
- [ 115] = _tag(UNIV, PRIM, OID),
- [ 116] = _action(ACT_pkcs7_note_OID),
- [ 117] = ASN1_OP_MATCH_ANY_OR_SKIP, // parameters
- [ 118] = ASN1_OP_END_SEQ,
- [ 119] = ASN1_OP_RETURN,
-
- // Certificate
- [ 120] = ASN1_OP_MATCH_ANY_ACT,
- [ 121] = _action(ACT_pkcs7_extract_cert),
- [ 122] = ASN1_OP_END_SEQ_OF,
- [ 123] = _jump_target(120),
- [ 124] = ASN1_OP_RETURN,
-
- [ 125] = ASN1_OP_MATCH_ACT, // version
- [ 126] = _tag(UNIV, PRIM, INT),
- [ 127] = _action(ACT_pkcs7_note_signerinfo_version),
- // SignerIdentifier
- // IssuerAndSerialNumber
- [ 128] = ASN1_OP_MATCH_JUMP_OR_SKIP, // issuerAndSerialNumber
- [ 129] = _tag(UNIV, CONS, SEQ),
- [ 130] = _jump_target(169), // --> IssuerAndSerialNumber
- // SubjectKeyIdentifier
- [ 131] = ASN1_OP_COND_MATCH_ACT_OR_SKIP, // subjectKeyIdentifier
- [ 132] = _tagn(CONT, PRIM, 0),
- [ 133] = _action(ACT_pkcs7_sig_note_skid),
- [ 134] = ASN1_OP_COND_FAIL,
- // DigestAlgorithmIdentifier
- [ 135] = ASN1_OP_MATCH_JUMP,
- [ 136] = _tag(UNIV, CONS, SEQ),
- [ 137] = _jump_target(114), // --> DigestAlgorithmIdentifier
- [ 138] = ASN1_OP_ACT,
- [ 139] = _action(ACT_pkcs7_sig_note_digest_algo),
- // SetOfAuthenticatedAttribute
- [ 140] = ASN1_OP_MATCH_JUMP_OR_SKIP, // aaSet
- [ 141] = _tagn(CONT, CONS, 0),
- [ 142] = _jump_target(192), // --> SetOfAuthenticatedAttribute
- [ 143] = ASN1_OP_MAYBE_ACT,
- [ 144] = _action(ACT_pkcs7_sig_note_set_of_authattrs),
- [ 145] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // aaSequence
- [ 146] = _tagn(CONT, CONS, 2),
- [ 147] = _jump_target(198),
- // DigestEncryptionAlgorithmIdentifier
- [ 148] = ASN1_OP_MATCH,
- [ 149] = _tag(UNIV, CONS, SEQ),
- [ 150] = ASN1_OP_MATCH_ACT, // algorithm
- [ 151] = _tag(UNIV, PRIM, OID),
- [ 152] = _action(ACT_pkcs7_note_OID),
- [ 153] = ASN1_OP_MATCH_ANY_OR_SKIP, // parameters
- [ 154] = ASN1_OP_END_SEQ,
- [ 155] = ASN1_OP_ACT,
- [ 156] = _action(ACT_pkcs7_sig_note_pkey_algo),
- // EncryptedDigest
- [ 157] = ASN1_OP_MATCH_ACT,
- [ 158] = _tag(UNIV, PRIM, OTS),
- [ 159] = _action(ACT_pkcs7_sig_note_signature),
- [ 160] = ASN1_OP_MATCH_JUMP_OR_SKIP, // uaSet
- [ 161] = _tagn(CONT, CONS, 1),
- [ 162] = _jump_target(207),
- [ 163] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // uaSequence
- [ 164] = _tagn(CONT, CONS, 3),
- [ 165] = _jump_target(213),
- [ 166] = ASN1_OP_END_SEQ_ACT,
- [ 167] = _action(ACT_pkcs7_note_signed_info),
- [ 168] = ASN1_OP_RETURN,
-
- // Name
- [ 169] = ASN1_OP_MATCH,
- [ 170] = _tag(UNIV, CONS, SEQ),
- // RelativeDistinguishedName
- [ 171] = ASN1_OP_MATCH,
- [ 172] = _tag(UNIV, CONS, SET),
- // AttributeValueAssertion
- [ 173] = ASN1_OP_MATCH,
- [ 174] = _tag(UNIV, CONS, SEQ),
- [ 175] = ASN1_OP_MATCH_ACT, // attributeType
- [ 176] = _tag(UNIV, PRIM, OID),
- [ 177] = _action(ACT_pkcs7_note_OID),
- [ 178] = ASN1_OP_MATCH_ANY, // attributeValue
- [ 179] = ASN1_OP_END_SEQ,
- [ 180] = ASN1_OP_END_SET_OF,
- [ 181] = _jump_target(173),
- [ 182] = ASN1_OP_END_SEQ_OF,
- [ 183] = _jump_target(171),
- [ 184] = ASN1_OP_ACT,
- [ 185] = _action(ACT_pkcs7_sig_note_issuer),
- // CertificateSerialNumber
- [ 186] = ASN1_OP_MATCH,
- [ 187] = _tag(UNIV, PRIM, INT),
- [ 188] = ASN1_OP_ACT,
- [ 189] = _action(ACT_pkcs7_sig_note_serial),
- [ 190] = ASN1_OP_END_SEQ,
- [ 191] = ASN1_OP_RETURN,
-
- // AuthenticatedAttribute
- [ 192] = ASN1_OP_MATCH_JUMP,
- [ 193] = _tag(UNIV, CONS, SEQ),
- [ 194] = _jump_target(219), // --> AuthenticatedAttribute
- [ 195] = ASN1_OP_END_SET_OF,
- [ 196] = _jump_target(192),
- [ 197] = ASN1_OP_RETURN,
-
- [ 198] = ASN1_OP_MATCH, // aaSequence
- [ 199] = _tag(UNIV, CONS, SEQ),
- // AuthenticatedAttribute
- [ 200] = ASN1_OP_MATCH_JUMP,
- [ 201] = _tag(UNIV, CONS, SEQ),
- [ 202] = _jump_target(219), // --> AuthenticatedAttribute
- [ 203] = ASN1_OP_END_SEQ_OF,
- [ 204] = _jump_target(200),
- [ 205] = ASN1_OP_END_SEQ,
- [ 206] = ASN1_OP_RETURN,
-
- // UnauthenticatedAttribute
- [ 207] = ASN1_OP_MATCH_JUMP,
- [ 208] = _tag(UNIV, CONS, SEQ),
- [ 209] = _jump_target(230), // --> UnauthenticatedAttribute
- [ 210] = ASN1_OP_END_SET_OF,
- [ 211] = _jump_target(207),
- [ 212] = ASN1_OP_RETURN,
-
- // UnauthenticatedAttribute
- [ 213] = ASN1_OP_MATCH_JUMP,
- [ 214] = _tag(UNIV, CONS, SEQ),
- [ 215] = _jump_target(230), // --> UnauthenticatedAttribute
- [ 216] = ASN1_OP_END_SEQ_OF,
- [ 217] = _jump_target(213),
- [ 218] = ASN1_OP_RETURN,
-
- [ 219] = ASN1_OP_MATCH_ACT, // type
- [ 220] = _tag(UNIV, PRIM, OID),
- [ 221] = _action(ACT_pkcs7_note_OID),
- [ 222] = ASN1_OP_MATCH, // values
- [ 223] = _tag(UNIV, CONS, SET),
- [ 224] = ASN1_OP_MATCH_ANY_ACT,
- [ 225] = _action(ACT_pkcs7_sig_note_authenticated_attr),
- [ 226] = ASN1_OP_END_SET_OF,
- [ 227] = _jump_target(224),
- [ 228] = ASN1_OP_END_SEQ,
- [ 229] = ASN1_OP_RETURN,
-
- [ 230] = ASN1_OP_MATCH, // type
- [ 231] = _tag(UNIV, PRIM, OID),
- [ 232] = ASN1_OP_MATCH, // values
- [ 233] = _tag(UNIV, CONS, SET),
- [ 234] = ASN1_OP_MATCH_ANY,
- [ 235] = ASN1_OP_END_SET_OF,
- [ 236] = _jump_target(234),
- [ 237] = ASN1_OP_END_SEQ,
- [ 238] = ASN1_OP_RETURN,
-};
-
-const struct asn1_decoder pkcs7_decoder = {
- .machine = pkcs7_machine,
- .machlen = sizeof(pkcs7_machine),
- .actions = pkcs7_action_table,
-};
diff --git a/backport/compat/verification/pkcs7.asn1.h b/backport/compat/verification/pkcs7.asn1.h
deleted file mode 100644
index b34e160f..00000000
--- a/backport/compat/verification/pkcs7.asn1.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for pkcs7
- */
-#include <linux/asn1_decoder.h>
-
-extern const struct asn1_decoder pkcs7_decoder;
-
-extern int pkcs7_check_content_type(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_extract_cert(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_OID(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_certificate_list(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_content(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_data(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_signed_info(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_signeddata_version(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_note_signerinfo_version(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_authenticated_attr(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_digest_algo(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_issuer(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_pkey_algo(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_serial(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_set_of_authattrs(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_signature(void *, size_t, unsigned char, const void *, size_t);
-extern int pkcs7_sig_note_skid(void *, size_t, unsigned char, const void *, size_t);
-
diff --git a/backport/compat/verification/public_key.c b/backport/compat/verification/public_key.c
deleted file mode 100644
index 83a69357..00000000
--- a/backport/compat/verification/public_key.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Adapted from the kernel for simplicity in backports.
- *
- * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licence
- * as published by the Free Software Foundation; either version
- * 2 of the Licence, or (at your option) any later version.
- */
-
-#define pr_fmt(fmt) "PKEY: "fmt
-#include <linux/export.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/seq_file.h>
-#include <linux/scatterlist.h>
-#include <linux/asn1_decoder.h>
-#include <crypto/public_key.h>
-#include "rsapubkey.asn1.h"
-#include "mbedtls/rsa.h"
-#include "mbedtls/md.h"
-
-void public_key_free(struct public_key *key)
-{
- if (key) {
- kfree(key->key);
- kfree(key);
- }
-}
-
-int rsa_get_n(void *context, size_t hdrlen, unsigned char tag,
- const void *value, size_t vlen)
-{
- mbedtls_rsa_context *rsa = context;
-
- /* invalid key provided */
- if (!value || !vlen)
- return -EINVAL;
-
- return mbedtls_mpi_read_binary(&rsa->N, value, vlen) ? -EINVAL : 0;
-}
-
-int rsa_get_e(void *context, size_t hdrlen, unsigned char tag,
- const void *value, size_t vlen)
-{
- mbedtls_rsa_context *rsa = context;
-
- /* invalid key provided */
- if (!value || !vlen)
- return -EINVAL;
-
- return mbedtls_mpi_read_binary(&rsa->E, value, vlen) ? -EINVAL : 0;
-}
-
-int public_key_verify_signature(const struct public_key *pkey,
- const struct public_key_signature *sig)
-{
- mbedtls_rsa_context rsa;
- mbedtls_md_type_t md_alg;
- const u8 *sigdata = sig->s;
- int s_size = sig->s_size;
- int ret;
-
- if (WARN_ON(!pkey))
- return -EINVAL;
-
- if (strcmp(sig->pkey_algo, "rsa"))
- return -ENOTSUPP;
-
- if (strcmp(sig->hash_algo, "sha1") == 0)
- md_alg = MBEDTLS_MD_SHA1;
- else if (strcmp(sig->hash_algo, "sha256") == 0)
- md_alg = MBEDTLS_MD_SHA256;
- else
- return -ENOTSUPP;
-
- mbedtls_rsa_init(&rsa, MBEDTLS_RSA_PKCS_V15, 0);
-
- ret = asn1_ber_decoder(&rsapubkey_decoder, &rsa,
- pkey->key, pkey->keylen);
- if (ret)
- goto free;
-
- rsa.len = (mbedtls_mpi_bitlen(&rsa.N) + 7) >> 3;
-
- /*
- * In some cases (from X.509 certificates) we get here with a
- * BIT_STRING ASN.1 object, in which the first byte indicates
- * the number of unused bits in the bit string (in case the
- * string isn't a multiple of 8 long).
- * Assume here that it's always a multiple of 8, and just skip
- * the additional byte.
- */
- if (s_size == rsa.len + 1 && sigdata[0] == 0) {
- sigdata = sig->s + 1;
- s_size -= 1;
- }
-
- if (rsa.len != s_size) {
- ret = -EINVAL;
- goto free;
- }
-
- ret = mbedtls_rsa_pkcs1_verify(&rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC,
- md_alg, 0, sig->digest, sigdata);
-
- if (ret)
- ret = -EKEYREJECTED;
- else
- ret = 0;
-
- free:
- mbedtls_rsa_free(&rsa);
-
- return ret;
-}
-
-void public_key_signature_free(struct public_key_signature *sig)
-{
- int i;
-
- if (sig) {
- for (i = 0; i < ARRAY_SIZE(sig->auth_ids); i++)
- kfree(sig->auth_ids[i]);
- kfree(sig->s);
- kfree(sig->digest);
- kfree(sig);
- }
-}
diff --git a/backport/compat/verification/rsa.c b/backport/compat/verification/rsa.c
deleted file mode 100644
index 605bd885..00000000
--- a/backport/compat/verification/rsa.c
+++ /dev/null
@@ -1,1872 +0,0 @@
-/*
- * The RSA public-key cryptosystem
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-/*
- * The following sources were referenced in the design of this implementation
- * of the RSA algorithm:
- *
- * [1] A method for obtaining digital signatures and public-key cryptosystems
- * R Rivest, A Shamir, and L Adleman
- * http://people.csail.mit.edu/rivest/pubs.html#RSA78
- *
- * [2] Handbook of Applied Cryptography - 1997, Chapter 8
- * Menezes, van Oorschot and Vanstone
- *
- * [3] Malware Guard Extension: Using SGX to Conceal Cache Attacks
- * Michael Schwarz, Samuel Weiser, Daniel Gruss, Clémentine Maurice and
- * Stefan Mangard
- * https://arxiv.org/abs/1702.08719v2
- *
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_RSA_C)
-
-#include "mbedtls/rsa.h"
-#include "mbedtls/oid.h"
-
-#if defined(MBEDTLS_PKCS1_V21)
-#include "mbedtls/md.h"
-#endif
-
-#if defined(MBEDTLS_PKCS1_V15) && !defined(__OpenBSD__)
-#include <stdlib.h>
-#endif
-
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdio.h>
-#define mbedtls_printf printf
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif
-
-/* Implementation that should never be optimized out by the compiler */
-static void mbedtls_zeroize( void *v, size_t n ) {
- volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
-}
-
-/*
- * Initialize an RSA context
- */
-void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
- int padding,
- int hash_id )
-{
- memset( ctx, 0, sizeof( mbedtls_rsa_context ) );
-
- mbedtls_rsa_set_padding( ctx, padding, hash_id );
-
-#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_init( &ctx->mutex );
-#endif
-}
-
-/*
- * Set padding for an existing RSA context
- */
-void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id )
-{
- ctx->padding = padding;
- ctx->hash_id = hash_id;
-}
-
-#if defined(MBEDTLS_GENPRIME)
-
-/*
- * Generate an RSA keypair
- */
-int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- unsigned int nbits, int exponent )
-{
- int ret;
- mbedtls_mpi P1, Q1, H, G;
-
- if( f_rng == NULL || nbits < 128 || exponent < 3 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- if( nbits % 2 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 );
- mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
-
- /*
- * find primes P and Q with Q < P so that:
- * GCD( E, (P-1)*(Q-1) ) == 1
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->E, exponent ) );
-
- do
- {
- MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, 0,
- f_rng, p_rng ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, 0,
- f_rng, p_rng ) );
-
- if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
- continue;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) );
- if( mbedtls_mpi_bitlen( &ctx->N ) != nbits )
- continue;
-
- if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
- mbedtls_mpi_swap( &ctx->P, &ctx->Q );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) );
- }
- while( mbedtls_mpi_cmp_int( &G, 1 ) != 0 );
-
- /*
- * D = E^-1 mod ((P-1)*(Q-1))
- * DP = D mod (P - 1)
- * DQ = D mod (Q - 1)
- * QP = Q^-1 mod P
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D , &ctx->E, &H ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) );
-
- ctx->len = ( mbedtls_mpi_bitlen( &ctx->N ) + 7 ) >> 3;
-
-cleanup:
-
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
-
- if( ret != 0 )
- {
- mbedtls_rsa_free( ctx );
- return( MBEDTLS_ERR_RSA_KEY_GEN_FAILED + ret );
- }
-
- return( 0 );
-}
-
-#endif /* MBEDTLS_GENPRIME */
-
-/*
- * Check a public RSA key
- */
-int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx )
-{
- if( !ctx->N.p || !ctx->E.p )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- if( ( ctx->N.p[0] & 1 ) == 0 ||
- ( ctx->E.p[0] & 1 ) == 0 )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- if( mbedtls_mpi_bitlen( &ctx->N ) < 128 ||
- mbedtls_mpi_bitlen( &ctx->N ) > MBEDTLS_MPI_MAX_BITS )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- if( mbedtls_mpi_bitlen( &ctx->E ) < 2 ||
- mbedtls_mpi_cmp_mpi( &ctx->E, &ctx->N ) >= 0 )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- return( 0 );
-}
-
-/*
- * Check a private RSA key
- */
-int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx )
-{
- int ret;
- mbedtls_mpi PQ, DE, P1, Q1, H, I, G, G2, L1, L2, DP, DQ, QP;
-
- if( ( ret = mbedtls_rsa_check_pubkey( ctx ) ) != 0 )
- return( ret );
-
- if( !ctx->P.p || !ctx->Q.p || !ctx->D.p )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- mbedtls_mpi_init( &PQ ); mbedtls_mpi_init( &DE ); mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 );
- mbedtls_mpi_init( &H ); mbedtls_mpi_init( &I ); mbedtls_mpi_init( &G ); mbedtls_mpi_init( &G2 );
- mbedtls_mpi_init( &L1 ); mbedtls_mpi_init( &L2 ); mbedtls_mpi_init( &DP ); mbedtls_mpi_init( &DQ );
- mbedtls_mpi_init( &QP );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G2, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &L1, &L2, &H, &G2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &I, &DE, &L1 ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DP, &ctx->D, &P1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DQ, &ctx->D, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &QP, &ctx->Q, &ctx->P ) );
- /*
- * Check for a valid PKCS1v2 private key
- */
- if( mbedtls_mpi_cmp_mpi( &PQ, &ctx->N ) != 0 ||
- mbedtls_mpi_cmp_mpi( &DP, &ctx->DP ) != 0 ||
- mbedtls_mpi_cmp_mpi( &DQ, &ctx->DQ ) != 0 ||
- mbedtls_mpi_cmp_mpi( &QP, &ctx->QP ) != 0 ||
- mbedtls_mpi_cmp_int( &L2, 0 ) != 0 ||
- mbedtls_mpi_cmp_int( &I, 1 ) != 0 ||
- mbedtls_mpi_cmp_int( &G, 1 ) != 0 )
- {
- ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
- }
-
-cleanup:
- mbedtls_mpi_free( &PQ ); mbedtls_mpi_free( &DE ); mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 );
- mbedtls_mpi_free( &H ); mbedtls_mpi_free( &I ); mbedtls_mpi_free( &G ); mbedtls_mpi_free( &G2 );
- mbedtls_mpi_free( &L1 ); mbedtls_mpi_free( &L2 ); mbedtls_mpi_free( &DP ); mbedtls_mpi_free( &DQ );
- mbedtls_mpi_free( &QP );
-
- if( ret == MBEDTLS_ERR_RSA_KEY_CHECK_FAILED )
- return( ret );
-
- if( ret != 0 )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED + ret );
-
- return( 0 );
-}
-
-/*
- * Check if contexts holding a public and private key match
- */
-int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv )
-{
- if( mbedtls_rsa_check_pubkey( pub ) != 0 ||
- mbedtls_rsa_check_privkey( prv ) != 0 )
- {
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
- }
-
- if( mbedtls_mpi_cmp_mpi( &pub->N, &prv->N ) != 0 ||
- mbedtls_mpi_cmp_mpi( &pub->E, &prv->E ) != 0 )
- {
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
- }
-
- return( 0 );
-}
-
-/*
- * Do an RSA public key operation
- */
-int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
- const unsigned char *input,
- unsigned char *output )
-{
- int ret;
- size_t olen;
- mbedtls_mpi T;
-
- mbedtls_mpi_init( &T );
-
-#if defined(MBEDTLS_THREADING_C)
- if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
- return( ret );
-#endif
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) );
-
- if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
- {
- ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
- goto cleanup;
- }
-
- olen = ctx->len;
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, &ctx->E, &ctx->N, &ctx->RN ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &T, output, olen ) );
-
-cleanup:
-#if defined(MBEDTLS_THREADING_C)
- if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
- return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
-#endif
-
- mbedtls_mpi_free( &T );
-
- if( ret != 0 )
- return( MBEDTLS_ERR_RSA_PUBLIC_FAILED + ret );
-
- return( 0 );
-}
-
-/*
- * Generate or update blinding values, see section 10 of:
- * KOCHER, Paul C. Timing attacks on implementations of Diffie-Hellman, RSA,
- * DSS, and other systems. In : Advances in Cryptology-CRYPTO'96. Springer
- * Berlin Heidelberg, 1996. p. 104-113.
- */
-static int rsa_prepare_blinding( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
-{
- int ret, count = 0;
-
- if( ctx->Vf.p != NULL )
- {
- /* We already have blinding values, just update them by squaring */
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->N ) );
-
- goto cleanup;
- }
-
- /* Unblinding value: Vf = random number, invertible mod N */
- do {
- if( count++ > 10 )
- return( MBEDTLS_ERR_RSA_RNG_FAILED );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->Vf, ctx->len - 1, f_rng, p_rng ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &ctx->Vi, &ctx->Vf, &ctx->N ) );
- } while( mbedtls_mpi_cmp_int( &ctx->Vi, 1 ) != 0 );
-
- /* Blinding value: Vi = Vf^(-e) mod N */
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->Vi, &ctx->Vf, &ctx->N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &ctx->Vi, &ctx->Vi, &ctx->E, &ctx->N, &ctx->RN ) );
-
-
-cleanup:
- return( ret );
-}
-
-/*
- * Exponent blinding supposed to prevent side-channel attacks using multiple
- * traces of measurements to recover the RSA key. The more collisions are there,
- * the more bits of the key can be recovered. See [3].
- *
- * Collecting n collisions with m bit long blinding value requires 2^(m-m/n)
- * observations on avarage.
- *
- * For example with 28 byte blinding to achieve 2 collisions the adversary has
- * to make 2^112 observations on avarage.
- *
- * (With the currently (as of 2017 April) known best algorithms breaking 2048
- * bit RSA requires approximately as much time as trying out 2^112 random keys.
- * Thus in this sense with 28 byte blinding the security is not reduced by
- * side-channel attacks like the one in [3])
- *
- * This countermeasure does not help if the key recovery is possible with a
- * single trace.
- */
-#define RSA_EXPONENT_BLINDING 28
-
-/*
- * Do an RSA private key operation
- */
-int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- const unsigned char *input,
- unsigned char *output )
-{
- int ret;
- size_t olen;
- mbedtls_mpi T, T1, T2;
- mbedtls_mpi P1, Q1, R;
-#if defined(MBEDTLS_RSA_NO_CRT)
- mbedtls_mpi D_blind;
- mbedtls_mpi *D = &ctx->D;
-#else
- mbedtls_mpi DP_blind, DQ_blind;
- mbedtls_mpi *DP = &ctx->DP;
- mbedtls_mpi *DQ = &ctx->DQ;
-#endif
-
- /* Make sure we have private key info, prevent possible misuse */
- if( ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- mbedtls_mpi_init( &T ); mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 );
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &R );
-
-
- if( f_rng != NULL )
- {
-#if defined(MBEDTLS_RSA_NO_CRT)
- mbedtls_mpi_init( &D_blind );
-#else
- mbedtls_mpi_init( &DP_blind );
- mbedtls_mpi_init( &DQ_blind );
-#endif
- }
-
-
-#if defined(MBEDTLS_THREADING_C)
- if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
- return( ret );
-#endif
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) );
- if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
- {
- ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
- goto cleanup;
- }
-
- if( f_rng != NULL )
- {
- /*
- * Blinding
- * T = T * Vi mod N
- */
- MBEDTLS_MPI_CHK( rsa_prepare_blinding( ctx, f_rng, p_rng ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &T, &ctx->Vi ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) );
-
- /*
- * Exponent blinding
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
-
-#if defined(MBEDTLS_RSA_NO_CRT)
- /*
- * D_blind = ( P - 1 ) * ( Q - 1 ) * R + D
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
- f_rng, p_rng ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &D_blind, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &D_blind, &D_blind, &R ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &D_blind, &D_blind, &ctx->D ) );
-
- D = &D_blind;
-#else
- /*
- * DP_blind = ( P - 1 ) * R + DP
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
- f_rng, p_rng ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DP_blind, &P1, &R ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &DP_blind, &DP_blind,
- &ctx->DP ) );
-
- DP = &DP_blind;
-
- /*
- * DQ_blind = ( Q - 1 ) * R + DQ
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
- f_rng, p_rng ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DQ_blind, &Q1, &R ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &DQ_blind, &DQ_blind,
- &ctx->DQ ) );
-
- DQ = &DQ_blind;
-#endif /* MBEDTLS_RSA_NO_CRT */
- }
-
-#if defined(MBEDTLS_RSA_NO_CRT)
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, D, &ctx->N, &ctx->RN ) );
-#else
- /*
- * Faster decryption using the CRT
- *
- * T1 = input ^ dP mod P
- * T2 = input ^ dQ mod Q
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T1, &T, DP, &ctx->P, &ctx->RP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T2, &T, DQ, &ctx->Q, &ctx->RQ ) );
-
- /*
- * T = (T1 - T2) * (Q^-1 mod P) mod P
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &T1, &T2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->QP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T1, &ctx->P ) );
-
- /*
- * T = T2 + T * Q
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &T2, &T1 ) );
-#endif /* MBEDTLS_RSA_NO_CRT */
-
- if( f_rng != NULL )
- {
- /*
- * Unblind
- * T = T * Vf mod N
- */
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &T, &ctx->Vf ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) );
- }
-
- olen = ctx->len;
- MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &T, output, olen ) );
-
-cleanup:
-#if defined(MBEDTLS_THREADING_C)
- if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
- return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
-#endif
-
- mbedtls_mpi_free( &T ); mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 );
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &R );
-
- if( f_rng != NULL )
- {
-#if defined(MBEDTLS_RSA_NO_CRT)
- mbedtls_mpi_free( &D_blind );
-#else
- mbedtls_mpi_free( &DP_blind );
- mbedtls_mpi_free( &DQ_blind );
-#endif
- }
-
- if( ret != 0 )
- return( MBEDTLS_ERR_RSA_PRIVATE_FAILED + ret );
-
- return( 0 );
-}
-
-#if defined(MBEDTLS_PKCS1_V21)
-/**
- * Generate and apply the MGF1 operation (from PKCS#1 v2.1) to a buffer.
- *
- * \param dst buffer to mask
- * \param dlen length of destination buffer
- * \param src source of the mask generation
- * \param slen length of the source buffer
- * \param md_ctx message digest context to use
- */
-static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src,
- size_t slen, mbedtls_md_context_t *md_ctx )
-{
- unsigned char mask[MBEDTLS_MD_MAX_SIZE];
- unsigned char counter[4];
- unsigned char *p;
- unsigned int hlen;
- size_t i, use_len;
-
- memset( mask, 0, MBEDTLS_MD_MAX_SIZE );
- memset( counter, 0, 4 );
-
- hlen = mbedtls_md_get_size( md_ctx->md_info );
-
- /* Generate and apply dbMask */
- p = dst;
-
- while( dlen > 0 )
- {
- use_len = hlen;
- if( dlen < hlen )
- use_len = dlen;
-
- mbedtls_md_starts( md_ctx );
- mbedtls_md_update( md_ctx, src, slen );
- mbedtls_md_update( md_ctx, counter, 4 );
- mbedtls_md_finish( md_ctx, mask );
-
- for( i = 0; i < use_len; ++i )
- *p++ ^= mask[i];
-
- counter[3]++;
-
- dlen -= use_len;
- }
-
- mbedtls_zeroize( mask, sizeof( mask ) );
-}
-#endif /* MBEDTLS_PKCS1_V21 */
-
-#if defined(MBEDTLS_PKCS1_V21)
-/*
- * Implementation of the PKCS#1 v2.1 RSAES-OAEP-ENCRYPT function
- */
-int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- const unsigned char *label, size_t label_len,
- size_t ilen,
- const unsigned char *input,
- unsigned char *output )
-{
- size_t olen;
- int ret;
- unsigned char *p = output;
- unsigned int hlen;
- const mbedtls_md_info_t *md_info;
- mbedtls_md_context_t md_ctx;
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- if( f_rng == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- olen = ctx->len;
- hlen = mbedtls_md_get_size( md_info );
-
- /* first comparison checks for overflow */
- if( ilen + 2 * hlen + 2 < ilen || olen < ilen + 2 * hlen + 2 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- memset( output, 0, olen );
-
- *p++ = 0;
-
- /* Generate a random octet string seed */
- if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 )
- return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
-
- p += hlen;
-
- /* Construct DB */
- mbedtls_md( md_info, label, label_len, p );
- p += hlen;
- p += olen - 2 * hlen - 2 - ilen;
- *p++ = 1;
- memcpy( p, input, ilen );
-
- mbedtls_md_init( &md_ctx );
- if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- return( ret );
- }
-
- /* maskedDB: Apply dbMask to DB */
- mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen,
- &md_ctx );
-
- /* maskedSeed: Apply seedMask to seed */
- mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1,
- &md_ctx );
-
- mbedtls_md_free( &md_ctx );
-
- return( ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, output, output )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, output, output ) );
-}
-#endif /* MBEDTLS_PKCS1_V21 */
-
-#if defined(MBEDTLS_PKCS1_V15)
-/*
- * Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-ENCRYPT function
- */
-int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t ilen,
- const unsigned char *input,
- unsigned char *output )
-{
- size_t nb_pad, olen;
- int ret;
- unsigned char *p = output;
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- // We don't check p_rng because it won't be dereferenced here
- if( f_rng == NULL || input == NULL || output == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- olen = ctx->len;
-
- /* first comparison checks for overflow */
- if( ilen + 11 < ilen || olen < ilen + 11 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- nb_pad = olen - 3 - ilen;
-
- *p++ = 0;
- if( mode == MBEDTLS_RSA_PUBLIC )
- {
- *p++ = MBEDTLS_RSA_CRYPT;
-
- while( nb_pad-- > 0 )
- {
- int rng_dl = 100;
-
- do {
- ret = f_rng( p_rng, p, 1 );
- } while( *p == 0 && --rng_dl && ret == 0 );
-
- /* Check if RNG failed to generate data */
- if( rng_dl == 0 || ret != 0 )
- return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
-
- p++;
- }
- }
- else
- {
- *p++ = MBEDTLS_RSA_SIGN;
-
- while( nb_pad-- > 0 )
- *p++ = 0xFF;
- }
-
- *p++ = 0;
- memcpy( p, input, ilen );
-
- return( ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, output, output )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, output, output ) );
-}
-#endif /* MBEDTLS_PKCS1_V15 */
-
-/*
- * Add the message padding, then do an RSA operation
- */
-int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t ilen,
- const unsigned char *input,
- unsigned char *output )
-{
- switch( ctx->padding )
- {
-#if defined(MBEDTLS_PKCS1_V15)
- case MBEDTLS_RSA_PKCS_V15:
- return mbedtls_rsa_rsaes_pkcs1_v15_encrypt( ctx, f_rng, p_rng, mode, ilen,
- input, output );
-#endif
-
-#if defined(MBEDTLS_PKCS1_V21)
- case MBEDTLS_RSA_PKCS_V21:
- return mbedtls_rsa_rsaes_oaep_encrypt( ctx, f_rng, p_rng, mode, NULL, 0,
- ilen, input, output );
-#endif
-
- default:
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-}
-
-#if defined(MBEDTLS_PKCS1_V21)
-/*
- * Implementation of the PKCS#1 v2.1 RSAES-OAEP-DECRYPT function
- */
-int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- const unsigned char *label, size_t label_len,
- size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len )
-{
- int ret;
- size_t ilen, i, pad_len;
- unsigned char *p, bad, pad_done;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
- unsigned char lhash[MBEDTLS_MD_MAX_SIZE];
- unsigned int hlen;
- const mbedtls_md_info_t *md_info;
- mbedtls_md_context_t md_ctx;
-
- /*
- * Parameters sanity checks
- */
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ilen = ctx->len;
-
- if( ilen < 16 || ilen > sizeof( buf ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- hlen = mbedtls_md_get_size( md_info );
-
- // checking for integer underflow
- if( 2 * hlen + 2 > ilen )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- /*
- * RSA operation
- */
- ret = ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, input, buf )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
-
- if( ret != 0 )
- goto cleanup;
-
- /*
- * Unmask data and generate lHash
- */
- mbedtls_md_init( &md_ctx );
- if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- goto cleanup;
- }
-
-
- /* Generate lHash */
- mbedtls_md( md_info, label, label_len, lhash );
-
- /* seed: Apply seedMask to maskedSeed */
- mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1,
- &md_ctx );
-
- /* DB: Apply dbMask to maskedDB */
- mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen,
- &md_ctx );
-
- mbedtls_md_free( &md_ctx );
-
- /*
- * Check contents, in "constant-time"
- */
- p = buf;
- bad = 0;
-
- bad |= *p++; /* First byte must be 0 */
-
- p += hlen; /* Skip seed */
-
- /* Check lHash */
- for( i = 0; i < hlen; i++ )
- bad |= lhash[i] ^ *p++;
-
- /* Get zero-padding len, but always read till end of buffer
- * (minus one, for the 01 byte) */
- pad_len = 0;
- pad_done = 0;
- for( i = 0; i < ilen - 2 * hlen - 2; i++ )
- {
- pad_done |= p[i];
- pad_len += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
- }
-
- p += pad_len;
- bad |= *p++ ^ 0x01;
-
- /*
- * The only information "leaked" is whether the padding was correct or not
- * (eg, no data is copied if it was not correct). This meets the
- * recommendations in PKCS#1 v2.2: an opponent cannot distinguish between
- * the different error conditions.
- */
- if( bad != 0 )
- {
- ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
- goto cleanup;
- }
-
- if( ilen - ( p - buf ) > output_max_len )
- {
- ret = MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE;
- goto cleanup;
- }
-
- *olen = ilen - (p - buf);
- memcpy( output, p, *olen );
- ret = 0;
-
-cleanup:
- mbedtls_zeroize( buf, sizeof( buf ) );
- mbedtls_zeroize( lhash, sizeof( lhash ) );
-
- return( ret );
-}
-#endif /* MBEDTLS_PKCS1_V21 */
-
-#if defined(MBEDTLS_PKCS1_V15)
-/*
- * Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-DECRYPT function
- */
-int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len)
-{
- int ret;
- size_t ilen, pad_count = 0, i;
- unsigned char *p, bad, pad_done = 0;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ilen = ctx->len;
-
- if( ilen < 16 || ilen > sizeof( buf ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, input, buf )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
-
- if( ret != 0 )
- goto cleanup;
-
- p = buf;
- bad = 0;
-
- /*
- * Check and get padding len in "constant-time"
- */
- bad |= *p++; /* First byte must be 0 */
-
- /* This test does not depend on secret data */
- if( mode == MBEDTLS_RSA_PRIVATE )
- {
- bad |= *p++ ^ MBEDTLS_RSA_CRYPT;
-
- /* Get padding len, but always read till end of buffer
- * (minus one, for the 00 byte) */
- for( i = 0; i < ilen - 3; i++ )
- {
- pad_done |= ((p[i] | (unsigned char)-p[i]) >> 7) ^ 1;
- pad_count += ((pad_done | (unsigned char)-pad_done) >> 7) ^ 1;
- }
-
- p += pad_count;
- bad |= *p++; /* Must be zero */
- }
- else
- {
- bad |= *p++ ^ MBEDTLS_RSA_SIGN;
-
- /* Get padding len, but always read till end of buffer
- * (minus one, for the 00 byte) */
- for( i = 0; i < ilen - 3; i++ )
- {
- pad_done |= ( p[i] != 0xFF );
- pad_count += ( pad_done == 0 );
- }
-
- p += pad_count;
- bad |= *p++; /* Must be zero */
- }
-
- bad |= ( pad_count < 8 );
-
- if( bad )
- {
- ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
- goto cleanup;
- }
-
- if( ilen - ( p - buf ) > output_max_len )
- {
- ret = MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE;
- goto cleanup;
- }
-
- *olen = ilen - (p - buf);
- memcpy( output, p, *olen );
- ret = 0;
-
-cleanup:
- mbedtls_zeroize( buf, sizeof( buf ) );
-
- return( ret );
-}
-#endif /* MBEDTLS_PKCS1_V15 */
-
-/*
- * Do an RSA operation, then remove the message padding
- */
-int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode, size_t *olen,
- const unsigned char *input,
- unsigned char *output,
- size_t output_max_len)
-{
- switch( ctx->padding )
- {
-#if defined(MBEDTLS_PKCS1_V15)
- case MBEDTLS_RSA_PKCS_V15:
- return mbedtls_rsa_rsaes_pkcs1_v15_decrypt( ctx, f_rng, p_rng, mode, olen,
- input, output, output_max_len );
-#endif
-
-#if defined(MBEDTLS_PKCS1_V21)
- case MBEDTLS_RSA_PKCS_V21:
- return mbedtls_rsa_rsaes_oaep_decrypt( ctx, f_rng, p_rng, mode, NULL, 0,
- olen, input, output,
- output_max_len );
-#endif
-
- default:
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-}
-
-#if defined(MBEDTLS_PKCS1_V21)
-/*
- * Implementation of the PKCS#1 v2.1 RSASSA-PSS-SIGN function
- */
-int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig )
-{
- size_t olen;
- unsigned char *p = sig;
- unsigned char salt[MBEDTLS_MD_MAX_SIZE];
- unsigned int slen, hlen, offset = 0;
- int ret;
- size_t msb;
- const mbedtls_md_info_t *md_info;
- mbedtls_md_context_t md_ctx;
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- if( f_rng == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- olen = ctx->len;
-
- if( md_alg != MBEDTLS_MD_NONE )
- {
- /* Gather length of hash to sign */
- md_info = mbedtls_md_info_from_type( md_alg );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- hashlen = mbedtls_md_get_size( md_info );
- }
-
- md_info = mbedtls_md_info_from_type( (mbedtls_md_type_t) ctx->hash_id );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- hlen = mbedtls_md_get_size( md_info );
- slen = hlen;
-
- if( olen < hlen + slen + 2 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- memset( sig, 0, olen );
-
- /* Generate salt of length slen */
- if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 )
- return( MBEDTLS_ERR_RSA_RNG_FAILED + ret );
-
- /* Note: EMSA-PSS encoding is over the length of N - 1 bits */
- msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
- p += olen - hlen * 2 - 2;
- *p++ = 0x01;
- memcpy( p, salt, slen );
- p += slen;
-
- mbedtls_md_init( &md_ctx );
- if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- /* No need to zeroize salt: we didn't use it. */
- return( ret );
- }
-
- /* Generate H = Hash( M' ) */
- mbedtls_md_starts( &md_ctx );
- mbedtls_md_update( &md_ctx, p, 8 );
- mbedtls_md_update( &md_ctx, hash, hashlen );
- mbedtls_md_update( &md_ctx, salt, slen );
- mbedtls_md_finish( &md_ctx, p );
- mbedtls_zeroize( salt, sizeof( salt ) );
-
- /* Compensate for boundary condition when applying mask */
- if( msb % 8 == 0 )
- offset = 1;
-
- /* maskedDB: Apply dbMask to DB */
- mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx );
-
- mbedtls_md_free( &md_ctx );
-
- msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
- sig[0] &= 0xFF >> ( olen * 8 - msb );
-
- p += hlen;
- *p++ = 0xBC;
-
- return( ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, sig, sig )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig ) );
-}
-#endif /* MBEDTLS_PKCS1_V21 */
-
-#if defined(MBEDTLS_PKCS1_V15)
-/*
- * Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-V1_5-SIGN function
- */
-/*
- * Do an RSA operation to sign the message digest
- */
-int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig )
-{
- size_t nb_pad, olen, oid_size = 0;
- unsigned char *p = sig;
- const char *oid = NULL;
- unsigned char *sig_try = NULL, *verif = NULL;
- size_t i;
- unsigned char diff;
- volatile unsigned char diff_no_optimize;
- int ret;
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- olen = ctx->len;
- nb_pad = olen - 3;
-
- if( md_alg != MBEDTLS_MD_NONE )
- {
- const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- if( mbedtls_oid_get_oid_by_md( md_alg, &oid, &oid_size ) != 0 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- nb_pad -= 10 + oid_size;
-
- hashlen = mbedtls_md_get_size( md_info );
- }
-
- nb_pad -= hashlen;
-
- if( ( nb_pad < 8 ) || ( nb_pad > olen ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- *p++ = 0;
- *p++ = MBEDTLS_RSA_SIGN;
- memset( p, 0xFF, nb_pad );
- p += nb_pad;
- *p++ = 0;
-
- if( md_alg == MBEDTLS_MD_NONE )
- {
- memcpy( p, hash, hashlen );
- }
- else
- {
- /*
- * DigestInfo ::= SEQUENCE {
- * digestAlgorithm DigestAlgorithmIdentifier,
- * digest Digest }
- *
- * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * Digest ::= OCTET STRING
- */
- *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
- *p++ = (unsigned char) ( 0x08 + oid_size + hashlen );
- *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
- *p++ = (unsigned char) ( 0x04 + oid_size );
- *p++ = MBEDTLS_ASN1_OID;
- *p++ = oid_size & 0xFF;
- memcpy( p, oid, oid_size );
- p += oid_size;
- *p++ = MBEDTLS_ASN1_NULL;
- *p++ = 0x00;
- *p++ = MBEDTLS_ASN1_OCTET_STRING;
- *p++ = hashlen;
- memcpy( p, hash, hashlen );
- }
-
- if( mode == MBEDTLS_RSA_PUBLIC )
- return( mbedtls_rsa_public( ctx, sig, sig ) );
-
- /*
- * In order to prevent Lenstra's attack, make the signature in a
- * temporary buffer and check it before returning it.
- */
- sig_try = mbedtls_calloc( 1, ctx->len );
- if( sig_try == NULL )
- return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
-
- verif = mbedtls_calloc( 1, ctx->len );
- if( verif == NULL )
- {
- mbedtls_free( sig_try );
- return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
- }
-
- MBEDTLS_MPI_CHK( mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig_try ) );
- MBEDTLS_MPI_CHK( mbedtls_rsa_public( ctx, sig_try, verif ) );
-
- /* Compare in constant time just in case */
- for( diff = 0, i = 0; i < ctx->len; i++ )
- diff |= verif[i] ^ sig[i];
- diff_no_optimize = diff;
-
- if( diff_no_optimize != 0 )
- {
- ret = MBEDTLS_ERR_RSA_PRIVATE_FAILED;
- goto cleanup;
- }
-
- memcpy( sig, sig_try, ctx->len );
-
-cleanup:
- mbedtls_free( sig_try );
- mbedtls_free( verif );
-
- return( ret );
-}
-#endif /* MBEDTLS_PKCS1_V15 */
-
-/*
- * Do an RSA operation to sign the message digest
- */
-int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig )
-{
- switch( ctx->padding )
- {
-#if defined(MBEDTLS_PKCS1_V15)
- case MBEDTLS_RSA_PKCS_V15:
- return mbedtls_rsa_rsassa_pkcs1_v15_sign( ctx, f_rng, p_rng, mode, md_alg,
- hashlen, hash, sig );
-#endif
-
-#if defined(MBEDTLS_PKCS1_V21)
- case MBEDTLS_RSA_PKCS_V21:
- return mbedtls_rsa_rsassa_pss_sign( ctx, f_rng, p_rng, mode, md_alg,
- hashlen, hash, sig );
-#endif
-
- default:
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-}
-
-#if defined(MBEDTLS_PKCS1_V21)
-/*
- * Implementation of the PKCS#1 v2.1 RSASSA-PSS-VERIFY function
- */
-int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- mbedtls_md_type_t mgf1_hash_id,
- int expected_salt_len,
- const unsigned char *sig )
-{
- int ret;
- size_t siglen;
- unsigned char *p;
- unsigned char result[MBEDTLS_MD_MAX_SIZE];
- unsigned char zeros[8];
- unsigned int hlen;
- size_t slen, msb;
- const mbedtls_md_info_t *md_info;
- mbedtls_md_context_t md_ctx;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- siglen = ctx->len;
-
- if( siglen < 16 || siglen > sizeof( buf ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, sig, buf )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, buf );
-
- if( ret != 0 )
- return( ret );
-
- p = buf;
-
- if( buf[siglen - 1] != 0xBC )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
-
- if( md_alg != MBEDTLS_MD_NONE )
- {
- /* Gather length of hash to sign */
- md_info = mbedtls_md_info_from_type( md_alg );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- hashlen = mbedtls_md_get_size( md_info );
- }
-
- md_info = mbedtls_md_info_from_type( mgf1_hash_id );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- hlen = mbedtls_md_get_size( md_info );
- slen = siglen - hlen - 1; /* Currently length of salt + padding */
-
- memset( zeros, 0, 8 );
-
- /*
- * Note: EMSA-PSS verification is over the length of N - 1 bits
- */
- msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
-
- /* Compensate for boundary condition when applying mask */
- if( msb % 8 == 0 )
- {
- p++;
- siglen -= 1;
- }
- if( buf[0] >> ( 8 - siglen * 8 + msb ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- mbedtls_md_init( &md_ctx );
- if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- return( ret );
- }
-
- mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );
-
- buf[0] &= 0xFF >> ( siglen * 8 - msb );
-
- while( p < buf + siglen && *p == 0 )
- p++;
-
- if( p == buf + siglen ||
- *p++ != 0x01 )
- {
- mbedtls_md_free( &md_ctx );
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-
- /* Actual salt len */
- slen -= p - buf;
-
- if( expected_salt_len != MBEDTLS_RSA_SALT_LEN_ANY &&
- slen != (size_t) expected_salt_len )
- {
- mbedtls_md_free( &md_ctx );
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-
- /*
- * Generate H = Hash( M' )
- */
- mbedtls_md_starts( &md_ctx );
- mbedtls_md_update( &md_ctx, zeros, 8 );
- mbedtls_md_update( &md_ctx, hash, hashlen );
- mbedtls_md_update( &md_ctx, p, slen );
- mbedtls_md_finish( &md_ctx, result );
-
- mbedtls_md_free( &md_ctx );
-
- if( memcmp( p + slen, result, hlen ) == 0 )
- return( 0 );
- else
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-}
-
-/*
- * Simplified PKCS#1 v2.1 RSASSA-PSS-VERIFY function
- */
-int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig )
-{
- mbedtls_md_type_t mgf1_hash_id = ( ctx->hash_id != MBEDTLS_MD_NONE )
- ? (mbedtls_md_type_t) ctx->hash_id
- : md_alg;
-
- return( mbedtls_rsa_rsassa_pss_verify_ext( ctx, f_rng, p_rng, mode,
- md_alg, hashlen, hash,
- mgf1_hash_id, MBEDTLS_RSA_SALT_LEN_ANY,
- sig ) );
-
-}
-#endif /* MBEDTLS_PKCS1_V21 */
-
-#if defined(MBEDTLS_PKCS1_V15)
-/*
- * Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-v1_5-VERIFY function
- */
-int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig )
-{
- int ret;
- size_t len, siglen, asn1_len;
- unsigned char *p, *p0, *end;
- mbedtls_md_type_t msg_md_alg;
- const mbedtls_md_info_t *md_info;
- mbedtls_asn1_buf oid;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- siglen = ctx->len;
-
- if( siglen < 16 || siglen > sizeof( buf ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, sig, buf )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, buf );
-
- if( ret != 0 )
- return( ret );
-
- p = buf;
-
- if( *p++ != 0 || *p++ != MBEDTLS_RSA_SIGN )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
-
- while( *p != 0 )
- {
- if( p >= buf + siglen - 1 || *p != 0xFF )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- p++;
- }
- p++; /* skip 00 byte */
-
- /* We've read: 00 01 PS 00 where PS must be at least 8 bytes */
- if( p - buf < 11 )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
-
- len = siglen - ( p - buf );
-
- if( len == hashlen && md_alg == MBEDTLS_MD_NONE )
- {
- if( memcmp( p, hash, hashlen ) == 0 )
- return( 0 );
- else
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- }
-
- md_info = mbedtls_md_info_from_type( md_alg );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- hashlen = mbedtls_md_get_size( md_info );
-
- end = p + len;
-
- /*
- * Parse the ASN.1 structure inside the PKCS#1 v1.5 structure.
- * Insist on 2-byte length tags, to protect against variants of
- * Bleichenbacher's forgery attack against lax PKCS#1v1.5 verification.
- */
- p0 = p;
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( p != p0 + 2 || asn1_len + 2 != len )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- p0 = p;
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( p != p0 + 2 || asn1_len + 6 + hashlen != len )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- p0 = p;
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &oid.len, MBEDTLS_ASN1_OID ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( p != p0 + 2 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- oid.p = p;
- p += oid.len;
-
- if( mbedtls_oid_get_md_alg( &oid, &msg_md_alg ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( md_alg != msg_md_alg )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- /*
- * assume the algorithm parameters must be NULL
- */
- p0 = p;
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_NULL ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( p != p0 + 2 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- p0 = p;
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( p != p0 + 2 || asn1_len != hashlen )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( memcmp( p, hash, hashlen ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- p += hashlen;
-
- if( p != end )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- return( 0 );
-}
-#endif /* MBEDTLS_PKCS1_V15 */
-
-/*
- * Do an RSA operation and check the message digest
- */
-int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- const unsigned char *sig )
-{
- switch( ctx->padding )
- {
-#if defined(MBEDTLS_PKCS1_V15)
- case MBEDTLS_RSA_PKCS_V15:
- return mbedtls_rsa_rsassa_pkcs1_v15_verify( ctx, f_rng, p_rng, mode, md_alg,
- hashlen, hash, sig );
-#endif
-
-#if defined(MBEDTLS_PKCS1_V21)
- case MBEDTLS_RSA_PKCS_V21:
- return mbedtls_rsa_rsassa_pss_verify( ctx, f_rng, p_rng, mode, md_alg,
- hashlen, hash, sig );
-#endif
-
- default:
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- }
-}
-
-/*
- * Copy the components of an RSA key
- */
-int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src )
-{
- int ret;
-
- dst->ver = src->ver;
- dst->len = src->len;
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->N, &src->N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->E, &src->E ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->D, &src->D ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->P, &src->P ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Q, &src->Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DP, &src->DP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DQ, &src->DQ ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->QP, &src->QP ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RN, &src->RN ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RP, &src->RP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RQ, &src->RQ ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vi, &src->Vi ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vf, &src->Vf ) );
-
- dst->padding = src->padding;
- dst->hash_id = src->hash_id;
-
-cleanup:
- if( ret != 0 )
- mbedtls_rsa_free( dst );
-
- return( ret );
-}
-
-/*
- * Free the components of an RSA key
- */
-void mbedtls_rsa_free( mbedtls_rsa_context *ctx )
-{
- mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->Vf );
- mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP ); mbedtls_mpi_free( &ctx->RN );
- mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ ); mbedtls_mpi_free( &ctx->DP );
- mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P ); mbedtls_mpi_free( &ctx->D );
- mbedtls_mpi_free( &ctx->E ); mbedtls_mpi_free( &ctx->N );
-
-#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_free( &ctx->mutex );
-#endif
-}
-
-#if defined(MBEDTLS_SELF_TEST)
-
-#include "mbedtls/sha1.h"
-
-/*
- * Example RSA-1024 keypair, for test purposes
- */
-#define KEY_LEN 128
-
-#define RSA_N "9292758453063D803DD603D5E777D788" \
- "8ED1D5BF35786190FA2F23EBC0848AEA" \
- "DDA92CA6C3D80B32C4D109BE0F36D6AE" \
- "7130B9CED7ACDF54CFC7555AC14EEBAB" \
- "93A89813FBF3C4F8066D2D800F7C38A8" \
- "1AE31942917403FF4946B0A83D3D3E05" \
- "EE57C6F5F5606FB5D4BC6CD34EE0801A" \
- "5E94BB77B07507233A0BC7BAC8F90F79"
-
-#define RSA_E "10001"
-
-#define RSA_D "24BF6185468786FDD303083D25E64EFC" \
- "66CA472BC44D253102F8B4A9D3BFA750" \
- "91386C0077937FE33FA3252D28855837" \
- "AE1B484A8A9A45F7EE8C0C634F99E8CD" \
- "DF79C5CE07EE72C7F123142198164234" \
- "CABB724CF78B8173B9F880FC86322407" \
- "AF1FEDFDDE2BEB674CA15F3E81A1521E" \
- "071513A1E85B5DFA031F21ECAE91A34D"
-
-#define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \
- "2C01CAD19EA484A87EA4377637E75500" \
- "FCB2005C5C7DD6EC4AC023CDA285D796" \
- "C3D9E75E1EFC42488BB4F1D13AC30A57"
-
-#define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \
- "E211C2B9E5DB1ED0BF61D0D9899620F4" \
- "910E4168387E3C30AA1E00C339A79508" \
- "8452DD96A9A5EA5D9DCA68DA636032AF"
-
-#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
- "3C94D22288ACD763FD8E5600ED4A702D" \
- "F84198A5F06C2E72236AE490C93F07F8" \
- "3CC559CD27BC2D1CA488811730BB5725"
-
-#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
- "D8AAEA56749EA28623272E4F7D0592AF" \
- "7C1F1313CAC9471B5C523BFE592F517B" \
- "407A1BD76C164B93DA2D32A383E58357"
-
-#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
- "F38D18D2B2F0E2DD275AA977E2BF4411" \
- "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
- "A74206CEC169D74BF5A8C50D6F48EA08"
-
-#define PT_LEN 24
-#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
- "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
-
-#if defined(MBEDTLS_PKCS1_V15)
-static int myrand( void *rng_state, unsigned char *output, size_t len )
-{
-#if !defined(__OpenBSD__)
- size_t i;
-
- if( rng_state != NULL )
- rng_state = NULL;
-
- for( i = 0; i < len; ++i )
- output[i] = rand();
-#else
- if( rng_state != NULL )
- rng_state = NULL;
-
- arc4random_buf( output, len );
-#endif /* !OpenBSD */
-
- return( 0 );
-}
-#endif /* MBEDTLS_PKCS1_V15 */
-
-/*
- * Checkup routine
- */
-int mbedtls_rsa_self_test( int verbose )
-{
- int ret = 0;
-#if defined(MBEDTLS_PKCS1_V15)
- size_t len;
- mbedtls_rsa_context rsa;
- unsigned char rsa_plaintext[PT_LEN];
- unsigned char rsa_decrypted[PT_LEN];
- unsigned char rsa_ciphertext[KEY_LEN];
-#if defined(MBEDTLS_SHA1_C)
- unsigned char sha1sum[20];
-#endif
-
- mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
-
- rsa.len = KEY_LEN;
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.N , 16, RSA_N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.E , 16, RSA_E ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.D , 16, RSA_D ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.P , 16, RSA_P ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.Q , 16, RSA_Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DP, 16, RSA_DP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DQ, 16, RSA_DQ ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.QP, 16, RSA_QP ) );
-
- if( verbose != 0 )
- mbedtls_printf( " RSA key validation: " );
-
- if( mbedtls_rsa_check_pubkey( &rsa ) != 0 ||
- mbedtls_rsa_check_privkey( &rsa ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n PKCS#1 encryption : " );
-
- memcpy( rsa_plaintext, RSA_PT, PT_LEN );
-
- if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PUBLIC, PT_LEN,
- rsa_plaintext, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n PKCS#1 decryption : " );
-
- if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, &len,
- rsa_ciphertext, rsa_decrypted,
- sizeof(rsa_decrypted) ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-
-#if defined(MBEDTLS_SHA1_C)
- if( verbose != 0 )
- mbedtls_printf( " PKCS#1 data sign : " );
-
- mbedtls_sha1( rsa_plaintext, PT_LEN, sha1sum );
-
- if( mbedtls_rsa_pkcs1_sign( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA1, 0,
- sha1sum, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n PKCS#1 sig. verify: " );
-
- if( mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA1, 0,
- sha1sum, rsa_ciphertext ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
-#endif /* MBEDTLS_SHA1_C */
-
- if( verbose != 0 )
- mbedtls_printf( "\n" );
-
-cleanup:
- mbedtls_rsa_free( &rsa );
-#else /* MBEDTLS_PKCS1_V15 */
- ((void) verbose);
-#endif /* MBEDTLS_PKCS1_V15 */
- return( ret );
-}
-
-#endif /* MBEDTLS_SELF_TEST */
-
-#endif /* MBEDTLS_RSA_C */
diff --git a/backport/compat/verification/rsapubkey.asn1.c b/backport/compat/verification/rsapubkey.asn1.c
deleted file mode 100644
index 6bb1994e..00000000
--- a/backport/compat/verification/rsapubkey.asn1.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for rsapubkey
- */
-#include <linux/asn1_ber_bytecode.h>
-#include "rsapubkey.asn1.h"
-
-enum rsapubkey_actions {
- ACT_rsa_get_e = 0,
- ACT_rsa_get_n = 1,
- NR__rsapubkey_actions = 2
-};
-
-static const asn1_action_t rsapubkey_action_table[NR__rsapubkey_actions] = {
- [ 0] = rsa_get_e,
- [ 1] = rsa_get_n,
-};
-
-static const unsigned char rsapubkey_machine[] = {
- // RsaPubKey
- [ 0] = ASN1_OP_MATCH,
- [ 1] = _tag(UNIV, CONS, SEQ),
- [ 2] = ASN1_OP_MATCH_ACT, // n
- [ 3] = _tag(UNIV, PRIM, INT),
- [ 4] = _action(ACT_rsa_get_n),
- [ 5] = ASN1_OP_MATCH_ACT, // e
- [ 6] = _tag(UNIV, PRIM, INT),
- [ 7] = _action(ACT_rsa_get_e),
- [ 8] = ASN1_OP_END_SEQ,
- [ 9] = ASN1_OP_COMPLETE,
-};
-
-const struct asn1_decoder rsapubkey_decoder = {
- .machine = rsapubkey_machine,
- .machlen = sizeof(rsapubkey_machine),
- .actions = rsapubkey_action_table,
-};
diff --git a/backport/compat/verification/rsapubkey.asn1.h b/backport/compat/verification/rsapubkey.asn1.h
deleted file mode 100644
index 81a82d40..00000000
--- a/backport/compat/verification/rsapubkey.asn1.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for rsapubkey
- */
-#include <linux/asn1_decoder.h>
-
-extern const struct asn1_decoder rsapubkey_decoder;
-
-#define rsa_get_e LINUX_BACKPORT(rsa_get_e)
-#define rsa_get_n LINUX_BACKPORT(rsa_get_n)
-
-extern int rsa_get_e(void *, size_t, unsigned char, const void *, size_t);
-extern int rsa_get_n(void *, size_t, unsigned char, const void *, size_t);
-
diff --git a/backport/compat/verification/sha256.c b/backport/compat/verification/sha256.c
deleted file mode 100644
index 52fedf6a..00000000
--- a/backport/compat/verification/sha256.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * FIPS-180-2 compliant SHA-256 implementation
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: GPL-2.0
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-/*
- * The SHA-256 Secure Hash Standard was published by NIST in 2002.
- *
- * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
- */
-
-#if !defined(MBEDTLS_CONFIG_FILE)
-#include "mbedtls/config.h"
-#else
-#include MBEDTLS_CONFIG_FILE
-#endif
-
-#if defined(MBEDTLS_SHA256_C)
-
-#include "mbedtls/sha256.h"
-
-#if defined(MBEDTLS_SELF_TEST)
-#if defined(MBEDTLS_PLATFORM_C)
-#include "mbedtls/platform.h"
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#define mbedtls_printf printf
-#define mbedtls_calloc calloc
-#define mbedtls_free free
-#endif /* MBEDTLS_PLATFORM_C */
-#endif /* MBEDTLS_SELF_TEST */
-
-#if !defined(MBEDTLS_SHA256_ALT)
-
-/* Implementation that should never be optimized out by the compiler */
-static void mbedtls_zeroize( void *v, size_t n ) {
- volatile unsigned char *p = v; while( n-- ) *p++ = 0;
-}
-
-/*
- * 32-bit integer manipulation macros (big endian)
- */
-#ifndef GET_UINT32_BE
-#define GET_UINT32_BE(n,b,i) \
-do { \
- (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
- | ( (uint32_t) (b)[(i) + 1] << 16 ) \
- | ( (uint32_t) (b)[(i) + 2] << 8 ) \
- | ( (uint32_t) (b)[(i) + 3] ); \
-} while( 0 )
-#endif
-
-#ifndef PUT_UINT32_BE
-#define PUT_UINT32_BE(n,b,i) \
-do { \
- (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
- (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
- (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
- (b)[(i) + 3] = (unsigned char) ( (n) ); \
-} while( 0 )
-#endif
-
-void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
-{
- memset( ctx, 0, sizeof( mbedtls_sha256_context ) );
-}
-
-void mbedtls_sha256_free( mbedtls_sha256_context *ctx )
-{
- if( ctx == NULL )
- return;
-
- mbedtls_zeroize( ctx, sizeof( mbedtls_sha256_context ) );
-}
-
-void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
- const mbedtls_sha256_context *src )
-{
- *dst = *src;
-}
-
-/*
- * SHA-256 context setup
- */
-void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
-{
- ctx->total[0] = 0;
- ctx->total[1] = 0;
-
- if( is224 == 0 )
- {
- /* SHA-256 */
- ctx->state[0] = 0x6A09E667;
- ctx->state[1] = 0xBB67AE85;
- ctx->state[2] = 0x3C6EF372;
- ctx->state[3] = 0xA54FF53A;
- ctx->state[4] = 0x510E527F;
- ctx->state[5] = 0x9B05688C;
- ctx->state[6] = 0x1F83D9AB;
- ctx->state[7] = 0x5BE0CD19;
- }
- else
- {
- /* SHA-224 */
- ctx->state[0] = 0xC1059ED8;
- ctx->state[1] = 0x367CD507;
- ctx->state[2] = 0x3070DD17;
- ctx->state[3] = 0xF70E5939;
- ctx->state[4] = 0xFFC00B31;
- ctx->state[5] = 0x68581511;
- ctx->state[6] = 0x64F98FA7;
- ctx->state[7] = 0xBEFA4FA4;
- }
-
- ctx->is224 = is224;
-}
-
-#if !defined(MBEDTLS_SHA256_PROCESS_ALT)
-static const uint32_t K[] =
-{
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
-};
-
-#define SHR(x,n) ((x & 0xFFFFFFFF) >> n)
-#define ROTR(x,n) (SHR(x,n) | (x << (32 - n)))
-
-#define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
-#define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
-
-#define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
-#define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
-
-#define F0(x,y,z) ((x & y) | (z & (x | y)))
-#define F1(x,y,z) (z ^ (x & (y ^ z)))
-
-#define R(t) \
-( \
- W[t] = S1(W[t - 2]) + W[t - 7] + \
- S0(W[t - 15]) + W[t - 16] \
-)
-
-#define P(a,b,c,d,e,f,g,h,x,K) \
-{ \
- temp1 = h + S3(e) + F1(e,f,g) + K + x; \
- temp2 = S2(a) + F0(a,b,c); \
- d += temp1; h = temp1 + temp2; \
-}
-
-void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] )
-{
- uint32_t temp1, temp2, W[64];
- uint32_t A[8];
- unsigned int i;
-
- for( i = 0; i < 8; i++ )
- A[i] = ctx->state[i];
-
-#if defined(MBEDTLS_SHA256_SMALLER)
- for( i = 0; i < 64; i++ )
- {
- if( i < 16 )
- GET_UINT32_BE( W[i], data, 4 * i );
- else
- R( i );
-
- P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[i], K[i] );
-
- temp1 = A[7]; A[7] = A[6]; A[6] = A[5]; A[5] = A[4]; A[4] = A[3];
- A[3] = A[2]; A[2] = A[1]; A[1] = A[0]; A[0] = temp1;
- }
-#else /* MBEDTLS_SHA256_SMALLER */
- for( i = 0; i < 16; i++ )
- GET_UINT32_BE( W[i], data, 4 * i );
-
- for( i = 0; i < 16; i += 8 )
- {
- P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], W[i+0], K[i+0] );
- P( A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], W[i+1], K[i+1] );
- P( A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], W[i+2], K[i+2] );
- P( A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], W[i+3], K[i+3] );
- P( A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], W[i+4], K[i+4] );
- P( A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], W[i+5], K[i+5] );
- P( A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], W[i+6], K[i+6] );
- P( A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], W[i+7], K[i+7] );
- }
-
- for( i = 16; i < 64; i += 8 )
- {
- P( A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], R(i+0), K[i+0] );
- P( A[7], A[0], A[1], A[2], A[3], A[4], A[5], A[6], R(i+1), K[i+1] );
- P( A[6], A[7], A[0], A[1], A[2], A[3], A[4], A[5], R(i+2), K[i+2] );
- P( A[5], A[6], A[7], A[0], A[1], A[2], A[3], A[4], R(i+3), K[i+3] );
- P( A[4], A[5], A[6], A[7], A[0], A[1], A[2], A[3], R(i+4), K[i+4] );
- P( A[3], A[4], A[5], A[6], A[7], A[0], A[1], A[2], R(i+5), K[i+5] );
- P( A[2], A[3], A[4], A[5], A[6], A[7], A[0], A[1], R(i+6), K[i+6] );
- P( A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[0], R(i+7), K[i+7] );
- }
-#endif /* MBEDTLS_SHA256_SMALLER */
-
- for( i = 0; i < 8; i++ )
- ctx->state[i] += A[i];
-}
-#endif /* !MBEDTLS_SHA256_PROCESS_ALT */
-
-/*
- * SHA-256 process buffer
- */
-void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
- size_t ilen )
-{
- size_t fill;
- uint32_t left;
-
- if( ilen == 0 )
- return;
-
- left = ctx->total[0] & 0x3F;
- fill = 64 - left;
-
- ctx->total[0] += (uint32_t) ilen;
- ctx->total[0] &= 0xFFFFFFFF;
-
- if( ctx->total[0] < (uint32_t) ilen )
- ctx->total[1]++;
-
- if( left && ilen >= fill )
- {
- memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_sha256_process( ctx, ctx->buffer );
- input += fill;
- ilen -= fill;
- left = 0;
- }
-
- while( ilen >= 64 )
- {
- mbedtls_sha256_process( ctx, input );
- input += 64;
- ilen -= 64;
- }
-
- if( ilen > 0 )
- memcpy( (void *) (ctx->buffer + left), input, ilen );
-}
-
-static const unsigned char sha256_padding[64] =
-{
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/*
- * SHA-256 final digest
- */
-void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] )
-{
- uint32_t last, padn;
- uint32_t high, low;
- unsigned char msglen[8];
-
- high = ( ctx->total[0] >> 29 )
- | ( ctx->total[1] << 3 );
- low = ( ctx->total[0] << 3 );
-
- PUT_UINT32_BE( high, msglen, 0 );
- PUT_UINT32_BE( low, msglen, 4 );
-
- last = ctx->total[0] & 0x3F;
- padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
-
- mbedtls_sha256_update( ctx, sha256_padding, padn );
- mbedtls_sha256_update( ctx, msglen, 8 );
-
- PUT_UINT32_BE( ctx->state[0], output, 0 );
- PUT_UINT32_BE( ctx->state[1], output, 4 );
- PUT_UINT32_BE( ctx->state[2], output, 8 );
- PUT_UINT32_BE( ctx->state[3], output, 12 );
- PUT_UINT32_BE( ctx->state[4], output, 16 );
- PUT_UINT32_BE( ctx->state[5], output, 20 );
- PUT_UINT32_BE( ctx->state[6], output, 24 );
-
- if( ctx->is224 == 0 )
- PUT_UINT32_BE( ctx->state[7], output, 28 );
-}
-
-#endif /* !MBEDTLS_SHA256_ALT */
-
-/*
- * output = SHA-256( input buffer )
- */
-void mbedtls_sha256( const unsigned char *input, size_t ilen,
- unsigned char output[32], int is224 )
-{
- mbedtls_sha256_context ctx;
-
- mbedtls_sha256_init( &ctx );
- mbedtls_sha256_starts( &ctx, is224 );
- mbedtls_sha256_update( &ctx, input, ilen );
- mbedtls_sha256_finish( &ctx, output );
- mbedtls_sha256_free( &ctx );
-}
-
-#if defined(MBEDTLS_SELF_TEST)
-/*
- * FIPS-180-2 test vectors
- */
-static const unsigned char sha256_test_buf[3][57] =
-{
- { "abc" },
- { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
- { "" }
-};
-
-static const int sha256_test_buflen[3] =
-{
- 3, 56, 1000
-};
-
-static const unsigned char sha256_test_sum[6][32] =
-{
- /*
- * SHA-224 test vectors
- */
- { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22,
- 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3,
- 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7,
- 0xE3, 0x6C, 0x9D, 0xA7 },
- { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC,
- 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50,
- 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19,
- 0x52, 0x52, 0x25, 0x25 },
- { 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8,
- 0xBB, 0xB4, 0xC1, 0xEA, 0x97, 0x61, 0x8A, 0x4B,
- 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48, 0xB2, 0xEE,
- 0x4E, 0xE7, 0xAD, 0x67 },
-
- /*
- * SHA-256 test vectors
- */
- { 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA,
- 0x41, 0x41, 0x40, 0xDE, 0x5D, 0xAE, 0x22, 0x23,
- 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A, 0x9C,
- 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD },
- { 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8,
- 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39,
- 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
- 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 },
- { 0xCD, 0xC7, 0x6E, 0x5C, 0x99, 0x14, 0xFB, 0x92,
- 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7, 0x3E, 0x67,
- 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E,
- 0x04, 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0 }
-};
-
-/*
- * Checkup routine
- */
-int mbedtls_sha256_self_test( int verbose )
-{
- int i, j, k, buflen, ret = 0;
- unsigned char *buf;
- unsigned char sha256sum[32];
- mbedtls_sha256_context ctx;
-
- buf = mbedtls_calloc( 1024, sizeof(unsigned char) );
- if( NULL == buf )
- {
- if( verbose != 0 )
- mbedtls_printf( "Buffer allocation failed\n" );
-
- return( 1 );
- }
-
- mbedtls_sha256_init( &ctx );
-
- for( i = 0; i < 6; i++ )
- {
- j = i % 3;
- k = i < 3;
-
- if( verbose != 0 )
- mbedtls_printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 );
-
- mbedtls_sha256_starts( &ctx, k );
-
- if( j == 2 )
- {
- memset( buf, 'a', buflen = 1000 );
-
- for( j = 0; j < 1000; j++ )
- mbedtls_sha256_update( &ctx, buf, buflen );
- }
- else
- mbedtls_sha256_update( &ctx, sha256_test_buf[j],
- sha256_test_buflen[j] );
-
- mbedtls_sha256_finish( &ctx, sha256sum );
-
- if( memcmp( sha256sum, sha256_test_sum[i], 32 - k * 4 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
-
- if( verbose != 0 )
- mbedtls_printf( "passed\n" );
- }
-
- if( verbose != 0 )
- mbedtls_printf( "\n" );
-
-exit:
- mbedtls_sha256_free( &ctx );
- mbedtls_free( buf );
-
- return( ret );
-}
-
-#endif /* MBEDTLS_SELF_TEST */
-
-#endif /* MBEDTLS_SHA256_C */
diff --git a/backport/compat/verification/verify.c b/backport/compat/verification/verify.c
deleted file mode 100644
index 6f686a63..00000000
--- a/backport/compat/verification/verify.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/bug.h>
-#include <linux/verification.h>
-#include <linux/export.h>
-#include <linux/err.h>
-#include <crypto/pkcs7.h>
-
-int verify_pkcs7_signature(const void *data, size_t len,
- const void *raw_pkcs7, size_t pkcs7_len,
- struct key *trusted_keys,
- enum key_being_used_for usage,
- int (*view_content)(void *ctx,
- const void *data, size_t len,
- size_t asn1hdrlen),
- void *ctx)
-{
- struct pkcs7_message *pkcs7;
- int ret;
-
- pkcs7 = pkcs7_parse_message(raw_pkcs7, pkcs7_len);
- if (IS_ERR(pkcs7))
- return PTR_ERR(pkcs7);
-
- /* The data should be detached - so we need to supply it. */
- if (data && pkcs7_supply_detached_data(pkcs7, data, len) < 0) {
- pr_err("PKCS#7 signature with non-detached data\n");
- ret = -EBADMSG;
- goto error;
- }
-
- ret = pkcs7_verify(pkcs7, usage);
- if (ret < 0)
- goto error;
-
- if (WARN_ON(!trusted_keys)) {
- ret = -EINVAL;
- goto error;
- }
-
- ret = pkcs7_validate_trust(pkcs7, trusted_keys);
- if (ret < 0) {
- if (ret == -ENOKEY)
- pr_err("PKCS#7 signature not signed with a trusted key\n");
- goto error;
- }
-
- if (view_content) {
- size_t asn1hdrlen;
-
- ret = pkcs7_get_content_data(pkcs7, &data, &len, &asn1hdrlen);
- if (ret < 0) {
- if (ret == -ENODATA)
- pr_devel("PKCS#7 message does not contain data\n");
- goto error;
- }
-
- ret = view_content(ctx, data, len, asn1hdrlen);
- }
-
-error:
- pkcs7_free_message(pkcs7);
- pr_devel("<==%s() = %d\n", __func__, ret);
- return ret;
-}
-EXPORT_SYMBOL_GPL(verify_pkcs7_signature);
diff --git a/backport/compat/verification/x509.asn1.c b/backport/compat/verification/x509.asn1.c
deleted file mode 100644
index 316c10e3..00000000
--- a/backport/compat/verification/x509.asn1.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for x509
- */
-#include <linux/asn1_ber_bytecode.h>
-#include "x509.asn1.h"
-
-enum x509_actions {
- ACT_x509_extract_key_data = 0,
- ACT_x509_extract_name_segment = 1,
- ACT_x509_note_OID = 2,
- ACT_x509_note_issuer = 3,
- ACT_x509_note_not_after = 4,
- ACT_x509_note_not_before = 5,
- ACT_x509_note_pkey_algo = 6,
- ACT_x509_note_serial = 7,
- ACT_x509_note_signature = 8,
- ACT_x509_note_subject = 9,
- ACT_x509_note_tbs_certificate = 10,
- ACT_x509_process_extension = 11,
- NR__x509_actions = 12
-};
-
-static const asn1_action_t x509_action_table[NR__x509_actions] = {
- [ 0] = x509_extract_key_data,
- [ 1] = x509_extract_name_segment,
- [ 2] = x509_note_OID,
- [ 3] = x509_note_issuer,
- [ 4] = x509_note_not_after,
- [ 5] = x509_note_not_before,
- [ 6] = x509_note_pkey_algo,
- [ 7] = x509_note_serial,
- [ 8] = x509_note_signature,
- [ 9] = x509_note_subject,
- [ 10] = x509_note_tbs_certificate,
- [ 11] = x509_process_extension,
-};
-
-static const unsigned char x509_machine[] = {
- // Certificate
- [ 0] = ASN1_OP_MATCH,
- [ 1] = _tag(UNIV, CONS, SEQ),
- // TBSCertificate
- [ 2] = ASN1_OP_MATCH,
- [ 3] = _tag(UNIV, CONS, SEQ),
- [ 4] = ASN1_OP_MATCH_JUMP_OR_SKIP, // version
- [ 5] = _tagn(CONT, CONS, 0),
- [ 6] = _jump_target(70),
- // CertificateSerialNumber
- [ 7] = ASN1_OP_MATCH,
- [ 8] = _tag(UNIV, PRIM, INT),
- [ 9] = ASN1_OP_ACT,
- [ 10] = _action(ACT_x509_note_serial),
- // AlgorithmIdentifier
- [ 11] = ASN1_OP_MATCH_JUMP,
- [ 12] = _tag(UNIV, CONS, SEQ),
- [ 13] = _jump_target(74), // --> AlgorithmIdentifier
- [ 14] = ASN1_OP_ACT,
- [ 15] = _action(ACT_x509_note_pkey_algo),
- // Name
- [ 16] = ASN1_OP_MATCH_JUMP,
- [ 17] = _tag(UNIV, CONS, SEQ),
- [ 18] = _jump_target(80), // --> Name
- [ 19] = ASN1_OP_ACT,
- [ 20] = _action(ACT_x509_note_issuer),
- // Validity
- [ 21] = ASN1_OP_MATCH,
- [ 22] = _tag(UNIV, CONS, SEQ),
- // Time
- [ 23] = ASN1_OP_MATCH_OR_SKIP, // utcTime
- [ 24] = _tag(UNIV, PRIM, UNITIM),
- [ 25] = ASN1_OP_COND_MATCH_OR_SKIP, // generalTime
- [ 26] = _tag(UNIV, PRIM, GENTIM),
- [ 27] = ASN1_OP_COND_FAIL,
- [ 28] = ASN1_OP_ACT,
- [ 29] = _action(ACT_x509_note_not_before),
- // Time
- [ 30] = ASN1_OP_MATCH_OR_SKIP, // utcTime
- [ 31] = _tag(UNIV, PRIM, UNITIM),
- [ 32] = ASN1_OP_COND_MATCH_OR_SKIP, // generalTime
- [ 33] = _tag(UNIV, PRIM, GENTIM),
- [ 34] = ASN1_OP_COND_FAIL,
- [ 35] = ASN1_OP_ACT,
- [ 36] = _action(ACT_x509_note_not_after),
- [ 37] = ASN1_OP_END_SEQ,
- // Name
- [ 38] = ASN1_OP_MATCH_JUMP,
- [ 39] = _tag(UNIV, CONS, SEQ),
- [ 40] = _jump_target(80), // --> Name
- [ 41] = ASN1_OP_ACT,
- [ 42] = _action(ACT_x509_note_subject),
- // SubjectPublicKeyInfo
- [ 43] = ASN1_OP_MATCH,
- [ 44] = _tag(UNIV, CONS, SEQ),
- // AlgorithmIdentifier
- [ 45] = ASN1_OP_MATCH_JUMP,
- [ 46] = _tag(UNIV, CONS, SEQ),
- [ 47] = _jump_target(74), // --> AlgorithmIdentifier
- [ 48] = ASN1_OP_MATCH_ACT, // subjectPublicKey
- [ 49] = _tag(UNIV, PRIM, BTS),
- [ 50] = _action(ACT_x509_extract_key_data),
- [ 51] = ASN1_OP_END_SEQ,
- // UniqueIdentifier
- [ 52] = ASN1_OP_MATCH_OR_SKIP, // issuerUniqueID
- [ 53] = _tagn(CONT, PRIM, 1),
- // UniqueIdentifier
- [ 54] = ASN1_OP_MATCH_OR_SKIP, // subjectUniqueID
- [ 55] = _tagn(CONT, PRIM, 2),
- [ 56] = ASN1_OP_MATCH_JUMP_OR_SKIP, // extensions
- [ 57] = _tagn(CONT, CONS, 3),
- [ 58] = _jump_target(95),
- [ 59] = ASN1_OP_END_SEQ,
- [ 60] = ASN1_OP_ACT,
- [ 61] = _action(ACT_x509_note_tbs_certificate),
- // AlgorithmIdentifier
- [ 62] = ASN1_OP_MATCH_JUMP,
- [ 63] = _tag(UNIV, CONS, SEQ),
- [ 64] = _jump_target(74), // --> AlgorithmIdentifier
- [ 65] = ASN1_OP_MATCH_ACT, // signature
- [ 66] = _tag(UNIV, PRIM, BTS),
- [ 67] = _action(ACT_x509_note_signature),
- [ 68] = ASN1_OP_END_SEQ,
- [ 69] = ASN1_OP_COMPLETE,
-
- // Version
- [ 70] = ASN1_OP_MATCH,
- [ 71] = _tag(UNIV, PRIM, INT),
- [ 72] = ASN1_OP_END_SEQ,
- [ 73] = ASN1_OP_RETURN,
-
- [ 74] = ASN1_OP_MATCH_ACT, // algorithm
- [ 75] = _tag(UNIV, PRIM, OID),
- [ 76] = _action(ACT_x509_note_OID),
- [ 77] = ASN1_OP_MATCH_ANY_OR_SKIP, // parameters
- [ 78] = ASN1_OP_END_SEQ,
- [ 79] = ASN1_OP_RETURN,
-
- // RelativeDistinguishedName
- [ 80] = ASN1_OP_MATCH,
- [ 81] = _tag(UNIV, CONS, SET),
- // AttributeValueAssertion
- [ 82] = ASN1_OP_MATCH,
- [ 83] = _tag(UNIV, CONS, SEQ),
- [ 84] = ASN1_OP_MATCH_ACT, // attributeType
- [ 85] = _tag(UNIV, PRIM, OID),
- [ 86] = _action(ACT_x509_note_OID),
- [ 87] = ASN1_OP_MATCH_ANY_ACT, // attributeValue
- [ 88] = _action(ACT_x509_extract_name_segment),
- [ 89] = ASN1_OP_END_SEQ,
- [ 90] = ASN1_OP_END_SET_OF,
- [ 91] = _jump_target(82),
- [ 92] = ASN1_OP_END_SEQ_OF,
- [ 93] = _jump_target(80),
- [ 94] = ASN1_OP_RETURN,
-
- // Extensions
- [ 95] = ASN1_OP_MATCH,
- [ 96] = _tag(UNIV, CONS, SEQ),
- // Extension
- [ 97] = ASN1_OP_MATCH,
- [ 98] = _tag(UNIV, CONS, SEQ),
- [ 99] = ASN1_OP_MATCH_ACT, // extnid
- [ 100] = _tag(UNIV, PRIM, OID),
- [ 101] = _action(ACT_x509_note_OID),
- [ 102] = ASN1_OP_MATCH_OR_SKIP, // critical
- [ 103] = _tag(UNIV, PRIM, BOOL),
- [ 104] = ASN1_OP_MATCH_ACT, // extnValue
- [ 105] = _tag(UNIV, PRIM, OTS),
- [ 106] = _action(ACT_x509_process_extension),
- [ 107] = ASN1_OP_END_SEQ,
- [ 108] = ASN1_OP_END_SEQ_OF,
- [ 109] = _jump_target(97),
- [ 110] = ASN1_OP_END_SEQ,
- [ 111] = ASN1_OP_RETURN,
-};
-
-const struct asn1_decoder x509_decoder = {
- .machine = x509_machine,
- .machlen = sizeof(x509_machine),
- .actions = x509_action_table,
-};
diff --git a/backport/compat/verification/x509.asn1.h b/backport/compat/verification/x509.asn1.h
deleted file mode 100644
index 4f32a25d..00000000
--- a/backport/compat/verification/x509.asn1.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for x509
- */
-#include <linux/asn1_decoder.h>
-
-extern const struct asn1_decoder x509_decoder;
-
-extern int x509_extract_key_data(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_extract_name_segment(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_OID(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_issuer(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_not_after(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_not_before(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_pkey_algo(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_serial(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_signature(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_subject(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_tbs_certificate(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_process_extension(void *, size_t, unsigned char, const void *, size_t);
-
diff --git a/backport/compat/verification/x509_akid.asn1.c b/backport/compat/verification/x509_akid.asn1.c
deleted file mode 100644
index 10f4802a..00000000
--- a/backport/compat/verification/x509_akid.asn1.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for x509_akid
- */
-#include <linux/asn1_ber_bytecode.h>
-#include "x509_akid.asn1.h"
-
-enum x509_akid_actions {
- ACT_x509_akid_note_kid = 0,
- ACT_x509_akid_note_name = 1,
- ACT_x509_akid_note_serial = 2,
- ACT_x509_extract_name_segment = 3,
- ACT_x509_note_OID = 4,
- NR__x509_akid_actions = 5
-};
-
-static const asn1_action_t x509_akid_action_table[NR__x509_akid_actions] = {
- [ 0] = x509_akid_note_kid,
- [ 1] = x509_akid_note_name,
- [ 2] = x509_akid_note_serial,
- [ 3] = x509_extract_name_segment,
- [ 4] = x509_note_OID,
-};
-
-static const unsigned char x509_akid_machine[] = {
- // AuthorityKeyIdentifier
- [ 0] = ASN1_OP_MATCH,
- [ 1] = _tag(UNIV, CONS, SEQ),
- // KeyIdentifier
- [ 2] = ASN1_OP_MATCH_ACT_OR_SKIP, // keyIdentifier
- [ 3] = _tagn(CONT, PRIM, 0),
- [ 4] = _action(ACT_x509_akid_note_kid),
- // GeneralNames
- [ 5] = ASN1_OP_MATCH_JUMP_OR_SKIP, // authorityCertIssuer
- [ 6] = _tagn(CONT, CONS, 1),
- [ 7] = _jump_target(13), // --> GeneralNames
- // CertificateSerialNumber
- [ 8] = ASN1_OP_MATCH_ACT_OR_SKIP, // authorityCertSerialNumber
- [ 9] = _tagn(CONT, PRIM, 2),
- [ 10] = _action(ACT_x509_akid_note_serial),
- [ 11] = ASN1_OP_END_SEQ,
- [ 12] = ASN1_OP_COMPLETE,
-
- // GeneralName
- [ 13] = ASN1_OP_MATCH_JUMP_OR_SKIP, // otherName
- [ 14] = _tagn(CONT, CONS, 0),
- [ 15] = _jump_target(44),
- [ 16] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // rfc822Name
- [ 17] = _tagn(CONT, CONS, 1),
- [ 18] = _jump_target(47),
- [ 19] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // dNSName
- [ 20] = _tagn(CONT, CONS, 2),
- [ 21] = _jump_target(51),
- [ 22] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // x400Address
- [ 23] = _tagn(CONT, CONS, 3),
- [ 24] = _jump_target(55),
- [ 25] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // directoryName
- [ 26] = _tagn(CONT, CONS, 4),
- [ 27] = _jump_target(58),
- [ 28] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // ediPartyName
- [ 29] = _tagn(CONT, CONS, 5),
- [ 30] = _jump_target(78),
- [ 31] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // uniformResourceIdentifier
- [ 32] = _tagn(CONT, CONS, 6),
- [ 33] = _jump_target(81),
- [ 34] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // iPAddress
- [ 35] = _tagn(CONT, CONS, 7),
- [ 36] = _jump_target(85),
- [ 37] = ASN1_OP_COND_MATCH_JUMP_OR_SKIP, // registeredID
- [ 38] = _tagn(CONT, CONS, 8),
- [ 39] = _jump_target(89),
- [ 40] = ASN1_OP_COND_FAIL,
- [ 41] = ASN1_OP_END_SEQ_OF,
- [ 42] = _jump_target(13),
- [ 43] = ASN1_OP_RETURN,
-
- [ 44] = ASN1_OP_MATCH_ANY, // otherName
- [ 45] = ASN1_OP_END_SEQ,
- [ 46] = ASN1_OP_RETURN,
-
- [ 47] = ASN1_OP_MATCH, // rfc822Name
- [ 48] = _tag(UNIV, PRIM, IA5STR),
- [ 49] = ASN1_OP_END_SEQ,
- [ 50] = ASN1_OP_RETURN,
-
- [ 51] = ASN1_OP_MATCH, // dNSName
- [ 52] = _tag(UNIV, PRIM, IA5STR),
- [ 53] = ASN1_OP_END_SEQ,
- [ 54] = ASN1_OP_RETURN,
-
- [ 55] = ASN1_OP_MATCH_ANY, // x400Address
- [ 56] = ASN1_OP_END_SEQ,
- [ 57] = ASN1_OP_RETURN,
-
- // Name
- [ 58] = ASN1_OP_MATCH,
- [ 59] = _tag(UNIV, CONS, SEQ),
- // RelativeDistinguishedName
- [ 60] = ASN1_OP_MATCH,
- [ 61] = _tag(UNIV, CONS, SET),
- // AttributeValueAssertion
- [ 62] = ASN1_OP_MATCH,
- [ 63] = _tag(UNIV, CONS, SEQ),
- [ 64] = ASN1_OP_MATCH_ACT, // attributeType
- [ 65] = _tag(UNIV, PRIM, OID),
- [ 66] = _action(ACT_x509_note_OID),
- [ 67] = ASN1_OP_MATCH_ANY_ACT, // attributeValue
- [ 68] = _action(ACT_x509_extract_name_segment),
- [ 69] = ASN1_OP_END_SEQ,
- [ 70] = ASN1_OP_END_SET_OF,
- [ 71] = _jump_target(62),
- [ 72] = ASN1_OP_END_SEQ_OF,
- [ 73] = _jump_target(60),
- [ 74] = ASN1_OP_ACT,
- [ 75] = _action(ACT_x509_akid_note_name),
- [ 76] = ASN1_OP_END_SEQ,
- [ 77] = ASN1_OP_RETURN,
-
- [ 78] = ASN1_OP_MATCH_ANY, // ediPartyName
- [ 79] = ASN1_OP_END_SEQ,
- [ 80] = ASN1_OP_RETURN,
-
- [ 81] = ASN1_OP_MATCH, // uniformResourceIdentifier
- [ 82] = _tag(UNIV, PRIM, IA5STR),
- [ 83] = ASN1_OP_END_SEQ,
- [ 84] = ASN1_OP_RETURN,
-
- [ 85] = ASN1_OP_MATCH, // iPAddress
- [ 86] = _tag(UNIV, PRIM, OTS),
- [ 87] = ASN1_OP_END_SEQ,
- [ 88] = ASN1_OP_RETURN,
-
- [ 89] = ASN1_OP_MATCH, // registeredID
- [ 90] = _tag(UNIV, PRIM, OID),
- [ 91] = ASN1_OP_END_SEQ,
- [ 92] = ASN1_OP_RETURN,
-};
-
-const struct asn1_decoder x509_akid_decoder = {
- .machine = x509_akid_machine,
- .machlen = sizeof(x509_akid_machine),
- .actions = x509_akid_action_table,
-};
diff --git a/backport/compat/verification/x509_akid.asn1.h b/backport/compat/verification/x509_akid.asn1.h
deleted file mode 100644
index 92914da5..00000000
--- a/backport/compat/verification/x509_akid.asn1.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Automatically generated by asn1_compiler. Do not edit
- *
- * ASN.1 parser for x509_akid
- */
-#include <linux/asn1_decoder.h>
-
-extern const struct asn1_decoder x509_akid_decoder;
-
-extern int x509_akid_note_kid(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_akid_note_name(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_akid_note_serial(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_extract_name_segment(void *, size_t, unsigned char, const void *, size_t);
-extern int x509_note_OID(void *, size_t, unsigned char, const void *, size_t);
-
diff --git a/backport/defconfigs/ar5523 b/backport/defconfigs/ar5523
deleted file mode 100644
index 101c3a26..00000000
--- a/backport/defconfigs/ar5523
+++ /dev/null
@@ -1,8 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_AR5523=m
diff --git a/backport/defconfigs/ath10k b/backport/defconfigs/ath10k
deleted file mode 100644
index 43d200e6..00000000
--- a/backport/defconfigs/ath10k
+++ /dev/null
@@ -1,13 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_ATH10K_PCI=m
-CPTCFG_ATH10K_SDIO=m
-CPTCFG_ATH10K_USB=m
-CPTCFG_ATH10K=m
-CPTCFG_ATH10K_DEBUG=y
-CPTCFG_ATH10K_DEBUGFS=y
diff --git a/backport/defconfigs/ath5k b/backport/defconfigs/ath5k
deleted file mode 100644
index 920c6c64..00000000
--- a/backport/defconfigs/ath5k
+++ /dev/null
@@ -1,8 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_ATH5K=m
diff --git a/backport/defconfigs/ath6kl b/backport/defconfigs/ath6kl
deleted file mode 100644
index a1a1fdd3..00000000
--- a/backport/defconfigs/ath6kl
+++ /dev/null
@@ -1,7 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_ATH6KL=m
-CPTCFG_ATH6KL_SDIO=m
-CPTCFG_ATH6KL_USB=m
diff --git a/backport/defconfigs/ath9k b/backport/defconfigs/ath9k
deleted file mode 100644
index c7097f9f..00000000
--- a/backport/defconfigs/ath9k
+++ /dev/null
@@ -1,9 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_ATH9K=m
-CPTCFG_ATH9K_HTC=m
diff --git a/backport/defconfigs/ath9k-debug b/backport/defconfigs/ath9k-debug
deleted file mode 100644
index d9cf94fe..00000000
--- a/backport/defconfigs/ath9k-debug
+++ /dev/null
@@ -1,19 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_MAC80211_DEBUGFS=y
-CPTCFG_MAC80211_DEBUG_MENU=y
-CPTCFG_MAC80211_VERBOSE_DEBUG=y
-CPTCFG_MAC80211_MLME_DEBUG=y
-CPTCFG_MAC80211_STA_DEBUG=y
-CPTCFG_MAC80211_HT_DEBUG=y
-CPTCFG_MAC80211_IBSS_DEBUG=y
-CPTCFG_MAC80211_PS_DEBUG=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_ATH9K=m
-CPTCFG_ATH9K_HTC=m
-CPTCFG_ATH_DEBUG=y
-CPTCFG_ATH9K_DEBUGFS=y
diff --git a/backport/defconfigs/b43 b/backport/defconfigs/b43
deleted file mode 100644
index 27bfb9e2..00000000
--- a/backport/defconfigs/b43
+++ /dev/null
@@ -1,20 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_MESH=y
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_BROADCOM=y
-CPTCFG_B43=m
-CPTCFG_B43_BCMA=y
-CPTCFG_B43_SDIO=y
-CPTCFG_B43_PHY_N=y
-CPTCFG_B43_PHY_LP=y
-CPTCFG_B43_PHY_HT=y
-CPTCFG_BCMA=m
-CPTCFG_BCMA_HOST_PCI=y
-CPTCFG_SSB=m
-CPTCFG_SSB_PCIHOST=y
-CPTCFG_SSB_PCMCIAHOST=y
-CPTCFG_SSB_SDIOHOST=y
-CPTCFG_SSB_DRIVER_PCICORE=y
diff --git a/backport/defconfigs/b43legacy b/backport/defconfigs/b43legacy
deleted file mode 100644
index 71787081..00000000
--- a/backport/defconfigs/b43legacy
+++ /dev/null
@@ -1,13 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_MESH=y
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_BROADCOM=y
-CPTCFG_B43LEGACY=m
-CPTCFG_SSB=m
-CPTCFG_SSB_PCIHOST=y
-CPTCFG_SSB_PCMCIAHOST=y
-CPTCFG_SSB_SDIOHOST=y
-CPTCFG_SSB_DRIVER_PCICORE=y
diff --git a/backport/defconfigs/brcmfmac b/backport/defconfigs/brcmfmac
deleted file mode 100644
index 0e940ce3..00000000
--- a/backport/defconfigs/brcmfmac
+++ /dev/null
@@ -1,8 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_BROADCOM=y
-CPTCFG_BRCMFMAC=m
-CPTCFG_BRCMFMAC_SDIO=y
-CPTCFG_BRCMFMAC_USB=y
-CPTCFG_BRCMFMAC_PCIE=y
diff --git a/backport/defconfigs/brcmsmac b/backport/defconfigs/brcmsmac
deleted file mode 100644
index 2c2edd23..00000000
--- a/backport/defconfigs/brcmsmac
+++ /dev/null
@@ -1,9 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_BROADCOM=y
-CPTCFG_BRCMSMAC=m
-CPTCFG_BCMA=m
-CPTCFG_BCMA_HOST_PCI=y
diff --git a/backport/defconfigs/carl9170 b/backport/defconfigs/carl9170
deleted file mode 100644
index 002e0f1d..00000000
--- a/backport/defconfigs/carl9170
+++ /dev/null
@@ -1,8 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_CARL9170=m
diff --git a/backport/defconfigs/cw1200 b/backport/defconfigs/cw1200
deleted file mode 100644
index b9dfd4b2..00000000
--- a/backport/defconfigs/cw1200
+++ /dev/null
@@ -1,10 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211_MESH=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ST=y
-CPTCFG_CW1200=m
-CPTCFG_CW1200_WLAN_SDIO=m
-CPTCFG_CW1200_WLAN_SPI=m
diff --git a/backport/defconfigs/hwsim b/backport/defconfigs/hwsim
deleted file mode 100644
index 9d8006ea..00000000
--- a/backport/defconfigs/hwsim
+++ /dev/null
@@ -1,12 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_DEFAULT_PS=y
-CPTCFG_CFG80211_DEBUGFS=y
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-# CPTCFG_MAC80211_RC_PID is not set
-# CPTCFG_MAC80211_RC_MINSTREL is not set
-# CPTCFG_MAC80211_RC_DEFAULT_MINSTREL is not set
-CPTCFG_MAC80211_DEBUGFS=y
-CPTCFG_MAC80211_MESSAGE_TRACING=y
-CPTCFG_WLAN=y
-CPTCFG_MAC80211_HWSIM=m
diff --git a/backport/defconfigs/iwlwifi b/backport/defconfigs/iwlwifi
deleted file mode 100644
index 1c1acf31..00000000
--- a/backport/defconfigs/iwlwifi
+++ /dev/null
@@ -1,18 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_DEFAULT_PS=y
-CPTCFG_CFG80211_DEBUGFS=y
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-# CPTCFG_MAC80211_RC_PID is not set
-# CPTCFG_MAC80211_RC_MINSTREL is not set
-# CPTCFG_MAC80211_RC_DEFAULT_MINSTREL is not set
-CPTCFG_MAC80211_DEBUGFS=y
-CPTCFG_MAC80211_MESSAGE_TRACING=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_INTEL=y
-CPTCFG_IWLWIFI=m
-CPTCFG_IWLDVM=m
-CPTCFG_IWLMVM=m
-CPTCFG_IWLWIFI_DEBUG=y
-CPTCFG_IWLWIFI_DEBUGFS=y
-CPTCFG_IWLWIFI_DEVICE_TRACING=y
diff --git a/backport/defconfigs/rtlwifi b/backport/defconfigs/rtlwifi
deleted file mode 100644
index 00cb4acd..00000000
--- a/backport/defconfigs/rtlwifi
+++ /dev/null
@@ -1,25 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_DEFAULT_PS=y
-CPTCFG_CFG80211_DEBUGFS=y
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_MAC80211=m
-# CPTCFG_MAC80211_RC_PID is not set
-# CPTCFG_MAC80211_RC_MINSTREL is not set
-# CPTCFG_MAC80211_RC_DEFAULT_MINSTREL is not set
-CPTCFG_MAC80211_DEBUGFS=y
-CPTCFG_MAC80211_MESSAGE_TRACING=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_REALTEK=y
-CPTCFG_RTLWIFI=m
-CPTCFG_RTLWIFI_DEBUG=y
-CPTCFG_RTL8192CE=m
-CPTCFG_RTL8192SE=m
-CPTCFG_RTL8192DE=m
-CPTCFG_RTL8723AE=m
-CPTCFG_RTL8723BE=m
-CPTCFG_RTL8188EE=m
-CPTCFG_RTL8192CU=m
-CPTCFG_RTL8192C_COMMON=m
-CPTCFG_RTL8192EE=m
-CPTCFG_RTL8821AE=m
-CPTCFG_RTL8XXXU=m
diff --git a/backport/defconfigs/wcn36xx b/backport/defconfigs/wcn36xx
deleted file mode 100644
index a0ed8097..00000000
--- a/backport/defconfigs/wcn36xx
+++ /dev/null
@@ -1,13 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_DEFAULT_PS=y
-CPTCFG_CFG80211_DEBUGFS=y
-CPTCFG_MAC80211=m
-# CPTCFG_MAC80211_RC_PID is not set
-# CPTCFG_MAC80211_RC_MINSTREL is not set
-# CPTCFG_MAC80211_RC_DEFAULT_MINSTREL is not set
-CPTCFG_MAC80211_DEBUGFS=y
-CPTCFG_MAC80211_MESSAGE_TRACING=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_WCN36XX=m
-CPTCFG_WCN36XX_DEBUGFS=y
diff --git a/backport/defconfigs/wifi b/backport/defconfigs/wifi
deleted file mode 100644
index 4f6929dd..00000000
--- a/backport/defconfigs/wifi
+++ /dev/null
@@ -1,149 +0,0 @@
-CPTCFG_ADM8211=m
-CPTCFG_AR5523=m
-CPTCFG_AIRO=m
-CPTCFG_AIRO_CS=m
-CPTCFG_AT76C50X_USB=m
-CPTCFG_ATH10K=m
-CPTCFG_ATH10K_PCI=m
-CPTCFG_ATH10K_SDIO=m
-CPTCFG_ATH10K_USB=m
-CPTCFG_ATH5K=m
-CPTCFG_ATH6KL=m
-CPTCFG_ATH6KL_SDIO=m
-CPTCFG_ATH6KL_USB=m
-CPTCFG_ATH9K_HTC=m
-CPTCFG_ATH9K=m
-CPTCFG_ATMEL=m
-CPTCFG_B43LEGACY=m
-CPTCFG_B43=m
-CPTCFG_B43_PHY_HT=y
-CPTCFG_B43_PHY_N=y
-CPTCFG_B43_SDIO=y
-CPTCFG_BCMA_DRIVER_GPIO=y
-CPTCFG_BCMA_HOST_PCI=y
-CPTCFG_BCMA=m
-CPTCFG_BRCMFMAC=m
-CPTCFG_BRCMFMAC_PCIE=y
-CPTCFG_BRCMFMAC_USB=y
-CPTCFG_BRCMSMAC=m
-CPTCFG_CARL9170=m
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_CW1200=m
-CPTCFG_CW1200_WLAN_SDIO=m
-CPTCFG_CW1200_WLAN_SPI=m
-CPTCFG_HERMES=m
-CPTCFG_HERMES_PRISM=y
-CPTCFG_IPW2100=m
-CPTCFG_IPW2100_MONITOR=y
-CPTCFG_IPW2200=m
-CPTCFG_IPW2200_MONITOR=y
-CPTCFG_IPW2200_PROMISCUOUS=y
-CPTCFG_IPW2200_QOS=y
-CPTCFG_IPW2200_RADIOTAP=y
-CPTCFG_IWL3945=m
-CPTCFG_IWL4965=m
-CPTCFG_IWLDVM=m
-CPTCFG_IWLMVM=m
-CPTCFG_IWLWIFI=m
-CPTCFG_LIBERTAS_CS=m
-CPTCFG_LIBERTAS=m
-CPTCFG_LIBERTAS_MESH=y
-CPTCFG_LIBERTAS_SDIO=m
-CPTCFG_LIBERTAS_SPI=m
-CPTCFG_LIBERTAS_THINFIRM=m
-CPTCFG_LIBERTAS_THINFIRM_USB=m
-CPTCFG_LIBERTAS_USB=m
-CPTCFG_MAC80211_HWSIM=m
-CPTCFG_MAC80211_LEDS=y
-CPTCFG_MAC80211=m
-CPTCFG_MAC80211_MESH=y
-CPTCFG_MT7601U=m
-CPTCFG_MT76x0U=m
-CPTCFG_MT76x0E=m
-CPTCFG_MT76x2E=m
-CPTCFG_MT76x2U=m
-CPTCFG_MWIFIEX=m
-CPTCFG_MWIFIEX_PCIE=m
-CPTCFG_MWIFIEX_SDIO=m
-CPTCFG_MWIFIEX_USB=m
-CPTCFG_MWL8K=m
-CPTCFG_NORTEL_HERMES=m
-CPTCFG_ORINOCO_USB=m
-CPTCFG_P54_COMMON=m
-CPTCFG_P54_PCI=m
-CPTCFG_P54_SPI=m
-CPTCFG_P54_USB=m
-CPTCFG_PRISM54=m
-CPTCFG_PCI_ATMEL=m
-CPTCFG_PCI_HERMES=m
-CPTCFG_PCMCIA_ATMEL=m
-CPTCFG_PCMCIA_HERMES=m
-CPTCFG_PCMCIA_SPECTRUM=m
-CPTCFG_PLX_HERMES=m
-CPTCFG_RSI_91X=m
-CPTCFG_QTNFMAC_PCIE=m
-CPTCFG_R8188EU=m
-CPTCFG_R8822BE=m
-CPTCFG_RT2400PCI=m
-CPTCFG_RT2500PCI=m
-CPTCFG_RT2500USB=m
-CPTCFG_RT2800PCI=m
-CPTCFG_RT2800USB=m
-CPTCFG_RT2800USB_RT3573=y
-CPTCFG_RT2800USB_RT53XX=y
-CPTCFG_RT2800USB_RT55XX=y
-CPTCFG_RT2800USB_UNKNOWN=y
-CPTCFG_RT2X00=m
-CPTCFG_RT61PCI=m
-CPTCFG_RT73USB=m
-CPTCFG_RTL8180=m
-CPTCFG_RTL8187=m
-CPTCFG_RTL8188EE=m
-CPTCFG_RTL8192C_COMMON=m
-CPTCFG_RTL8192CE=m
-CPTCFG_RTL8192CU=m
-CPTCFG_RTL8192DE=m
-CPTCFG_RTL8192EE=m
-CPTCFG_RTL8192SE=m
-CPTCFG_RTL8723AE=m
-CPTCFG_RTL8723BE=m
-CPTCFG_RTL8723BS=m
-CPTCFG_RTL8821AE=m
-CPTCFG_RTL8XXXU=m
-CPTCFG_RTLWIFI=m
-CPTCFG_SSB=m
-CPTCFG_SSB_PCMCIAHOST=y
-CPTCFG_SSB_SDIOHOST=y
-CPTCFG_STAGING=y
-CPTCFG_TMD_HERMES=m
-CPTCFG_USB_NET_RNDIS_WLAN=m
-CPTCFG_USB_ZD1201=m
-CPTCFG_WCN36XX=m
-CPTCFG_WIL6210=m
-CPTCFG_WL1251=m
-CPTCFG_WL1251_SDIO=m
-CPTCFG_WL1251_SPI=m
-CPTCFG_WL12XX=m
-CPTCFG_WL18XX=m
-CPTCFG_WLAN=y
-CPTCFG_WLCORE=m
-CPTCFG_WLCORE_SDIO=m
-CPTCFG_WLCORE_SPI=m
-CPTCFG_WLAN_VENDOR_ADMTEK=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_WLAN_VENDOR_ATMEL=y
-CPTCFG_WLAN_VENDOR_BROADCOM=y
-CPTCFG_WLAN_VENDOR_CISCO=y
-CPTCFG_WLAN_VENDOR_INTEL=y
-CPTCFG_WLAN_VENDOR_INTERSIL=y
-CPTCFG_WLAN_VENDOR_MARVELL=y
-CPTCFG_WLAN_VENDOR_MEDIATEK=y
-CPTCFG_WLAN_VENDOR_QUANTENNA=y
-CPTCFG_WLAN_VENDOR_RALINK=y
-CPTCFG_WLAN_VENDOR_REALTEK=y
-CPTCFG_WLAN_VENDOR_RSI=y
-CPTCFG_WLAN_VENDOR_ST=y
-CPTCFG_WLAN_VENDOR_TI=y
-CPTCFG_WLAN_VENDOR_ZYDAS=y
-CPTCFG_ZD1211RW=m
diff --git a/backport/defconfigs/wil6210 b/backport/defconfigs/wil6210
deleted file mode 100644
index e449a691..00000000
--- a/backport/defconfigs/wil6210
+++ /dev/null
@@ -1,5 +0,0 @@
-CPTCFG_CFG80211=m
-CPTCFG_CFG80211_WEXT=y
-CPTCFG_WLAN=y
-CPTCFG_WLAN_VENDOR_ATH=y
-CPTCFG_WIL6210=m
diff --git a/backport/defconfigs/wwan b/backport/defconfigs/wwan
deleted file mode 100644
index 5b4d2e78..00000000
--- a/backport/defconfigs/wwan
+++ /dev/null
@@ -1,6 +0,0 @@
-CPTCFG_USB_USBNET=m
-CPTCFG_USB_NET_CDC_NCM=m
-CPTCFG_USB_NET_CDC_MBIM=m
-CPTCFG_USB_NET_QMI_WWAN=m
-CPTCFG_USB_SIERRA_NET=m
-CPTCFG_USB_WDM=m
diff --git a/backport/kconf/Makefile b/backport/kconf/Makefile
deleted file mode 100644
index 9edd957a..00000000
--- a/backport/kconf/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-CFLAGS=-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
-
-LXDIALOG := lxdialog/checklist.o lxdialog/inputbox.o lxdialog/menubox.o lxdialog/textbox.o lxdialog/util.o lxdialog/yesno.o
-
-conf: conf.o zconf.tab.o
-mconf_CFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ccflags) -DLOCALE
-mconf_LDFLAGS := $(shell ./lxdialog/check-lxdialog.sh -ldflags $(CC))
-mconf: CFLAGS += $(mconf_CFLAGS)
-
-mconf: mconf.o zconf.tab.o $(LXDIALOG)
- $(CC) -o mconf $^ $(mconf_LDFLAGS)
-
-.PHONY: clean
-clean:
- @rm -f mconf conf *.o lxdialog/*.o
diff --git a/backport/kconf/conf.c b/backport/kconf/conf.c
deleted file mode 100644
index 866369f1..00000000
--- a/backport/kconf/conf.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <locale.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <errno.h>
-
-#include "lkc.h"
-
-static void conf(struct menu *menu);
-static void check_conf(struct menu *menu);
-static void xfgets(char *str, int size, FILE *in);
-
-enum input_mode {
- oldaskconfig,
- silentoldconfig,
- oldconfig,
- allnoconfig,
- allyesconfig,
- allmodconfig,
- alldefconfig,
- randconfig,
- defconfig,
- savedefconfig,
- listnewconfig,
- olddefconfig,
-} input_mode = oldaskconfig;
-
-static int indent = 1;
-static int tty_stdio;
-static int valid_stdin = 1;
-static int sync_kconfig;
-static int conf_cnt;
-static char line[PATH_MAX];
-static struct menu *rootEntry;
-
-static void print_help(struct menu *menu)
-{
- struct gstr help = str_new();
-
- menu_get_ext_help(menu, &help);
-
- printf("\n%s\n", str_get(&help));
- str_free(&help);
-}
-
-static void strip(char *str)
-{
- char *p = str;
- int l;
-
- while ((isspace(*p)))
- p++;
- l = strlen(p);
- if (p != str)
- memmove(str, p, l + 1);
- if (!l)
- return;
- p = str + l - 1;
- while ((isspace(*p)))
- *p-- = 0;
-}
-
-static void check_stdin(void)
-{
- if (!valid_stdin) {
- printf(_("aborted!\n\n"));
- printf(_("Console input/output is redirected. "));
- printf(_("Run 'make oldconfig' to update configuration.\n\n"));
- exit(1);
- }
-}
-
-static int conf_askvalue(struct symbol *sym, const char *def)
-{
- enum symbol_type type = sym_get_type(sym);
-
- if (!sym_has_value(sym))
- printf(_("(NEW) "));
-
- line[0] = '\n';
- line[1] = 0;
-
- if (!sym_is_changable(sym)) {
- printf("%s\n", def);
- line[0] = '\n';
- line[1] = 0;
- return 0;
- }
-
- switch (input_mode) {
- case oldconfig:
- case silentoldconfig:
- if (sym_has_value(sym)) {
- printf("%s\n", def);
- return 0;
- }
- check_stdin();
- /* fall through */
- case oldaskconfig:
- fflush(stdout);
- xfgets(line, sizeof(line), stdin);
- if (!tty_stdio)
- printf("\n");
- return 1;
- default:
- break;
- }
-
- switch (type) {
- case S_INT:
- case S_HEX:
- case S_STRING:
- printf("%s\n", def);
- return 1;
- default:
- ;
- }
- printf("%s", line);
- return 1;
-}
-
-static int conf_string(struct menu *menu)
-{
- struct symbol *sym = menu->sym;
- const char *def;
-
- while (1) {
- printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
- printf("(%s) ", sym->name);
- def = sym_get_string_value(sym);
- if (sym_get_string_value(sym))
- printf("[%s] ", def);
- if (!conf_askvalue(sym, def))
- return 0;
- switch (line[0]) {
- case '\n':
- break;
- case '?':
- /* print help */
- if (line[1] == '\n') {
- print_help(menu);
- def = NULL;
- break;
- }
- /* fall through */
- default:
- line[strlen(line)-1] = 0;
- def = line;
- }
- if (def && sym_set_string_value(sym, def))
- return 0;
- }
-}
-
-static int conf_sym(struct menu *menu)
-{
- struct symbol *sym = menu->sym;
- tristate oldval, newval;
-
- while (1) {
- printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
- if (sym->name)
- printf("(%s) ", sym->name);
- putchar('[');
- oldval = sym_get_tristate_value(sym);
- switch (oldval) {
- case no:
- putchar('N');
- break;
- case mod:
- putchar('M');
- break;
- case yes:
- putchar('Y');
- break;
- }
- if (oldval != no && sym_tristate_within_range(sym, no))
- printf("/n");
- if (oldval != mod && sym_tristate_within_range(sym, mod))
- printf("/m");
- if (oldval != yes && sym_tristate_within_range(sym, yes))
- printf("/y");
- if (menu_has_help(menu))
- printf("/?");
- printf("] ");
- if (!conf_askvalue(sym, sym_get_string_value(sym)))
- return 0;
- strip(line);
-
- switch (line[0]) {
- case 'n':
- case 'N':
- newval = no;
- if (!line[1] || !strcmp(&line[1], "o"))
- break;
- continue;
- case 'm':
- case 'M':
- newval = mod;
- if (!line[1])
- break;
- continue;
- case 'y':
- case 'Y':
- newval = yes;
- if (!line[1] || !strcmp(&line[1], "es"))
- break;
- continue;
- case 0:
- newval = oldval;
- break;
- case '?':
- goto help;
- default:
- continue;
- }
- if (sym_set_tristate_value(sym, newval))
- return 0;
-help:
- print_help(menu);
- }
-}
-
-static int conf_choice(struct menu *menu)
-{
- struct symbol *sym, *def_sym;
- struct menu *child;
- bool is_new;
-
- sym = menu->sym;
- is_new = !sym_has_value(sym);
- if (sym_is_changable(sym)) {
- conf_sym(menu);
- sym_calc_value(sym);
- switch (sym_get_tristate_value(sym)) {
- case no:
- return 1;
- case mod:
- return 0;
- case yes:
- break;
- }
- } else {
- switch (sym_get_tristate_value(sym)) {
- case no:
- return 1;
- case mod:
- printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
- return 0;
- case yes:
- break;
- }
- }
-
- while (1) {
- int cnt, def;
-
- printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
- def_sym = sym_get_choice_value(sym);
- cnt = def = 0;
- line[0] = 0;
- for (child = menu->list; child; child = child->next) {
- if (!menu_is_visible(child))
- continue;
- if (!child->sym) {
- printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
- continue;
- }
- cnt++;
- if (child->sym == def_sym) {
- def = cnt;
- printf("%*c", indent, '>');
- } else
- printf("%*c", indent, ' ');
- printf(" %d. %s", cnt, _(menu_get_prompt(child)));
- if (child->sym->name)
- printf(" (%s)", child->sym->name);
- if (!sym_has_value(child->sym))
- printf(_(" (NEW)"));
- printf("\n");
- }
- printf(_("%*schoice"), indent - 1, "");
- if (cnt == 1) {
- printf("[1]: 1\n");
- goto conf_childs;
- }
- printf("[1-%d", cnt);
- if (menu_has_help(menu))
- printf("?");
- printf("]: ");
- switch (input_mode) {
- case oldconfig:
- case silentoldconfig:
- if (!is_new) {
- cnt = def;
- printf("%d\n", cnt);
- break;
- }
- check_stdin();
- /* fall through */
- case oldaskconfig:
- fflush(stdout);
- xfgets(line, sizeof(line), stdin);
- strip(line);
- if (line[0] == '?') {
- print_help(menu);
- continue;
- }
- if (!line[0])
- cnt = def;
- else if (isdigit(line[0]))
- cnt = atoi(line);
- else
- continue;
- break;
- default:
- break;
- }
-
- conf_childs:
- for (child = menu->list; child; child = child->next) {
- if (!child->sym || !menu_is_visible(child))
- continue;
- if (!--cnt)
- break;
- }
- if (!child)
- continue;
- if (line[0] && line[strlen(line) - 1] == '?') {
- print_help(child);
- continue;
- }
- sym_set_choice_value(sym, child->sym);
- for (child = child->list; child; child = child->next) {
- indent += 2;
- conf(child);
- indent -= 2;
- }
- return 1;
- }
-}
-
-static void conf(struct menu *menu)
-{
- struct symbol *sym;
- struct property *prop;
- struct menu *child;
-
- if (!menu_is_visible(menu))
- return;
-
- sym = menu->sym;
- prop = menu->prompt;
- if (prop) {
- const char *prompt;
-
- switch (prop->type) {
- case P_MENU:
- if ((input_mode == silentoldconfig ||
- input_mode == listnewconfig ||
- input_mode == olddefconfig) &&
- rootEntry != menu) {
- check_conf(menu);
- return;
- }
- /* fall through */
- case P_COMMENT:
- prompt = menu_get_prompt(menu);
- if (prompt)
- printf("%*c\n%*c %s\n%*c\n",
- indent, '*',
- indent, '*', _(prompt),
- indent, '*');
- default:
- ;
- }
- }
-
- if (!sym)
- goto conf_childs;
-
- if (sym_is_choice(sym)) {
- conf_choice(menu);
- if (sym->curr.tri != mod)
- return;
- goto conf_childs;
- }
-
- switch (sym->type) {
- case S_INT:
- case S_HEX:
- case S_STRING:
- conf_string(menu);
- break;
- default:
- conf_sym(menu);
- break;
- }
-
-conf_childs:
- if (sym)
- indent += 2;
- for (child = menu->list; child; child = child->next)
- conf(child);
- if (sym)
- indent -= 2;
-}
-
-static void check_conf(struct menu *menu)
-{
- struct symbol *sym;
- struct menu *child;
-
- if (!menu_is_visible(menu))
- return;
-
- sym = menu->sym;
- if (sym && !sym_has_value(sym)) {
- if (sym_is_changable(sym) ||
- (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
- if (input_mode == listnewconfig) {
- if (sym->name && !sym_is_choice_value(sym)) {
- printf("%s%s\n", CONFIG_, sym->name);
- }
- } else if (input_mode != olddefconfig) {
- if (!conf_cnt++)
- printf(_("*\n* Restart config...\n*\n"));
- rootEntry = menu_get_parent_menu(menu);
- conf(rootEntry);
- }
- }
- }
-
- for (child = menu->list; child; child = child->next)
- check_conf(child);
-}
-
-static struct option long_opts[] = {
- {"oldaskconfig", no_argument, NULL, oldaskconfig},
- {"oldconfig", no_argument, NULL, oldconfig},
- {"silentoldconfig", no_argument, NULL, silentoldconfig},
- {"defconfig", optional_argument, NULL, defconfig},
- {"savedefconfig", required_argument, NULL, savedefconfig},
- {"allnoconfig", no_argument, NULL, allnoconfig},
- {"allyesconfig", no_argument, NULL, allyesconfig},
- {"allmodconfig", no_argument, NULL, allmodconfig},
- {"alldefconfig", no_argument, NULL, alldefconfig},
- {"randconfig", no_argument, NULL, randconfig},
- {"listnewconfig", no_argument, NULL, listnewconfig},
- {"olddefconfig", no_argument, NULL, olddefconfig},
- /*
- * oldnoconfig is an alias of olddefconfig, because people already
- * are dependent on its behavior(sets new symbols to their default
- * value but not 'n') with the counter-intuitive name.
- */
- {"oldnoconfig", no_argument, NULL, olddefconfig},
- {NULL, 0, NULL, 0}
-};
-
-static void conf_usage(const char *progname)
-{
-
- printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
- printf("[option] is _one_ of the following:\n");
- printf(" --listnewconfig List new options\n");
- printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
- printf(" --oldconfig Update a configuration using a provided .config as base\n");
- printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
- printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
- printf(" --oldnoconfig An alias of olddefconfig\n");
- printf(" --defconfig <file> New config with default defined in <file>\n");
- printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
- printf(" --allnoconfig New config where all options are answered with no\n");
- printf(" --allyesconfig New config where all options are answered with yes\n");
- printf(" --allmodconfig New config where all options are answered with mod\n");
- printf(" --alldefconfig New config with all symbols set to default\n");
- printf(" --randconfig New config with random answer to all options\n");
-}
-
-int main(int ac, char **av)
-{
- const char *progname = av[0];
- int opt;
- const char *name, *defconfig_file = NULL /* gcc uninit */;
- struct stat tmpstat;
-
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- tty_stdio = isatty(0) && isatty(1) && isatty(2);
-
- while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
- if (opt == 's') {
- conf_set_message_callback(NULL);
- continue;
- }
- input_mode = (enum input_mode)opt;
- switch (opt) {
- case silentoldconfig:
- sync_kconfig = 1;
- break;
- case defconfig:
- case savedefconfig:
- defconfig_file = optarg;
- break;
- case randconfig:
- {
- struct timeval now;
- unsigned int seed;
- char *seed_env;
-
- /*
- * Use microseconds derived seed,
- * compensate for systems where it may be zero
- */
- gettimeofday(&now, NULL);
- seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
-
- seed_env = getenv("KCONFIG_SEED");
- if( seed_env && *seed_env ) {
- char *endp;
- int tmp = (int)strtol(seed_env, &endp, 0);
- if (*endp == '\0') {
- seed = tmp;
- }
- }
- fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
- srand(seed);
- break;
- }
- case oldaskconfig:
- case oldconfig:
- case allnoconfig:
- case allyesconfig:
- case allmodconfig:
- case alldefconfig:
- case listnewconfig:
- case olddefconfig:
- break;
- case '?':
- conf_usage(progname);
- exit(1);
- break;
- }
- }
- if (ac == optind) {
- printf(_("%s: Kconfig file missing\n"), av[0]);
- conf_usage(progname);
- exit(1);
- }
- name = av[optind];
- conf_parse(name);
- //zconfdump(stdout);
- if (sync_kconfig) {
- name = conf_get_configname();
- if (stat(name, &tmpstat)) {
- fprintf(stderr, _("***\n"
- "*** Configuration file \"%s\" not found!\n"
- "***\n"
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
- "*** \"make menuconfig\" or \"make xconfig\").\n"
- "***\n"), name);
- exit(1);
- }
- }
-
- switch (input_mode) {
- case defconfig:
- if (!defconfig_file)
- defconfig_file = conf_get_default_confname();
- if (conf_read(defconfig_file)) {
- printf(_("***\n"
- "*** Can't find default configuration \"%s\"!\n"
- "***\n"), defconfig_file);
- exit(1);
- }
- break;
- case savedefconfig:
- case silentoldconfig:
- case oldaskconfig:
- case oldconfig:
- case listnewconfig:
- case olddefconfig:
- conf_read(NULL);
- break;
- case allnoconfig:
- case allyesconfig:
- case allmodconfig:
- case alldefconfig:
- case randconfig:
- name = getenv("KCONFIG_ALLCONFIG");
- if (!name)
- break;
- if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
- if (conf_read_simple(name, S_DEF_USER)) {
- fprintf(stderr,
- _("*** Can't read seed configuration \"%s\"!\n"),
- name);
- exit(1);
- }
- break;
- }
- switch (input_mode) {
- case allnoconfig: name = "allno.config"; break;
- case allyesconfig: name = "allyes.config"; break;
- case allmodconfig: name = "allmod.config"; break;
- case alldefconfig: name = "alldef.config"; break;
- case randconfig: name = "allrandom.config"; break;
- default: break;
- }
- if (conf_read_simple(name, S_DEF_USER) &&
- conf_read_simple("all.config", S_DEF_USER)) {
- fprintf(stderr,
- _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
- name);
- exit(1);
- }
- break;
- default:
- break;
- }
-
- if (sync_kconfig) {
- if (conf_get_changed()) {
- name = getenv("KCONFIG_NOSILENTUPDATE");
- if (name && *name) {
- fprintf(stderr,
- _("\n*** The configuration requires explicit update.\n\n"));
- return 1;
- }
- }
- valid_stdin = tty_stdio;
- }
-
- switch (input_mode) {
- case allnoconfig:
- conf_set_all_new_symbols(def_no);
- break;
- case allyesconfig:
- conf_set_all_new_symbols(def_yes);
- break;
- case allmodconfig:
- conf_set_all_new_symbols(def_mod);
- break;
- case alldefconfig:
- conf_set_all_new_symbols(def_default);
- break;
- case randconfig:
- /* Really nothing to do in this loop */
- while (conf_set_all_new_symbols(def_random)) ;
- break;
- case defconfig:
- conf_set_all_new_symbols(def_default);
- break;
- case savedefconfig:
- break;
- case oldaskconfig:
- rootEntry = &rootmenu;
- conf(&rootmenu);
- input_mode = silentoldconfig;
- /* fall through */
- case oldconfig:
- case listnewconfig:
- case olddefconfig:
- case silentoldconfig:
- /* Update until a loop caused no more changes */
- do {
- conf_cnt = 0;
- check_conf(&rootmenu);
- } while (conf_cnt &&
- (input_mode != listnewconfig &&
- input_mode != olddefconfig));
- break;
- }
-
- if (sync_kconfig) {
- /* silentoldconfig is used during the build so we shall update autoconf.
- * All other commands are only used to generate a config.
- */
- if (conf_get_changed() && conf_write(NULL)) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- exit(1);
- }
- if (conf_write_autoconf()) {
- fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
- return 1;
- }
- } else if (input_mode == savedefconfig) {
- if (conf_write_defconfig(defconfig_file)) {
- fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
- defconfig_file);
- return 1;
- }
- } else if (input_mode != listnewconfig) {
- if (conf_write(NULL)) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- exit(1);
- }
- }
- return 0;
-}
-
-/*
- * Helper function to facilitate fgets() by Jean Sacren.
- */
-void xfgets(char *str, int size, FILE *in)
-{
- if (fgets(str, size, in) == NULL)
- fprintf(stderr, "\nError in reading or end of file.\n");
-}
diff --git a/backport/kconf/confdata.c b/backport/kconf/confdata.c
deleted file mode 100644
index 297b079a..00000000
--- a/backport/kconf/confdata.c
+++ /dev/null
@@ -1,1249 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <sys/stat.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "lkc.h"
-
-struct conf_printer {
- void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
- void (*print_comment)(FILE *, const char *, void *);
-};
-
-static void conf_warning(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-static void conf_message(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-static const char *conf_filename;
-static int conf_lineno, conf_warnings, conf_unsaved;
-
-const char conf_defname[] = "arch/$ARCH/defconfig";
-
-static void conf_warning(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
- conf_warnings++;
-}
-
-static void conf_default_message_callback(const char *fmt, va_list ap)
-{
- printf("#\n# ");
- vprintf(fmt, ap);
- printf("\n#\n");
-}
-
-static void (*conf_message_callback) (const char *fmt, va_list ap) =
- conf_default_message_callback;
-void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
-{
- conf_message_callback = fn;
-}
-
-static void conf_message(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (conf_message_callback)
- conf_message_callback(fmt, ap);
- va_end(ap);
-}
-
-const char *conf_get_configname(void)
-{
- char *name = getenv("KCONFIG_CONFIG");
-
- return name ? name : ".config";
-}
-
-const char *conf_get_autoconfig_name(void)
-{
- char *name = getenv("KCONFIG_AUTOCONFIG");
-
- return name ? name : "include/config/auto.conf";
-}
-
-static char *conf_expand_value(const char *in)
-{
- struct symbol *sym;
- const char *src;
- static char res_value[SYMBOL_MAXLENGTH];
- char *dst, name[SYMBOL_MAXLENGTH];
-
- res_value[0] = 0;
- dst = name;
- while ((src = strchr(in, '$'))) {
- strncat(res_value, in, src - in);
- src++;
- dst = name;
- while (isalnum(*src) || *src == '_')
- *dst++ = *src++;
- *dst = 0;
- sym = sym_lookup(name, 0);
- sym_calc_value(sym);
- strcat(res_value, sym_get_string_value(sym));
- in = src;
- }
- strcat(res_value, in);
-
- return res_value;
-}
-
-char *conf_get_default_confname(void)
-{
- struct stat buf;
- static char fullname[PATH_MAX+1];
- char *env, *name;
-
- name = conf_expand_value(conf_defname);
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- if (!stat(fullname, &buf))
- return fullname;
- }
- return name;
-}
-
-static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
-{
- char *p2;
-
- switch (sym->type) {
- case S_TRISTATE:
- if (p[0] == 'm') {
- sym->def[def].tri = mod;
- sym->flags |= def_flags;
- break;
- }
- /* fall through */
- case S_BOOLEAN:
- if (p[0] == 'y') {
- sym->def[def].tri = yes;
- sym->flags |= def_flags;
- break;
- }
- if (p[0] == 'n') {
- sym->def[def].tri = no;
- sym->flags |= def_flags;
- break;
- }
- if (def != S_DEF_AUTO)
- conf_warning("symbol value '%s' invalid for %s",
- p, sym->name);
- return 1;
- case S_OTHER:
- if (*p != '"') {
- for (p2 = p; *p2 && !isspace(*p2); p2++)
- ;
- sym->type = S_STRING;
- goto done;
- }
- /* fall through */
- case S_STRING:
- if (*p++ != '"')
- break;
- for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
- if (*p2 == '"') {
- *p2 = 0;
- break;
- }
- memmove(p2, p2 + 1, strlen(p2));
- }
- if (!p2) {
- if (def != S_DEF_AUTO)
- conf_warning("invalid string found");
- return 1;
- }
- /* fall through */
- case S_INT:
- case S_HEX:
- done:
- if (sym_string_valid(sym, p)) {
- sym->def[def].val = strdup(p);
- sym->flags |= def_flags;
- } else {
- if (def != S_DEF_AUTO)
- conf_warning("symbol value '%s' invalid for %s",
- p, sym->name);
- return 1;
- }
- break;
- default:
- ;
- }
- return 0;
-}
-
-#define LINE_GROWTH 16
-static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
-{
- char *nline;
- size_t new_size = slen + 1;
- if (new_size > *n) {
- new_size += LINE_GROWTH - 1;
- new_size *= 2;
- nline = realloc(*lineptr, new_size);
- if (!nline)
- return -1;
-
- *lineptr = nline;
- *n = new_size;
- }
-
- (*lineptr)[slen] = c;
-
- return 0;
-}
-
-static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
-{
- char *line = *lineptr;
- size_t slen = 0;
-
- for (;;) {
- int c = getc(stream);
-
- switch (c) {
- case '\n':
- if (add_byte(c, &line, slen, n) < 0)
- goto e_out;
- slen++;
- /* fall through */
- case EOF:
- if (add_byte('\0', &line, slen, n) < 0)
- goto e_out;
- *lineptr = line;
- if (slen == 0)
- return -1;
- return slen;
- default:
- if (add_byte(c, &line, slen, n) < 0)
- goto e_out;
- slen++;
- }
- }
-
-e_out:
- line[slen-1] = '\0';
- *lineptr = line;
- return -1;
-}
-
-int conf_read_simple(const char *name, int def)
-{
- FILE *in = NULL;
- char *line = NULL;
- size_t line_asize = 0;
- char *p, *p2;
- struct symbol *sym;
- int i, def_flags;
-
- if (name) {
- in = zconf_fopen(name);
- } else {
- struct property *prop;
-
- name = conf_get_configname();
- in = zconf_fopen(name);
- if (in)
- goto load;
- sym_add_change_count(1);
- if (!sym_defconfig_list)
- return 1;
-
- for_all_defaults(sym_defconfig_list, prop) {
- if (expr_calc_value(prop->visible.expr) == no ||
- prop->expr->type != E_SYMBOL)
- continue;
- name = conf_expand_value(prop->expr->left.sym->name);
- in = zconf_fopen(name);
- if (in) {
- conf_message(_("using defaults found in %s"),
- name);
- goto load;
- }
- }
- }
- if (!in)
- return 1;
-
-load:
- conf_filename = name;
- conf_lineno = 0;
- conf_warnings = 0;
- conf_unsaved = 0;
-
- def_flags = SYMBOL_DEF << def;
- for_all_symbols(i, sym) {
- sym->flags |= SYMBOL_CHANGED;
- sym->flags &= ~(def_flags|SYMBOL_VALID);
- if (sym_is_choice(sym))
- sym->flags |= def_flags;
- switch (sym->type) {
- case S_INT:
- case S_HEX:
- case S_STRING:
- if (sym->def[def].val)
- free(sym->def[def].val);
- /* fall through */
- default:
- sym->def[def].val = NULL;
- sym->def[def].tri = no;
- }
- }
-
- while (compat_getline(&line, &line_asize, in) != -1) {
- conf_lineno++;
- sym = NULL;
- if (line[0] == '#') {
- if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
- continue;
- p = strchr(line + 2 + strlen(CONFIG_), ' ');
- if (!p)
- continue;
- *p++ = 0;
- if (strncmp(p, "is not set", 10))
- continue;
- if (def == S_DEF_USER) {
- sym = sym_find(line + 2 + strlen(CONFIG_));
- if (!sym) {
- sym_add_change_count(1);
- goto setsym;
- }
- } else {
- sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
- if (sym->type == S_UNKNOWN)
- sym->type = S_BOOLEAN;
- }
- if (sym->flags & def_flags) {
- conf_warning("override: reassigning to symbol %s", sym->name);
- }
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- sym->def[def].tri = no;
- sym->flags |= def_flags;
- break;
- default:
- ;
- }
- } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
- p = strchr(line + strlen(CONFIG_), '=');
- if (!p)
- continue;
- *p++ = 0;
- p2 = strchr(p, '\n');
- if (p2) {
- *p2-- = 0;
- if (*p2 == '\r')
- *p2 = 0;
- }
- if (def == S_DEF_USER) {
- sym = sym_find(line + strlen(CONFIG_));
- if (!sym) {
- sym_add_change_count(1);
- goto setsym;
- }
- } else {
- sym = sym_lookup(line + strlen(CONFIG_), 0);
- if (sym->type == S_UNKNOWN)
- sym->type = S_OTHER;
- }
- if (sym->flags & def_flags) {
- conf_warning("override: reassigning to symbol %s", sym->name);
- }
- if (conf_set_sym_val(sym, def, def_flags, p))
- continue;
- } else {
- if (line[0] != '\r' && line[0] != '\n')
- conf_warning("unexpected data: %.*s",
- (int)strcspn(line, "\r\n"), line);
-
- continue;
- }
-setsym:
- if (sym && sym_is_choice_value(sym)) {
- struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
- switch (sym->def[def].tri) {
- case no:
- break;
- case mod:
- if (cs->def[def].tri == yes) {
- conf_warning("%s creates inconsistent choice state", sym->name);
- cs->flags &= ~def_flags;
- }
- break;
- case yes:
- if (cs->def[def].tri != no)
- conf_warning("override: %s changes choice state", sym->name);
- cs->def[def].val = sym;
- break;
- }
- cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
- }
- }
- free(line);
- fclose(in);
- return 0;
-}
-
-int conf_read(const char *name)
-{
- struct symbol *sym;
- int i;
-
- sym_set_change_count(0);
-
- if (conf_read_simple(name, S_DEF_USER)) {
- sym_calc_value(modules_sym);
- return 1;
- }
-
- sym_calc_value(modules_sym);
-
- for_all_symbols(i, sym) {
- sym_calc_value(sym);
- if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
- continue;
- if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
- /* check that calculated value agrees with saved value */
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
- break;
- if (!sym_is_choice(sym))
- continue;
- /* fall through */
- default:
- if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
- continue;
- break;
- }
- } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
- /* no previous value and not saved */
- continue;
- conf_unsaved++;
- /* maybe print value in verbose mode... */
- }
-
- for_all_symbols(i, sym) {
- if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
- /* Reset values of generates values, so they'll appear
- * as new, if they should become visible, but that
- * doesn't quite work if the Kconfig and the saved
- * configuration disagree.
- */
- if (sym->visible == no && !conf_unsaved)
- sym->flags &= ~SYMBOL_DEF_USER;
- switch (sym->type) {
- case S_STRING:
- case S_INT:
- case S_HEX:
- /* Reset a string value if it's out of range */
- if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
- break;
- sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
- conf_unsaved++;
- break;
- default:
- break;
- }
- }
- }
-
- sym_add_change_count(conf_warnings || conf_unsaved);
-
- return 0;
-}
-
-/*
- * Kconfig configuration printer
- *
- * This printer is used when generating the resulting configuration after
- * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
- * passing a non-NULL argument to the printer.
- *
- */
-static void
-kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (*value == 'n') {
- bool skip_unset = (arg != NULL);
-
- if (!skip_unset)
- fprintf(fp, "# %s%s is not set\n",
- CONFIG_, sym->name);
- return;
- }
- break;
- default:
- break;
- }
-
- fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
-}
-
-static void
-kconfig_print_comment(FILE *fp, const char *value, void *arg)
-{
- const char *p = value;
- size_t l;
-
- for (;;) {
- l = strcspn(p, "\n");
- fprintf(fp, "#");
- if (l) {
- fprintf(fp, " ");
- xfwrite(p, l, 1, fp);
- p += l;
- }
- fprintf(fp, "\n");
- if (*p++ == '\0')
- break;
- }
-}
-
-static struct conf_printer kconfig_printer_cb =
-{
- .print_symbol = kconfig_print_symbol,
- .print_comment = kconfig_print_comment,
-};
-
-/*
- * Header printer
- *
- * This printer is used when generating the `include/generated/autoconf.h' file.
- */
-static void
-header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE: {
- const char *suffix = "";
-
- switch (*value) {
- case 'n':
- break;
- case 'm':
- suffix = "_MODULE";
- /* fall through */
- default:
- fprintf(fp, "#define %s%s%s 1\n",
- CONFIG_, sym->name, suffix);
- }
- break;
- }
- case S_HEX: {
- const char *prefix = "";
-
- if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
- prefix = "0x";
- fprintf(fp, "#define %s%s %s%s\n",
- CONFIG_, sym->name, prefix, value);
- break;
- }
- case S_STRING:
- case S_INT:
- fprintf(fp, "#define %s%s %s\n",
- CONFIG_, sym->name, value);
- break;
- default:
- break;
- }
-
-}
-
-static void
-header_print_comment(FILE *fp, const char *value, void *arg)
-{
- const char *p = value;
- size_t l;
-
- fprintf(fp, "/*\n");
- for (;;) {
- l = strcspn(p, "\n");
- fprintf(fp, " *");
- if (l) {
- fprintf(fp, " ");
- xfwrite(p, l, 1, fp);
- p += l;
- }
- fprintf(fp, "\n");
- if (*p++ == '\0')
- break;
- }
- fprintf(fp, " */\n");
-}
-
-static struct conf_printer header_printer_cb =
-{
- .print_symbol = header_print_symbol,
- .print_comment = header_print_comment,
-};
-
-/*
- * Tristate printer
- *
- * This printer is used when generating the `include/config/tristate.conf' file.
- */
-static void
-tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-
- if (sym->type == S_TRISTATE && *value != 'n')
- fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
-}
-
-static struct conf_printer tristate_printer_cb =
-{
- .print_symbol = tristate_print_symbol,
- .print_comment = kconfig_print_comment,
-};
-
-static void conf_write_symbol(FILE *fp, struct symbol *sym,
- struct conf_printer *printer, void *printer_arg)
-{
- const char *str;
-
- switch (sym->type) {
- case S_OTHER:
- case S_UNKNOWN:
- break;
- case S_STRING:
- str = sym_get_string_value(sym);
- str = sym_escape_string_value(str);
- printer->print_symbol(fp, sym, str, printer_arg);
- free((void *)str);
- break;
- default:
- str = sym_get_string_value(sym);
- printer->print_symbol(fp, sym, str, printer_arg);
- }
-}
-
-static void
-conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg)
-{
- char buf[256];
-
- snprintf(buf, sizeof(buf),
- "\n"
- "Automatically generated file; DO NOT EDIT.\n"
- "%s\n",
- rootmenu.prompt->text);
-
- printer->print_comment(fp, buf, printer_arg);
-}
-
-/*
- * Write out a minimal config.
- * All values that has default values are skipped as this is redundant.
- */
-int conf_write_defconfig(const char *filename)
-{
- struct symbol *sym;
- struct menu *menu;
- FILE *out;
-
- out = fopen(filename, "w");
- if (!out)
- return 1;
-
- sym_clear_all_valid();
-
- /* Traverse all menus to find all relevant symbols */
- menu = rootmenu.list;
-
- while (menu != NULL)
- {
- sym = menu->sym;
- if (sym == NULL) {
- if (!menu_is_visible(menu))
- goto next_menu;
- } else if (!sym_is_choice(sym)) {
- sym_calc_value(sym);
- if (!(sym->flags & SYMBOL_WRITE))
- goto next_menu;
- sym->flags &= ~SYMBOL_WRITE;
- /* If we cannot change the symbol - skip */
- if (!sym_is_changable(sym))
- goto next_menu;
- /* If symbol equals to default value - skip */
- if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
- goto next_menu;
-
- /*
- * If symbol is a choice value and equals to the
- * default for a choice - skip.
- * But only if value is bool and equal to "y" and
- * choice is not "optional".
- * (If choice is "optional" then all values can be "n")
- */
- if (sym_is_choice_value(sym)) {
- struct symbol *cs;
- struct symbol *ds;
-
- cs = prop_get_symbol(sym_get_choice_prop(sym));
- ds = sym_choice_default(cs);
- if (!sym_is_optional(cs) && sym == ds) {
- if ((sym->type == S_BOOLEAN) &&
- sym_get_tristate_value(sym) == yes)
- goto next_menu;
- }
- }
- conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
- }
-next_menu:
- if (menu->list != NULL) {
- menu = menu->list;
- }
- else if (menu->next != NULL) {
- menu = menu->next;
- } else {
- while ((menu = menu->parent)) {
- if (menu->next != NULL) {
- menu = menu->next;
- break;
- }
- }
- }
- }
- fclose(out);
- return 0;
-}
-
-int conf_write(const char *name)
-{
- FILE *out;
- struct symbol *sym;
- struct menu *menu;
- const char *basename;
- const char *str;
- char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
- char *env;
-
- dirname[0] = 0;
- if (name && name[0]) {
- struct stat st;
- char *slash;
-
- if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
- strcpy(dirname, name);
- strcat(dirname, "/");
- basename = conf_get_configname();
- } else if ((slash = strrchr(name, '/'))) {
- int size = slash - name + 1;
- memcpy(dirname, name, size);
- dirname[size] = 0;
- if (slash[1])
- basename = slash + 1;
- else
- basename = conf_get_configname();
- } else
- basename = name;
- } else
- basename = conf_get_configname();
-
- sprintf(newname, "%s%s", dirname, basename);
- env = getenv("KCONFIG_OVERWRITECONFIG");
- if (!env || !*env) {
- sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
- out = fopen(tmpname, "w");
- } else {
- *tmpname = 0;
- out = fopen(newname, "w");
- }
- if (!out)
- return 1;
-
- conf_write_heading(out, &kconfig_printer_cb, NULL);
-
- if (!conf_get_changed())
- sym_clear_all_valid();
-
- menu = rootmenu.list;
- while (menu) {
- sym = menu->sym;
- if (!sym) {
- if (!menu_is_visible(menu))
- goto next;
- str = menu_get_prompt(menu);
- fprintf(out, "\n"
- "#\n"
- "# %s\n"
- "#\n", str);
- } else if (!(sym->flags & SYMBOL_CHOICE)) {
- sym_calc_value(sym);
- if (!(sym->flags & SYMBOL_WRITE))
- goto next;
- sym->flags &= ~SYMBOL_WRITE;
-
- conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
- }
-
-next:
- if (menu->list) {
- menu = menu->list;
- continue;
- }
- if (menu->next)
- menu = menu->next;
- else while ((menu = menu->parent)) {
- if (menu->next) {
- menu = menu->next;
- break;
- }
- }
- }
- fclose(out);
-
- if (*tmpname) {
- strcat(dirname, basename);
- strcat(dirname, ".old");
- rename(newname, dirname);
- if (rename(tmpname, newname))
- return 1;
- }
-
- conf_message(_("configuration written to %s"), newname);
-
- sym_set_change_count(0);
-
- return 0;
-}
-
-static int conf_split_config(void)
-{
- const char *name;
- char path[PATH_MAX+1];
- char *s, *d, c;
- struct symbol *sym;
- struct stat sb;
- int res, i, fd;
-
- name = conf_get_autoconfig_name();
- conf_read_simple(name, S_DEF_AUTO);
- sym_calc_value(modules_sym);
-
- if (chdir("include/config"))
- return 1;
-
- res = 0;
- for_all_symbols(i, sym) {
- sym_calc_value(sym);
- if ((sym->flags & SYMBOL_AUTO) || !sym->name)
- continue;
- if (sym->flags & SYMBOL_WRITE) {
- if (sym->flags & SYMBOL_DEF_AUTO) {
- /*
- * symbol has old and new value,
- * so compare them...
- */
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (sym_get_tristate_value(sym) ==
- sym->def[S_DEF_AUTO].tri)
- continue;
- break;
- case S_STRING:
- case S_HEX:
- case S_INT:
- if (!strcmp(sym_get_string_value(sym),
- sym->def[S_DEF_AUTO].val))
- continue;
- break;
- default:
- break;
- }
- } else {
- /*
- * If there is no old value, only 'no' (unset)
- * is allowed as new value.
- */
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (sym_get_tristate_value(sym) == no)
- continue;
- break;
- default:
- break;
- }
- }
- } else if (!(sym->flags & SYMBOL_DEF_AUTO))
- /* There is neither an old nor a new value. */
- continue;
- /* else
- * There is an old value, but no new value ('no' (unset)
- * isn't saved in auto.conf, so the old value is always
- * different from 'no').
- */
-
- /* Replace all '_' and append ".h" */
- s = sym->name;
- d = path;
- while ((c = *s++)) {
- c = tolower(c);
- *d++ = (c == '_') ? '/' : c;
- }
- strcpy(d, ".h");
-
- /* Assume directory path already exists. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- if (errno != ENOENT) {
- res = 1;
- break;
- }
- /*
- * Create directory components,
- * unless they exist already.
- */
- d = path;
- while ((d = strchr(d, '/'))) {
- *d = 0;
- if (stat(path, &sb) && mkdir(path, 0755)) {
- res = 1;
- goto out;
- }
- *d++ = '/';
- }
- /* Try it again. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- res = 1;
- break;
- }
- }
- close(fd);
- }
-out:
- if (chdir("../.."))
- return 1;
-
- return res;
-}
-
-int conf_write_autoconf(void)
-{
- struct symbol *sym;
- const char *name;
- FILE *out, *tristate, *out_h;
- int i;
-
- sym_clear_all_valid();
-
- file_write_dep("include/config/auto.conf.cmd");
-
- if (conf_split_config())
- return 1;
-
- out = fopen(".tmpconfig", "w");
- if (!out)
- return 1;
-
- tristate = fopen(".tmpconfig_tristate", "w");
- if (!tristate) {
- fclose(out);
- return 1;
- }
-
- out_h = fopen(".tmpconfig.h", "w");
- if (!out_h) {
- fclose(out);
- fclose(tristate);
- return 1;
- }
-
- conf_write_heading(out, &kconfig_printer_cb, NULL);
-
- conf_write_heading(tristate, &tristate_printer_cb, NULL);
-
- conf_write_heading(out_h, &header_printer_cb, NULL);
-
- for_all_symbols(i, sym) {
- sym_calc_value(sym);
- if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
- continue;
-
- /* write symbol to auto.conf, tristate and header files */
- conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
-
- conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
-
- conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
- }
- fclose(out);
- fclose(tristate);
- fclose(out_h);
-
- name = getenv("KCONFIG_AUTOHEADER");
- if (!name)
- name = "include/generated/autoconf.h";
- if (rename(".tmpconfig.h", name))
- return 1;
- name = getenv("KCONFIG_TRISTATE");
- if (!name)
- name = "include/config/tristate.conf";
- if (rename(".tmpconfig_tristate", name))
- return 1;
- name = conf_get_autoconfig_name();
- /*
- * This must be the last step, kbuild has a dependency on auto.conf
- * and this marks the successful completion of the previous steps.
- */
- if (rename(".tmpconfig", name))
- return 1;
-
- return 0;
-}
-
-static int sym_change_count;
-static void (*conf_changed_callback)(void);
-
-void sym_set_change_count(int count)
-{
- int _sym_change_count = sym_change_count;
- sym_change_count = count;
- if (conf_changed_callback &&
- (bool)_sym_change_count != (bool)count)
- conf_changed_callback();
-}
-
-void sym_add_change_count(int count)
-{
- sym_set_change_count(count + sym_change_count);
-}
-
-bool conf_get_changed(void)
-{
- return sym_change_count;
-}
-
-void conf_set_changed_callback(void (*fn)(void))
-{
- conf_changed_callback = fn;
-}
-
-static bool randomize_choice_values(struct symbol *csym)
-{
- struct property *prop;
- struct symbol *sym;
- struct expr *e;
- int cnt, def;
-
- /*
- * If choice is mod then we may have more items selected
- * and if no then no-one.
- * In both cases stop.
- */
- if (csym->curr.tri != yes)
- return false;
-
- prop = sym_get_choice_prop(csym);
-
- /* count entries in choice block */
- cnt = 0;
- expr_list_for_each_sym(prop->expr, e, sym)
- cnt++;
-
- /*
- * find a random value and set it to yes,
- * set the rest to no so we have only one set
- */
- def = (rand() % cnt);
-
- cnt = 0;
- expr_list_for_each_sym(prop->expr, e, sym) {
- if (def == cnt++) {
- sym->def[S_DEF_USER].tri = yes;
- csym->def[S_DEF_USER].val = sym;
- }
- else {
- sym->def[S_DEF_USER].tri = no;
- }
- sym->flags |= SYMBOL_DEF_USER;
- /* clear VALID to get value calculated */
- sym->flags &= ~SYMBOL_VALID;
- }
- csym->flags |= SYMBOL_DEF_USER;
- /* clear VALID to get value calculated */
- csym->flags &= ~(SYMBOL_VALID);
-
- return true;
-}
-
-void set_all_choice_values(struct symbol *csym)
-{
- struct property *prop;
- struct symbol *sym;
- struct expr *e;
-
- prop = sym_get_choice_prop(csym);
-
- /*
- * Set all non-assinged choice values to no
- */
- expr_list_for_each_sym(prop->expr, e, sym) {
- if (!sym_has_value(sym))
- sym->def[S_DEF_USER].tri = no;
- }
- csym->flags |= SYMBOL_DEF_USER;
- /* clear VALID to get value calculated */
- csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
-}
-
-bool conf_set_all_new_symbols(enum conf_def_mode mode)
-{
- struct symbol *sym, *csym;
- int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
- * pty: probability of tristate = y
- * ptm: probability of tristate = m
- */
-
- pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
- * below, otherwise gcc whines about
- * -Wmaybe-uninitialized */
- if (mode == def_random) {
- int n, p[3];
- char *env = getenv("KCONFIG_PROBABILITY");
- n = 0;
- while( env && *env ) {
- char *endp;
- int tmp = strtol( env, &endp, 10 );
- if( tmp >= 0 && tmp <= 100 ) {
- p[n++] = tmp;
- } else {
- errno = ERANGE;
- perror( "KCONFIG_PROBABILITY" );
- exit( 1 );
- }
- env = (*endp == ':') ? endp+1 : endp;
- if( n >=3 ) {
- break;
- }
- }
- switch( n ) {
- case 1:
- pby = p[0]; ptm = pby/2; pty = pby-ptm;
- break;
- case 2:
- pty = p[0]; ptm = p[1]; pby = pty + ptm;
- break;
- case 3:
- pby = p[0]; pty = p[1]; ptm = p[2];
- break;
- }
-
- if( pty+ptm > 100 ) {
- errno = ERANGE;
- perror( "KCONFIG_PROBABILITY" );
- exit( 1 );
- }
- }
- bool has_changed = false;
-
- for_all_symbols(i, sym) {
- if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
- continue;
- switch (sym_get_type(sym)) {
- case S_BOOLEAN:
- case S_TRISTATE:
- has_changed = true;
- switch (mode) {
- case def_yes:
- sym->def[S_DEF_USER].tri = yes;
- break;
- case def_mod:
- sym->def[S_DEF_USER].tri = mod;
- break;
- case def_no:
- if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
- sym->def[S_DEF_USER].tri = yes;
- else
- sym->def[S_DEF_USER].tri = no;
- break;
- case def_random:
- sym->def[S_DEF_USER].tri = no;
- cnt = rand() % 100;
- if (sym->type == S_TRISTATE) {
- if (cnt < pty)
- sym->def[S_DEF_USER].tri = yes;
- else if (cnt < (pty+ptm))
- sym->def[S_DEF_USER].tri = mod;
- } else if (cnt < pby)
- sym->def[S_DEF_USER].tri = yes;
- break;
- default:
- continue;
- }
- if (!(sym_is_choice(sym) && mode == def_random))
- sym->flags |= SYMBOL_DEF_USER;
- break;
- default:
- break;
- }
-
- }
-
- sym_clear_all_valid();
-
- /*
- * We have different type of choice blocks.
- * If curr.tri equals to mod then we can select several
- * choice symbols in one block.
- * In this case we do nothing.
- * If curr.tri equals yes then only one symbol can be
- * selected in a choice block and we set it to yes,
- * and the rest to no.
- */
- if (mode != def_random) {
- for_all_symbols(i, csym) {
- if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
- sym_is_choice_value(csym))
- csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
- }
- }
-
- for_all_symbols(i, csym) {
- if (sym_has_value(csym) || !sym_is_choice(csym))
- continue;
-
- sym_calc_value(csym);
- if (mode == def_random)
- has_changed = randomize_choice_values(csym);
- else {
- set_all_choice_values(csym);
- has_changed = true;
- }
- }
-
- return has_changed;
-}
diff --git a/backport/kconf/expr.c b/backport/kconf/expr.c
deleted file mode 100644
index cbf4996d..00000000
--- a/backport/kconf/expr.c
+++ /dev/null
@@ -1,1206 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "lkc.h"
-
-#define DEBUG_EXPR 0
-
-static int expr_eq(struct expr *e1, struct expr *e2);
-static struct expr *expr_eliminate_yn(struct expr *e);
-
-struct expr *expr_alloc_symbol(struct symbol *sym)
-{
- struct expr *e = xcalloc(1, sizeof(*e));
- e->type = E_SYMBOL;
- e->left.sym = sym;
- return e;
-}
-
-struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
-{
- struct expr *e = xcalloc(1, sizeof(*e));
- e->type = type;
- e->left.expr = ce;
- return e;
-}
-
-struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
-{
- struct expr *e = xcalloc(1, sizeof(*e));
- e->type = type;
- e->left.expr = e1;
- e->right.expr = e2;
- return e;
-}
-
-struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
-{
- struct expr *e = xcalloc(1, sizeof(*e));
- e->type = type;
- e->left.sym = s1;
- e->right.sym = s2;
- return e;
-}
-
-struct expr *expr_alloc_and(struct expr *e1, struct expr *e2)
-{
- if (!e1)
- return e2;
- return e2 ? expr_alloc_two(E_AND, e1, e2) : e1;
-}
-
-struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
-{
- if (!e1)
- return e2;
- return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
-}
-
-struct expr *expr_copy(const struct expr *org)
-{
- struct expr *e;
-
- if (!org)
- return NULL;
-
- e = xmalloc(sizeof(*org));
- memcpy(e, org, sizeof(*org));
- switch (org->type) {
- case E_SYMBOL:
- e->left = org->left;
- break;
- case E_NOT:
- e->left.expr = expr_copy(org->left.expr);
- break;
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- e->left.sym = org->left.sym;
- e->right.sym = org->right.sym;
- break;
- case E_AND:
- case E_OR:
- case E_LIST:
- e->left.expr = expr_copy(org->left.expr);
- e->right.expr = expr_copy(org->right.expr);
- break;
- default:
- printf("can't copy type %d\n", e->type);
- free(e);
- e = NULL;
- break;
- }
-
- return e;
-}
-
-void expr_free(struct expr *e)
-{
- if (!e)
- return;
-
- switch (e->type) {
- case E_SYMBOL:
- break;
- case E_NOT:
- expr_free(e->left.expr);
- return;
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- break;
- case E_OR:
- case E_AND:
- expr_free(e->left.expr);
- expr_free(e->right.expr);
- break;
- default:
- printf("how to free type %d?\n", e->type);
- break;
- }
- free(e);
-}
-
-static int trans_count;
-
-#define e1 (*ep1)
-#define e2 (*ep2)
-
-static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
-{
- if (e1->type == type) {
- __expr_eliminate_eq(type, &e1->left.expr, &e2);
- __expr_eliminate_eq(type, &e1->right.expr, &e2);
- return;
- }
- if (e2->type == type) {
- __expr_eliminate_eq(type, &e1, &e2->left.expr);
- __expr_eliminate_eq(type, &e1, &e2->right.expr);
- return;
- }
- if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
- e1->left.sym == e2->left.sym &&
- (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
- return;
- if (!expr_eq(e1, e2))
- return;
- trans_count++;
- expr_free(e1); expr_free(e2);
- switch (type) {
- case E_OR:
- e1 = expr_alloc_symbol(&symbol_no);
- e2 = expr_alloc_symbol(&symbol_no);
- break;
- case E_AND:
- e1 = expr_alloc_symbol(&symbol_yes);
- e2 = expr_alloc_symbol(&symbol_yes);
- break;
- default:
- ;
- }
-}
-
-void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
-{
- if (!e1 || !e2)
- return;
- switch (e1->type) {
- case E_OR:
- case E_AND:
- __expr_eliminate_eq(e1->type, ep1, ep2);
- default:
- ;
- }
- if (e1->type != e2->type) switch (e2->type) {
- case E_OR:
- case E_AND:
- __expr_eliminate_eq(e2->type, ep1, ep2);
- default:
- ;
- }
- e1 = expr_eliminate_yn(e1);
- e2 = expr_eliminate_yn(e2);
-}
-
-#undef e1
-#undef e2
-
-static int expr_eq(struct expr *e1, struct expr *e2)
-{
- int res, old_count;
-
- if (e1->type != e2->type)
- return 0;
- switch (e1->type) {
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
- case E_SYMBOL:
- return e1->left.sym == e2->left.sym;
- case E_NOT:
- return expr_eq(e1->left.expr, e2->left.expr);
- case E_AND:
- case E_OR:
- e1 = expr_copy(e1);
- e2 = expr_copy(e2);
- old_count = trans_count;
- expr_eliminate_eq(&e1, &e2);
- res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
- e1->left.sym == e2->left.sym);
- expr_free(e1);
- expr_free(e2);
- trans_count = old_count;
- return res;
- case E_LIST:
- case E_RANGE:
- case E_NONE:
- /* panic */;
- }
-
- if (DEBUG_EXPR) {
- expr_fprint(e1, stdout);
- printf(" = ");
- expr_fprint(e2, stdout);
- printf(" ?\n");
- }
-
- return 0;
-}
-
-static struct expr *expr_eliminate_yn(struct expr *e)
-{
- struct expr *tmp;
-
- if (e) switch (e->type) {
- case E_AND:
- e->left.expr = expr_eliminate_yn(e->left.expr);
- e->right.expr = expr_eliminate_yn(e->right.expr);
- if (e->left.expr->type == E_SYMBOL) {
- if (e->left.expr->left.sym == &symbol_no) {
- expr_free(e->left.expr);
- expr_free(e->right.expr);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_no;
- e->right.expr = NULL;
- return e;
- } else if (e->left.expr->left.sym == &symbol_yes) {
- free(e->left.expr);
- tmp = e->right.expr;
- *e = *(e->right.expr);
- free(tmp);
- return e;
- }
- }
- if (e->right.expr->type == E_SYMBOL) {
- if (e->right.expr->left.sym == &symbol_no) {
- expr_free(e->left.expr);
- expr_free(e->right.expr);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_no;
- e->right.expr = NULL;
- return e;
- } else if (e->right.expr->left.sym == &symbol_yes) {
- free(e->right.expr);
- tmp = e->left.expr;
- *e = *(e->left.expr);
- free(tmp);
- return e;
- }
- }
- break;
- case E_OR:
- e->left.expr = expr_eliminate_yn(e->left.expr);
- e->right.expr = expr_eliminate_yn(e->right.expr);
- if (e->left.expr->type == E_SYMBOL) {
- if (e->left.expr->left.sym == &symbol_no) {
- free(e->left.expr);
- tmp = e->right.expr;
- *e = *(e->right.expr);
- free(tmp);
- return e;
- } else if (e->left.expr->left.sym == &symbol_yes) {
- expr_free(e->left.expr);
- expr_free(e->right.expr);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_yes;
- e->right.expr = NULL;
- return e;
- }
- }
- if (e->right.expr->type == E_SYMBOL) {
- if (e->right.expr->left.sym == &symbol_no) {
- free(e->right.expr);
- tmp = e->left.expr;
- *e = *(e->left.expr);
- free(tmp);
- return e;
- } else if (e->right.expr->left.sym == &symbol_yes) {
- expr_free(e->left.expr);
- expr_free(e->right.expr);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_yes;
- e->right.expr = NULL;
- return e;
- }
- }
- break;
- default:
- ;
- }
- return e;
-}
-
-/*
- * bool FOO!=n => FOO
- */
-struct expr *expr_trans_bool(struct expr *e)
-{
- if (!e)
- return NULL;
- switch (e->type) {
- case E_AND:
- case E_OR:
- case E_NOT:
- e->left.expr = expr_trans_bool(e->left.expr);
- e->right.expr = expr_trans_bool(e->right.expr);
- break;
- case E_UNEQUAL:
- // FOO!=n -> FOO
- if (e->left.sym->type == S_TRISTATE) {
- if (e->right.sym == &symbol_no) {
- e->type = E_SYMBOL;
- e->right.sym = NULL;
- }
- }
- break;
- default:
- ;
- }
- return e;
-}
-
-/*
- * e1 || e2 -> ?
- */
-static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
-{
- struct expr *tmp;
- struct symbol *sym1, *sym2;
-
- if (expr_eq(e1, e2))
- return expr_copy(e1);
- if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
- return NULL;
- if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
- return NULL;
- if (e1->type == E_NOT) {
- tmp = e1->left.expr;
- if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
- return NULL;
- sym1 = tmp->left.sym;
- } else
- sym1 = e1->left.sym;
- if (e2->type == E_NOT) {
- if (e2->left.expr->type != E_SYMBOL)
- return NULL;
- sym2 = e2->left.expr->left.sym;
- } else
- sym2 = e2->left.sym;
- if (sym1 != sym2)
- return NULL;
- if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
- return NULL;
- if (sym1->type == S_TRISTATE) {
- if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
- ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
- (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
- // (a='y') || (a='m') -> (a!='n')
- return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no);
- }
- if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
- ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
- (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
- // (a='y') || (a='n') -> (a!='m')
- return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod);
- }
- if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
- ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
- (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
- // (a='m') || (a='n') -> (a!='y')
- return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes);
- }
- }
- if (sym1->type == S_BOOLEAN && sym1 == sym2) {
- if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) ||
- (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL))
- return expr_alloc_symbol(&symbol_yes);
- }
-
- if (DEBUG_EXPR) {
- printf("optimize (");
- expr_fprint(e1, stdout);
- printf(") || (");
- expr_fprint(e2, stdout);
- printf(")?\n");
- }
- return NULL;
-}
-
-static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
-{
- struct expr *tmp;
- struct symbol *sym1, *sym2;
-
- if (expr_eq(e1, e2))
- return expr_copy(e1);
- if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
- return NULL;
- if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
- return NULL;
- if (e1->type == E_NOT) {
- tmp = e1->left.expr;
- if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
- return NULL;
- sym1 = tmp->left.sym;
- } else
- sym1 = e1->left.sym;
- if (e2->type == E_NOT) {
- if (e2->left.expr->type != E_SYMBOL)
- return NULL;
- sym2 = e2->left.expr->left.sym;
- } else
- sym2 = e2->left.sym;
- if (sym1 != sym2)
- return NULL;
- if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
- return NULL;
-
- if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) ||
- (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes))
- // (a) && (a='y') -> (a='y')
- return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
-
- if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) ||
- (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no))
- // (a) && (a!='n') -> (a)
- return expr_alloc_symbol(sym1);
-
- if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) ||
- (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod))
- // (a) && (a!='m') -> (a='y')
- return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
-
- if (sym1->type == S_TRISTATE) {
- if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) {
- // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
- sym2 = e1->right.sym;
- if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
- return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
- : expr_alloc_symbol(&symbol_no);
- }
- if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) {
- // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
- sym2 = e2->right.sym;
- if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
- return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
- : expr_alloc_symbol(&symbol_no);
- }
- if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
- ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
- (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes)))
- // (a!='y') && (a!='n') -> (a='m')
- return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod);
-
- if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
- ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
- (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes)))
- // (a!='y') && (a!='m') -> (a='n')
- return expr_alloc_comp(E_EQUAL, sym1, &symbol_no);
-
- if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
- ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
- (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod)))
- // (a!='m') && (a!='n') -> (a='m')
- return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
-
- if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) ||
- (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) ||
- (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) ||
- (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes))
- return NULL;
- }
-
- if (DEBUG_EXPR) {
- printf("optimize (");
- expr_fprint(e1, stdout);
- printf(") && (");
- expr_fprint(e2, stdout);
- printf(")?\n");
- }
- return NULL;
-}
-
-static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
-{
-#define e1 (*ep1)
-#define e2 (*ep2)
- struct expr *tmp;
-
- if (e1->type == type) {
- expr_eliminate_dups1(type, &e1->left.expr, &e2);
- expr_eliminate_dups1(type, &e1->right.expr, &e2);
- return;
- }
- if (e2->type == type) {
- expr_eliminate_dups1(type, &e1, &e2->left.expr);
- expr_eliminate_dups1(type, &e1, &e2->right.expr);
- return;
- }
- if (e1 == e2)
- return;
-
- switch (e1->type) {
- case E_OR: case E_AND:
- expr_eliminate_dups1(e1->type, &e1, &e1);
- default:
- ;
- }
-
- switch (type) {
- case E_OR:
- tmp = expr_join_or(e1, e2);
- if (tmp) {
- expr_free(e1); expr_free(e2);
- e1 = expr_alloc_symbol(&symbol_no);
- e2 = tmp;
- trans_count++;
- }
- break;
- case E_AND:
- tmp = expr_join_and(e1, e2);
- if (tmp) {
- expr_free(e1); expr_free(e2);
- e1 = expr_alloc_symbol(&symbol_yes);
- e2 = tmp;
- trans_count++;
- }
- break;
- default:
- ;
- }
-#undef e1
-#undef e2
-}
-
-struct expr *expr_eliminate_dups(struct expr *e)
-{
- int oldcount;
- if (!e)
- return e;
-
- oldcount = trans_count;
- while (1) {
- trans_count = 0;
- switch (e->type) {
- case E_OR: case E_AND:
- expr_eliminate_dups1(e->type, &e, &e);
- default:
- ;
- }
- if (!trans_count)
- break;
- e = expr_eliminate_yn(e);
- }
- trans_count = oldcount;
- return e;
-}
-
-struct expr *expr_transform(struct expr *e)
-{
- struct expr *tmp;
-
- if (!e)
- return NULL;
- switch (e->type) {
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- case E_SYMBOL:
- case E_LIST:
- break;
- default:
- e->left.expr = expr_transform(e->left.expr);
- e->right.expr = expr_transform(e->right.expr);
- }
-
- switch (e->type) {
- case E_EQUAL:
- if (e->left.sym->type != S_BOOLEAN)
- break;
- if (e->right.sym == &symbol_no) {
- e->type = E_NOT;
- e->left.expr = expr_alloc_symbol(e->left.sym);
- e->right.sym = NULL;
- break;
- }
- if (e->right.sym == &symbol_mod) {
- printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_no;
- e->right.sym = NULL;
- break;
- }
- if (e->right.sym == &symbol_yes) {
- e->type = E_SYMBOL;
- e->right.sym = NULL;
- break;
- }
- break;
- case E_UNEQUAL:
- if (e->left.sym->type != S_BOOLEAN)
- break;
- if (e->right.sym == &symbol_no) {
- e->type = E_SYMBOL;
- e->right.sym = NULL;
- break;
- }
- if (e->right.sym == &symbol_mod) {
- printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
- e->type = E_SYMBOL;
- e->left.sym = &symbol_yes;
- e->right.sym = NULL;
- break;
- }
- if (e->right.sym == &symbol_yes) {
- e->type = E_NOT;
- e->left.expr = expr_alloc_symbol(e->left.sym);
- e->right.sym = NULL;
- break;
- }
- break;
- case E_NOT:
- switch (e->left.expr->type) {
- case E_NOT:
- // !!a -> a
- tmp = e->left.expr->left.expr;
- free(e->left.expr);
- free(e);
- e = tmp;
- e = expr_transform(e);
- break;
- case E_EQUAL:
- case E_UNEQUAL:
- // !a='x' -> a!='x'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
- break;
- case E_LEQ:
- case E_GEQ:
- // !a<='x' -> a>'x'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = e->type == E_LEQ ? E_GTH : E_LTH;
- break;
- case E_LTH:
- case E_GTH:
- // !a<'x' -> a>='x'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = e->type == E_LTH ? E_GEQ : E_LEQ;
- break;
- case E_OR:
- // !(a || b) -> !a && !b
- tmp = e->left.expr;
- e->type = E_AND;
- e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
- tmp->type = E_NOT;
- tmp->right.expr = NULL;
- e = expr_transform(e);
- break;
- case E_AND:
- // !(a && b) -> !a || !b
- tmp = e->left.expr;
- e->type = E_OR;
- e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
- tmp->type = E_NOT;
- tmp->right.expr = NULL;
- e = expr_transform(e);
- break;
- case E_SYMBOL:
- if (e->left.expr->left.sym == &symbol_yes) {
- // !'y' -> 'n'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = E_SYMBOL;
- e->left.sym = &symbol_no;
- break;
- }
- if (e->left.expr->left.sym == &symbol_mod) {
- // !'m' -> 'm'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = E_SYMBOL;
- e->left.sym = &symbol_mod;
- break;
- }
- if (e->left.expr->left.sym == &symbol_no) {
- // !'n' -> 'y'
- tmp = e->left.expr;
- free(e);
- e = tmp;
- e->type = E_SYMBOL;
- e->left.sym = &symbol_yes;
- break;
- }
- break;
- default:
- ;
- }
- break;
- default:
- ;
- }
- return e;
-}
-
-int expr_contains_symbol(struct expr *dep, struct symbol *sym)
-{
- if (!dep)
- return 0;
-
- switch (dep->type) {
- case E_AND:
- case E_OR:
- return expr_contains_symbol(dep->left.expr, sym) ||
- expr_contains_symbol(dep->right.expr, sym);
- case E_SYMBOL:
- return dep->left.sym == sym;
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- return dep->left.sym == sym ||
- dep->right.sym == sym;
- case E_NOT:
- return expr_contains_symbol(dep->left.expr, sym);
- default:
- ;
- }
- return 0;
-}
-
-bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
-{
- if (!dep)
- return false;
-
- switch (dep->type) {
- case E_AND:
- return expr_depends_symbol(dep->left.expr, sym) ||
- expr_depends_symbol(dep->right.expr, sym);
- case E_SYMBOL:
- return dep->left.sym == sym;
- case E_EQUAL:
- if (dep->left.sym == sym) {
- if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod)
- return true;
- }
- break;
- case E_UNEQUAL:
- if (dep->left.sym == sym) {
- if (dep->right.sym == &symbol_no)
- return true;
- }
- break;
- default:
- ;
- }
- return false;
-}
-
-struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
-{
- struct expr *e1, *e2;
-
- if (!e) {
- e = expr_alloc_symbol(sym);
- if (type == E_UNEQUAL)
- e = expr_alloc_one(E_NOT, e);
- return e;
- }
- switch (e->type) {
- case E_AND:
- e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
- e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
- if (sym == &symbol_yes)
- e = expr_alloc_two(E_AND, e1, e2);
- if (sym == &symbol_no)
- e = expr_alloc_two(E_OR, e1, e2);
- if (type == E_UNEQUAL)
- e = expr_alloc_one(E_NOT, e);
- return e;
- case E_OR:
- e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
- e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
- if (sym == &symbol_yes)
- e = expr_alloc_two(E_OR, e1, e2);
- if (sym == &symbol_no)
- e = expr_alloc_two(E_AND, e1, e2);
- if (type == E_UNEQUAL)
- e = expr_alloc_one(E_NOT, e);
- return e;
- case E_NOT:
- return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
- case E_UNEQUAL:
- case E_LTH:
- case E_LEQ:
- case E_GTH:
- case E_GEQ:
- case E_EQUAL:
- if (type == E_EQUAL) {
- if (sym == &symbol_yes)
- return expr_copy(e);
- if (sym == &symbol_mod)
- return expr_alloc_symbol(&symbol_no);
- if (sym == &symbol_no)
- return expr_alloc_one(E_NOT, expr_copy(e));
- } else {
- if (sym == &symbol_yes)
- return expr_alloc_one(E_NOT, expr_copy(e));
- if (sym == &symbol_mod)
- return expr_alloc_symbol(&symbol_yes);
- if (sym == &symbol_no)
- return expr_copy(e);
- }
- break;
- case E_SYMBOL:
- return expr_alloc_comp(type, e->left.sym, sym);
- case E_LIST:
- case E_RANGE:
- case E_NONE:
- /* panic */;
- }
- return NULL;
-}
-
-enum string_value_kind {
- k_string,
- k_signed,
- k_unsigned,
- k_invalid
-};
-
-union string_value {
- unsigned long long u;
- signed long long s;
-};
-
-static enum string_value_kind expr_parse_string(const char *str,
- enum symbol_type type,
- union string_value *val)
-{
- char *tail;
- enum string_value_kind kind;
-
- errno = 0;
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- return k_string;
- case S_INT:
- val->s = strtoll(str, &tail, 10);
- kind = k_signed;
- break;
- case S_HEX:
- val->u = strtoull(str, &tail, 16);
- kind = k_unsigned;
- break;
- case S_STRING:
- case S_UNKNOWN:
- val->s = strtoll(str, &tail, 0);
- kind = k_signed;
- break;
- default:
- return k_invalid;
- }
- return !errno && !*tail && tail > str && isxdigit(tail[-1])
- ? kind : k_string;
-}
-
-tristate expr_calc_value(struct expr *e)
-{
- tristate val1, val2;
- const char *str1, *str2;
- enum string_value_kind k1 = k_string, k2 = k_string;
- union string_value lval = {}, rval = {};
- int res;
-
- if (!e)
- return yes;
-
- switch (e->type) {
- case E_SYMBOL:
- sym_calc_value(e->left.sym);
- return e->left.sym->curr.tri;
- case E_AND:
- val1 = expr_calc_value(e->left.expr);
- val2 = expr_calc_value(e->right.expr);
- return EXPR_AND(val1, val2);
- case E_OR:
- val1 = expr_calc_value(e->left.expr);
- val2 = expr_calc_value(e->right.expr);
- return EXPR_OR(val1, val2);
- case E_NOT:
- val1 = expr_calc_value(e->left.expr);
- return EXPR_NOT(val1);
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- break;
- default:
- printf("expr_calc_value: %d?\n", e->type);
- return no;
- }
-
- sym_calc_value(e->left.sym);
- sym_calc_value(e->right.sym);
- str1 = sym_get_string_value(e->left.sym);
- str2 = sym_get_string_value(e->right.sym);
-
- if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) {
- k1 = expr_parse_string(str1, e->left.sym->type, &lval);
- k2 = expr_parse_string(str2, e->right.sym->type, &rval);
- }
-
- if (k1 == k_string || k2 == k_string)
- res = strcmp(str1, str2);
- else if (k1 == k_invalid || k2 == k_invalid) {
- if (e->type != E_EQUAL && e->type != E_UNEQUAL) {
- printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2);
- return no;
- }
- res = strcmp(str1, str2);
- } else if (k1 == k_unsigned || k2 == k_unsigned)
- res = (lval.u > rval.u) - (lval.u < rval.u);
- else /* if (k1 == k_signed && k2 == k_signed) */
- res = (lval.s > rval.s) - (lval.s < rval.s);
-
- switch(e->type) {
- case E_EQUAL:
- return res ? no : yes;
- case E_GEQ:
- return res >= 0 ? yes : no;
- case E_GTH:
- return res > 0 ? yes : no;
- case E_LEQ:
- return res <= 0 ? yes : no;
- case E_LTH:
- return res < 0 ? yes : no;
- case E_UNEQUAL:
- return res ? yes : no;
- default:
- printf("expr_calc_value: relation %d?\n", e->type);
- return no;
- }
-}
-
-static int expr_compare_type(enum expr_type t1, enum expr_type t2)
-{
- if (t1 == t2)
- return 0;
- switch (t1) {
- case E_LEQ:
- case E_LTH:
- case E_GEQ:
- case E_GTH:
- if (t2 == E_EQUAL || t2 == E_UNEQUAL)
- return 1;
- case E_EQUAL:
- case E_UNEQUAL:
- if (t2 == E_NOT)
- return 1;
- case E_NOT:
- if (t2 == E_AND)
- return 1;
- case E_AND:
- if (t2 == E_OR)
- return 1;
- case E_OR:
- if (t2 == E_LIST)
- return 1;
- case E_LIST:
- if (t2 == 0)
- return 1;
- default:
- return -1;
- }
- printf("[%dgt%d?]", t1, t2);
- return 0;
-}
-
-static inline struct expr *
-expr_get_leftmost_symbol(const struct expr *e)
-{
-
- if (e == NULL)
- return NULL;
-
- while (e->type != E_SYMBOL)
- e = e->left.expr;
-
- return expr_copy(e);
-}
-
-/*
- * Given expression `e1' and `e2', returns the leaf of the longest
- * sub-expression of `e1' not containing 'e2.
- */
-struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
-{
- struct expr *ret;
-
- switch (e1->type) {
- case E_OR:
- return expr_alloc_and(
- expr_simplify_unmet_dep(e1->left.expr, e2),
- expr_simplify_unmet_dep(e1->right.expr, e2));
- case E_AND: {
- struct expr *e;
- e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
- e = expr_eliminate_dups(e);
- ret = (!expr_eq(e, e1)) ? e1 : NULL;
- expr_free(e);
- break;
- }
- default:
- ret = e1;
- break;
- }
-
- return expr_get_leftmost_symbol(ret);
-}
-
-void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
-{
- if (!e) {
- fn(data, NULL, "y");
- return;
- }
-
- if (expr_compare_type(prevtoken, e->type) > 0)
- fn(data, NULL, "(");
- switch (e->type) {
- case E_SYMBOL:
- if (e->left.sym->name)
- fn(data, e->left.sym, e->left.sym->name);
- else
- fn(data, NULL, "<choice>");
- break;
- case E_NOT:
- fn(data, NULL, "!");
- expr_print(e->left.expr, fn, data, E_NOT);
- break;
- case E_EQUAL:
- if (e->left.sym->name)
- fn(data, e->left.sym, e->left.sym->name);
- else
- fn(data, NULL, "<choice>");
- fn(data, NULL, "=");
- fn(data, e->right.sym, e->right.sym->name);
- break;
- case E_LEQ:
- case E_LTH:
- if (e->left.sym->name)
- fn(data, e->left.sym, e->left.sym->name);
- else
- fn(data, NULL, "<choice>");
- fn(data, NULL, e->type == E_LEQ ? "<=" : "<");
- fn(data, e->right.sym, e->right.sym->name);
- break;
- case E_GEQ:
- case E_GTH:
- if (e->left.sym->name)
- fn(data, e->left.sym, e->left.sym->name);
- else
- fn(data, NULL, "<choice>");
- fn(data, NULL, e->type == E_GEQ ? ">=" : ">");
- fn(data, e->right.sym, e->right.sym->name);
- break;
- case E_UNEQUAL:
- if (e->left.sym->name)
- fn(data, e->left.sym, e->left.sym->name);
- else
- fn(data, NULL, "<choice>");
- fn(data, NULL, "!=");
- fn(data, e->right.sym, e->right.sym->name);
- break;
- case E_OR:
- expr_print(e->left.expr, fn, data, E_OR);
- fn(data, NULL, " || ");
- expr_print(e->right.expr, fn, data, E_OR);
- break;
- case E_AND:
- expr_print(e->left.expr, fn, data, E_AND);
- fn(data, NULL, " && ");
- expr_print(e->right.expr, fn, data, E_AND);
- break;
- case E_LIST:
- fn(data, e->right.sym, e->right.sym->name);
- if (e->left.expr) {
- fn(data, NULL, " ^ ");
- expr_print(e->left.expr, fn, data, E_LIST);
- }
- break;
- case E_RANGE:
- fn(data, NULL, "[");
- fn(data, e->left.sym, e->left.sym->name);
- fn(data, NULL, " ");
- fn(data, e->right.sym, e->right.sym->name);
- fn(data, NULL, "]");
- break;
- default:
- {
- char buf[32];
- sprintf(buf, "<unknown type %d>", e->type);
- fn(data, NULL, buf);
- break;
- }
- }
- if (expr_compare_type(prevtoken, e->type) > 0)
- fn(data, NULL, ")");
-}
-
-static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
-{
- xfwrite(str, strlen(str), 1, data);
-}
-
-void expr_fprint(struct expr *e, FILE *out)
-{
- expr_print(e, expr_print_file_helper, out, E_NONE);
-}
-
-static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
-{
- struct gstr *gs = (struct gstr*)data;
- const char *sym_str = NULL;
-
- if (sym)
- sym_str = sym_get_string_value(sym);
-
- if (gs->max_width) {
- unsigned extra_length = strlen(str);
- const char *last_cr = strrchr(gs->s, '\n');
- unsigned last_line_length;
-
- if (sym_str)
- extra_length += 4 + strlen(sym_str);
-
- if (!last_cr)
- last_cr = gs->s;
-
- last_line_length = strlen(gs->s) - (last_cr - gs->s);
-
- if ((last_line_length + extra_length) > gs->max_width)
- str_append(gs, "\\\n");
- }
-
- str_append(gs, str);
- if (sym && sym->type != S_UNKNOWN)
- str_printf(gs, " [=%s]", sym_str);
-}
-
-void expr_gstr_print(struct expr *e, struct gstr *gs)
-{
- expr_print(e, expr_print_gstr_helper, gs, E_NONE);
-}
diff --git a/backport/kconf/expr.h b/backport/kconf/expr.h
deleted file mode 100644
index a73f762c..00000000
--- a/backport/kconf/expr.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#ifndef EXPR_H
-#define EXPR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <assert.h>
-#include <stdio.h>
-#include "list.h"
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif
-
-struct file {
- struct file *next;
- struct file *parent;
- const char *name;
- int lineno;
-};
-
-typedef enum tristate {
- no, mod, yes
-} tristate;
-
-enum expr_type {
- E_NONE, E_OR, E_AND, E_NOT,
- E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ,
- E_LIST, E_SYMBOL, E_RANGE
-};
-
-union expr_data {
- struct expr *expr;
- struct symbol *sym;
-};
-
-struct expr {
- enum expr_type type;
- union expr_data left, right;
-};
-
-#define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
-#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
-#define EXPR_NOT(dep) (2-(dep))
-
-#define expr_list_for_each_sym(l, e, s) \
- for (e = (l); e && (s = e->right.sym); e = e->left.expr)
-
-struct expr_value {
- struct expr *expr;
- tristate tri;
-};
-
-struct symbol_value {
- void *val;
- tristate tri;
-};
-
-enum symbol_type {
- S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
-};
-
-/* enum values are used as index to symbol.def[] */
-enum {
- S_DEF_USER, /* main user value */
- S_DEF_AUTO, /* values read from auto.conf */
- S_DEF_DEF3, /* Reserved for UI usage */
- S_DEF_DEF4, /* Reserved for UI usage */
- S_DEF_COUNT
-};
-
-struct symbol {
- struct symbol *next;
- char *name;
- enum symbol_type type;
- struct symbol_value curr;
- struct symbol_value def[S_DEF_COUNT];
- tristate visible;
- int flags;
- struct property *prop;
- struct expr_value dir_dep;
- struct expr_value rev_dep;
- struct expr_value implied;
-};
-
-#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
-
-#define SYMBOL_CONST 0x0001 /* symbol is const */
-#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
-#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
-#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
-#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
-#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
-#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
-#define SYMBOL_CHANGED 0x0400 /* ? */
-#define SYMBOL_AUTO 0x1000 /* value from environment variable */
-#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
-#define SYMBOL_WARNED 0x8000 /* warning has been issued */
-
-/* Set when symbol.def[] is used */
-#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */
-#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */
-#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */
-#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
-#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
-
-/* choice values need to be set before calculating this symbol value */
-#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
-
-/* Set symbol to y if allnoconfig; used for symbols that hide others */
-#define SYMBOL_ALLNOCONFIG_Y 0x200000
-
-#define SYMBOL_MAXLENGTH 256
-#define SYMBOL_HASHSIZE 9973
-
-/* A property represent the config options that can be associated
- * with a config "symbol".
- * Sample:
- * config FOO
- * default y
- * prompt "foo prompt"
- * select BAR
- * config BAZ
- * int "BAZ Value"
- * range 1..255
- */
-enum prop_type {
- P_UNKNOWN,
- P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
- P_COMMENT, /* text associated with a comment */
- P_MENU, /* prompt associated with a menuconfig option */
- P_DEFAULT, /* default y */
- P_CHOICE, /* choice value */
- P_SELECT, /* select BAR */
- P_IMPLY, /* imply BAR */
- P_RANGE, /* range 7..100 (for a symbol) */
- P_ENV, /* value from environment variable */
- P_SYMBOL, /* where a symbol is defined */
-};
-
-struct property {
- struct property *next; /* next property - null if last */
- struct symbol *sym; /* the symbol for which the property is associated */
- enum prop_type type; /* type of property */
- const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
- struct expr_value visible;
- struct expr *expr; /* the optional conditional part of the property */
- struct menu *menu; /* the menu the property are associated with
- * valid for: P_SELECT, P_RANGE, P_CHOICE,
- * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
- struct file *file; /* what file was this property defined */
- int lineno; /* what lineno was this property defined */
-};
-
-#define for_all_properties(sym, st, tok) \
- for (st = sym->prop; st; st = st->next) \
- if (st->type == (tok))
-#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
-#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
-#define for_all_prompts(sym, st) \
- for (st = sym->prop; st; st = st->next) \
- if (st->text)
-
-struct menu {
- struct menu *next;
- struct menu *parent;
- struct menu *list;
- struct symbol *sym;
- struct property *prompt;
- struct expr *visibility;
- struct expr *dep;
- unsigned int flags;
- char *help;
- struct file *file;
- int lineno;
- void *data;
-};
-
-#define MENU_CHANGED 0x0001
-#define MENU_ROOT 0x0002
-
-struct jump_key {
- struct list_head entries;
- size_t offset;
- struct menu *target;
- int index;
-};
-
-#define JUMP_NB 9
-
-extern struct file *file_list;
-extern struct file *current_file;
-struct file *lookup_file(const char *name);
-
-extern struct symbol symbol_yes, symbol_no, symbol_mod;
-extern struct symbol *modules_sym;
-extern struct symbol *sym_defconfig_list;
-extern int cdebug;
-struct expr *expr_alloc_symbol(struct symbol *sym);
-struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
-struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
-struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
-struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
-struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
-struct expr *expr_copy(const struct expr *org);
-void expr_free(struct expr *e);
-void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
-tristate expr_calc_value(struct expr *e);
-struct expr *expr_trans_bool(struct expr *e);
-struct expr *expr_eliminate_dups(struct expr *e);
-struct expr *expr_transform(struct expr *e);
-int expr_contains_symbol(struct expr *dep, struct symbol *sym);
-bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
-struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
-struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
-
-void expr_fprint(struct expr *e, FILE *out);
-struct gstr; /* forward */
-void expr_gstr_print(struct expr *e, struct gstr *gs);
-
-static inline int expr_is_yes(struct expr *e)
-{
- return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
-}
-
-static inline int expr_is_no(struct expr *e)
-{
- return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* EXPR_H */
diff --git a/backport/kconf/list.h b/backport/kconf/list.h
deleted file mode 100644
index 2cf23f00..00000000
--- a/backport/kconf/list.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#ifndef LIST_H
-#define LIST_H
-
-/*
- * Copied from include/linux/...
- */
-
-#undef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-
-struct list_head {
- struct list_head *next, *prev;
-};
-
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
-
-/**
- * list_entry - get the struct for this entry
- * @ptr: the &struct list_head pointer.
- * @type: the type of the struct this is embedded in.
- * @member: the name of the list_head within the struct.
- */
-#define list_entry(ptr, type, member) \
- container_of(ptr, type, member)
-
-/**
- * list_for_each_entry - iterate over list of given type
- * @pos: the type * to use as a loop cursor.
- * @head: the head for your list.
- * @member: the name of the list_head within the struct.
- */
-#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-/**
- * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
- * @pos: the type * to use as a loop cursor.
- * @n: another type * to use as temporary storage
- * @head: the head for your list.
- * @member: the name of the list_head within the struct.
- */
-#define list_for_each_entry_safe(pos, n, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member), \
- n = list_entry(pos->member.next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = n, n = list_entry(n->member.next, typeof(*n), member))
-
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(const struct list_head *head)
-{
- return head->next == head;
-}
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *_new,
- struct list_head *prev,
- struct list_head *next)
-{
- next->prev = _new;
- _new->next = next;
- _new->prev = prev;
- prev->next = _new;
-}
-
-/**
- * list_add_tail - add a new entry
- * @new: new entry to be added
- * @head: list head to add it before
- *
- * Insert a new entry before the specified head.
- * This is useful for implementing queues.
- */
-static inline void list_add_tail(struct list_head *_new, struct list_head *head)
-{
- __list_add(_new, head->prev, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head *prev, struct list_head *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-#define LIST_POISON1 ((void *) 0x00100100)
-#define LIST_POISON2 ((void *) 0x00200200)
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty() on entry does not return true after this, the entry is
- * in an undefined state.
- */
-static inline void list_del(struct list_head *entry)
-{
- __list_del(entry->prev, entry->next);
- entry->next = (struct list_head*)LIST_POISON1;
- entry->prev = (struct list_head*)LIST_POISON2;
-}
-#endif
diff --git a/backport/kconf/lkc.h b/backport/kconf/lkc.h
deleted file mode 100644
index 91ca126e..00000000
--- a/backport/kconf/lkc.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#ifndef LKC_H
-#define LKC_H
-
-#include "expr.h"
-
-#ifndef KBUILD_NO_NLS
-# include <libintl.h>
-#else
-static inline const char *gettext(const char *txt) { return txt; }
-static inline void textdomain(const char *domainname) {}
-static inline void bindtextdomain(const char *name, const char *dir) {}
-static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "lkc_proto.h"
-
-#define SRCTREE "srctree"
-
-#ifndef PACKAGE
-#define PACKAGE "linux"
-#endif
-
-#define LOCALEDIR "/usr/share/locale"
-
-#define _(text) gettext(text)
-#define N_(text) (text)
-
-#ifndef CONFIG_
-#define CONFIG_ "CONFIG_"
-#endif
-static inline const char *CONFIG_prefix(void)
-{
- return getenv( "CONFIG_" ) ?: CONFIG_;
-}
-#undef CONFIG_
-#define CONFIG_ CONFIG_prefix()
-
-#define TF_COMMAND 0x0001
-#define TF_PARAM 0x0002
-#define TF_OPTION 0x0004
-
-enum conf_def_mode {
- def_default,
- def_yes,
- def_mod,
- def_no,
- def_random
-};
-
-#define T_OPT_MODULES 1
-#define T_OPT_DEFCONFIG_LIST 2
-#define T_OPT_ENV 3
-#define T_OPT_ALLNOCONFIG_Y 4
-
-struct kconf_id {
- int name;
- int token;
- unsigned int flags;
- enum symbol_type stype;
-};
-
-void zconfdump(FILE *out);
-void zconf_starthelp(void);
-FILE *zconf_fopen(const char *name);
-void zconf_initscan(const char *name);
-void zconf_nextfile(const char *name);
-int zconf_lineno(void);
-const char *zconf_curname(void);
-
-/* confdata.c */
-const char *conf_get_configname(void);
-const char *conf_get_autoconfig_name(void);
-char *conf_get_default_confname(void);
-void sym_set_change_count(int count);
-void sym_add_change_count(int count);
-bool conf_set_all_new_symbols(enum conf_def_mode mode);
-void set_all_choice_values(struct symbol *csym);
-
-/* confdata.c and expr.c */
-static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
-{
- assert(len != 0);
-
- if (fwrite(str, len, count, out) != count)
- fprintf(stderr, "Error in writing or end of file.\n");
-}
-
-/* menu.c */
-void _menu_init(void);
-void menu_warn(struct menu *menu, const char *fmt, ...);
-struct menu *menu_add_menu(void);
-void menu_end_menu(void);
-void menu_add_entry(struct symbol *sym);
-void menu_end_entry(void);
-void menu_add_dep(struct expr *dep);
-void menu_add_visibility(struct expr *dep);
-struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
-void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
-void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
-void menu_add_option(int token, char *arg);
-void menu_finalize(struct menu *parent);
-void menu_set_type(int type);
-
-/* util.c */
-struct file *file_lookup(const char *name);
-int file_write_dep(const char *name);
-void *xmalloc(size_t size);
-void *xcalloc(size_t nmemb, size_t size);
-
-struct gstr {
- size_t len;
- char *s;
- /*
- * when max_width is not zero long lines in string s (if any) get
- * wrapped not to exceed the max_width value
- */
- int max_width;
-};
-struct gstr str_new(void);
-void str_free(struct gstr *gs);
-void str_append(struct gstr *gs, const char *s);
-void str_printf(struct gstr *gs, const char *fmt, ...);
-const char *str_get(struct gstr *gs);
-
-/* symbol.c */
-extern struct expr *sym_env_list;
-
-void sym_init(void);
-void sym_clear_all_valid(void);
-struct symbol *sym_choice_default(struct symbol *sym);
-const char *sym_get_string_default(struct symbol *sym);
-struct symbol *sym_check_deps(struct symbol *sym);
-struct property *prop_alloc(enum prop_type type, struct symbol *sym);
-struct symbol *prop_get_symbol(struct property *prop);
-struct property *sym_get_env_prop(struct symbol *sym);
-
-static inline tristate sym_get_tristate_value(struct symbol *sym)
-{
- return sym->curr.tri;
-}
-
-
-static inline struct symbol *sym_get_choice_value(struct symbol *sym)
-{
- return (struct symbol *)sym->curr.val;
-}
-
-static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
-{
- return sym_set_tristate_value(chval, yes);
-}
-
-static inline bool sym_is_choice(struct symbol *sym)
-{
- return sym->flags & SYMBOL_CHOICE ? true : false;
-}
-
-static inline bool sym_is_choice_value(struct symbol *sym)
-{
- return sym->flags & SYMBOL_CHOICEVAL ? true : false;
-}
-
-static inline bool sym_is_optional(struct symbol *sym)
-{
- return sym->flags & SYMBOL_OPTIONAL ? true : false;
-}
-
-static inline bool sym_has_value(struct symbol *sym)
-{
- return sym->flags & SYMBOL_DEF_USER ? true : false;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LKC_H */
diff --git a/backport/kconf/lkc_proto.h b/backport/kconf/lkc_proto.h
deleted file mode 100644
index d5398718..00000000
--- a/backport/kconf/lkc_proto.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdarg.h>
-
-/* confdata.c */
-void conf_parse(const char *name);
-int conf_read(const char *name);
-int conf_read_simple(const char *name, int);
-int conf_write_defconfig(const char *name);
-int conf_write(const char *name);
-int conf_write_autoconf(void);
-bool conf_get_changed(void);
-void conf_set_changed_callback(void (*fn)(void));
-void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap));
-
-/* menu.c */
-extern struct menu rootmenu;
-
-bool menu_is_empty(struct menu *menu);
-bool menu_is_visible(struct menu *menu);
-bool menu_has_prompt(struct menu *menu);
-const char * menu_get_prompt(struct menu *menu);
-struct menu * menu_get_root_menu(struct menu *menu);
-struct menu * menu_get_parent_menu(struct menu *menu);
-bool menu_has_help(struct menu *menu);
-const char * menu_get_help(struct menu *menu);
-struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
-void menu_get_ext_help(struct menu *menu, struct gstr *help);
-
-/* symbol.c */
-extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
-
-struct symbol * sym_lookup(const char *name, int flags);
-struct symbol * sym_find(const char *name);
-const char * sym_expand_string_value(const char *in);
-const char * sym_escape_string_value(const char *in);
-struct symbol ** sym_re_search(const char *pattern);
-const char * sym_type_name(enum symbol_type type);
-void sym_calc_value(struct symbol *sym);
-enum symbol_type sym_get_type(struct symbol *sym);
-bool sym_tristate_within_range(struct symbol *sym,tristate tri);
-bool sym_set_tristate_value(struct symbol *sym,tristate tri);
-tristate sym_toggle_tristate_value(struct symbol *sym);
-bool sym_string_valid(struct symbol *sym, const char *newval);
-bool sym_string_within_range(struct symbol *sym, const char *str);
-bool sym_set_string_value(struct symbol *sym, const char *newval);
-bool sym_is_changable(struct symbol *sym);
-struct property * sym_get_choice_prop(struct symbol *sym);
-const char * sym_get_string_value(struct symbol *sym);
-
-const char * prop_get_type_name(enum prop_type type);
-
-/* expr.c */
-void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken);
diff --git a/backport/kconf/lxdialog/check-lxdialog.sh b/backport/kconf/lxdialog/check-lxdialog.sh
deleted file mode 100755
index 5075ebf2..00000000
--- a/backport/kconf/lxdialog/check-lxdialog.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-# Check ncurses compatibility
-
-# What library to link
-ldflags()
-{
- pkg-config --libs ncursesw 2>/dev/null && exit
- pkg-config --libs ncurses 2>/dev/null && exit
- for ext in so a dll.a dylib ; do
- for lib in ncursesw ncurses curses ; do
- $cc -print-file-name=lib${lib}.${ext} | grep -q /
- if [ $? -eq 0 ]; then
- echo "-l${lib}"
- exit
- fi
- done
- done
- exit 1
-}
-
-# Where is ncurses.h?
-ccflags()
-{
- if pkg-config --cflags ncursesw 2>/dev/null; then
- echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
- elif pkg-config --cflags ncurses 2>/dev/null; then
- echo '-DCURSES_LOC="<ncurses.h>"'
- elif [ -f /usr/include/ncursesw/curses.h ]; then
- echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
- echo ' -DNCURSES_WIDECHAR=1'
- elif [ -f /usr/include/ncurses/ncurses.h ]; then
- echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
- elif [ -f /usr/include/ncurses/curses.h ]; then
- echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
- elif [ -f /usr/include/ncurses.h ]; then
- echo '-DCURSES_LOC="<ncurses.h>"'
- else
- echo '-DCURSES_LOC="<curses.h>"'
- fi
-}
-
-# Temp file, try to clean up after us
-tmp=.lxdialog.tmp
-trap "rm -f $tmp" 0 1 2 3 15
-
-# Check if we can link to ncurses
-check() {
- $cc -x c - -o $tmp 2>/dev/null <<'EOF'
-#include CURSES_LOC
-main() {}
-EOF
- if [ $? != 0 ]; then
- echo " *** Unable to find the ncurses libraries or the" 1>&2
- echo " *** required header files." 1>&2
- echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
- echo " *** " 1>&2
- echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
- echo " *** " 1>&2
- exit 1
- fi
-}
-
-usage() {
- printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
-}
-
-if [ $# -eq 0 ]; then
- usage
- exit 1
-fi
-
-cc=""
-case "$1" in
- "-check")
- shift
- cc="$@"
- check
- ;;
- "-ccflags")
- ccflags
- ;;
- "-ldflags")
- shift
- cc="$@"
- ldflags
- ;;
- "*")
- usage
- exit 1
- ;;
-esac
diff --git a/backport/kconf/lxdialog/checklist.c b/backport/kconf/lxdialog/checklist.c
deleted file mode 100644
index 8d016faa..00000000
--- a/backport/kconf/lxdialog/checklist.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * checklist.c -- implements the checklist box
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
- * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "dialog.h"
-
-static int list_width, check_x, item_x;
-
-/*
- * Print list item
- */
-static void print_item(WINDOW * win, int choice, int selected)
-{
- int i;
- char *list_item = malloc(list_width + 1);
-
- strncpy(list_item, item_str(), list_width - item_x);
- list_item[list_width - item_x] = '\0';
-
- /* Clear 'residue' of last item */
- wattrset(win, dlg.menubox.atr);
- wmove(win, choice, 0);
- for (i = 0; i < list_width; i++)
- waddch(win, ' ');
-
- wmove(win, choice, check_x);
- wattrset(win, selected ? dlg.check_selected.atr
- : dlg.check.atr);
- if (!item_is_tag(':'))
- wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
-
- wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
- mvwaddch(win, choice, item_x, list_item[0]);
- wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
- waddstr(win, list_item + 1);
- if (selected) {
- wmove(win, choice, check_x + 1);
- wrefresh(win);
- }
- free(list_item);
-}
-
-/*
- * Print the scroll indicators.
- */
-static void print_arrows(WINDOW * win, int choice, int item_no, int scroll,
- int y, int x, int height)
-{
- wmove(win, y, x);
-
- if (scroll > 0) {
- wattrset(win, dlg.uarrow.atr);
- waddch(win, ACS_UARROW);
- waddstr(win, "(-)");
- } else {
- wattrset(win, dlg.menubox.atr);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- }
-
- y = y + height + 1;
- wmove(win, y, x);
-
- if ((height < item_no) && (scroll + choice < item_no - 1)) {
- wattrset(win, dlg.darrow.atr);
- waddch(win, ACS_DARROW);
- waddstr(win, "(+)");
- } else {
- wattrset(win, dlg.menubox_border.atr);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- }
-}
-
-/*
- * Display the termination buttons
- */
-static void print_buttons(WINDOW * dialog, int height, int width, int selected)
-{
- int x = width / 2 - 11;
- int y = height - 2;
-
- print_button(dialog, gettext("Select"), y, x, selected == 0);
- print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
-
- wmove(dialog, y, x + 1 + 14 * selected);
- wrefresh(dialog);
-}
-
-/*
- * Display a dialog box with a list of options that can be turned on or off
- * in the style of radiolist (only one option turned on at a time).
- */
-int dialog_checklist(const char *title, const char *prompt, int height,
- int width, int list_height)
-{
- int i, x, y, box_x, box_y;
- int key = 0, button = 0, choice = 0, scroll = 0, max_choice;
- WINDOW *dialog, *list;
-
- /* which item to highlight */
- item_foreach() {
- if (item_is_tag('X'))
- choice = item_n();
- if (item_is_selected()) {
- choice = item_n();
- break;
- }
- }
-
-do_resize:
- if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
- return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
- return -ERRDISPLAYTOOSMALL;
-
- max_choice = MIN(list_height, item_count());
-
- /* center dialog box on screen */
- x = (getmaxx(stdscr) - width) / 2;
- y = (getmaxy(stdscr) - height) / 2;
-
- draw_shadow(stdscr, y, x, height, width);
-
- dialog = newwin(height, width, y, x);
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width,
- dlg.dialog.atr, dlg.border.atr);
- wattrset(dialog, dlg.border.atr);
- mvwaddch(dialog, height - 3, 0, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dlg.dialog.atr);
- waddch(dialog, ACS_RTEE);
-
- print_title(dialog, title, width);
-
- wattrset(dialog, dlg.dialog.atr);
- print_autowrap(dialog, prompt, width - 2, 1, 3);
-
- list_width = width - 6;
- box_y = height - list_height - 5;
- box_x = (width - list_width) / 2 - 1;
-
- /* create new window for the list */
- list = subwin(dialog, list_height, list_width, y + box_y + 1,
- x + box_x + 1);
-
- keypad(list, TRUE);
-
- /* draw a box around the list items */
- draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
- dlg.menubox_border.atr, dlg.menubox.atr);
-
- /* Find length of longest item in order to center checklist */
- check_x = 0;
- item_foreach()
- check_x = MAX(check_x, strlen(item_str()) + 4);
- check_x = MIN(check_x, list_width);
-
- check_x = (list_width - check_x) / 2;
- item_x = check_x + 4;
-
- if (choice >= list_height) {
- scroll = choice - list_height + 1;
- choice -= scroll;
- }
-
- /* Print the list */
- for (i = 0; i < max_choice; i++) {
- item_set(scroll + i);
- print_item(list, i, i == choice);
- }
-
- print_arrows(dialog, choice, item_count(), scroll,
- box_y, box_x + check_x + 5, list_height);
-
- print_buttons(dialog, height, width, 0);
-
- wnoutrefresh(dialog);
- wnoutrefresh(list);
- doupdate();
-
- while (key != KEY_ESC) {
- key = wgetch(dialog);
-
- for (i = 0; i < max_choice; i++) {
- item_set(i + scroll);
- if (toupper(key) == toupper(item_str()[0]))
- break;
- }
-
- if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
- key == '+' || key == '-') {
- if (key == KEY_UP || key == '-') {
- if (!choice) {
- if (!scroll)
- continue;
- /* Scroll list down */
- if (list_height > 1) {
- /* De-highlight current first item */
- item_set(scroll);
- print_item(list, 0, FALSE);
- scrollok(list, TRUE);
- wscrl(list, -1);
- scrollok(list, FALSE);
- }
- scroll--;
- item_set(scroll);
- print_item(list, 0, TRUE);
- print_arrows(dialog, choice, item_count(),
- scroll, box_y, box_x + check_x + 5, list_height);
-
- wnoutrefresh(dialog);
- wrefresh(list);
-
- continue; /* wait for another key press */
- } else
- i = choice - 1;
- } else if (key == KEY_DOWN || key == '+') {
- if (choice == max_choice - 1) {
- if (scroll + choice >= item_count() - 1)
- continue;
- /* Scroll list up */
- if (list_height > 1) {
- /* De-highlight current last item before scrolling up */
- item_set(scroll + max_choice - 1);
- print_item(list,
- max_choice - 1,
- FALSE);
- scrollok(list, TRUE);
- wscrl(list, 1);
- scrollok(list, FALSE);
- }
- scroll++;
- item_set(scroll + max_choice - 1);
- print_item(list, max_choice - 1, TRUE);
-
- print_arrows(dialog, choice, item_count(),
- scroll, box_y, box_x + check_x + 5, list_height);
-
- wnoutrefresh(dialog);
- wrefresh(list);
-
- continue; /* wait for another key press */
- } else
- i = choice + 1;
- }
- if (i != choice) {
- /* De-highlight current item */
- item_set(scroll + choice);
- print_item(list, choice, FALSE);
- /* Highlight new item */
- choice = i;
- item_set(scroll + choice);
- print_item(list, choice, TRUE);
- wnoutrefresh(dialog);
- wrefresh(list);
- }
- continue; /* wait for another key press */
- }
- switch (key) {
- case 'H':
- case 'h':
- case '?':
- button = 1;
- /* fall-through */
- case 'S':
- case 's':
- case ' ':
- case '\n':
- item_foreach()
- item_set_selected(0);
- item_set(scroll + choice);
- item_set_selected(1);
- delwin(list);
- delwin(dialog);
- return button;
- case TAB:
- case KEY_LEFT:
- case KEY_RIGHT:
- button = ((key == KEY_LEFT ? --button : ++button) < 0)
- ? 1 : (button > 1 ? 0 : button);
-
- print_buttons(dialog, height, width, button);
- wrefresh(dialog);
- break;
- case 'X':
- case 'x':
- key = KEY_ESC;
- break;
- case KEY_ESC:
- key = on_key_esc(dialog);
- break;
- case KEY_RESIZE:
- delwin(list);
- delwin(dialog);
- on_key_resize();
- goto do_resize;
- }
-
- /* Now, update everything... */
- doupdate();
- }
- delwin(list);
- delwin(dialog);
- return key; /* ESC pressed */
-}
diff --git a/backport/kconf/lxdialog/dialog.h b/backport/kconf/lxdialog/dialog.h
deleted file mode 100644
index fcffd5b4..00000000
--- a/backport/kconf/lxdialog/dialog.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * dialog.h -- common declarations for all dialog modules
- *
- * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#ifndef KBUILD_NO_NLS
-# include <libintl.h>
-#else
-# define gettext(Msgid) ((const char *) (Msgid))
-#endif
-
-#ifdef __sun__
-#define CURS_MACROS
-#endif
-#include CURSES_LOC
-
-/*
- * Colors in ncurses 1.9.9e do not work properly since foreground and
- * background colors are OR'd rather than separately masked. This version
- * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
- * with standard curses. The simplest fix (to make this work with standard
- * curses) uses the wbkgdset() function, not used in the original hack.
- * Turn it off if we're building with 1.9.9e, since it just confuses things.
- */
-#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
-#define OLD_NCURSES 1
-#undef wbkgdset
-#define wbkgdset(w,p) /*nothing */
-#else
-#define OLD_NCURSES 0
-#endif
-
-#define TR(params) _tracef params
-
-#define KEY_ESC 27
-#define TAB 9
-#define MAX_LEN 2048
-#define BUF_SIZE (10*1024)
-#define MIN(x,y) (x < y ? x : y)
-#define MAX(x,y) (x > y ? x : y)
-
-#ifndef ACS_ULCORNER
-#define ACS_ULCORNER '+'
-#endif
-#ifndef ACS_LLCORNER
-#define ACS_LLCORNER '+'
-#endif
-#ifndef ACS_URCORNER
-#define ACS_URCORNER '+'
-#endif
-#ifndef ACS_LRCORNER
-#define ACS_LRCORNER '+'
-#endif
-#ifndef ACS_HLINE
-#define ACS_HLINE '-'
-#endif
-#ifndef ACS_VLINE
-#define ACS_VLINE '|'
-#endif
-#ifndef ACS_LTEE
-#define ACS_LTEE '+'
-#endif
-#ifndef ACS_RTEE
-#define ACS_RTEE '+'
-#endif
-#ifndef ACS_UARROW
-#define ACS_UARROW '^'
-#endif
-#ifndef ACS_DARROW
-#define ACS_DARROW 'v'
-#endif
-
-/* error return codes */
-#define ERRDISPLAYTOOSMALL (KEY_MAX + 1)
-
-/*
- * Color definitions
- */
-struct dialog_color {
- chtype atr; /* Color attribute */
- int fg; /* foreground */
- int bg; /* background */
- int hl; /* highlight this item */
-};
-
-struct subtitle_list {
- struct subtitle_list *next;
- const char *text;
-};
-
-struct dialog_info {
- const char *backtitle;
- struct subtitle_list *subtitles;
- struct dialog_color screen;
- struct dialog_color shadow;
- struct dialog_color dialog;
- struct dialog_color title;
- struct dialog_color border;
- struct dialog_color button_active;
- struct dialog_color button_inactive;
- struct dialog_color button_key_active;
- struct dialog_color button_key_inactive;
- struct dialog_color button_label_active;
- struct dialog_color button_label_inactive;
- struct dialog_color inputbox;
- struct dialog_color inputbox_border;
- struct dialog_color searchbox;
- struct dialog_color searchbox_title;
- struct dialog_color searchbox_border;
- struct dialog_color position_indicator;
- struct dialog_color menubox;
- struct dialog_color menubox_border;
- struct dialog_color item;
- struct dialog_color item_selected;
- struct dialog_color tag;
- struct dialog_color tag_selected;
- struct dialog_color tag_key;
- struct dialog_color tag_key_selected;
- struct dialog_color check;
- struct dialog_color check_selected;
- struct dialog_color uarrow;
- struct dialog_color darrow;
-};
-
-/*
- * Global variables
- */
-extern struct dialog_info dlg;
-extern char dialog_input_result[];
-extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */
-
-/*
- * Function prototypes
- */
-
-/* item list as used by checklist and menubox */
-void item_reset(void);
-void item_make(const char *fmt, ...);
-void item_add_str(const char *fmt, ...);
-void item_set_tag(char tag);
-void item_set_data(void *p);
-void item_set_selected(int val);
-int item_activate_selected(void);
-void *item_data(void);
-char item_tag(void);
-
-/* item list manipulation for lxdialog use */
-#define MAXITEMSTR 200
-struct dialog_item {
- char str[MAXITEMSTR]; /* prompt displayed */
- char tag;
- void *data; /* pointer to menu item - used by menubox+checklist */
- int selected; /* Set to 1 by dialog_*() function if selected. */
-};
-
-/* list of lialog_items */
-struct dialog_list {
- struct dialog_item node;
- struct dialog_list *next;
-};
-
-extern struct dialog_list *item_cur;
-extern struct dialog_list item_nil;
-extern struct dialog_list *item_head;
-
-int item_count(void);
-void item_set(int n);
-int item_n(void);
-const char *item_str(void);
-int item_is_selected(void);
-int item_is_tag(char tag);
-#define item_foreach() \
- for (item_cur = item_head ? item_head: item_cur; \
- item_cur && (item_cur != &item_nil); item_cur = item_cur->next)
-
-/* generic key handlers */
-int on_key_esc(WINDOW *win);
-int on_key_resize(void);
-
-/* minimum (re)size values */
-#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
-#define CHECKLIST_WIDTH_MIN 6
-#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
-#define INPUTBOX_WIDTH_MIN 2
-#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
-#define MENUBOX_WIDTH_MIN 65
-#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
-#define TEXTBOX_WIDTH_MIN 8
-#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
-#define YESNO_WIDTH_MIN 4
-#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
-#define WINDOW_WIDTH_MIN 80
-
-int init_dialog(const char *backtitle);
-void set_dialog_backtitle(const char *backtitle);
-void set_dialog_subtitles(struct subtitle_list *subtitles);
-void end_dialog(int x, int y);
-void attr_clear(WINDOW * win, int height, int width, chtype attr);
-void dialog_clear(void);
-void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
-void print_button(WINDOW * win, const char *label, int y, int x, int selected);
-void print_title(WINDOW *dialog, const char *title, int width);
-void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box,
- chtype border);
-void draw_shadow(WINDOW * win, int y, int x, int height, int width);
-
-int first_alpha(const char *string, const char *exempt);
-int dialog_yesno(const char *title, const char *prompt, int height, int width);
-int dialog_msgbox(const char *title, const char *prompt, int height,
- int width, int pause);
-
-
-typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void
- *_data);
-int dialog_textbox(const char *title, char *tbuf, int initial_height,
- int initial_width, int *keys, int *_vscroll, int *_hscroll,
- update_text_fn update_text, void *data);
-int dialog_menu(const char *title, const char *prompt,
- const void *selected, int *s_scroll);
-int dialog_checklist(const char *title, const char *prompt, int height,
- int width, int list_height);
-int dialog_inputbox(const char *title, const char *prompt, int height,
- int width, const char *init);
-
-/*
- * This is the base for fictitious keys, which activate
- * the buttons.
- *
- * Mouse-generated keys are the following:
- * -- the first 32 are used as numbers, in addition to '0'-'9'
- * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
- * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
- */
-#define M_EVENT (KEY_MAX+1)
diff --git a/backport/kconf/lxdialog/inputbox.c b/backport/kconf/lxdialog/inputbox.c
deleted file mode 100644
index d58de1dc..00000000
--- a/backport/kconf/lxdialog/inputbox.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * inputbox.c -- implements the input box
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "dialog.h"
-
-char dialog_input_result[MAX_LEN + 1];
-
-/*
- * Print the termination buttons
- */
-static void print_buttons(WINDOW * dialog, int height, int width, int selected)
-{
- int x = width / 2 - 11;
- int y = height - 2;
-
- print_button(dialog, gettext(" Ok "), y, x, selected == 0);
- print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
-
- wmove(dialog, y, x + 1 + 14 * selected);
- wrefresh(dialog);
-}
-
-/*
- * Display a dialog box for inputing a string
- */
-int dialog_inputbox(const char *title, const char *prompt, int height, int width,
- const char *init)
-{
- int i, x, y, box_y, box_x, box_width;
- int input_x = 0, key = 0, button = -1;
- int show_x, len, pos;
- char *instr = dialog_input_result;
- WINDOW *dialog;
-
- if (!init)
- instr[0] = '\0';
- else
- strcpy(instr, init);
-
-do_resize:
- if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
- return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
- return -ERRDISPLAYTOOSMALL;
-
- /* center dialog box on screen */
- x = (getmaxx(stdscr) - width) / 2;
- y = (getmaxy(stdscr) - height) / 2;
-
- draw_shadow(stdscr, y, x, height, width);
-
- dialog = newwin(height, width, y, x);
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width,
- dlg.dialog.atr, dlg.border.atr);
- wattrset(dialog, dlg.border.atr);
- mvwaddch(dialog, height - 3, 0, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dlg.dialog.atr);
- waddch(dialog, ACS_RTEE);
-
- print_title(dialog, title, width);
-
- wattrset(dialog, dlg.dialog.atr);
- print_autowrap(dialog, prompt, width - 2, 1, 3);
-
- /* Draw the input field box */
- box_width = width - 6;
- getyx(dialog, y, x);
- box_y = y + 2;
- box_x = (width - box_width) / 2;
- draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
- dlg.dialog.atr, dlg.border.atr);
-
- print_buttons(dialog, height, width, 0);
-
- /* Set up the initial value */
- wmove(dialog, box_y, box_x);
- wattrset(dialog, dlg.inputbox.atr);
-
- len = strlen(instr);
- pos = len;
-
- if (len >= box_width) {
- show_x = len - box_width + 1;
- input_x = box_width - 1;
- for (i = 0; i < box_width - 1; i++)
- waddch(dialog, instr[show_x + i]);
- } else {
- show_x = 0;
- input_x = len;
- waddstr(dialog, instr);
- }
-
- wmove(dialog, box_y, box_x + input_x);
-
- wrefresh(dialog);
-
- while (key != KEY_ESC) {
- key = wgetch(dialog);
-
- if (button == -1) { /* Input box selected */
- switch (key) {
- case TAB:
- case KEY_UP:
- case KEY_DOWN:
- break;
- case KEY_BACKSPACE:
- case 127:
- if (pos) {
- wattrset(dialog, dlg.inputbox.atr);
- if (input_x == 0) {
- show_x--;
- } else
- input_x--;
-
- if (pos < len) {
- for (i = pos - 1; i < len; i++) {
- instr[i] = instr[i+1];
- }
- }
-
- pos--;
- len--;
- instr[len] = '\0';
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++) {
- if (!instr[show_x + i]) {
- waddch(dialog, ' ');
- break;
- }
- waddch(dialog, instr[show_x + i]);
- }
- wmove(dialog, box_y, input_x + box_x);
- wrefresh(dialog);
- }
- continue;
- case KEY_LEFT:
- if (pos > 0) {
- if (input_x > 0) {
- wmove(dialog, box_y, --input_x + box_x);
- } else if (input_x == 0) {
- show_x--;
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++) {
- if (!instr[show_x + i]) {
- waddch(dialog, ' ');
- break;
- }
- waddch(dialog, instr[show_x + i]);
- }
- wmove(dialog, box_y, box_x);
- }
- pos--;
- }
- continue;
- case KEY_RIGHT:
- if (pos < len) {
- if (input_x < box_width - 1) {
- wmove(dialog, box_y, ++input_x + box_x);
- } else if (input_x == box_width - 1) {
- show_x++;
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++) {
- if (!instr[show_x + i]) {
- waddch(dialog, ' ');
- break;
- }
- waddch(dialog, instr[show_x + i]);
- }
- wmove(dialog, box_y, input_x + box_x);
- }
- pos++;
- }
- continue;
- default:
- if (key < 0x100 && isprint(key)) {
- if (len < MAX_LEN) {
- wattrset(dialog, dlg.inputbox.atr);
- if (pos < len) {
- for (i = len; i > pos; i--)
- instr[i] = instr[i-1];
- instr[pos] = key;
- } else {
- instr[len] = key;
- }
- pos++;
- len++;
- instr[len] = '\0';
-
- if (input_x == box_width - 1) {
- show_x++;
- } else {
- input_x++;
- }
-
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++) {
- if (!instr[show_x + i]) {
- waddch(dialog, ' ');
- break;
- }
- waddch(dialog, instr[show_x + i]);
- }
- wmove(dialog, box_y, input_x + box_x);
- wrefresh(dialog);
- } else
- flash(); /* Alarm user about overflow */
- continue;
- }
- }
- }
- switch (key) {
- case 'O':
- case 'o':
- delwin(dialog);
- return 0;
- case 'H':
- case 'h':
- delwin(dialog);
- return 1;
- case KEY_UP:
- case KEY_LEFT:
- switch (button) {
- case -1:
- button = 1; /* Indicates "Help" button is selected */
- print_buttons(dialog, height, width, 1);
- break;
- case 0:
- button = -1; /* Indicates input box is selected */
- print_buttons(dialog, height, width, 0);
- wmove(dialog, box_y, box_x + input_x);
- wrefresh(dialog);
- break;
- case 1:
- button = 0; /* Indicates "OK" button is selected */
- print_buttons(dialog, height, width, 0);
- break;
- }
- break;
- case TAB:
- case KEY_DOWN:
- case KEY_RIGHT:
- switch (button) {
- case -1:
- button = 0; /* Indicates "OK" button is selected */
- print_buttons(dialog, height, width, 0);
- break;
- case 0:
- button = 1; /* Indicates "Help" button is selected */
- print_buttons(dialog, height, width, 1);
- break;
- case 1:
- button = -1; /* Indicates input box is selected */
- print_buttons(dialog, height, width, 0);
- wmove(dialog, box_y, box_x + input_x);
- wrefresh(dialog);
- break;
- }
- break;
- case ' ':
- case '\n':
- delwin(dialog);
- return (button == -1 ? 0 : button);
- case 'X':
- case 'x':
- key = KEY_ESC;
- break;
- case KEY_ESC:
- key = on_key_esc(dialog);
- break;
- case KEY_RESIZE:
- delwin(dialog);
- on_key_resize();
- goto do_resize;
- }
- }
-
- delwin(dialog);
- return KEY_ESC; /* ESC pressed */
-}
diff --git a/backport/kconf/lxdialog/menubox.c b/backport/kconf/lxdialog/menubox.c
deleted file mode 100644
index 11ae9ad7..00000000
--- a/backport/kconf/lxdialog/menubox.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * menubox.c -- implements the menu box
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * Changes by Clifford Wolf (god@clifford.at)
- *
- * [ 1998-06-13 ]
- *
- * *) A bugfix for the Page-Down problem
- *
- * *) Formerly when I used Page Down and Page Up, the cursor would be set
- * to the first position in the menu box. Now lxdialog is a bit
- * smarter and works more like other menu systems (just have a look at
- * it).
- *
- * *) Formerly if I selected something my scrolling would be broken because
- * lxdialog is re-invoked by the Menuconfig shell script, can't
- * remember the last scrolling position, and just sets it so that the
- * cursor is at the bottom of the box. Now it writes the temporary file
- * lxdialog.scrltmp which contains this information. The file is
- * deleted by lxdialog if the user leaves a submenu or enters a new
- * one, but it would be nice if Menuconfig could make another "rm -f"
- * just to be sure. Just try it out - you will recognise a difference!
- *
- * [ 1998-06-14 ]
- *
- * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files
- * and menus change their size on the fly.
- *
- * *) If for some reason the last scrolling position is not saved by
- * lxdialog, it sets the scrolling so that the selected item is in the
- * middle of the menu box, not at the bottom.
- *
- * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
- * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus.
- * This fixes a bug in Menuconfig where using ' ' to descend into menus
- * would leave mis-synchronized lxdialog.scrltmp files lying around,
- * fscanf would read in 'scroll', and eventually that value would get used.
- */
-
-#include "dialog.h"
-
-static int menu_width, item_x;
-
-/*
- * Print menu item
- */
-static void do_print_item(WINDOW * win, const char *item, int line_y,
- int selected, int hotkey)
-{
- int j;
- char *menu_item = malloc(menu_width + 1);
-
- strncpy(menu_item, item, menu_width - item_x);
- menu_item[menu_width - item_x] = '\0';
- j = first_alpha(menu_item, "YyNnMmHh");
-
- /* Clear 'residue' of last item */
- wattrset(win, dlg.menubox.atr);
- wmove(win, line_y, 0);
-#if OLD_NCURSES
- {
- int i;
- for (i = 0; i < menu_width; i++)
- waddch(win, ' ');
- }
-#else
- wclrtoeol(win);
-#endif
- wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
- mvwaddstr(win, line_y, item_x, menu_item);
- if (hotkey) {
- wattrset(win, selected ? dlg.tag_key_selected.atr
- : dlg.tag_key.atr);
- mvwaddch(win, line_y, item_x + j, menu_item[j]);
- }
- if (selected) {
- wmove(win, line_y, item_x + 1);
- }
- free(menu_item);
- wrefresh(win);
-}
-
-#define print_item(index, choice, selected) \
-do { \
- item_set(index); \
- do_print_item(menu, item_str(), choice, selected, !item_is_tag(':')); \
-} while (0)
-
-/*
- * Print the scroll indicators.
- */
-static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
- int height)
-{
- int cur_y, cur_x;
-
- getyx(win, cur_y, cur_x);
-
- wmove(win, y, x);
-
- if (scroll > 0) {
- wattrset(win, dlg.uarrow.atr);
- waddch(win, ACS_UARROW);
- waddstr(win, "(-)");
- } else {
- wattrset(win, dlg.menubox.atr);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- }
-
- y = y + height + 1;
- wmove(win, y, x);
- wrefresh(win);
-
- if ((height < item_no) && (scroll + height < item_no)) {
- wattrset(win, dlg.darrow.atr);
- waddch(win, ACS_DARROW);
- waddstr(win, "(+)");
- } else {
- wattrset(win, dlg.menubox_border.atr);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- waddch(win, ACS_HLINE);
- }
-
- wmove(win, cur_y, cur_x);
- wrefresh(win);
-}
-
-/*
- * Display the termination buttons.
- */
-static void print_buttons(WINDOW * win, int height, int width, int selected)
-{
- int x = width / 2 - 28;
- int y = height - 2;
-
- print_button(win, gettext("Select"), y, x, selected == 0);
- print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
- print_button(win, gettext(" Help "), y, x + 24, selected == 2);
- print_button(win, gettext(" Save "), y, x + 36, selected == 3);
- print_button(win, gettext(" Load "), y, x + 48, selected == 4);
-
- wmove(win, y, x + 1 + 12 * selected);
- wrefresh(win);
-}
-
-/* scroll up n lines (n may be negative) */
-static void do_scroll(WINDOW *win, int *scroll, int n)
-{
- /* Scroll menu up */
- scrollok(win, TRUE);
- wscrl(win, n);
- scrollok(win, FALSE);
- *scroll = *scroll + n;
- wrefresh(win);
-}
-
-/*
- * Display a menu for choosing among a number of options
- */
-int dialog_menu(const char *title, const char *prompt,
- const void *selected, int *s_scroll)
-{
- int i, j, x, y, box_x, box_y;
- int height, width, menu_height;
- int key = 0, button = 0, scroll = 0, choice = 0;
- int first_item = 0, max_choice;
- WINDOW *dialog, *menu;
-
-do_resize:
- height = getmaxy(stdscr);
- width = getmaxx(stdscr);
- if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
- return -ERRDISPLAYTOOSMALL;
-
- height -= 4;
- width -= 5;
- menu_height = height - 10;
-
- max_choice = MIN(menu_height, item_count());
-
- /* center dialog box on screen */
- x = (getmaxx(stdscr) - width) / 2;
- y = (getmaxy(stdscr) - height) / 2;
-
- draw_shadow(stdscr, y, x, height, width);
-
- dialog = newwin(height, width, y, x);
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width,
- dlg.dialog.atr, dlg.border.atr);
- wattrset(dialog, dlg.border.atr);
- mvwaddch(dialog, height - 3, 0, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dlg.dialog.atr);
- wbkgdset(dialog, dlg.dialog.atr & A_COLOR);
- waddch(dialog, ACS_RTEE);
-
- print_title(dialog, title, width);
-
- wattrset(dialog, dlg.dialog.atr);
- print_autowrap(dialog, prompt, width - 2, 1, 3);
-
- menu_width = width - 6;
- box_y = height - menu_height - 5;
- box_x = (width - menu_width) / 2 - 1;
-
- /* create new window for the menu */
- menu = subwin(dialog, menu_height, menu_width,
- y + box_y + 1, x + box_x + 1);
- keypad(menu, TRUE);
-
- /* draw a box around the menu items */
- draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
- dlg.menubox_border.atr, dlg.menubox.atr);
-
- if (menu_width >= 80)
- item_x = (menu_width - 70) / 2;
- else
- item_x = 4;
-
- /* Set choice to default item */
- item_foreach()
- if (selected && (selected == item_data()))
- choice = item_n();
- /* get the saved scroll info */
- scroll = *s_scroll;
- if ((scroll <= choice) && (scroll + max_choice > choice) &&
- (scroll >= 0) && (scroll + max_choice <= item_count())) {
- first_item = scroll;
- choice = choice - scroll;
- } else {
- scroll = 0;
- }
- if ((choice >= max_choice)) {
- if (choice >= item_count() - max_choice / 2)
- scroll = first_item = item_count() - max_choice;
- else
- scroll = first_item = choice - max_choice / 2;
- choice = choice - scroll;
- }
-
- /* Print the menu */
- for (i = 0; i < max_choice; i++) {
- print_item(first_item + i, i, i == choice);
- }
-
- wnoutrefresh(menu);
-
- print_arrows(dialog, item_count(), scroll,
- box_y, box_x + item_x + 1, menu_height);
-
- print_buttons(dialog, height, width, 0);
- wmove(menu, choice, item_x + 1);
- wrefresh(menu);
-
- while (key != KEY_ESC) {
- key = wgetch(menu);
-
- if (key < 256 && isalpha(key))
- key = tolower(key);
-
- if (strchr("ynmh", key))
- i = max_choice;
- else {
- for (i = choice + 1; i < max_choice; i++) {
- item_set(scroll + i);
- j = first_alpha(item_str(), "YyNnMmHh");
- if (key == tolower(item_str()[j]))
- break;
- }
- if (i == max_choice)
- for (i = 0; i < max_choice; i++) {
- item_set(scroll + i);
- j = first_alpha(item_str(), "YyNnMmHh");
- if (key == tolower(item_str()[j]))
- break;
- }
- }
-
- if (item_count() != 0 &&
- (i < max_choice ||
- key == KEY_UP || key == KEY_DOWN ||
- key == '-' || key == '+' ||
- key == KEY_PPAGE || key == KEY_NPAGE)) {
- /* Remove highligt of current item */
- print_item(scroll + choice, choice, FALSE);
-
- if (key == KEY_UP || key == '-') {
- if (choice < 2 && scroll) {
- /* Scroll menu down */
- do_scroll(menu, &scroll, -1);
-
- print_item(scroll, 0, FALSE);
- } else
- choice = MAX(choice - 1, 0);
-
- } else if (key == KEY_DOWN || key == '+') {
- print_item(scroll+choice, choice, FALSE);
-
- if ((choice > max_choice - 3) &&
- (scroll + max_choice < item_count())) {
- /* Scroll menu up */
- do_scroll(menu, &scroll, 1);
-
- print_item(scroll+max_choice - 1,
- max_choice - 1, FALSE);
- } else
- choice = MIN(choice + 1, max_choice - 1);
-
- } else if (key == KEY_PPAGE) {
- scrollok(menu, TRUE);
- for (i = 0; (i < max_choice); i++) {
- if (scroll > 0) {
- do_scroll(menu, &scroll, -1);
- print_item(scroll, 0, FALSE);
- } else {
- if (choice > 0)
- choice--;
- }
- }
-
- } else if (key == KEY_NPAGE) {
- for (i = 0; (i < max_choice); i++) {
- if (scroll + max_choice < item_count()) {
- do_scroll(menu, &scroll, 1);
- print_item(scroll+max_choice-1,
- max_choice - 1, FALSE);
- } else {
- if (choice + 1 < max_choice)
- choice++;
- }
- }
- } else
- choice = i;
-
- print_item(scroll + choice, choice, TRUE);
-
- print_arrows(dialog, item_count(), scroll,
- box_y, box_x + item_x + 1, menu_height);
-
- wnoutrefresh(dialog);
- wrefresh(menu);
-
- continue; /* wait for another key press */
- }
-
- switch (key) {
- case KEY_LEFT:
- case TAB:
- case KEY_RIGHT:
- button = ((key == KEY_LEFT ? --button : ++button) < 0)
- ? 4 : (button > 4 ? 0 : button);
-
- print_buttons(dialog, height, width, button);
- wrefresh(menu);
- break;
- case ' ':
- case 's':
- case 'y':
- case 'n':
- case 'm':
- case '/':
- case 'h':
- case '?':
- case 'z':
- case '\n':
- /* save scroll info */
- *s_scroll = scroll;
- delwin(menu);
- delwin(dialog);
- item_set(scroll + choice);
- item_set_selected(1);
- switch (key) {
- case 'h':
- case '?':
- return 2;
- case 's':
- case 'y':
- return 5;
- case 'n':
- return 6;
- case 'm':
- return 7;
- case ' ':
- return 8;
- case '/':
- return 9;
- case 'z':
- return 10;
- case '\n':
- return button;
- }
- return 0;
- case 'e':
- case 'x':
- key = KEY_ESC;
- break;
- case KEY_ESC:
- key = on_key_esc(menu);
- break;
- case KEY_RESIZE:
- on_key_resize();
- delwin(menu);
- delwin(dialog);
- goto do_resize;
- }
- }
- delwin(menu);
- delwin(dialog);
- return key; /* ESC pressed */
-}
diff --git a/backport/kconf/lxdialog/textbox.c b/backport/kconf/lxdialog/textbox.c
deleted file mode 100644
index 1773319b..00000000
--- a/backport/kconf/lxdialog/textbox.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * textbox.c -- implements the text box
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "dialog.h"
-
-static void back_lines(int n);
-static void print_page(WINDOW *win, int height, int width, update_text_fn
- update_text, void *data);
-static void print_line(WINDOW *win, int row, int width);
-static char *get_line(void);
-static void print_position(WINDOW * win);
-
-static int hscroll;
-static int begin_reached, end_reached, page_length;
-static char *buf;
-static char *page;
-
-/*
- * refresh window content
- */
-static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
- int cur_y, int cur_x, update_text_fn update_text,
- void *data)
-{
- print_page(box, boxh, boxw, update_text, data);
- print_position(dialog);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
-}
-
-
-/*
- * Display text from a file in a dialog box.
- *
- * keys is a null-terminated array
- * update_text() may not add or remove any '\n' or '\0' in tbuf
- */
-int dialog_textbox(const char *title, char *tbuf, int initial_height,
- int initial_width, int *keys, int *_vscroll, int *_hscroll,
- update_text_fn update_text, void *data)
-{
- int i, x, y, cur_x, cur_y, key = 0;
- int height, width, boxh, boxw;
- WINDOW *dialog, *box;
- bool done = false;
-
- begin_reached = 1;
- end_reached = 0;
- page_length = 0;
- hscroll = 0;
- buf = tbuf;
- page = buf; /* page is pointer to start of page to be displayed */
-
- if (_vscroll && *_vscroll) {
- begin_reached = 0;
-
- for (i = 0; i < *_vscroll; i++)
- get_line();
- }
- if (_hscroll)
- hscroll = *_hscroll;
-
-do_resize:
- getmaxyx(stdscr, height, width);
- if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
- return -ERRDISPLAYTOOSMALL;
- if (initial_height != 0)
- height = initial_height;
- else
- if (height > 4)
- height -= 4;
- else
- height = 0;
- if (initial_width != 0)
- width = initial_width;
- else
- if (width > 5)
- width -= 5;
- else
- width = 0;
-
- /* center dialog box on screen */
- x = (getmaxx(stdscr) - width) / 2;
- y = (getmaxy(stdscr) - height) / 2;
-
- draw_shadow(stdscr, y, x, height, width);
-
- dialog = newwin(height, width, y, x);
- keypad(dialog, TRUE);
-
- /* Create window for box region, used for scrolling text */
- boxh = height - 4;
- boxw = width - 2;
- box = subwin(dialog, boxh, boxw, y + 1, x + 1);
- wattrset(box, dlg.dialog.atr);
- wbkgdset(box, dlg.dialog.atr & A_COLOR);
-
- keypad(box, TRUE);
-
- /* register the new window, along with its borders */
- draw_box(dialog, 0, 0, height, width,
- dlg.dialog.atr, dlg.border.atr);
-
- wattrset(dialog, dlg.border.atr);
- mvwaddch(dialog, height - 3, 0, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dlg.dialog.atr);
- wbkgdset(dialog, dlg.dialog.atr & A_COLOR);
- waddch(dialog, ACS_RTEE);
-
- print_title(dialog, title, width);
-
- print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE);
- wnoutrefresh(dialog);
- getyx(dialog, cur_y, cur_x); /* Save cursor position */
-
- /* Print first page of text */
- attr_clear(box, boxh, boxw, dlg.dialog.atr);
- refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text,
- data);
-
- while (!done) {
- key = wgetch(dialog);
- switch (key) {
- case 'E': /* Exit */
- case 'e':
- case 'X':
- case 'x':
- case 'q':
- case '\n':
- done = true;
- break;
- case 'g': /* First page */
- case KEY_HOME:
- if (!begin_reached) {
- begin_reached = 1;
- page = buf;
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x, update_text,
- data);
- }
- break;
- case 'G': /* Last page */
- case KEY_END:
-
- end_reached = 1;
- /* point to last char in buf */
- page = buf + strlen(buf);
- back_lines(boxh);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case 'K': /* Previous line */
- case 'k':
- case KEY_UP:
- if (begin_reached)
- break;
-
- back_lines(page_length + 1);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case 'B': /* Previous page */
- case 'b':
- case 'u':
- case KEY_PPAGE:
- if (begin_reached)
- break;
- back_lines(page_length + boxh);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case 'J': /* Next line */
- case 'j':
- case KEY_DOWN:
- if (end_reached)
- break;
-
- back_lines(page_length - 1);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case KEY_NPAGE: /* Next page */
- case ' ':
- case 'd':
- if (end_reached)
- break;
-
- begin_reached = 0;
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case '0': /* Beginning of line */
- case 'H': /* Scroll left */
- case 'h':
- case KEY_LEFT:
- if (hscroll <= 0)
- break;
-
- if (key == '0')
- hscroll = 0;
- else
- hscroll--;
- /* Reprint current page to scroll horizontally */
- back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case 'L': /* Scroll right */
- case 'l':
- case KEY_RIGHT:
- if (hscroll >= MAX_LEN)
- break;
- hscroll++;
- /* Reprint current page to scroll horizontally */
- back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw, cur_y,
- cur_x, update_text, data);
- break;
- case KEY_ESC:
- if (on_key_esc(dialog) == KEY_ESC)
- done = true;
- break;
- case KEY_RESIZE:
- back_lines(height);
- delwin(box);
- delwin(dialog);
- on_key_resize();
- goto do_resize;
- default:
- for (i = 0; keys[i]; i++) {
- if (key == keys[i]) {
- done = true;
- break;
- }
- }
- }
- }
- delwin(box);
- delwin(dialog);
- if (_vscroll) {
- const char *s;
-
- s = buf;
- *_vscroll = 0;
- back_lines(page_length);
- while (s < page && (s = strchr(s, '\n'))) {
- (*_vscroll)++;
- s++;
- }
- }
- if (_hscroll)
- *_hscroll = hscroll;
- return key;
-}
-
-/*
- * Go back 'n' lines in text. Called by dialog_textbox().
- * 'page' will be updated to point to the desired line in 'buf'.
- */
-static void back_lines(int n)
-{
- int i;
-
- begin_reached = 0;
- /* Go back 'n' lines */
- for (i = 0; i < n; i++) {
- if (*page == '\0') {
- if (end_reached) {
- end_reached = 0;
- continue;
- }
- }
- if (page == buf) {
- begin_reached = 1;
- return;
- }
- page--;
- do {
- if (page == buf) {
- begin_reached = 1;
- return;
- }
- page--;
- } while (*page != '\n');
- page++;
- }
-}
-
-/*
- * Print a new page of text.
- */
-static void print_page(WINDOW *win, int height, int width, update_text_fn
- update_text, void *data)
-{
- int i, passed_end = 0;
-
- if (update_text) {
- char *end;
-
- for (i = 0; i < height; i++)
- get_line();
- end = page;
- back_lines(height);
- update_text(buf, page - buf, end - buf, data);
- }
-
- page_length = 0;
- for (i = 0; i < height; i++) {
- print_line(win, i, width);
- if (!passed_end)
- page_length++;
- if (end_reached && !passed_end)
- passed_end = 1;
- }
- wnoutrefresh(win);
-}
-
-/*
- * Print a new line of text.
- */
-static void print_line(WINDOW * win, int row, int width)
-{
- char *line;
-
- line = get_line();
- line += MIN(strlen(line), hscroll); /* Scroll horizontally */
- wmove(win, row, 0); /* move cursor to correct line */
- waddch(win, ' ');
- waddnstr(win, line, MIN(strlen(line), width - 2));
-
- /* Clear 'residue' of previous line */
-#if OLD_NCURSES
- {
- int x = getcurx(win);
- int i;
- for (i = 0; i < width - x; i++)
- waddch(win, ' ');
- }
-#else
- wclrtoeol(win);
-#endif
-}
-
-/*
- * Return current line of text. Called by dialog_textbox() and print_line().
- * 'page' should point to start of current line before calling, and will be
- * updated to point to start of next line.
- */
-static char *get_line(void)
-{
- int i = 0;
- static char line[MAX_LEN + 1];
-
- end_reached = 0;
- while (*page != '\n') {
- if (*page == '\0') {
- end_reached = 1;
- break;
- } else if (i < MAX_LEN)
- line[i++] = *(page++);
- else {
- /* Truncate lines longer than MAX_LEN characters */
- if (i == MAX_LEN)
- line[i++] = '\0';
- page++;
- }
- }
- if (i <= MAX_LEN)
- line[i] = '\0';
- if (!end_reached)
- page++; /* move past '\n' */
-
- return line;
-}
-
-/*
- * Print current position
- */
-static void print_position(WINDOW * win)
-{
- int percent;
-
- wattrset(win, dlg.position_indicator.atr);
- wbkgdset(win, dlg.position_indicator.atr & A_COLOR);
- percent = (page - buf) * 100 / strlen(buf);
- wmove(win, getmaxy(win) - 3, getmaxx(win) - 9);
- wprintw(win, "(%3d%%)", percent);
-}
diff --git a/backport/kconf/lxdialog/util.c b/backport/kconf/lxdialog/util.c
deleted file mode 100644
index f7abdeb9..00000000
--- a/backport/kconf/lxdialog/util.c
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- * util.c
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <stdarg.h>
-
-#include "dialog.h"
-
-/* Needed in signal handler in mconf.c */
-int saved_x, saved_y;
-
-struct dialog_info dlg;
-
-static void set_mono_theme(void)
-{
- dlg.screen.atr = A_NORMAL;
- dlg.shadow.atr = A_NORMAL;
- dlg.dialog.atr = A_NORMAL;
- dlg.title.atr = A_BOLD;
- dlg.border.atr = A_NORMAL;
- dlg.button_active.atr = A_REVERSE;
- dlg.button_inactive.atr = A_DIM;
- dlg.button_key_active.atr = A_REVERSE;
- dlg.button_key_inactive.atr = A_BOLD;
- dlg.button_label_active.atr = A_REVERSE;
- dlg.button_label_inactive.atr = A_NORMAL;
- dlg.inputbox.atr = A_NORMAL;
- dlg.inputbox_border.atr = A_NORMAL;
- dlg.searchbox.atr = A_NORMAL;
- dlg.searchbox_title.atr = A_BOLD;
- dlg.searchbox_border.atr = A_NORMAL;
- dlg.position_indicator.atr = A_BOLD;
- dlg.menubox.atr = A_NORMAL;
- dlg.menubox_border.atr = A_NORMAL;
- dlg.item.atr = A_NORMAL;
- dlg.item_selected.atr = A_REVERSE;
- dlg.tag.atr = A_BOLD;
- dlg.tag_selected.atr = A_REVERSE;
- dlg.tag_key.atr = A_BOLD;
- dlg.tag_key_selected.atr = A_REVERSE;
- dlg.check.atr = A_BOLD;
- dlg.check_selected.atr = A_REVERSE;
- dlg.uarrow.atr = A_BOLD;
- dlg.darrow.atr = A_BOLD;
-}
-
-#define DLG_COLOR(dialog, f, b, h) \
-do { \
- dlg.dialog.fg = (f); \
- dlg.dialog.bg = (b); \
- dlg.dialog.hl = (h); \
-} while (0)
-
-static void set_classic_theme(void)
-{
- DLG_COLOR(screen, COLOR_CYAN, COLOR_BLUE, true);
- DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, true);
- DLG_COLOR(dialog, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(title, COLOR_YELLOW, COLOR_WHITE, true);
- DLG_COLOR(border, COLOR_WHITE, COLOR_WHITE, true);
- DLG_COLOR(button_active, COLOR_WHITE, COLOR_BLUE, true);
- DLG_COLOR(button_inactive, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(button_key_active, COLOR_WHITE, COLOR_BLUE, true);
- DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_WHITE, false);
- DLG_COLOR(button_label_active, COLOR_YELLOW, COLOR_BLUE, true);
- DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_WHITE, true);
- DLG_COLOR(inputbox, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(inputbox_border, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(searchbox, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_WHITE, true);
- DLG_COLOR(searchbox_border, COLOR_WHITE, COLOR_WHITE, true);
- DLG_COLOR(position_indicator, COLOR_YELLOW, COLOR_WHITE, true);
- DLG_COLOR(menubox, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(menubox_border, COLOR_WHITE, COLOR_WHITE, true);
- DLG_COLOR(item, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(item_selected, COLOR_WHITE, COLOR_BLUE, true);
- DLG_COLOR(tag, COLOR_YELLOW, COLOR_WHITE, true);
- DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_BLUE, true);
- DLG_COLOR(tag_key, COLOR_YELLOW, COLOR_WHITE, true);
- DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_BLUE, true);
- DLG_COLOR(check, COLOR_BLACK, COLOR_WHITE, false);
- DLG_COLOR(check_selected, COLOR_WHITE, COLOR_BLUE, true);
- DLG_COLOR(uarrow, COLOR_GREEN, COLOR_WHITE, true);
- DLG_COLOR(darrow, COLOR_GREEN, COLOR_WHITE, true);
-}
-
-static void set_blackbg_theme(void)
-{
- DLG_COLOR(screen, COLOR_RED, COLOR_BLACK, true);
- DLG_COLOR(shadow, COLOR_BLACK, COLOR_BLACK, false);
- DLG_COLOR(dialog, COLOR_WHITE, COLOR_BLACK, false);
- DLG_COLOR(title, COLOR_RED, COLOR_BLACK, false);
- DLG_COLOR(border, COLOR_BLACK, COLOR_BLACK, true);
-
- DLG_COLOR(button_active, COLOR_YELLOW, COLOR_RED, false);
- DLG_COLOR(button_inactive, COLOR_YELLOW, COLOR_BLACK, false);
- DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_RED, true);
- DLG_COLOR(button_key_inactive, COLOR_RED, COLOR_BLACK, false);
- DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_RED, false);
- DLG_COLOR(button_label_inactive, COLOR_BLACK, COLOR_BLACK, true);
-
- DLG_COLOR(inputbox, COLOR_YELLOW, COLOR_BLACK, false);
- DLG_COLOR(inputbox_border, COLOR_YELLOW, COLOR_BLACK, false);
-
- DLG_COLOR(searchbox, COLOR_YELLOW, COLOR_BLACK, false);
- DLG_COLOR(searchbox_title, COLOR_YELLOW, COLOR_BLACK, true);
- DLG_COLOR(searchbox_border, COLOR_BLACK, COLOR_BLACK, true);
-
- DLG_COLOR(position_indicator, COLOR_RED, COLOR_BLACK, false);
-
- DLG_COLOR(menubox, COLOR_YELLOW, COLOR_BLACK, false);
- DLG_COLOR(menubox_border, COLOR_BLACK, COLOR_BLACK, true);
-
- DLG_COLOR(item, COLOR_WHITE, COLOR_BLACK, false);
- DLG_COLOR(item_selected, COLOR_WHITE, COLOR_RED, false);
-
- DLG_COLOR(tag, COLOR_RED, COLOR_BLACK, false);
- DLG_COLOR(tag_selected, COLOR_YELLOW, COLOR_RED, true);
- DLG_COLOR(tag_key, COLOR_RED, COLOR_BLACK, false);
- DLG_COLOR(tag_key_selected, COLOR_YELLOW, COLOR_RED, true);
-
- DLG_COLOR(check, COLOR_YELLOW, COLOR_BLACK, false);
- DLG_COLOR(check_selected, COLOR_YELLOW, COLOR_RED, true);
-
- DLG_COLOR(uarrow, COLOR_RED, COLOR_BLACK, false);
- DLG_COLOR(darrow, COLOR_RED, COLOR_BLACK, false);
-}
-
-static void set_bluetitle_theme(void)
-{
- set_classic_theme();
- DLG_COLOR(title, COLOR_BLUE, COLOR_WHITE, true);
- DLG_COLOR(button_key_active, COLOR_YELLOW, COLOR_BLUE, true);
- DLG_COLOR(button_label_active, COLOR_WHITE, COLOR_BLUE, true);
- DLG_COLOR(searchbox_title, COLOR_BLUE, COLOR_WHITE, true);
- DLG_COLOR(position_indicator, COLOR_BLUE, COLOR_WHITE, true);
- DLG_COLOR(tag, COLOR_BLUE, COLOR_WHITE, true);
- DLG_COLOR(tag_key, COLOR_BLUE, COLOR_WHITE, true);
-
-}
-
-/*
- * Select color theme
- */
-static int set_theme(const char *theme)
-{
- int use_color = 1;
- if (!theme)
- set_bluetitle_theme();
- else if (strcmp(theme, "classic") == 0)
- set_classic_theme();
- else if (strcmp(theme, "bluetitle") == 0)
- set_bluetitle_theme();
- else if (strcmp(theme, "blackbg") == 0)
- set_blackbg_theme();
- else if (strcmp(theme, "mono") == 0)
- use_color = 0;
-
- return use_color;
-}
-
-static void init_one_color(struct dialog_color *color)
-{
- static int pair = 0;
-
- pair++;
- init_pair(pair, color->fg, color->bg);
- if (color->hl)
- color->atr = A_BOLD | COLOR_PAIR(pair);
- else
- color->atr = COLOR_PAIR(pair);
-}
-
-static void init_dialog_colors(void)
-{
- init_one_color(&dlg.screen);
- init_one_color(&dlg.shadow);
- init_one_color(&dlg.dialog);
- init_one_color(&dlg.title);
- init_one_color(&dlg.border);
- init_one_color(&dlg.button_active);
- init_one_color(&dlg.button_inactive);
- init_one_color(&dlg.button_key_active);
- init_one_color(&dlg.button_key_inactive);
- init_one_color(&dlg.button_label_active);
- init_one_color(&dlg.button_label_inactive);
- init_one_color(&dlg.inputbox);
- init_one_color(&dlg.inputbox_border);
- init_one_color(&dlg.searchbox);
- init_one_color(&dlg.searchbox_title);
- init_one_color(&dlg.searchbox_border);
- init_one_color(&dlg.position_indicator);
- init_one_color(&dlg.menubox);
- init_one_color(&dlg.menubox_border);
- init_one_color(&dlg.item);
- init_one_color(&dlg.item_selected);
- init_one_color(&dlg.tag);
- init_one_color(&dlg.tag_selected);
- init_one_color(&dlg.tag_key);
- init_one_color(&dlg.tag_key_selected);
- init_one_color(&dlg.check);
- init_one_color(&dlg.check_selected);
- init_one_color(&dlg.uarrow);
- init_one_color(&dlg.darrow);
-}
-
-/*
- * Setup for color display
- */
-static void color_setup(const char *theme)
-{
- int use_color;
-
- use_color = set_theme(theme);
- if (use_color && has_colors()) {
- start_color();
- init_dialog_colors();
- } else
- set_mono_theme();
-}
-
-/*
- * Set window to attribute 'attr'
- */
-void attr_clear(WINDOW * win, int height, int width, chtype attr)
-{
- int i, j;
-
- wattrset(win, attr);
- for (i = 0; i < height; i++) {
- wmove(win, i, 0);
- for (j = 0; j < width; j++)
- waddch(win, ' ');
- }
- touchwin(win);
-}
-
-void dialog_clear(void)
-{
- int lines, columns;
-
- lines = getmaxy(stdscr);
- columns = getmaxx(stdscr);
-
- attr_clear(stdscr, lines, columns, dlg.screen.atr);
- /* Display background title if it exists ... - SLH */
- if (dlg.backtitle != NULL) {
- int i, len = 0, skip = 0;
- struct subtitle_list *pos;
-
- wattrset(stdscr, dlg.screen.atr);
- mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
-
- for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
- /* 3 is for the arrow and spaces */
- len += strlen(pos->text) + 3;
- }
-
- wmove(stdscr, 1, 1);
- if (len > columns - 2) {
- const char *ellipsis = "[...] ";
- waddstr(stdscr, ellipsis);
- skip = len - (columns - 2 - strlen(ellipsis));
- }
-
- for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
- if (skip == 0)
- waddch(stdscr, ACS_RARROW);
- else
- skip--;
-
- if (skip == 0)
- waddch(stdscr, ' ');
- else
- skip--;
-
- if (skip < strlen(pos->text)) {
- waddstr(stdscr, pos->text + skip);
- skip = 0;
- } else
- skip -= strlen(pos->text);
-
- if (skip == 0)
- waddch(stdscr, ' ');
- else
- skip--;
- }
-
- for (i = len + 1; i < columns - 1; i++)
- waddch(stdscr, ACS_HLINE);
- }
- wnoutrefresh(stdscr);
-}
-
-/*
- * Do some initialization for dialog
- */
-int init_dialog(const char *backtitle)
-{
- int height, width;
-
- initscr(); /* Init curses */
-
- /* Get current cursor position for signal handler in mconf.c */
- getyx(stdscr, saved_y, saved_x);
-
- getmaxyx(stdscr, height, width);
- if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
- endwin();
- return -ERRDISPLAYTOOSMALL;
- }
-
- dlg.backtitle = backtitle;
- color_setup(getenv("MENUCONFIG_COLOR"));
-
- keypad(stdscr, TRUE);
- cbreak();
- noecho();
- dialog_clear();
-
- return 0;
-}
-
-void set_dialog_backtitle(const char *backtitle)
-{
- dlg.backtitle = backtitle;
-}
-
-void set_dialog_subtitles(struct subtitle_list *subtitles)
-{
- dlg.subtitles = subtitles;
-}
-
-/*
- * End using dialog functions.
- */
-void end_dialog(int x, int y)
-{
- /* move cursor back to original position */
- move(y, x);
- refresh();
- endwin();
-}
-
-/* Print the title of the dialog. Center the title and truncate
- * tile if wider than dialog (- 2 chars).
- **/
-void print_title(WINDOW *dialog, const char *title, int width)
-{
- if (title) {
- int tlen = MIN(width - 2, strlen(title));
- wattrset(dialog, dlg.title.atr);
- mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' ');
- mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen);
- waddch(dialog, ' ');
- }
-}
-
-/*
- * Print a string of text in a window, automatically wrap around to the
- * next line if the string is too long to fit on one line. Newline
- * characters '\n' are propperly processed. We start on a new line
- * if there is no room for at least 4 nonblanks following a double-space.
- */
-void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
-{
- int newl, cur_x, cur_y;
- int prompt_len, room, wlen;
- char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
-
- strcpy(tempstr, prompt);
-
- prompt_len = strlen(tempstr);
-
- if (prompt_len <= width - x * 2) { /* If prompt is short */
- wmove(win, y, (width - prompt_len) / 2);
- waddstr(win, tempstr);
- } else {
- cur_x = x;
- cur_y = y;
- newl = 1;
- word = tempstr;
- while (word && *word) {
- sp = strpbrk(word, "\n ");
- if (sp && *sp == '\n')
- newline_separator = sp;
-
- if (sp)
- *sp++ = 0;
-
- /* Wrap to next line if either the word does not fit,
- or it is the first word of a new sentence, and it is
- short, and the next word does not fit. */
- room = width - cur_x;
- wlen = strlen(word);
- if (wlen > room ||
- (newl && wlen < 4 && sp
- && wlen + 1 + strlen(sp) > room
- && (!(sp2 = strpbrk(sp, "\n "))
- || wlen + 1 + (sp2 - sp) > room))) {
- cur_y++;
- cur_x = x;
- }
- wmove(win, cur_y, cur_x);
- waddstr(win, word);
- getyx(win, cur_y, cur_x);
-
- /* Move to the next line if the word separator was a newline */
- if (newline_separator) {
- cur_y++;
- cur_x = x;
- newline_separator = 0;
- } else
- cur_x++;
-
- if (sp && *sp == ' ') {
- cur_x++; /* double space */
- while (*++sp == ' ') ;
- newl = 1;
- } else
- newl = 0;
- word = sp;
- }
- }
-}
-
-/*
- * Print a button
- */
-void print_button(WINDOW * win, const char *label, int y, int x, int selected)
-{
- int i, temp;
-
- wmove(win, y, x);
- wattrset(win, selected ? dlg.button_active.atr
- : dlg.button_inactive.atr);
- waddstr(win, "<");
- temp = strspn(label, " ");
- label += temp;
- wattrset(win, selected ? dlg.button_label_active.atr
- : dlg.button_label_inactive.atr);
- for (i = 0; i < temp; i++)
- waddch(win, ' ');
- wattrset(win, selected ? dlg.button_key_active.atr
- : dlg.button_key_inactive.atr);
- waddch(win, label[0]);
- wattrset(win, selected ? dlg.button_label_active.atr
- : dlg.button_label_inactive.atr);
- waddstr(win, (char *)label + 1);
- wattrset(win, selected ? dlg.button_active.atr
- : dlg.button_inactive.atr);
- waddstr(win, ">");
- wmove(win, y, x + temp + 1);
-}
-
-/*
- * Draw a rectangular box with line drawing characters
- */
-void
-draw_box(WINDOW * win, int y, int x, int height, int width,
- chtype box, chtype border)
-{
- int i, j;
-
- wattrset(win, 0);
- for (i = 0; i < height; i++) {
- wmove(win, y + i, x);
- for (j = 0; j < width; j++)
- if (!i && !j)
- waddch(win, border | ACS_ULCORNER);
- else if (i == height - 1 && !j)
- waddch(win, border | ACS_LLCORNER);
- else if (!i && j == width - 1)
- waddch(win, box | ACS_URCORNER);
- else if (i == height - 1 && j == width - 1)
- waddch(win, box | ACS_LRCORNER);
- else if (!i)
- waddch(win, border | ACS_HLINE);
- else if (i == height - 1)
- waddch(win, box | ACS_HLINE);
- else if (!j)
- waddch(win, border | ACS_VLINE);
- else if (j == width - 1)
- waddch(win, box | ACS_VLINE);
- else
- waddch(win, box | ' ');
- }
-}
-
-/*
- * Draw shadows along the right and bottom edge to give a more 3D look
- * to the boxes
- */
-void draw_shadow(WINDOW * win, int y, int x, int height, int width)
-{
- int i;
-
- if (has_colors()) { /* Whether terminal supports color? */
- wattrset(win, dlg.shadow.atr);
- wmove(win, y + height, x + 2);
- for (i = 0; i < width; i++)
- waddch(win, winch(win) & A_CHARTEXT);
- for (i = y + 1; i < y + height + 1; i++) {
- wmove(win, i, x + width);
- waddch(win, winch(win) & A_CHARTEXT);
- waddch(win, winch(win) & A_CHARTEXT);
- }
- wnoutrefresh(win);
- }
-}
-
-/*
- * Return the position of the first alphabetic character in a string.
- */
-int first_alpha(const char *string, const char *exempt)
-{
- int i, in_paren = 0, c;
-
- for (i = 0; i < strlen(string); i++) {
- c = tolower(string[i]);
-
- if (strchr("<[(", c))
- ++in_paren;
- if (strchr(">])", c) && in_paren > 0)
- --in_paren;
-
- if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0)
- return i;
- }
-
- return 0;
-}
-
-/*
- * ncurses uses ESC to detect escaped char sequences. This resutl in
- * a small timeout before ESC is actually delivered to the application.
- * lxdialog suggest <ESC> <ESC> which is correctly translated to two
- * times esc. But then we need to ignore the second esc to avoid stepping
- * out one menu too much. Filter away all escaped key sequences since
- * keypad(FALSE) turn off ncurses support for escape sequences - and thats
- * needed to make notimeout() do as expected.
- */
-int on_key_esc(WINDOW *win)
-{
- int key;
- int key2;
- int key3;
-
- nodelay(win, TRUE);
- keypad(win, FALSE);
- key = wgetch(win);
- key2 = wgetch(win);
- do {
- key3 = wgetch(win);
- } while (key3 != ERR);
- nodelay(win, FALSE);
- keypad(win, TRUE);
- if (key == KEY_ESC && key2 == ERR)
- return KEY_ESC;
- else if (key != ERR && key != KEY_ESC && key2 == ERR)
- ungetch(key);
-
- return -1;
-}
-
-/* redraw screen in new size */
-int on_key_resize(void)
-{
- dialog_clear();
- return KEY_RESIZE;
-}
-
-struct dialog_list *item_cur;
-struct dialog_list item_nil;
-struct dialog_list *item_head;
-
-void item_reset(void)
-{
- struct dialog_list *p, *next;
-
- for (p = item_head; p; p = next) {
- next = p->next;
- free(p);
- }
- item_head = NULL;
- item_cur = &item_nil;
-}
-
-void item_make(const char *fmt, ...)
-{
- va_list ap;
- struct dialog_list *p = malloc(sizeof(*p));
-
- if (item_head)
- item_cur->next = p;
- else
- item_head = p;
- item_cur = p;
- memset(p, 0, sizeof(*p));
-
- va_start(ap, fmt);
- vsnprintf(item_cur->node.str, sizeof(item_cur->node.str), fmt, ap);
- va_end(ap);
-}
-
-void item_add_str(const char *fmt, ...)
-{
- va_list ap;
- size_t avail;
-
- avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str);
-
- va_start(ap, fmt);
- vsnprintf(item_cur->node.str + strlen(item_cur->node.str),
- avail, fmt, ap);
- item_cur->node.str[sizeof(item_cur->node.str) - 1] = '\0';
- va_end(ap);
-}
-
-void item_set_tag(char tag)
-{
- item_cur->node.tag = tag;
-}
-void item_set_data(void *ptr)
-{
- item_cur->node.data = ptr;
-}
-
-void item_set_selected(int val)
-{
- item_cur->node.selected = val;
-}
-
-int item_activate_selected(void)
-{
- item_foreach()
- if (item_is_selected())
- return 1;
- return 0;
-}
-
-void *item_data(void)
-{
- return item_cur->node.data;
-}
-
-char item_tag(void)
-{
- return item_cur->node.tag;
-}
-
-int item_count(void)
-{
- int n = 0;
- struct dialog_list *p;
-
- for (p = item_head; p; p = p->next)
- n++;
- return n;
-}
-
-void item_set(int n)
-{
- int i = 0;
- item_foreach()
- if (i++ == n)
- return;
-}
-
-int item_n(void)
-{
- int n = 0;
- struct dialog_list *p;
-
- for (p = item_head; p; p = p->next) {
- if (p == item_cur)
- return n;
- n++;
- }
- return 0;
-}
-
-const char *item_str(void)
-{
- return item_cur->node.str;
-}
-
-int item_is_selected(void)
-{
- return (item_cur->node.selected != 0);
-}
-
-int item_is_tag(char tag)
-{
- return (item_cur->node.tag == tag);
-}
diff --git a/backport/kconf/lxdialog/yesno.c b/backport/kconf/lxdialog/yesno.c
deleted file mode 100644
index 676fb2f8..00000000
--- a/backport/kconf/lxdialog/yesno.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * yesno.c -- implements the yes/no box
- *
- * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "dialog.h"
-
-/*
- * Display termination buttons
- */
-static void print_buttons(WINDOW * dialog, int height, int width, int selected)
-{
- int x = width / 2 - 10;
- int y = height - 2;
-
- print_button(dialog, gettext(" Yes "), y, x, selected == 0);
- print_button(dialog, gettext(" No "), y, x + 13, selected == 1);
-
- wmove(dialog, y, x + 1 + 13 * selected);
- wrefresh(dialog);
-}
-
-/*
- * Display a dialog box with two buttons - Yes and No
- */
-int dialog_yesno(const char *title, const char *prompt, int height, int width)
-{
- int i, x, y, key = 0, button = 0;
- WINDOW *dialog;
-
-do_resize:
- if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
- return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
- return -ERRDISPLAYTOOSMALL;
-
- /* center dialog box on screen */
- x = (getmaxx(stdscr) - width) / 2;
- y = (getmaxy(stdscr) - height) / 2;
-
- draw_shadow(stdscr, y, x, height, width);
-
- dialog = newwin(height, width, y, x);
- keypad(dialog, TRUE);
-
- draw_box(dialog, 0, 0, height, width,
- dlg.dialog.atr, dlg.border.atr);
- wattrset(dialog, dlg.border.atr);
- mvwaddch(dialog, height - 3, 0, ACS_LTEE);
- for (i = 0; i < width - 2; i++)
- waddch(dialog, ACS_HLINE);
- wattrset(dialog, dlg.dialog.atr);
- waddch(dialog, ACS_RTEE);
-
- print_title(dialog, title, width);
-
- wattrset(dialog, dlg.dialog.atr);
- print_autowrap(dialog, prompt, width - 2, 1, 3);
-
- print_buttons(dialog, height, width, 0);
-
- while (key != KEY_ESC) {
- key = wgetch(dialog);
- switch (key) {
- case 'Y':
- case 'y':
- delwin(dialog);
- return 0;
- case 'N':
- case 'n':
- delwin(dialog);
- return 1;
-
- case TAB:
- case KEY_LEFT:
- case KEY_RIGHT:
- button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button);
-
- print_buttons(dialog, height, width, button);
- wrefresh(dialog);
- break;
- case ' ':
- case '\n':
- delwin(dialog);
- return button;
- case KEY_ESC:
- key = on_key_esc(dialog);
- break;
- case KEY_RESIZE:
- delwin(dialog);
- on_key_resize();
- goto do_resize;
- }
- }
-
- delwin(dialog);
- return key; /* ESC pressed */
-}
diff --git a/backport/kconf/mconf.c b/backport/kconf/mconf.c
deleted file mode 100644
index 315ce2c7..00000000
--- a/backport/kconf/mconf.c
+++ /dev/null
@@ -1,1047 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- *
- * Introduced single menu mode (show all sub-menus in one large tree).
- * 2002-11-06 Petr Baudis <pasky@ucw.cz>
- *
- * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <locale.h>
-
-#include "lkc.h"
-#include "lxdialog/dialog.h"
-
-static const char mconf_readme[] = N_(
-"Overview\n"
-"--------\n"
-"This interface lets you select features and parameters for the build.\n"
-"Features can either be built-in, modularized, or ignored. Parameters\n"
-"must be entered in as decimal or hexadecimal numbers or text.\n"
-"\n"
-"Menu items beginning with following braces represent features that\n"
-" [ ] can be built in or removed\n"
-" < > can be built in, modularized or removed\n"
-" { } can be built in or modularized (selected by other feature)\n"
-" - - are selected by other feature,\n"
-"while *, M or whitespace inside braces means to build in, build as\n"
-"a module or to exclude the feature respectively.\n"
-"\n"
-"To change any of these features, highlight it with the cursor\n"
-"keys and press <Y> to build it in, <M> to make it a module or\n"
-"<N> to remove it. You may also press the <Space Bar> to cycle\n"
-"through the available options (i.e. Y->N->M->Y).\n"
-"\n"
-"Some additional keyboard hints:\n"
-"\n"
-"Menus\n"
-"----------\n"
-"o Use the Up/Down arrow keys (cursor keys) to highlight the item you\n"
-" wish to change or the submenu you wish to select and press <Enter>.\n"
-" Submenus are designated by \"--->\", empty ones by \"----\".\n"
-"\n"
-" Shortcut: Press the option's highlighted letter (hotkey).\n"
-" Pressing a hotkey more than once will sequence\n"
-" through all visible items which use that hotkey.\n"
-"\n"
-" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
-" unseen options into view.\n"
-"\n"
-"o To exit a menu use the cursor keys to highlight the <Exit> button\n"
-" and press <ENTER>.\n"
-"\n"
-" Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n"
-" using those letters. You may press a single <ESC>, but\n"
-" there is a delayed response which you may find annoying.\n"
-"\n"
-" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
-" <Exit>, <Help>, <Save>, and <Load>.\n"
-"\n"
-"o To get help with an item, use the cursor keys to highlight <Help>\n"
-" and press <ENTER>.\n"
-"\n"
-" Shortcut: Press <H> or <?>.\n"
-"\n"
-"o To toggle the display of hidden options, press <Z>.\n"
-"\n"
-"\n"
-"Radiolists (Choice lists)\n"
-"-----------\n"
-"o Use the cursor keys to select the option you wish to set and press\n"
-" <S> or the <SPACE BAR>.\n"
-"\n"
-" Shortcut: Press the first letter of the option you wish to set then\n"
-" press <S> or <SPACE BAR>.\n"
-"\n"
-"o To see available help for the item, use the cursor keys to highlight\n"
-" <Help> and Press <ENTER>.\n"
-"\n"
-" Shortcut: Press <H> or <?>.\n"
-"\n"
-" Also, the <TAB> and cursor keys will cycle between <Select> and\n"
-" <Help>\n"
-"\n"
-"\n"
-"Data Entry\n"
-"-----------\n"
-"o Enter the requested information and press <ENTER>\n"
-" If you are entering hexadecimal values, it is not necessary to\n"
-" add the '0x' prefix to the entry.\n"
-"\n"
-"o For help, use the <TAB> or cursor keys to highlight the help option\n"
-" and press <ENTER>. You can try <TAB><H> as well.\n"
-"\n"
-"\n"
-"Text Box (Help Window)\n"
-"--------\n"
-"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
-" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n"
-" those who are familiar with less and lynx.\n"
-"\n"
-"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
-"\n"
-"\n"
-"Alternate Configuration Files\n"
-"-----------------------------\n"
-"Menuconfig supports the use of alternate configuration files for\n"
-"those who, for various reasons, find it necessary to switch\n"
-"between different configurations.\n"
-"\n"
-"The <Save> button will let you save the current configuration to\n"
-"a file of your choosing. Use the <Load> button to load a previously\n"
-"saved alternate configuration.\n"
-"\n"
-"Even if you don't use alternate configuration files, but you find\n"
-"during a Menuconfig session that you have completely messed up your\n"
-"settings, you may use the <Load> button to restore your previously\n"
-"saved settings from \".config\" without restarting Menuconfig.\n"
-"\n"
-"Other information\n"
-"-----------------\n"
-"If you use Menuconfig in an XTERM window, make sure you have your\n"
-"$TERM variable set to point to an xterm definition which supports\n"
-"color. Otherwise, Menuconfig will look rather bad. Menuconfig will\n"
-"not display correctly in an RXVT window because rxvt displays only one\n"
-"intensity of color, bright.\n"
-"\n"
-"Menuconfig will display larger menus on screens or xterms which are\n"
-"set to display more than the standard 25 row by 80 column geometry.\n"
-"In order for this to work, the \"stty size\" command must be able to\n"
-"display the screen's current row and column geometry. I STRONGLY\n"
-"RECOMMEND that you make sure you do NOT have the shell variables\n"
-"LINES and COLUMNS exported into your environment. Some distributions\n"
-"export those variables via /etc/profile. Some ncurses programs can\n"
-"become confused when those variables (LINES & COLUMNS) don't reflect\n"
-"the true screen size.\n"
-"\n"
-"Optional personality available\n"
-"------------------------------\n"
-"If you prefer to have all of the options listed in a single menu,\n"
-"rather than the default multimenu hierarchy, run the menuconfig with\n"
-"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
-"\n"
-"make MENUCONFIG_MODE=single_menu menuconfig\n"
-"\n"
-"<Enter> will then unroll the appropriate category, or enfold it if it\n"
-"is already unrolled.\n"
-"\n"
-"Note that this mode can eventually be a little more CPU expensive\n"
-"(especially with a larger number of unrolled categories) than the\n"
-"default mode.\n"
-"\n"
-"Different color themes available\n"
-"--------------------------------\n"
-"It is possible to select different color themes using the variable\n"
-"MENUCONFIG_COLOR. To select a theme use:\n"
-"\n"
-"make MENUCONFIG_COLOR=<theme> menuconfig\n"
-"\n"
-"Available themes are\n"
-" mono => selects colors suitable for monochrome displays\n"
-" blackbg => selects a color scheme with black background\n"
-" classic => theme with blue background. The classic look\n"
-" bluetitle => an LCD friendly version of classic. (default)\n"
-"\n"),
-menu_instructions[] = N_(
- "Arrow keys navigate the menu. "
- "<Enter> selects submenus ---> (or empty submenus ----). "
- "Highlighted letters are hotkeys. "
- "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
- "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
- "Legend: [*] built-in [ ] excluded <M> module < > module capable"),
-radiolist_instructions[] = N_(
- "Use the arrow keys to navigate this window or "
- "press the hotkey of the item you wish to select "
- "followed by the <SPACE BAR>. "
- "Press <?> for additional information about this option."),
-inputbox_instructions_int[] = N_(
- "Please enter a decimal value. "
- "Fractions will not be accepted. "
- "Use the <TAB> key to move from the input field to the buttons below it."),
-inputbox_instructions_hex[] = N_(
- "Please enter a hexadecimal value. "
- "Use the <TAB> key to move from the input field to the buttons below it."),
-inputbox_instructions_string[] = N_(
- "Please enter a string value. "
- "Use the <TAB> key to move from the input field to the buttons below it."),
-setmod_text[] = N_(
- "This feature depends on another which has been configured as a module.\n"
- "As a result, this feature will be built as a module."),
-load_config_text[] = N_(
- "Enter the name of the configuration file you wish to load. "
- "Accept the name shown to restore the configuration you "
- "last retrieved. Leave blank to abort."),
-load_config_help[] = N_(
- "\n"
- "For various reasons, one may wish to keep several different\n"
- "configurations available on a single machine.\n"
- "\n"
- "If you have saved a previous configuration in a file other than the\n"
- "default one, entering its name here will allow you to modify that\n"
- "configuration.\n"
- "\n"
- "If you are uncertain, then you have probably never used alternate\n"
- "configuration files. You should therefore leave this blank to abort.\n"),
-save_config_text[] = N_(
- "Enter a filename to which this configuration should be saved "
- "as an alternate. Leave blank to abort."),
-save_config_help[] = N_(
- "\n"
- "For various reasons, one may wish to keep different configurations\n"
- "available on a single machine.\n"
- "\n"
- "Entering a file name here will allow you to later retrieve, modify\n"
- "and use the current configuration as an alternate to whatever\n"
- "configuration options you have selected at that time.\n"
- "\n"
- "If you are uncertain what all this means then you should probably\n"
- "leave this blank.\n"),
-search_help[] = N_(
- "\n"
- "Search for symbols and display their relations.\n"
- "Regular expressions are allowed.\n"
- "Example: search for \"^FOO\"\n"
- "Result:\n"
- "-----------------------------------------------------------------\n"
- "Symbol: FOO [=m]\n"
- "Type : tristate\n"
- "Prompt: Foo bus is used to drive the bar HW\n"
- " Location:\n"
- " -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
- " -> PCI support (PCI [=y])\n"
- "(1) -> PCI access mode (<choice> [=y])\n"
- " Defined at drivers/pci/Kconfig:47\n"
- " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
- " Selects: LIBCRC32\n"
- " Selected by: BAR [=n]\n"
- "-----------------------------------------------------------------\n"
- "o The line 'Type:' shows the type of the configuration option for\n"
- " this symbol (boolean, tristate, string, ...)\n"
- "o The line 'Prompt:' shows the text used in the menu structure for\n"
- " this symbol\n"
- "o The 'Defined at' line tells at what file / line number the symbol\n"
- " is defined\n"
- "o The 'Depends on:' line tells what symbols need to be defined for\n"
- " this symbol to be visible in the menu (selectable)\n"
- "o The 'Location:' lines tells where in the menu structure this symbol\n"
- " is located\n"
- " A location followed by a [=y] indicates that this is a\n"
- " selectable menu item - and the current value is displayed inside\n"
- " brackets.\n"
- " Press the key in the (#) prefix to jump directly to that\n"
- " location. You will be returned to the current search results\n"
- " after exiting this new menu.\n"
- "o The 'Selects:' line tells what symbols will be automatically\n"
- " selected if this symbol is selected (y or m)\n"
- "o The 'Selected by' line tells what symbol has selected this symbol\n"
- "\n"
- "Only relevant lines are shown.\n"
- "\n\n"
- "Search examples:\n"
- "Examples: USB => find all symbols containing USB\n"
- " ^USB => find all symbols starting with USB\n"
- " USB$ => find all symbols ending with USB\n"
- "\n");
-
-static int indent;
-static struct menu *current_menu;
-static int child_count;
-static int single_menu_mode;
-static int show_all_options;
-static int save_and_exit;
-static int silent;
-
-static void conf(struct menu *menu, struct menu *active_menu);
-static void conf_choice(struct menu *menu);
-static void conf_string(struct menu *menu);
-static void conf_load(void);
-static void conf_save(void);
-static int show_textbox_ext(const char *title, char *text, int r, int c,
- int *keys, int *vscroll, int *hscroll,
- update_text_fn update_text, void *data);
-static void show_textbox(const char *title, const char *text, int r, int c);
-static void show_helptext(const char *title, const char *text);
-static void show_help(struct menu *menu);
-
-static char filename[PATH_MAX+1];
-static void set_config_filename(const char *config_filename)
-{
- static char menu_backtitle[PATH_MAX+128];
- int size;
-
- size = snprintf(menu_backtitle, sizeof(menu_backtitle),
- "%s - %s", config_filename, rootmenu.prompt->text);
- if (size >= sizeof(menu_backtitle))
- menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
- set_dialog_backtitle(menu_backtitle);
-
- size = snprintf(filename, sizeof(filename), "%s", config_filename);
- if (size >= sizeof(filename))
- filename[sizeof(filename)-1] = '\0';
-}
-
-struct subtitle_part {
- struct list_head entries;
- const char *text;
-};
-static LIST_HEAD(trail);
-
-static struct subtitle_list *subtitles;
-static void set_subtitle(void)
-{
- struct subtitle_part *sp;
- struct subtitle_list *pos, *tmp;
-
- for (pos = subtitles; pos != NULL; pos = tmp) {
- tmp = pos->next;
- free(pos);
- }
-
- subtitles = NULL;
- list_for_each_entry(sp, &trail, entries) {
- if (sp->text) {
- if (pos) {
- pos->next = xcalloc(1, sizeof(*pos));
- pos = pos->next;
- } else {
- subtitles = pos = xcalloc(1, sizeof(*pos));
- }
- pos->text = sp->text;
- }
- }
-
- set_dialog_subtitles(subtitles);
-}
-
-static void reset_subtitle(void)
-{
- struct subtitle_list *pos, *tmp;
-
- for (pos = subtitles; pos != NULL; pos = tmp) {
- tmp = pos->next;
- free(pos);
- }
- subtitles = NULL;
- set_dialog_subtitles(subtitles);
-}
-
-struct search_data {
- struct list_head *head;
- struct menu **targets;
- int *keys;
-};
-
-static void update_text(char *buf, size_t start, size_t end, void *_data)
-{
- struct search_data *data = _data;
- struct jump_key *pos;
- int k = 0;
-
- list_for_each_entry(pos, data->head, entries) {
- if (pos->offset >= start && pos->offset < end) {
- char header[4];
-
- if (k < JUMP_NB) {
- int key = '0' + (pos->index % JUMP_NB) + 1;
-
- sprintf(header, "(%c)", key);
- data->keys[k] = key;
- data->targets[k] = pos->target;
- k++;
- } else {
- sprintf(header, " ");
- }
-
- memcpy(buf + pos->offset, header, sizeof(header) - 1);
- }
- }
- data->keys[k] = 0;
-}
-
-static void search_conf(void)
-{
- struct symbol **sym_arr;
- struct gstr res;
- struct gstr title;
- char *dialog_input;
- int dres, vscroll = 0, hscroll = 0;
- bool again;
- struct gstr sttext;
- struct subtitle_part stpart;
-
- title = str_new();
- str_printf( &title, _("Enter (sub)string or regexp to search for "
- "(with or without \"%s\")"), CONFIG_);
-
-again:
- dialog_clear();
- dres = dialog_inputbox(_("Search Configuration Parameter"),
- str_get(&title),
- 10, 75, "");
- switch (dres) {
- case 0:
- break;
- case 1:
- show_helptext(_("Search Configuration"), search_help);
- goto again;
- default:
- str_free(&title);
- return;
- }
-
- /* strip the prefix if necessary */
- dialog_input = dialog_input_result;
- if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
- dialog_input += strlen(CONFIG_);
-
- sttext = str_new();
- str_printf(&sttext, "Search (%s)", dialog_input_result);
- stpart.text = str_get(&sttext);
- list_add_tail(&stpart.entries, &trail);
-
- sym_arr = sym_re_search(dialog_input);
- do {
- LIST_HEAD(head);
- struct menu *targets[JUMP_NB];
- int keys[JUMP_NB + 1], i;
- struct search_data data = {
- .head = &head,
- .targets = targets,
- .keys = keys,
- };
- struct jump_key *pos, *tmp;
-
- res = get_relations_str(sym_arr, &head);
- set_subtitle();
- dres = show_textbox_ext(_("Search Results"), (char *)
- str_get(&res), 0, 0, keys, &vscroll,
- &hscroll, &update_text, (void *)
- &data);
- again = false;
- for (i = 0; i < JUMP_NB && keys[i]; i++)
- if (dres == keys[i]) {
- conf(targets[i]->parent, targets[i]);
- again = true;
- }
- str_free(&res);
- list_for_each_entry_safe(pos, tmp, &head, entries)
- free(pos);
- } while (again);
- free(sym_arr);
- str_free(&title);
- list_del(trail.prev);
- str_free(&sttext);
-}
-
-static void build_conf(struct menu *menu)
-{
- struct symbol *sym;
- struct property *prop;
- struct menu *child;
- int type, tmp, doint = 2;
- tristate val;
- char ch;
- bool visible;
-
- /*
- * note: menu_is_visible() has side effect that it will
- * recalc the value of the symbol.
- */
- visible = menu_is_visible(menu);
- if (show_all_options && !menu_has_prompt(menu))
- return;
- else if (!show_all_options && !visible)
- return;
-
- sym = menu->sym;
- prop = menu->prompt;
- if (!sym) {
- if (prop && menu != current_menu) {
- const char *prompt = menu_get_prompt(menu);
- switch (prop->type) {
- case P_MENU:
- child_count++;
- prompt = _(prompt);
- if (single_menu_mode) {
- item_make("%s%*c%s",
- menu->data ? "-->" : "++>",
- indent + 1, ' ', prompt);
- } else
- item_make(" %*c%s %s",
- indent + 1, ' ', prompt,
- menu_is_empty(menu) ? "----" : "--->");
- item_set_tag('m');
- item_set_data(menu);
- if (single_menu_mode && menu->data)
- goto conf_childs;
- return;
- case P_COMMENT:
- if (prompt) {
- child_count++;
- item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt));
- item_set_tag(':');
- item_set_data(menu);
- }
- break;
- default:
- if (prompt) {
- child_count++;
- item_make("---%*c%s", indent + 1, ' ', _(prompt));
- item_set_tag(':');
- item_set_data(menu);
- }
- }
- } else
- doint = 0;
- goto conf_childs;
- }
-
- type = sym_get_type(sym);
- if (sym_is_choice(sym)) {
- struct symbol *def_sym = sym_get_choice_value(sym);
- struct menu *def_menu = NULL;
-
- child_count++;
- for (child = menu->list; child; child = child->next) {
- if (menu_is_visible(child) && child->sym == def_sym)
- def_menu = child;
- }
-
- val = sym_get_tristate_value(sym);
- if (sym_is_changable(sym)) {
- switch (type) {
- case S_BOOLEAN:
- item_make("[%c]", val == no ? ' ' : '*');
- break;
- case S_TRISTATE:
- switch (val) {
- case yes: ch = '*'; break;
- case mod: ch = 'M'; break;
- default: ch = ' '; break;
- }
- item_make("<%c>", ch);
- break;
- }
- item_set_tag('t');
- item_set_data(menu);
- } else {
- item_make(" ");
- item_set_tag(def_menu ? 't' : ':');
- item_set_data(menu);
- }
-
- item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu)));
- if (val == yes) {
- if (def_menu) {
- item_add_str(" (%s)", _(menu_get_prompt(def_menu)));
- item_add_str(" --->");
- if (def_menu->list) {
- indent += 2;
- build_conf(def_menu);
- indent -= 2;
- }
- }
- return;
- }
- } else {
- if (menu == current_menu) {
- item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu)));
- item_set_tag(':');
- item_set_data(menu);
- goto conf_childs;
- }
- child_count++;
- val = sym_get_tristate_value(sym);
- if (sym_is_choice_value(sym) && val == yes) {
- item_make(" ");
- item_set_tag(':');
- item_set_data(menu);
- } else {
- switch (type) {
- case S_BOOLEAN:
- if (sym_is_changable(sym))
- item_make("[%c]", val == no ? ' ' : '*');
- else
- item_make("-%c-", val == no ? ' ' : '*');
- item_set_tag('t');
- item_set_data(menu);
- break;
- case S_TRISTATE:
- switch (val) {
- case yes: ch = '*'; break;
- case mod: ch = 'M'; break;
- default: ch = ' '; break;
- }
- if (sym_is_changable(sym)) {
- if (sym->rev_dep.tri == mod)
- item_make("{%c}", ch);
- else
- item_make("<%c>", ch);
- } else
- item_make("-%c-", ch);
- item_set_tag('t');
- item_set_data(menu);
- break;
- default:
- tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */
- item_make("(%s)", sym_get_string_value(sym));
- tmp = indent - tmp + 4;
- if (tmp < 0)
- tmp = 0;
- item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)),
- (sym_has_value(sym) || !sym_is_changable(sym)) ?
- "" : _(" (NEW)"));
- item_set_tag('s');
- item_set_data(menu);
- goto conf_childs;
- }
- }
- item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)),
- (sym_has_value(sym) || !sym_is_changable(sym)) ?
- "" : _(" (NEW)"));
- if (menu->prompt->type == P_MENU) {
- item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
- return;
- }
- }
-
-conf_childs:
- indent += doint;
- for (child = menu->list; child; child = child->next)
- build_conf(child);
- indent -= doint;
-}
-
-static void conf(struct menu *menu, struct menu *active_menu)
-{
- struct menu *submenu;
- const char *prompt = menu_get_prompt(menu);
- struct subtitle_part stpart;
- struct symbol *sym;
- int res;
- int s_scroll = 0;
-
- if (menu != &rootmenu)
- stpart.text = menu_get_prompt(menu);
- else
- stpart.text = NULL;
- list_add_tail(&stpart.entries, &trail);
-
- while (1) {
- item_reset();
- current_menu = menu;
- build_conf(menu);
- if (!child_count)
- break;
- set_subtitle();
- dialog_clear();
- res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
- _(menu_instructions),
- active_menu, &s_scroll);
- if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
- break;
- if (item_count() != 0) {
- if (!item_activate_selected())
- continue;
- if (!item_tag())
- continue;
- }
- submenu = item_data();
- active_menu = item_data();
- if (submenu)
- sym = submenu->sym;
- else
- sym = NULL;
-
- switch (res) {
- case 0:
- switch (item_tag()) {
- case 'm':
- if (single_menu_mode)
- submenu->data = (void *) (long) !submenu->data;
- else
- conf(submenu, NULL);
- break;
- case 't':
- if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
- conf_choice(submenu);
- else if (submenu->prompt->type == P_MENU)
- conf(submenu, NULL);
- break;
- case 's':
- conf_string(submenu);
- break;
- }
- break;
- case 2:
- if (sym)
- show_help(submenu);
- else {
- reset_subtitle();
- show_helptext(_("README"), _(mconf_readme));
- }
- break;
- case 3:
- reset_subtitle();
- conf_save();
- break;
- case 4:
- reset_subtitle();
- conf_load();
- break;
- case 5:
- if (item_is_tag('t')) {
- if (sym_set_tristate_value(sym, yes))
- break;
- if (sym_set_tristate_value(sym, mod))
- show_textbox(NULL, setmod_text, 6, 74);
- }
- break;
- case 6:
- if (item_is_tag('t'))
- sym_set_tristate_value(sym, no);
- break;
- case 7:
- if (item_is_tag('t'))
- sym_set_tristate_value(sym, mod);
- break;
- case 8:
- if (item_is_tag('t'))
- sym_toggle_tristate_value(sym);
- else if (item_is_tag('m'))
- conf(submenu, NULL);
- break;
- case 9:
- search_conf();
- break;
- case 10:
- show_all_options = !show_all_options;
- break;
- }
- }
-
- list_del(trail.prev);
-}
-
-static int show_textbox_ext(const char *title, char *text, int r, int c, int
- *keys, int *vscroll, int *hscroll, update_text_fn
- update_text, void *data)
-{
- dialog_clear();
- return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
- update_text, data);
-}
-
-static void show_textbox(const char *title, const char *text, int r, int c)
-{
- show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
- NULL, NULL);
-}
-
-static void show_helptext(const char *title, const char *text)
-{
- show_textbox(title, text, 0, 0);
-}
-
-static void conf_message_callback(const char *fmt, va_list ap)
-{
- char buf[PATH_MAX+1];
-
- vsnprintf(buf, sizeof(buf), fmt, ap);
- if (save_and_exit) {
- if (!silent)
- printf("%s", buf);
- } else {
- show_textbox(NULL, buf, 6, 60);
- }
-}
-
-static void show_help(struct menu *menu)
-{
- struct gstr help = str_new();
-
- help.max_width = getmaxx(stdscr) - 10;
- menu_get_ext_help(menu, &help);
-
- show_helptext(_(menu_get_prompt(menu)), str_get(&help));
- str_free(&help);
-}
-
-static void conf_choice(struct menu *menu)
-{
- const char *prompt = _(menu_get_prompt(menu));
- struct menu *child;
- struct symbol *active;
-
- active = sym_get_choice_value(menu->sym);
- while (1) {
- int res;
- int selected;
- item_reset();
-
- current_menu = menu;
- for (child = menu->list; child; child = child->next) {
- if (!menu_is_visible(child))
- continue;
- if (child->sym)
- item_make("%s", _(menu_get_prompt(child)));
- else {
- item_make("*** %s ***", _(menu_get_prompt(child)));
- item_set_tag(':');
- }
- item_set_data(child);
- if (child->sym == active)
- item_set_selected(1);
- if (child->sym == sym_get_choice_value(menu->sym))
- item_set_tag('X');
- }
- dialog_clear();
- res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
- _(radiolist_instructions),
- MENUBOX_HEIGTH_MIN,
- MENUBOX_WIDTH_MIN,
- CHECKLIST_HEIGTH_MIN);
- selected = item_activate_selected();
- switch (res) {
- case 0:
- if (selected) {
- child = item_data();
- if (!child->sym)
- break;
-
- sym_set_tristate_value(child->sym, yes);
- }
- return;
- case 1:
- if (selected) {
- child = item_data();
- show_help(child);
- active = child->sym;
- } else
- show_help(menu);
- break;
- case KEY_ESC:
- return;
- case -ERRDISPLAYTOOSMALL:
- return;
- }
- }
-}
-
-static void conf_string(struct menu *menu)
-{
- const char *prompt = menu_get_prompt(menu);
-
- while (1) {
- int res;
- const char *heading;
-
- switch (sym_get_type(menu->sym)) {
- case S_INT:
- heading = _(inputbox_instructions_int);
- break;
- case S_HEX:
- heading = _(inputbox_instructions_hex);
- break;
- case S_STRING:
- heading = _(inputbox_instructions_string);
- break;
- default:
- heading = _("Internal mconf error!");
- }
- dialog_clear();
- res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"),
- heading, 10, 75,
- sym_get_string_value(menu->sym));
- switch (res) {
- case 0:
- if (sym_set_string_value(menu->sym, dialog_input_result))
- return;
- show_textbox(NULL, _("You have made an invalid entry."), 5, 43);
- break;
- case 1:
- show_help(menu);
- break;
- case KEY_ESC:
- return;
- }
- }
-}
-
-static void conf_load(void)
-{
-
- while (1) {
- int res;
- dialog_clear();
- res = dialog_inputbox(NULL, load_config_text,
- 11, 55, filename);
- switch(res) {
- case 0:
- if (!dialog_input_result[0])
- return;
- if (!conf_read(dialog_input_result)) {
- set_config_filename(dialog_input_result);
- sym_set_change_count(1);
- return;
- }
- show_textbox(NULL, _("File does not exist!"), 5, 38);
- break;
- case 1:
- show_helptext(_("Load Alternate Configuration"), load_config_help);
- break;
- case KEY_ESC:
- return;
- }
- }
-}
-
-static void conf_save(void)
-{
- while (1) {
- int res;
- dialog_clear();
- res = dialog_inputbox(NULL, save_config_text,
- 11, 55, filename);
- switch(res) {
- case 0:
- if (!dialog_input_result[0])
- return;
- if (!conf_write(dialog_input_result)) {
- set_config_filename(dialog_input_result);
- return;
- }
- show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60);
- break;
- case 1:
- show_helptext(_("Save Alternate Configuration"), save_config_help);
- break;
- case KEY_ESC:
- return;
- }
- }
-}
-
-static int handle_exit(void)
-{
- int res;
-
- save_and_exit = 1;
- reset_subtitle();
- dialog_clear();
- if (conf_get_changed())
- res = dialog_yesno(NULL,
- _("Do you wish to save your new configuration?\n"
- "(Press <ESC><ESC> to continue kernel configuration.)"),
- 6, 60);
- else
- res = -1;
-
- end_dialog(saved_x, saved_y);
-
- switch (res) {
- case 0:
- if (conf_write(filename)) {
- fprintf(stderr, _("\n\n"
- "Error while writing of the configuration.\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- return 1;
- }
- /* fall through */
- case -1:
- if (!silent)
- printf(_("\n\n"
- "*** End of the configuration.\n"
- "*** Execute 'make' to start the build or try 'make help'."
- "\n\n"));
- res = 0;
- break;
- default:
- if (!silent)
- fprintf(stderr, _("\n\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- if (res != KEY_ESC)
- res = 0;
- }
-
- return res;
-}
-
-static void sig_handler(int signo)
-{
- exit(handle_exit());
-}
-
-int main(int ac, char **av)
-{
- char *mode;
- int res;
-
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- signal(SIGINT, sig_handler);
-
- if (ac > 1 && strcmp(av[1], "-s") == 0) {
- silent = 1;
- /* Silence conf_read() until the real callback is set up */
- conf_set_message_callback(NULL);
- av++;
- }
- conf_parse(av[1]);
- conf_read(NULL);
-
- mode = getenv("MENUCONFIG_MODE");
- if (mode) {
- if (!strcasecmp(mode, "single_menu"))
- single_menu_mode = 1;
- }
-
- if (init_dialog(NULL)) {
- fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
- fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
- return 1;
- }
-
- set_config_filename(conf_get_configname());
- conf_set_message_callback(conf_message_callback);
- do {
- conf(&rootmenu, NULL);
- res = handle_exit();
- } while (res == KEY_ESC);
-
- return res;
-}
diff --git a/backport/kconf/menu.c b/backport/kconf/menu.c
deleted file mode 100644
index e9357931..00000000
--- a/backport/kconf/menu.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "lkc.h"
-
-static const char nohelp_text[] = "There is no help available for this option.";
-
-struct menu rootmenu;
-static struct menu **last_entry_ptr;
-
-struct file *file_list;
-struct file *current_file;
-
-void menu_warn(struct menu *menu, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-static void prop_warn(struct property *prop, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-void _menu_init(void)
-{
- current_entry = current_menu = &rootmenu;
- last_entry_ptr = &rootmenu.list;
-}
-
-void menu_add_entry(struct symbol *sym)
-{
- struct menu *menu;
-
- menu = xmalloc(sizeof(*menu));
- memset(menu, 0, sizeof(*menu));
- menu->sym = sym;
- menu->parent = current_menu;
- menu->file = current_file;
- menu->lineno = zconf_lineno();
-
- *last_entry_ptr = menu;
- last_entry_ptr = &menu->next;
- current_entry = menu;
- if (sym)
- menu_add_symbol(P_SYMBOL, sym, NULL);
-}
-
-void menu_end_entry(void)
-{
-}
-
-struct menu *menu_add_menu(void)
-{
- menu_end_entry();
- last_entry_ptr = &current_entry->list;
- return current_menu = current_entry;
-}
-
-void menu_end_menu(void)
-{
- last_entry_ptr = &current_menu->next;
- current_menu = current_menu->parent;
-}
-
-static struct expr *menu_check_dep(struct expr *e)
-{
- if (!e)
- return e;
-
- switch (e->type) {
- case E_NOT:
- e->left.expr = menu_check_dep(e->left.expr);
- break;
- case E_OR:
- case E_AND:
- e->left.expr = menu_check_dep(e->left.expr);
- e->right.expr = menu_check_dep(e->right.expr);
- break;
- case E_SYMBOL:
- /* change 'm' into 'm' && MODULES */
- if (e->left.sym == &symbol_mod)
- return expr_alloc_and(e, expr_alloc_symbol(modules_sym));
- break;
- default:
- break;
- }
- return e;
-}
-
-void menu_add_dep(struct expr *dep)
-{
- current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
-}
-
-void menu_set_type(int type)
-{
- struct symbol *sym = current_entry->sym;
-
- if (sym->type == type)
- return;
- if (sym->type == S_UNKNOWN) {
- sym->type = type;
- return;
- }
- menu_warn(current_entry,
- "ignoring type redefinition of '%s' from '%s' to '%s'",
- sym->name ? sym->name : "<choice>",
- sym_type_name(sym->type), sym_type_name(type));
-}
-
-static struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
-{
- struct property *prop = prop_alloc(type, current_entry->sym);
-
- prop->menu = current_entry;
- prop->expr = expr;
- prop->visible.expr = menu_check_dep(dep);
-
- if (prompt) {
- if (isspace(*prompt)) {
- prop_warn(prop, "leading whitespace ignored");
- while (isspace(*prompt))
- prompt++;
- }
- if (current_entry->prompt && current_entry != &rootmenu)
- prop_warn(prop, "prompt redefined");
-
- /* Apply all upper menus' visibilities to actual prompts. */
- if(type == P_PROMPT) {
- struct menu *menu = current_entry;
-
- while ((menu = menu->parent) != NULL) {
- struct expr *dup_expr;
-
- if (!menu->visibility)
- continue;
- /*
- * Do not add a reference to the
- * menu's visibility expression but
- * use a copy of it. Otherwise the
- * expression reduction functions
- * will modify expressions that have
- * multiple references which can
- * cause unwanted side effects.
- */
- dup_expr = expr_copy(menu->visibility);
-
- prop->visible.expr
- = expr_alloc_and(prop->visible.expr,
- dup_expr);
- }
- }
-
- current_entry->prompt = prop;
- }
- prop->text = prompt;
-
- return prop;
-}
-
-struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
-{
- return menu_add_prop(type, prompt, NULL, dep);
-}
-
-void menu_add_visibility(struct expr *expr)
-{
- current_entry->visibility = expr_alloc_and(current_entry->visibility,
- expr);
-}
-
-void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
-{
- menu_add_prop(type, NULL, expr, dep);
-}
-
-void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
-{
- menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
-}
-
-void menu_add_option(int token, char *arg)
-{
- switch (token) {
- case T_OPT_MODULES:
- if (modules_sym)
- zconf_error("symbol '%s' redefines option 'modules'"
- " already defined by symbol '%s'",
- current_entry->sym->name,
- modules_sym->name
- );
- modules_sym = current_entry->sym;
- break;
- case T_OPT_DEFCONFIG_LIST:
- if (!sym_defconfig_list)
- sym_defconfig_list = current_entry->sym;
- else if (sym_defconfig_list != current_entry->sym)
- zconf_error("trying to redefine defconfig symbol");
- break;
- case T_OPT_ENV:
- prop_add_env(arg);
- break;
- case T_OPT_ALLNOCONFIG_Y:
- current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
- break;
- }
-}
-
-static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
-{
- return sym2->type == S_INT || sym2->type == S_HEX ||
- (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
-}
-
-static void sym_check_prop(struct symbol *sym)
-{
- struct property *prop;
- struct symbol *sym2;
- char *use;
-
- for (prop = sym->prop; prop; prop = prop->next) {
- switch (prop->type) {
- case P_DEFAULT:
- if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
- prop->expr->type != E_SYMBOL)
- prop_warn(prop,
- "default for config symbol '%s'"
- " must be a single symbol", sym->name);
- if (prop->expr->type != E_SYMBOL)
- break;
- sym2 = prop_get_symbol(prop);
- if (sym->type == S_HEX || sym->type == S_INT) {
- if (!menu_validate_number(sym, sym2))
- prop_warn(prop,
- "'%s': number is invalid",
- sym->name);
- }
- break;
- case P_SELECT:
- case P_IMPLY:
- use = prop->type == P_SELECT ? "select" : "imply";
- sym2 = prop_get_symbol(prop);
- if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
- prop_warn(prop,
- "config symbol '%s' uses %s, but is "
- "not boolean or tristate", sym->name, use);
- else if (sym2->type != S_UNKNOWN &&
- sym2->type != S_BOOLEAN &&
- sym2->type != S_TRISTATE)
- prop_warn(prop,
- "'%s' has wrong type. '%s' only "
- "accept arguments of boolean and "
- "tristate type", sym2->name, use);
- break;
- case P_RANGE:
- if (sym->type != S_INT && sym->type != S_HEX)
- prop_warn(prop, "range is only allowed "
- "for int or hex symbols");
- if (!menu_validate_number(sym, prop->expr->left.sym) ||
- !menu_validate_number(sym, prop->expr->right.sym))
- prop_warn(prop, "range is invalid");
- break;
- default:
- ;
- }
- }
-}
-
-void menu_finalize(struct menu *parent)
-{
- struct menu *menu, *last_menu;
- struct symbol *sym;
- struct property *prop;
- struct expr *parentdep, *basedep, *dep, *dep2, **ep;
-
- sym = parent->sym;
- if (parent->list) {
- if (sym && sym_is_choice(sym)) {
- if (sym->type == S_UNKNOWN) {
- /* find the first choice value to find out choice type */
- current_entry = parent;
- for (menu = parent->list; menu; menu = menu->next) {
- if (menu->sym && menu->sym->type != S_UNKNOWN) {
- menu_set_type(menu->sym->type);
- break;
- }
- }
- }
- /* set the type of the remaining choice values */
- for (menu = parent->list; menu; menu = menu->next) {
- current_entry = menu;
- if (menu->sym && menu->sym->type == S_UNKNOWN)
- menu_set_type(sym->type);
- }
- parentdep = expr_alloc_symbol(sym);
- } else if (parent->prompt)
- parentdep = parent->prompt->visible.expr;
- else
- parentdep = parent->dep;
-
- for (menu = parent->list; menu; menu = menu->next) {
- basedep = expr_transform(menu->dep);
- basedep = expr_alloc_and(expr_copy(parentdep), basedep);
- basedep = expr_eliminate_dups(basedep);
- menu->dep = basedep;
- if (menu->sym)
- prop = menu->sym->prop;
- else
- prop = menu->prompt;
- for (; prop; prop = prop->next) {
- if (prop->menu != menu)
- continue;
- dep = expr_transform(prop->visible.expr);
- dep = expr_alloc_and(expr_copy(basedep), dep);
- dep = expr_eliminate_dups(dep);
- if (menu->sym && menu->sym->type != S_TRISTATE)
- dep = expr_trans_bool(dep);
- prop->visible.expr = dep;
- if (prop->type == P_SELECT) {
- struct symbol *es = prop_get_symbol(prop);
- es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
- expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
- } else if (prop->type == P_IMPLY) {
- struct symbol *es = prop_get_symbol(prop);
- es->implied.expr = expr_alloc_or(es->implied.expr,
- expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
- }
- }
- }
- for (menu = parent->list; menu; menu = menu->next)
- menu_finalize(menu);
- } else if (sym) {
- basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
- basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
- basedep = expr_eliminate_dups(expr_transform(basedep));
- last_menu = NULL;
- for (menu = parent->next; menu; menu = menu->next) {
- dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
- if (!expr_contains_symbol(dep, sym))
- break;
- if (expr_depends_symbol(dep, sym))
- goto next;
- dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
- dep = expr_eliminate_dups(expr_transform(dep));
- dep2 = expr_copy(basedep);
- expr_eliminate_eq(&dep, &dep2);
- expr_free(dep);
- if (!expr_is_yes(dep2)) {
- expr_free(dep2);
- break;
- }
- expr_free(dep2);
- next:
- menu_finalize(menu);
- menu->parent = parent;
- last_menu = menu;
- }
- if (last_menu) {
- parent->list = parent->next;
- parent->next = last_menu->next;
- last_menu->next = NULL;
- }
-
- sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep);
- }
- for (menu = parent->list; menu; menu = menu->next) {
- if (sym && sym_is_choice(sym) &&
- menu->sym && !sym_is_choice_value(menu->sym)) {
- current_entry = menu;
- menu->sym->flags |= SYMBOL_CHOICEVAL;
- if (!menu->prompt)
- menu_warn(menu, "choice value must have a prompt");
- for (prop = menu->sym->prop; prop; prop = prop->next) {
- if (prop->type == P_DEFAULT)
- prop_warn(prop, "defaults for choice "
- "values not supported");
- if (prop->menu == menu)
- continue;
- if (prop->type == P_PROMPT &&
- prop->menu->parent->sym != sym)
- prop_warn(prop, "choice value used outside its choice group");
- }
- /* Non-tristate choice values of tristate choices must
- * depend on the choice being set to Y. The choice
- * values' dependencies were propagated to their
- * properties above, so the change here must be re-
- * propagated.
- */
- if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
- basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
- menu->dep = expr_alloc_and(basedep, menu->dep);
- for (prop = menu->sym->prop; prop; prop = prop->next) {
- if (prop->menu != menu)
- continue;
- prop->visible.expr = expr_alloc_and(expr_copy(basedep),
- prop->visible.expr);
- }
- }
- menu_add_symbol(P_CHOICE, sym, NULL);
- prop = sym_get_choice_prop(sym);
- for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
- ;
- *ep = expr_alloc_one(E_LIST, NULL);
- (*ep)->right.sym = menu->sym;
- }
- if (menu->list && (!menu->prompt || !menu->prompt->text)) {
- for (last_menu = menu->list; ; last_menu = last_menu->next) {
- last_menu->parent = parent;
- if (!last_menu->next)
- break;
- }
- last_menu->next = menu->next;
- menu->next = menu->list;
- menu->list = NULL;
- }
- }
-
- if (sym && !(sym->flags & SYMBOL_WARNED)) {
- if (sym->type == S_UNKNOWN)
- menu_warn(parent, "config symbol defined without type");
-
- if (sym_is_choice(sym) && !parent->prompt)
- menu_warn(parent, "choice must have a prompt");
-
- /* Check properties connected to this symbol */
- sym_check_prop(sym);
- sym->flags |= SYMBOL_WARNED;
- }
-
- if (sym && !sym_is_optional(sym) && parent->prompt) {
- sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
- expr_alloc_and(parent->prompt->visible.expr,
- expr_alloc_symbol(&symbol_mod)));
- }
-}
-
-bool menu_has_prompt(struct menu *menu)
-{
- if (!menu->prompt)
- return false;
- return true;
-}
-
-/*
- * Determine if a menu is empty.
- * A menu is considered empty if it contains no or only
- * invisible entries.
- */
-bool menu_is_empty(struct menu *menu)
-{
- struct menu *child;
-
- for (child = menu->list; child; child = child->next) {
- if (menu_is_visible(child))
- return(false);
- }
- return(true);
-}
-
-bool menu_is_visible(struct menu *menu)
-{
- struct menu *child;
- struct symbol *sym;
- tristate visible;
-
- if (!menu->prompt)
- return false;
-
- if (menu->visibility) {
- if (expr_calc_value(menu->visibility) == no)
- return false;
- }
-
- sym = menu->sym;
- if (sym) {
- sym_calc_value(sym);
- visible = menu->prompt->visible.tri;
- } else
- visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
-
- if (visible != no)
- return true;
-
- if (!sym || sym_get_tristate_value(menu->sym) == no)
- return false;
-
- for (child = menu->list; child; child = child->next) {
- if (menu_is_visible(child)) {
- if (sym)
- sym->flags |= SYMBOL_DEF_USER;
- return true;
- }
- }
-
- return false;
-}
-
-const char *menu_get_prompt(struct menu *menu)
-{
- if (menu->prompt)
- return menu->prompt->text;
- else if (menu->sym)
- return menu->sym->name;
- return NULL;
-}
-
-struct menu *menu_get_root_menu(struct menu *menu)
-{
- return &rootmenu;
-}
-
-struct menu *menu_get_parent_menu(struct menu *menu)
-{
- enum prop_type type;
-
- for (; menu != &rootmenu; menu = menu->parent) {
- type = menu->prompt ? menu->prompt->type : 0;
- if (type == P_MENU)
- break;
- }
- return menu;
-}
-
-bool menu_has_help(struct menu *menu)
-{
- return menu->help != NULL;
-}
-
-const char *menu_get_help(struct menu *menu)
-{
- if (menu->help)
- return menu->help;
- else
- return "";
-}
-
-static void get_prompt_str(struct gstr *r, struct property *prop,
- struct list_head *head)
-{
- int i, j;
- struct menu *submenu[8], *menu, *location = NULL;
- struct jump_key *jump = NULL;
-
- str_printf(r, _("Prompt: %s\n"), _(prop->text));
- menu = prop->menu->parent;
- for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
- bool accessible = menu_is_visible(menu);
-
- submenu[i++] = menu;
- if (location == NULL && accessible)
- location = menu;
- }
- if (head && location) {
- jump = xmalloc(sizeof(struct jump_key));
-
- if (menu_is_visible(prop->menu)) {
- /*
- * There is not enough room to put the hint at the
- * beginning of the "Prompt" line. Put the hint on the
- * last "Location" line even when it would belong on
- * the former.
- */
- jump->target = prop->menu;
- } else
- jump->target = location;
-
- if (list_empty(head))
- jump->index = 0;
- else
- jump->index = list_entry(head->prev, struct jump_key,
- entries)->index + 1;
-
- list_add_tail(&jump->entries, head);
- }
-
- if (i > 0) {
- str_printf(r, _(" Location:\n"));
- for (j = 4; --i >= 0; j += 2) {
- menu = submenu[i];
- if (jump && menu == location)
- jump->offset = strlen(r->s);
- str_printf(r, "%*c-> %s", j, ' ',
- _(menu_get_prompt(menu)));
- if (menu->sym) {
- str_printf(r, " (%s [=%s])", menu->sym->name ?
- menu->sym->name : _("<choice>"),
- sym_get_string_value(menu->sym));
- }
- str_append(r, "\n");
- }
- }
-}
-
-/*
- * get property of type P_SYMBOL
- */
-static struct property *get_symbol_prop(struct symbol *sym)
-{
- struct property *prop = NULL;
-
- for_all_properties(sym, prop, P_SYMBOL)
- break;
- return prop;
-}
-
-static void get_symbol_props_str(struct gstr *r, struct symbol *sym,
- enum prop_type tok, const char *prefix)
-{
- bool hit = false;
- struct property *prop;
-
- for_all_properties(sym, prop, tok) {
- if (!hit) {
- str_append(r, prefix);
- hit = true;
- } else
- str_printf(r, " && ");
- expr_gstr_print(prop->expr, r);
- }
- if (hit)
- str_append(r, "\n");
-}
-
-/*
- * head is optional and may be NULL
- */
-static void get_symbol_str(struct gstr *r, struct symbol *sym,
- struct list_head *head)
-{
- struct property *prop;
-
- if (sym && sym->name) {
- str_printf(r, "Symbol: %s [=%s]\n", sym->name,
- sym_get_string_value(sym));
- str_printf(r, "Type : %s\n", sym_type_name(sym->type));
- if (sym->type == S_INT || sym->type == S_HEX) {
- prop = sym_get_range_prop(sym);
- if (prop) {
- str_printf(r, "Range : ");
- expr_gstr_print(prop->expr, r);
- str_append(r, "\n");
- }
- }
- }
- for_all_prompts(sym, prop)
- get_prompt_str(r, prop, head);
-
- prop = get_symbol_prop(sym);
- if (prop) {
- str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
- prop->menu->lineno);
- if (!expr_is_yes(prop->visible.expr)) {
- str_append(r, _(" Depends on: "));
- expr_gstr_print(prop->visible.expr, r);
- str_append(r, "\n");
- }
- }
-
- get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
- if (sym->rev_dep.expr) {
- str_append(r, _(" Selected by: "));
- expr_gstr_print(sym->rev_dep.expr, r);
- str_append(r, "\n");
- }
-
- get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
- if (sym->implied.expr) {
- str_append(r, _(" Implied by: "));
- expr_gstr_print(sym->implied.expr, r);
- str_append(r, "\n");
- }
-
- str_append(r, "\n\n");
-}
-
-struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
-{
- struct symbol *sym;
- struct gstr res = str_new();
- int i;
-
- for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
- get_symbol_str(&res, sym, head);
- if (!i)
- str_append(&res, _("No matches found.\n"));
- return res;
-}
-
-
-void menu_get_ext_help(struct menu *menu, struct gstr *help)
-{
- struct symbol *sym = menu->sym;
- const char *help_text = nohelp_text;
-
- if (menu_has_help(menu)) {
- if (sym->name)
- str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
- help_text = menu_get_help(menu);
- }
- str_printf(help, "%s\n", _(help_text));
- if (sym)
- get_symbol_str(help, sym, NULL);
-}
diff --git a/backport/kconf/symbol.c b/backport/kconf/symbol.c
deleted file mode 100644
index 20136ffe..00000000
--- a/backport/kconf/symbol.c
+++ /dev/null
@@ -1,1414 +0,0 @@
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <regex.h>
-#include <sys/utsname.h>
-
-#include "lkc.h"
-
-struct symbol symbol_yes = {
- .name = "y",
- .curr = { "y", yes },
- .flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_mod = {
- .name = "m",
- .curr = { "m", mod },
- .flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_no = {
- .name = "n",
- .curr = { "n", no },
- .flags = SYMBOL_CONST|SYMBOL_VALID,
-}, symbol_empty = {
- .name = "",
- .curr = { "", no },
- .flags = SYMBOL_VALID,
-};
-
-struct symbol *sym_defconfig_list;
-struct symbol *modules_sym;
-tristate modules_val;
-
-struct expr *sym_env_list;
-
-static void sym_add_default(struct symbol *sym, const char *def)
-{
- struct property *prop = prop_alloc(P_DEFAULT, sym);
-
- prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST));
-}
-
-void sym_init(void)
-{
- struct symbol *sym;
- struct utsname uts;
- static bool inited = false;
-
- if (inited)
- return;
- inited = true;
-
- uname(&uts);
-
- sym = sym_lookup("UNAME_RELEASE", 0);
- sym->type = S_STRING;
- sym->flags |= SYMBOL_AUTO;
- sym_add_default(sym, uts.release);
-}
-
-enum symbol_type sym_get_type(struct symbol *sym)
-{
- enum symbol_type type = sym->type;
-
- if (type == S_TRISTATE) {
- if (sym_is_choice_value(sym) && sym->visible == yes)
- type = S_BOOLEAN;
- else if (modules_val == no)
- type = S_BOOLEAN;
- }
- return type;
-}
-
-const char *sym_type_name(enum symbol_type type)
-{
- switch (type) {
- case S_BOOLEAN:
- return "boolean";
- case S_TRISTATE:
- return "tristate";
- case S_INT:
- return "integer";
- case S_HEX:
- return "hex";
- case S_STRING:
- return "string";
- case S_UNKNOWN:
- return "unknown";
- case S_OTHER:
- break;
- }
- return "???";
-}
-
-struct property *sym_get_choice_prop(struct symbol *sym)
-{
- struct property *prop;
-
- for_all_choices(sym, prop)
- return prop;
- return NULL;
-}
-
-struct property *sym_get_env_prop(struct symbol *sym)
-{
- struct property *prop;
-
- for_all_properties(sym, prop, P_ENV)
- return prop;
- return NULL;
-}
-
-static struct property *sym_get_default_prop(struct symbol *sym)
-{
- struct property *prop;
-
- for_all_defaults(sym, prop) {
- prop->visible.tri = expr_calc_value(prop->visible.expr);
- if (prop->visible.tri != no)
- return prop;
- }
- return NULL;
-}
-
-static struct property *sym_get_range_prop(struct symbol *sym)
-{
- struct property *prop;
-
- for_all_properties(sym, prop, P_RANGE) {
- prop->visible.tri = expr_calc_value(prop->visible.expr);
- if (prop->visible.tri != no)
- return prop;
- }
- return NULL;
-}
-
-static long long sym_get_range_val(struct symbol *sym, int base)
-{
- sym_calc_value(sym);
- switch (sym->type) {
- case S_INT:
- base = 10;
- break;
- case S_HEX:
- base = 16;
- break;
- default:
- break;
- }
- return strtoll(sym->curr.val, NULL, base);
-}
-
-static void sym_validate_range(struct symbol *sym)
-{
- struct property *prop;
- int base;
- long long val, val2;
- char str[64];
-
- switch (sym->type) {
- case S_INT:
- base = 10;
- break;
- case S_HEX:
- base = 16;
- break;
- default:
- return;
- }
- prop = sym_get_range_prop(sym);
- if (!prop)
- return;
- val = strtoll(sym->curr.val, NULL, base);
- val2 = sym_get_range_val(prop->expr->left.sym, base);
- if (val >= val2) {
- val2 = sym_get_range_val(prop->expr->right.sym, base);
- if (val <= val2)
- return;
- }
- if (sym->type == S_INT)
- sprintf(str, "%lld", val2);
- else
- sprintf(str, "0x%llx", val2);
- sym->curr.val = strdup(str);
-}
-
-static void sym_set_changed(struct symbol *sym)
-{
- struct property *prop;
-
- sym->flags |= SYMBOL_CHANGED;
- for (prop = sym->prop; prop; prop = prop->next) {
- if (prop->menu)
- prop->menu->flags |= MENU_CHANGED;
- }
-}
-
-static void sym_set_all_changed(void)
-{
- struct symbol *sym;
- int i;
-
- for_all_symbols(i, sym)
- sym_set_changed(sym);
-}
-
-static void sym_calc_visibility(struct symbol *sym)
-{
- struct property *prop;
- struct symbol *choice_sym = NULL;
- tristate tri;
-
- /* any prompt visible? */
- tri = no;
-
- if (sym_is_choice_value(sym))
- choice_sym = prop_get_symbol(sym_get_choice_prop(sym));
-
- for_all_prompts(sym, prop) {
- prop->visible.tri = expr_calc_value(prop->visible.expr);
- /*
- * Tristate choice_values with visibility 'mod' are
- * not visible if the corresponding choice's value is
- * 'yes'.
- */
- if (choice_sym && sym->type == S_TRISTATE &&
- prop->visible.tri == mod && choice_sym->curr.tri == yes)
- prop->visible.tri = no;
-
- tri = EXPR_OR(tri, prop->visible.tri);
- }
- if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
- tri = yes;
- if (sym->visible != tri) {
- sym->visible = tri;
- sym_set_changed(sym);
- }
- if (sym_is_choice_value(sym))
- return;
- /* defaulting to "yes" if no explicit "depends on" are given */
- tri = yes;
- if (sym->dir_dep.expr)
- tri = expr_calc_value(sym->dir_dep.expr);
- if (tri == mod)
- tri = yes;
- if (sym->dir_dep.tri != tri) {
- sym->dir_dep.tri = tri;
- sym_set_changed(sym);
- }
- tri = no;
- if (sym->rev_dep.expr)
- tri = expr_calc_value(sym->rev_dep.expr);
- if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
- tri = yes;
- if (sym->rev_dep.tri != tri) {
- sym->rev_dep.tri = tri;
- sym_set_changed(sym);
- }
- tri = no;
- if (sym->implied.expr && sym->dir_dep.tri != no)
- tri = expr_calc_value(sym->implied.expr);
- if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
- tri = yes;
- if (sym->implied.tri != tri) {
- sym->implied.tri = tri;
- sym_set_changed(sym);
- }
-}
-
-/*
- * Find the default symbol for a choice.
- * First try the default values for the choice symbol
- * Next locate the first visible choice value
- * Return NULL if none was found
- */
-struct symbol *sym_choice_default(struct symbol *sym)
-{
- struct symbol *def_sym;
- struct property *prop;
- struct expr *e;
-
- /* any of the defaults visible? */
- for_all_defaults(sym, prop) {
- prop->visible.tri = expr_calc_value(prop->visible.expr);
- if (prop->visible.tri == no)
- continue;
- def_sym = prop_get_symbol(prop);
- if (def_sym->visible != no)
- return def_sym;
- }
-
- /* just get the first visible value */
- prop = sym_get_choice_prop(sym);
- expr_list_for_each_sym(prop->expr, e, def_sym)
- if (def_sym->visible != no)
- return def_sym;
-
- /* failed to locate any defaults */
- return NULL;
-}
-
-static struct symbol *sym_calc_choice(struct symbol *sym)
-{
- struct symbol *def_sym;
- struct property *prop;
- struct expr *e;
- int flags;
-
- /* first calculate all choice values' visibilities */
- flags = sym->flags;
- prop = sym_get_choice_prop(sym);
- expr_list_for_each_sym(prop->expr, e, def_sym) {
- sym_calc_visibility(def_sym);
- if (def_sym->visible != no)
- flags &= def_sym->flags;
- }
-
- sym->flags &= flags | ~SYMBOL_DEF_USER;
-
- /* is the user choice visible? */
- def_sym = sym->def[S_DEF_USER].val;
- if (def_sym && def_sym->visible != no)
- return def_sym;
-
- def_sym = sym_choice_default(sym);
-
- if (def_sym == NULL)
- /* no choice? reset tristate value */
- sym->curr.tri = no;
-
- return def_sym;
-}
-
-void sym_calc_value(struct symbol *sym)
-{
- struct symbol_value newval, oldval;
- struct property *prop;
- struct expr *e;
-
- if (!sym)
- return;
-
- if (sym->flags & SYMBOL_VALID)
- return;
-
- if (sym_is_choice_value(sym) &&
- sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
- sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
- prop = sym_get_choice_prop(sym);
- sym_calc_value(prop_get_symbol(prop));
- }
-
- sym->flags |= SYMBOL_VALID;
-
- oldval = sym->curr;
-
- switch (sym->type) {
- case S_INT:
- case S_HEX:
- case S_STRING:
- newval = symbol_empty.curr;
- break;
- case S_BOOLEAN:
- case S_TRISTATE:
- newval = symbol_no.curr;
- break;
- default:
- sym->curr.val = sym->name;
- sym->curr.tri = no;
- return;
- }
- if (!sym_is_choice_value(sym))
- sym->flags &= ~SYMBOL_WRITE;
-
- sym_calc_visibility(sym);
-
- /* set default if recursively called */
- sym->curr = newval;
-
- switch (sym_get_type(sym)) {
- case S_BOOLEAN:
- case S_TRISTATE:
- if (sym_is_choice_value(sym) && sym->visible == yes) {
- prop = sym_get_choice_prop(sym);
- newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
- } else {
- if (sym->visible != no) {
- /* if the symbol is visible use the user value
- * if available, otherwise try the default value
- */
- sym->flags |= SYMBOL_WRITE;
- if (sym_has_value(sym)) {
- newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
- sym->visible);
- goto calc_newval;
- }
- }
- if (sym->rev_dep.tri != no)
- sym->flags |= SYMBOL_WRITE;
- if (!sym_is_choice(sym)) {
- prop = sym_get_default_prop(sym);
- if (prop) {
- sym->flags |= SYMBOL_WRITE;
- newval.tri = EXPR_AND(expr_calc_value(prop->expr),
- prop->visible.tri);
- }
- if (sym->implied.tri != no) {
- sym->flags |= SYMBOL_WRITE;
- newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
- }
- }
- calc_newval:
- if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
- struct expr *e;
- e = expr_simplify_unmet_dep(sym->rev_dep.expr,
- sym->dir_dep.expr);
- fprintf(stderr, "warning: (");
- expr_fprint(e, stderr);
- fprintf(stderr, ") selects %s which has unmet direct dependencies (",
- sym->name);
- expr_fprint(sym->dir_dep.expr, stderr);
- fprintf(stderr, ")\n");
- expr_free(e);
- }
- newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
- }
- if (newval.tri == mod &&
- (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes))
- newval.tri = yes;
- break;
- case S_STRING:
- case S_HEX:
- case S_INT:
- if (sym->visible != no) {
- sym->flags |= SYMBOL_WRITE;
- if (sym_has_value(sym)) {
- newval.val = sym->def[S_DEF_USER].val;
- break;
- }
- }
- prop = sym_get_default_prop(sym);
- if (prop) {
- struct symbol *ds = prop_get_symbol(prop);
- if (ds) {
- sym->flags |= SYMBOL_WRITE;
- sym_calc_value(ds);
- newval.val = ds->curr.val;
- }
- }
- break;
- default:
- ;
- }
-
- sym->curr = newval;
- if (sym_is_choice(sym) && newval.tri == yes)
- sym->curr.val = sym_calc_choice(sym);
- sym_validate_range(sym);
-
- if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
- sym_set_changed(sym);
- if (modules_sym == sym) {
- sym_set_all_changed();
- modules_val = modules_sym->curr.tri;
- }
- }
-
- if (sym_is_choice(sym)) {
- struct symbol *choice_sym;
-
- prop = sym_get_choice_prop(sym);
- expr_list_for_each_sym(prop->expr, e, choice_sym) {
- if ((sym->flags & SYMBOL_WRITE) &&
- choice_sym->visible != no)
- choice_sym->flags |= SYMBOL_WRITE;
- if (sym->flags & SYMBOL_CHANGED)
- sym_set_changed(choice_sym);
- }
- }
-
- if (sym->flags & SYMBOL_AUTO)
- sym->flags &= ~SYMBOL_WRITE;
-
- if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
- set_all_choice_values(sym);
-}
-
-void sym_clear_all_valid(void)
-{
- struct symbol *sym;
- int i;
-
- for_all_symbols(i, sym)
- sym->flags &= ~SYMBOL_VALID;
- sym_add_change_count(1);
- sym_calc_value(modules_sym);
-}
-
-bool sym_tristate_within_range(struct symbol *sym, tristate val)
-{
- int type = sym_get_type(sym);
-
- if (sym->visible == no)
- return false;
-
- if (type != S_BOOLEAN && type != S_TRISTATE)
- return false;
-
- if (type == S_BOOLEAN && val == mod)
- return false;
- if (sym->visible <= sym->rev_dep.tri)
- return false;
- if (sym->implied.tri == yes && val == mod)
- return false;
- if (sym_is_choice_value(sym) && sym->visible == yes)
- return val == yes;
- return val >= sym->rev_dep.tri && val <= sym->visible;
-}
-
-bool sym_set_tristate_value(struct symbol *sym, tristate val)
-{
- tristate oldval = sym_get_tristate_value(sym);
-
- if (oldval != val && !sym_tristate_within_range(sym, val))
- return false;
-
- if (!(sym->flags & SYMBOL_DEF_USER)) {
- sym->flags |= SYMBOL_DEF_USER;
- sym_set_changed(sym);
- }
- /*
- * setting a choice value also resets the new flag of the choice
- * symbol and all other choice values.
- */
- if (sym_is_choice_value(sym) && val == yes) {
- struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
- struct property *prop;
- struct expr *e;
-
- cs->def[S_DEF_USER].val = sym;
- cs->flags |= SYMBOL_DEF_USER;
- prop = sym_get_choice_prop(cs);
- for (e = prop->expr; e; e = e->left.expr) {
- if (e->right.sym->visible != no)
- e->right.sym->flags |= SYMBOL_DEF_USER;
- }
- }
-
- sym->def[S_DEF_USER].tri = val;
- if (oldval != val)
- sym_clear_all_valid();
-
- return true;
-}
-
-tristate sym_toggle_tristate_value(struct symbol *sym)
-{
- tristate oldval, newval;
-
- oldval = newval = sym_get_tristate_value(sym);
- do {
- switch (newval) {
- case no:
- newval = mod;
- break;
- case mod:
- newval = yes;
- break;
- case yes:
- newval = no;
- break;
- }
- if (sym_set_tristate_value(sym, newval))
- break;
- } while (oldval != newval);
- return newval;
-}
-
-bool sym_string_valid(struct symbol *sym, const char *str)
-{
- signed char ch;
-
- switch (sym->type) {
- case S_STRING:
- return true;
- case S_INT:
- ch = *str++;
- if (ch == '-')
- ch = *str++;
- if (!isdigit(ch))
- return false;
- if (ch == '0' && *str != 0)
- return false;
- while ((ch = *str++)) {
- if (!isdigit(ch))
- return false;
- }
- return true;
- case S_HEX:
- if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
- str += 2;
- ch = *str++;
- do {
- if (!isxdigit(ch))
- return false;
- } while ((ch = *str++));
- return true;
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (str[0]) {
- case 'y': case 'Y':
- case 'm': case 'M':
- case 'n': case 'N':
- return true;
- }
- return false;
- default:
- return false;
- }
-}
-
-bool sym_string_within_range(struct symbol *sym, const char *str)
-{
- struct property *prop;
- long long val;
-
- switch (sym->type) {
- case S_STRING:
- return sym_string_valid(sym, str);
- case S_INT:
- if (!sym_string_valid(sym, str))
- return false;
- prop = sym_get_range_prop(sym);
- if (!prop)
- return true;
- val = strtoll(str, NULL, 10);
- return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
- val <= sym_get_range_val(prop->expr->right.sym, 10);
- case S_HEX:
- if (!sym_string_valid(sym, str))
- return false;
- prop = sym_get_range_prop(sym);
- if (!prop)
- return true;
- val = strtoll(str, NULL, 16);
- return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
- val <= sym_get_range_val(prop->expr->right.sym, 16);
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (str[0]) {
- case 'y': case 'Y':
- return sym_tristate_within_range(sym, yes);
- case 'm': case 'M':
- return sym_tristate_within_range(sym, mod);
- case 'n': case 'N':
- return sym_tristate_within_range(sym, no);
- }
- return false;
- default:
- return false;
- }
-}
-
-bool sym_set_string_value(struct symbol *sym, const char *newval)
-{
- const char *oldval;
- char *val;
- int size;
-
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (newval[0]) {
- case 'y': case 'Y':
- return sym_set_tristate_value(sym, yes);
- case 'm': case 'M':
- return sym_set_tristate_value(sym, mod);
- case 'n': case 'N':
- return sym_set_tristate_value(sym, no);
- }
- return false;
- default:
- ;
- }
-
- if (!sym_string_within_range(sym, newval))
- return false;
-
- if (!(sym->flags & SYMBOL_DEF_USER)) {
- sym->flags |= SYMBOL_DEF_USER;
- sym_set_changed(sym);
- }
-
- oldval = sym->def[S_DEF_USER].val;
- size = strlen(newval) + 1;
- if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
- size += 2;
- sym->def[S_DEF_USER].val = val = xmalloc(size);
- *val++ = '0';
- *val++ = 'x';
- } else if (!oldval || strcmp(oldval, newval))
- sym->def[S_DEF_USER].val = val = xmalloc(size);
- else
- return true;
-
- strcpy(val, newval);
- free((void *)oldval);
- sym_clear_all_valid();
-
- return true;
-}
-
-/*
- * Find the default value associated to a symbol.
- * For tristate symbol handle the modules=n case
- * in which case "m" becomes "y".
- * If the symbol does not have any default then fallback
- * to the fixed default values.
- */
-const char *sym_get_string_default(struct symbol *sym)
-{
- struct property *prop;
- struct symbol *ds;
- const char *str;
- tristate val;
-
- sym_calc_visibility(sym);
- sym_calc_value(modules_sym);
- val = symbol_no.curr.tri;
- str = symbol_empty.curr.val;
-
- /* If symbol has a default value look it up */
- prop = sym_get_default_prop(sym);
- if (prop != NULL) {
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- /* The visibility may limit the value from yes => mod */
- val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
- break;
- default:
- /*
- * The following fails to handle the situation
- * where a default value is further limited by
- * the valid range.
- */
- ds = prop_get_symbol(prop);
- if (ds != NULL) {
- sym_calc_value(ds);
- str = (const char *)ds->curr.val;
- }
- }
- }
-
- /* Handle select statements */
- val = EXPR_OR(val, sym->rev_dep.tri);
-
- /* transpose mod to yes if modules are not enabled */
- if (val == mod)
- if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
- val = yes;
-
- /* transpose mod to yes if type is bool */
- if (sym->type == S_BOOLEAN && val == mod)
- val = yes;
-
- /* adjust the default value if this symbol is implied by another */
- if (val < sym->implied.tri)
- val = sym->implied.tri;
-
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (val) {
- case no: return "n";
- case mod: return "m";
- case yes: return "y";
- }
- case S_INT:
- case S_HEX:
- return str;
- case S_STRING:
- return str;
- case S_OTHER:
- case S_UNKNOWN:
- break;
- }
- return "";
-}
-
-const char *sym_get_string_value(struct symbol *sym)
-{
- tristate val;
-
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- val = sym_get_tristate_value(sym);
- switch (val) {
- case no:
- return "n";
- case mod:
- sym_calc_value(modules_sym);
- return (modules_sym->curr.tri == no) ? "n" : "m";
- case yes:
- return "y";
- }
- break;
- default:
- ;
- }
- return (const char *)sym->curr.val;
-}
-
-bool sym_is_changable(struct symbol *sym)
-{
- return sym->visible > sym->rev_dep.tri;
-}
-
-static unsigned strhash(const char *s)
-{
- /* fnv32 hash */
- unsigned hash = 2166136261U;
- for (; *s; s++)
- hash = (hash ^ *s) * 0x01000193;
- return hash;
-}
-
-struct symbol *sym_lookup(const char *name, int flags)
-{
- struct symbol *symbol;
- char *new_name;
- int hash;
-
- if (name) {
- if (name[0] && !name[1]) {
- switch (name[0]) {
- case 'y': return &symbol_yes;
- case 'm': return &symbol_mod;
- case 'n': return &symbol_no;
- }
- }
- hash = strhash(name) % SYMBOL_HASHSIZE;
-
- for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (symbol->name &&
- !strcmp(symbol->name, name) &&
- (flags ? symbol->flags & flags
- : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
- return symbol;
- }
- new_name = strdup(name);
- } else {
- new_name = NULL;
- hash = 0;
- }
-
- symbol = xmalloc(sizeof(*symbol));
- memset(symbol, 0, sizeof(*symbol));
- symbol->name = new_name;
- symbol->type = S_UNKNOWN;
- symbol->flags |= flags;
-
- symbol->next = symbol_hash[hash];
- symbol_hash[hash] = symbol;
-
- return symbol;
-}
-
-struct symbol *sym_find(const char *name)
-{
- struct symbol *symbol = NULL;
- int hash = 0;
-
- if (!name)
- return NULL;
-
- if (name[0] && !name[1]) {
- switch (name[0]) {
- case 'y': return &symbol_yes;
- case 'm': return &symbol_mod;
- case 'n': return &symbol_no;
- }
- }
- hash = strhash(name) % SYMBOL_HASHSIZE;
-
- for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (symbol->name &&
- !strcmp(symbol->name, name) &&
- !(symbol->flags & SYMBOL_CONST))
- break;
- }
-
- return symbol;
-}
-
-/*
- * Expand symbol's names embedded in the string given in argument. Symbols'
- * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
- * the empty string.
- */
-const char *sym_expand_string_value(const char *in)
-{
- const char *src;
- char *res;
- size_t reslen;
-
- reslen = strlen(in) + 1;
- res = xmalloc(reslen);
- res[0] = '\0';
-
- while ((src = strchr(in, '$'))) {
- char *p, name[SYMBOL_MAXLENGTH];
- const char *symval = "";
- struct symbol *sym;
- size_t newlen;
-
- strncat(res, in, src - in);
- src++;
-
- p = name;
- while (isalnum(*src) || *src == '_')
- *p++ = *src++;
- *p = '\0';
-
- sym = sym_find(name);
- if (sym != NULL) {
- sym_calc_value(sym);
- symval = sym_get_string_value(sym);
- }
-
- newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
- if (newlen > reslen) {
- reslen = newlen;
- res = realloc(res, reslen);
- }
-
- strcat(res, symval);
- in = src;
- }
- strcat(res, in);
-
- return res;
-}
-
-const char *sym_escape_string_value(const char *in)
-{
- const char *p;
- size_t reslen;
- char *res;
- size_t l;
-
- reslen = strlen(in) + strlen("\"\"") + 1;
-
- p = in;
- for (;;) {
- l = strcspn(p, "\"\\");
- p += l;
-
- if (p[0] == '\0')
- break;
-
- reslen++;
- p++;
- }
-
- res = xmalloc(reslen);
- res[0] = '\0';
-
- strcat(res, "\"");
-
- p = in;
- for (;;) {
- l = strcspn(p, "\"\\");
- strncat(res, p, l);
- p += l;
-
- if (p[0] == '\0')
- break;
-
- strcat(res, "\\");
- strncat(res, p++, 1);
- }
-
- strcat(res, "\"");
- return res;
-}
-
-struct sym_match {
- struct symbol *sym;
- off_t so, eo;
-};
-
-/* Compare matched symbols as thus:
- * - first, symbols that match exactly
- * - then, alphabetical sort
- */
-static int sym_rel_comp(const void *sym1, const void *sym2)
-{
- const struct sym_match *s1 = sym1;
- const struct sym_match *s2 = sym2;
- int exact1, exact2;
-
- /* Exact match:
- * - if matched length on symbol s1 is the length of that symbol,
- * then this symbol should come first;
- * - if matched length on symbol s2 is the length of that symbol,
- * then this symbol should come first.
- * Note: since the search can be a regexp, both symbols may match
- * exactly; if this is the case, we can't decide which comes first,
- * and we fallback to sorting alphabetically.
- */
- exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
- exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
- if (exact1 && !exact2)
- return -1;
- if (!exact1 && exact2)
- return 1;
-
- /* As a fallback, sort symbols alphabetically */
- return strcmp(s1->sym->name, s2->sym->name);
-}
-
-struct symbol **sym_re_search(const char *pattern)
-{
- struct symbol *sym, **sym_arr = NULL;
- struct sym_match *sym_match_arr = NULL;
- int i, cnt, size;
- regex_t re;
- regmatch_t match[1];
-
- cnt = size = 0;
- /* Skip if empty */
- if (strlen(pattern) == 0)
- return NULL;
- if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
- return NULL;
-
- for_all_symbols(i, sym) {
- if (sym->flags & SYMBOL_CONST || !sym->name)
- continue;
- if (regexec(&re, sym->name, 1, match, 0))
- continue;
- if (cnt >= size) {
- void *tmp;
- size += 16;
- tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
- if (!tmp)
- goto sym_re_search_free;
- sym_match_arr = tmp;
- }
- sym_calc_value(sym);
- /* As regexec returned 0, we know we have a match, so
- * we can use match[0].rm_[se]o without further checks
- */
- sym_match_arr[cnt].so = match[0].rm_so;
- sym_match_arr[cnt].eo = match[0].rm_eo;
- sym_match_arr[cnt++].sym = sym;
- }
- if (sym_match_arr) {
- qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
- sym_arr = malloc((cnt+1) * sizeof(struct symbol));
- if (!sym_arr)
- goto sym_re_search_free;
- for (i = 0; i < cnt; i++)
- sym_arr[i] = sym_match_arr[i].sym;
- sym_arr[cnt] = NULL;
- }
-sym_re_search_free:
- /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
- free(sym_match_arr);
- regfree(&re);
-
- return sym_arr;
-}
-
-/*
- * When we check for recursive dependencies we use a stack to save
- * current state so we can print out relevant info to user.
- * The entries are located on the call stack so no need to free memory.
- * Note insert() remove() must always match to properly clear the stack.
- */
-static struct dep_stack {
- struct dep_stack *prev, *next;
- struct symbol *sym;
- struct property *prop;
- struct expr *expr;
-} *check_top;
-
-static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
-{
- memset(stack, 0, sizeof(*stack));
- if (check_top)
- check_top->next = stack;
- stack->prev = check_top;
- stack->sym = sym;
- check_top = stack;
-}
-
-static void dep_stack_remove(void)
-{
- check_top = check_top->prev;
- if (check_top)
- check_top->next = NULL;
-}
-
-/*
- * Called when we have detected a recursive dependency.
- * check_top point to the top of the stact so we use
- * the ->prev pointer to locate the bottom of the stack.
- */
-static void sym_check_print_recursive(struct symbol *last_sym)
-{
- struct dep_stack *stack;
- struct symbol *sym, *next_sym;
- struct menu *menu = NULL;
- struct property *prop;
- struct dep_stack cv_stack;
-
- if (sym_is_choice_value(last_sym)) {
- dep_stack_insert(&cv_stack, last_sym);
- last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
- }
-
- for (stack = check_top; stack != NULL; stack = stack->prev)
- if (stack->sym == last_sym)
- break;
- if (!stack) {
- fprintf(stderr, "unexpected recursive dependency error\n");
- return;
- }
-
- for (; stack; stack = stack->next) {
- sym = stack->sym;
- next_sym = stack->next ? stack->next->sym : last_sym;
- prop = stack->prop;
- if (prop == NULL)
- prop = stack->sym->prop;
-
- /* for choice values find the menu entry (used below) */
- if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
- for (prop = sym->prop; prop; prop = prop->next) {
- menu = prop->menu;
- if (prop->menu)
- break;
- }
- }
- if (stack->sym == last_sym)
- fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
- prop->file->name, prop->lineno);
- fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
- fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n");
- if (stack->expr) {
- fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
- prop->file->name, prop->lineno,
- sym->name ? sym->name : "<choice>",
- prop_get_type_name(prop->type),
- next_sym->name ? next_sym->name : "<choice>");
- } else if (stack->prop) {
- fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
- prop->file->name, prop->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
- } else if (sym_is_choice(sym)) {
- fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
- menu->file->name, menu->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
- } else if (sym_is_choice_value(sym)) {
- fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
- menu->file->name, menu->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
- } else {
- fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
- prop->file->name, prop->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
- }
- }
-
- if (check_top == &cv_stack)
- dep_stack_remove();
-}
-
-static struct symbol *sym_check_expr_deps(struct expr *e)
-{
- struct symbol *sym;
-
- if (!e)
- return NULL;
- switch (e->type) {
- case E_OR:
- case E_AND:
- sym = sym_check_expr_deps(e->left.expr);
- if (sym)
- return sym;
- return sym_check_expr_deps(e->right.expr);
- case E_NOT:
- return sym_check_expr_deps(e->left.expr);
- case E_EQUAL:
- case E_GEQ:
- case E_GTH:
- case E_LEQ:
- case E_LTH:
- case E_UNEQUAL:
- sym = sym_check_deps(e->left.sym);
- if (sym)
- return sym;
- return sym_check_deps(e->right.sym);
- case E_SYMBOL:
- return sym_check_deps(e->left.sym);
- default:
- break;
- }
- printf("Oops! How to check %d?\n", e->type);
- return NULL;
-}
-
-/* return NULL when dependencies are OK */
-static struct symbol *sym_check_sym_deps(struct symbol *sym)
-{
- struct symbol *sym2;
- struct property *prop;
- struct dep_stack stack;
-
- dep_stack_insert(&stack, sym);
-
- sym2 = sym_check_expr_deps(sym->rev_dep.expr);
- if (sym2)
- goto out;
-
- for (prop = sym->prop; prop; prop = prop->next) {
- if (prop->type == P_CHOICE || prop->type == P_SELECT)
- continue;
- stack.prop = prop;
- sym2 = sym_check_expr_deps(prop->visible.expr);
- if (sym2)
- break;
- if (prop->type != P_DEFAULT || sym_is_choice(sym))
- continue;
- stack.expr = prop->expr;
- sym2 = sym_check_expr_deps(prop->expr);
- if (sym2)
- break;
- stack.expr = NULL;
- }
-
-out:
- dep_stack_remove();
-
- return sym2;
-}
-
-static struct symbol *sym_check_choice_deps(struct symbol *choice)
-{
- struct symbol *sym, *sym2;
- struct property *prop;
- struct expr *e;
- struct dep_stack stack;
-
- dep_stack_insert(&stack, choice);
-
- prop = sym_get_choice_prop(choice);
- expr_list_for_each_sym(prop->expr, e, sym)
- sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
-
- choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
- sym2 = sym_check_sym_deps(choice);
- choice->flags &= ~SYMBOL_CHECK;
- if (sym2)
- goto out;
-
- expr_list_for_each_sym(prop->expr, e, sym) {
- sym2 = sym_check_sym_deps(sym);
- if (sym2)
- break;
- }
-out:
- expr_list_for_each_sym(prop->expr, e, sym)
- sym->flags &= ~SYMBOL_CHECK;
-
- if (sym2 && sym_is_choice_value(sym2) &&
- prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
- sym2 = choice;
-
- dep_stack_remove();
-
- return sym2;
-}
-
-struct symbol *sym_check_deps(struct symbol *sym)
-{
- struct symbol *sym2;
- struct property *prop;
-
- if (sym->flags & SYMBOL_CHECK) {
- sym_check_print_recursive(sym);
- return sym;
- }
- if (sym->flags & SYMBOL_CHECKED)
- return NULL;
-
- if (sym_is_choice_value(sym)) {
- struct dep_stack stack;
-
- /* for choice groups start the check with main choice symbol */
- dep_stack_insert(&stack, sym);
- prop = sym_get_choice_prop(sym);
- sym2 = sym_check_deps(prop_get_symbol(prop));
- dep_stack_remove();
- } else if (sym_is_choice(sym)) {
- sym2 = sym_check_choice_deps(sym);
- } else {
- sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
- sym2 = sym_check_sym_deps(sym);
- sym->flags &= ~SYMBOL_CHECK;
- }
-
- if (sym2 && sym2 == sym)
- sym2 = NULL;
-
- return sym2;
-}
-
-struct property *prop_alloc(enum prop_type type, struct symbol *sym)
-{
- struct property *prop;
- struct property **propp;
-
- prop = xmalloc(sizeof(*prop));
- memset(prop, 0, sizeof(*prop));
- prop->type = type;
- prop->sym = sym;
- prop->file = current_file;
- prop->lineno = zconf_lineno();
-
- /* append property to the prop list of symbol */
- if (sym) {
- for (propp = &sym->prop; *propp; propp = &(*propp)->next)
- ;
- *propp = prop;
- }
-
- return prop;
-}
-
-struct symbol *prop_get_symbol(struct property *prop)
-{
- if (prop->expr && (prop->expr->type == E_SYMBOL ||
- prop->expr->type == E_LIST))
- return prop->expr->left.sym;
- return NULL;
-}
-
-const char *prop_get_type_name(enum prop_type type)
-{
- switch (type) {
- case P_PROMPT:
- return "prompt";
- case P_ENV:
- return "env";
- case P_COMMENT:
- return "comment";
- case P_MENU:
- return "menu";
- case P_DEFAULT:
- return "default";
- case P_CHOICE:
- return "choice";
- case P_SELECT:
- return "select";
- case P_IMPLY:
- return "imply";
- case P_RANGE:
- return "range";
- case P_SYMBOL:
- return "symbol";
- case P_UNKNOWN:
- break;
- }
- return "unknown";
-}
-
-static void prop_add_env(const char *env)
-{
- struct symbol *sym, *sym2;
- struct property *prop;
- char *p;
-
- sym = current_entry->sym;
- sym->flags |= SYMBOL_AUTO;
- for_all_properties(sym, prop, P_ENV) {
- sym2 = prop_get_symbol(prop);
- if (strcmp(sym2->name, env))
- menu_warn(current_entry, "redefining environment symbol from %s",
- sym2->name);
- return;
- }
-
- prop = prop_alloc(P_ENV, sym);
- prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST));
-
- sym_env_list = expr_alloc_one(E_LIST, sym_env_list);
- sym_env_list->right.sym = sym;
-
- p = getenv(env);
- if (p)
- sym_add_default(sym, p);
- else
- menu_warn(current_entry, "environment variable %s undefined", env);
-}
diff --git a/backport/kconf/util.c b/backport/kconf/util.c
deleted file mode 100644
index 0e760424..00000000
--- a/backport/kconf/util.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
- * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include "lkc.h"
-
-/* file already present in list? If not add it */
-struct file *file_lookup(const char *name)
-{
- struct file *file;
- const char *file_name = sym_expand_string_value(name);
-
- for (file = file_list; file; file = file->next) {
- if (!strcmp(name, file->name)) {
- free((void *)file_name);
- return file;
- }
- }
-
- file = xmalloc(sizeof(*file));
- memset(file, 0, sizeof(*file));
- file->name = file_name;
- file->next = file_list;
- file_list = file;
- return file;
-}
-
-/* write a dependency file as used by kbuild to track dependencies */
-int file_write_dep(const char *name)
-{
- struct symbol *sym, *env_sym;
- struct expr *e;
- struct file *file;
- FILE *out;
-
- if (!name)
- name = ".kconfig.d";
- out = fopen("..config.tmp", "w");
- if (!out)
- return 1;
- fprintf(out, "deps_config := \\\n");
- for (file = file_list; file; file = file->next) {
- if (file->next)
- fprintf(out, "\t%s \\\n", file->name);
- else
- fprintf(out, "\t%s\n", file->name);
- }
- fprintf(out, "\n%s: \\\n"
- "\t$(deps_config)\n\n", conf_get_autoconfig_name());
-
- expr_list_for_each_sym(sym_env_list, e, sym) {
- struct property *prop;
- const char *value;
-
- prop = sym_get_env_prop(sym);
- env_sym = prop_get_symbol(prop);
- if (!env_sym)
- continue;
- value = getenv(env_sym->name);
- if (!value)
- value = "";
- fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
- fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
- fprintf(out, "endif\n");
- }
-
- fprintf(out, "\n$(deps_config): ;\n");
- fclose(out);
- rename("..config.tmp", name);
- return 0;
-}
-
-
-/* Allocate initial growable string */
-struct gstr str_new(void)
-{
- struct gstr gs;
- gs.s = xmalloc(sizeof(char) * 64);
- gs.len = 64;
- gs.max_width = 0;
- strcpy(gs.s, "\0");
- return gs;
-}
-
-/* Free storage for growable string */
-void str_free(struct gstr *gs)
-{
- if (gs->s)
- free(gs->s);
- gs->s = NULL;
- gs->len = 0;
-}
-
-/* Append to growable string */
-void str_append(struct gstr *gs, const char *s)
-{
- size_t l;
- if (s) {
- l = strlen(gs->s) + strlen(s) + 1;
- if (l > gs->len) {
- gs->s = realloc(gs->s, l);
- gs->len = l;
- }
- strcat(gs->s, s);
- }
-}
-
-/* Append printf formatted string to growable string */
-void str_printf(struct gstr *gs, const char *fmt, ...)
-{
- va_list ap;
- char s[10000]; /* big enough... */
- va_start(ap, fmt);
- vsnprintf(s, sizeof(s), fmt, ap);
- str_append(gs, s);
- va_end(ap);
-}
-
-/* Retrieve value of growable string */
-const char *str_get(struct gstr *gs)
-{
- return gs->s;
-}
-
-void *xmalloc(size_t size)
-{
- void *p = malloc(size);
- if (p)
- return p;
- fprintf(stderr, "Out of memory.\n");
- exit(1);
-}
-
-void *xcalloc(size_t nmemb, size_t size)
-{
- void *p = calloc(nmemb, size);
- if (p)
- return p;
- fprintf(stderr, "Out of memory.\n");
- exit(1);
-}
diff --git a/backport/kconf/zconf.hash.c b/backport/kconf/zconf.hash.c
deleted file mode 100644
index d51b15de..00000000
--- a/backport/kconf/zconf.hash.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ANSI-C code produced by gperf version 3.0.4 */
-/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */
-
-#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
- && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
- && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
- && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
- && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
- && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
- && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
- && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
- && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
- && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
- && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
- && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
- && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
- && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
- && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
- && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
- && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
- && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
- && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
- && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
- && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
- && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
- && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
-/* The character set is not based on ISO-646. */
-#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
-#endif
-
-#line 10 "scripts/kconfig/zconf.gperf"
-struct kconf_id;
-
-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
-/* maximum key range = 71, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-kconf_id_hash (register const char *str, register unsigned int len)
-{
- static const unsigned char asso_values[] =
- {
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 0, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 10, 25, 25,
- 0, 0, 0, 5, 0, 0, 73, 73, 5, 0,
- 10, 5, 45, 73, 20, 20, 0, 15, 15, 73,
- 20, 0, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73
- };
- register int hval = len;
-
- switch (hval)
- {
- default:
- hval += asso_values[(unsigned char)str[2]];
- /*FALLTHROUGH*/
- case 2:
- case 1:
- hval += asso_values[(unsigned char)str[0]];
- break;
- }
- return hval + asso_values[(unsigned char)str[len - 1]];
-}
-
-struct kconf_id_strings_t
- {
- char kconf_id_strings_str2[sizeof("if")];
- char kconf_id_strings_str3[sizeof("int")];
- char kconf_id_strings_str5[sizeof("endif")];
- char kconf_id_strings_str7[sizeof("default")];
- char kconf_id_strings_str8[sizeof("tristate")];
- char kconf_id_strings_str9[sizeof("endchoice")];
- char kconf_id_strings_str10[sizeof("---help---")];
- char kconf_id_strings_str12[sizeof("def_tristate")];
- char kconf_id_strings_str13[sizeof("def_bool")];
- char kconf_id_strings_str14[sizeof("defconfig_list")];
- char kconf_id_strings_str17[sizeof("on")];
- char kconf_id_strings_str18[sizeof("optional")];
- char kconf_id_strings_str21[sizeof("option")];
- char kconf_id_strings_str22[sizeof("endmenu")];
- char kconf_id_strings_str23[sizeof("mainmenu")];
- char kconf_id_strings_str25[sizeof("menuconfig")];
- char kconf_id_strings_str27[sizeof("modules")];
- char kconf_id_strings_str28[sizeof("allnoconfig_y")];
- char kconf_id_strings_str29[sizeof("menu")];
- char kconf_id_strings_str31[sizeof("select")];
- char kconf_id_strings_str32[sizeof("comment")];
- char kconf_id_strings_str33[sizeof("env")];
- char kconf_id_strings_str35[sizeof("range")];
- char kconf_id_strings_str36[sizeof("choice")];
- char kconf_id_strings_str39[sizeof("bool")];
- char kconf_id_strings_str41[sizeof("source")];
- char kconf_id_strings_str42[sizeof("visible")];
- char kconf_id_strings_str43[sizeof("hex")];
- char kconf_id_strings_str46[sizeof("config")];
- char kconf_id_strings_str47[sizeof("boolean")];
- char kconf_id_strings_str50[sizeof("imply")];
- char kconf_id_strings_str51[sizeof("string")];
- char kconf_id_strings_str54[sizeof("help")];
- char kconf_id_strings_str56[sizeof("prompt")];
- char kconf_id_strings_str72[sizeof("depends")];
- };
-static const struct kconf_id_strings_t kconf_id_strings_contents =
- {
- "if",
- "int",
- "endif",
- "default",
- "tristate",
- "endchoice",
- "---help---",
- "def_tristate",
- "def_bool",
- "defconfig_list",
- "on",
- "optional",
- "option",
- "endmenu",
- "mainmenu",
- "menuconfig",
- "modules",
- "allnoconfig_y",
- "menu",
- "select",
- "comment",
- "env",
- "range",
- "choice",
- "bool",
- "source",
- "visible",
- "hex",
- "config",
- "boolean",
- "imply",
- "string",
- "help",
- "prompt",
- "depends"
- };
-#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
-#ifdef __GNUC__
-__inline
-#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
-const struct kconf_id *
-kconf_id_lookup (register const char *str, register unsigned int len)
-{
- enum
- {
- TOTAL_KEYWORDS = 35,
- MIN_WORD_LENGTH = 2,
- MAX_WORD_LENGTH = 14,
- MIN_HASH_VALUE = 2,
- MAX_HASH_VALUE = 72
- };
-
- static const struct kconf_id wordlist[] =
- {
- {-1}, {-1},
-#line 26 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
-#line 37 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
- {-1},
-#line 27 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
- {-1},
-#line 30 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
-#line 32 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
-#line 20 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
-#line 25 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_HELP, TF_COMMAND},
- {-1},
-#line 33 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE},
-#line 36 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
-#line 47 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION},
- {-1}, {-1},
-#line 45 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM},
-#line 29 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND},
- {-1}, {-1},
-#line 44 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND},
-#line 17 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND},
-#line 15 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND},
- {-1},
-#line 23 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND},
- {-1},
-#line 46 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
-#line 49 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPT_ALLNOCONFIG_Y,TF_OPTION},
-#line 16 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
- {-1},
-#line 40 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
-#line 21 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
-#line 48 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION},
- {-1},
-#line 42 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND},
-#line 19 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND},
- {-1}, {-1},
-#line 34 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {-1},
-#line 18 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND},
-#line 43 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND},
-#line 38 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX},
- {-1}, {-1},
-#line 22 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND},
-#line 35 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {-1}, {-1},
-#line 41 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str50, T_IMPLY, TF_COMMAND},
-#line 39 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING},
- {-1}, {-1},
-#line 24 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND},
- {-1},
-#line 31 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
-#line 28 "scripts/kconfig/zconf.gperf"
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND}
- };
-
- if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- {
- register int key = kconf_id_hash (str, len);
-
- if (key <= MAX_HASH_VALUE && key >= 0)
- {
- register int o = wordlist[key].name;
- if (o >= 0)
- {
- register const char *s = o + kconf_id_strings;
-
- if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
- return &wordlist[key];
- }
- }
- }
- return 0;
-}
-#line 50 "scripts/kconfig/zconf.gperf"
-
diff --git a/backport/kconf/zconf.lex.c b/backport/kconf/zconf.lex.c
deleted file mode 100644
index 37fdf612..00000000
--- a/backport/kconf/zconf.lex.c
+++ /dev/null
@@ -1,2473 +0,0 @@
-
-#line 3 "scripts/kconfig/zconf.lex.c_shipped"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define yy_create_buffer zconf_create_buffer
-#define yy_delete_buffer zconf_delete_buffer
-#define yy_flex_debug zconf_flex_debug
-#define yy_init_buffer zconf_init_buffer
-#define yy_flush_buffer zconf_flush_buffer
-#define yy_load_buffer_state zconf_load_buffer_state
-#define yy_switch_to_buffer zconf_switch_to_buffer
-#define yyin zconfin
-#define yyleng zconfleng
-#define yylex zconflex
-#define yylineno zconflineno
-#define yyout zconfout
-#define yyrestart zconfrestart
-#define yytext zconftext
-#define yywrap zconfwrap
-#define yyalloc zconfalloc
-#define yyrealloc zconfrealloc
-#define yyfree zconffree
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE zconfrestart(zconfin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
-#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int zconfleng;
-
-extern FILE *zconfin, *zconfout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up zconftext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up zconftext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via zconfrestart()), so that the user can continue scanning by
- * just pointing zconfin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when zconftext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int zconfleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow zconfwrap()'s to do buffer switches
- * instead of setting up a fresh zconfin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void zconfrestart (FILE *input_file );
-void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size );
-void zconf_delete_buffer (YY_BUFFER_STATE b );
-void zconf_flush_buffer (YY_BUFFER_STATE b );
-void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer );
-void zconfpop_buffer_state (void );
-
-static void zconfensure_buffer_stack (void );
-static void zconf_load_buffer_state (void );
-static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len );
-
-void *zconfalloc (yy_size_t );
-void *zconfrealloc (void *,yy_size_t );
-void zconffree (void * );
-
-#define yy_new_buffer zconf_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- zconfensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- zconfensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-#define zconfwrap(n) 1
-#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
-
-FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int zconflineno;
-
-int zconflineno = 1;
-
-extern char *zconftext;
-#define yytext_ptr zconftext
-static yyconst flex_int16_t yy_nxt[][18] =
- {
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
- },
-
- {
- 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12
- },
-
- {
- 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12
- },
-
- {
- 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 18, 16, 16, 16, 16, 16, 16
- },
-
- {
- 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 18, 16, 16, 16, 16, 16, 16
-
- },
-
- {
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19
- },
-
- {
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19
- },
-
- {
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 22, 25, 22
- },
-
- {
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 22, 25, 22
- },
-
- {
- 11, 26, 27, 28, 29, 30, 31, 32, 30, 33,
- 34, 35, 35, 36, 37, 38, 39, 40
-
- },
-
- {
- 11, 26, 27, 28, 29, 30, 31, 32, 30, 33,
- 34, 35, 35, 36, 37, 38, 39, 40
- },
-
- {
- -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
- -11, -11, -11, -11, -11, -11, -11, -11
- },
-
- {
- 11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
- -12, -12, -12, -12, -12, -12, -12, -12
- },
-
- {
- 11, -13, 41, 42, -13, -13, 43, -13, -13, -13,
- -13, -13, -13, -13, -13, -13, -13, -13
- },
-
- {
- 11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
- -14, -14, -14, -14, -14, -14, -14, -14
-
- },
-
- {
- 11, 44, 44, 45, 44, 44, 44, 44, 44, 44,
- 44, 44, 44, 44, 44, 44, 44, 44
- },
-
- {
- 11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
- -16, -16, -16, -16, -16, -16, -16, -16
- },
-
- {
- 11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
- -17, -17, -17, -17, -17, -17, -17, -17
- },
-
- {
- 11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
- -18, 46, -18, -18, -18, -18, -18, -18
- },
-
- {
- 11, 47, 47, -19, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47
-
- },
-
- {
- 11, -20, 48, 49, -20, -20, -20, -20, -20, -20,
- -20, -20, -20, -20, -20, -20, -20, -20
- },
-
- {
- 11, 50, -21, -21, 50, 50, 50, 50, 50, 50,
- 50, 50, 50, 50, 50, 50, 50, 50
- },
-
- {
- 11, 51, 51, 52, 51, -22, 51, 51, -22, 51,
- 51, 51, 51, 51, 51, 51, -22, 51
- },
-
- {
- 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
- -23, -23, -23, -23, -23, -23, -23, -23
- },
-
- {
- 11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- -24, -24, -24, -24, -24, -24, -24, -24
-
- },
-
- {
- 11, 53, 53, 54, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53
- },
-
- {
- 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
- -26, -26, -26, -26, -26, -26, -26, -26
- },
-
- {
- 11, -27, 55, -27, -27, -27, -27, -27, -27, -27,
- -27, -27, -27, -27, -27, -27, -27, -27
- },
-
- {
- 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
- -28, -28, -28, -28, -28, -28, -28, -28
- },
-
- {
- 11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
- -29, -29, -29, -29, 56, -29, -29, -29
-
- },
-
- {
- 11, -30, -30, -30, -30, -30, -30, -30, -30, -30,
- -30, -30, -30, -30, -30, -30, -30, -30
- },
-
- {
- 11, 57, 57, -31, 57, 57, 57, 57, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57
- },
-
- {
- 11, -32, -32, -32, -32, -32, -32, 58, -32, -32,
- -32, -32, -32, -32, -32, -32, -32, -32
- },
-
- {
- 11, -33, -33, -33, -33, -33, -33, -33, -33, -33,
- -33, -33, -33, -33, -33, -33, -33, -33
- },
-
- {
- 11, -34, -34, -34, -34, -34, -34, -34, -34, -34,
- -34, -34, -34, -34, -34, -34, -34, -34
-
- },
-
- {
- 11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
- -35, 59, 59, -35, -35, -35, -35, -35
- },
-
- {
- 11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
- -36, -36, -36, -36, 60, -36, -36, -36
- },
-
- {
- 11, -37, -37, -37, -37, -37, -37, -37, -37, -37,
- -37, -37, -37, -37, -37, -37, -37, -37
- },
-
- {
- 11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
- -38, -38, -38, -38, 61, -38, -38, -38
- },
-
- {
- 11, -39, -39, 62, -39, -39, -39, -39, -39, -39,
- -39, -39, -39, -39, -39, -39, -39, -39
-
- },
-
- {
- 11, -40, -40, -40, -40, -40, -40, -40, -40, -40,
- -40, -40, -40, -40, -40, -40, -40, 63
- },
-
- {
- 11, -41, 41, 42, -41, -41, 43, -41, -41, -41,
- -41, -41, -41, -41, -41, -41, -41, -41
- },
-
- {
- 11, -42, -42, -42, -42, -42, -42, -42, -42, -42,
- -42, -42, -42, -42, -42, -42, -42, -42
- },
-
- {
- 11, 44, 44, 45, 44, 44, 44, 44, 44, 44,
- 44, 44, 44, 44, 44, 44, 44, 44
- },
-
- {
- 11, 44, 44, 45, 44, 44, 44, 44, 44, 44,
- 44, 44, 44, 44, 44, 44, 44, 44
-
- },
-
- {
- 11, -45, -45, -45, -45, -45, -45, -45, -45, -45,
- -45, -45, -45, -45, -45, -45, -45, -45
- },
-
- {
- 11, -46, -46, -46, -46, -46, -46, -46, -46, -46,
- -46, 46, -46, -46, -46, -46, -46, -46
- },
-
- {
- 11, 47, 47, -47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47
- },
-
- {
- 11, -48, 48, 49, -48, -48, -48, -48, -48, -48,
- -48, -48, -48, -48, -48, -48, -48, -48
- },
-
- {
- 11, 50, -49, -49, 50, 50, 50, 50, 50, 50,
- 50, 50, 50, 50, 50, 50, 50, 50
-
- },
-
- {
- 11, -50, -50, -50, -50, -50, -50, -50, -50, -50,
- -50, -50, -50, -50, -50, -50, -50, -50
- },
-
- {
- 11, 51, 51, 52, 51, -51, 51, 51, -51, 51,
- 51, 51, 51, 51, 51, 51, -51, 51
- },
-
- {
- 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
- -52, -52, -52, -52, -52, -52, -52, -52
- },
-
- {
- 11, -53, -53, 54, -53, -53, -53, -53, -53, -53,
- -53, -53, -53, -53, -53, -53, -53, -53
- },
-
- {
- 11, -54, -54, -54, -54, -54, -54, -54, -54, -54,
- -54, -54, -54, -54, -54, -54, -54, -54
-
- },
-
- {
- 11, -55, 55, -55, -55, -55, -55, -55, -55, -55,
- -55, -55, -55, -55, -55, -55, -55, -55
- },
-
- {
- 11, -56, -56, -56, -56, -56, -56, -56, -56, -56,
- -56, -56, -56, -56, -56, -56, -56, -56
- },
-
- {
- 11, 57, 57, -57, 57, 57, 57, 57, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57
- },
-
- {
- 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
- -58, -58, -58, -58, -58, -58, -58, -58
- },
-
- {
- 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
- -59, 59, 59, -59, -59, -59, -59, -59
-
- },
-
- {
- 11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
- -60, -60, -60, -60, -60, -60, -60, -60
- },
-
- {
- 11, -61, -61, -61, -61, -61, -61, -61, -61, -61,
- -61, -61, -61, -61, -61, -61, -61, -61
- },
-
- {
- 11, -62, -62, -62, -62, -62, -62, -62, -62, -62,
- -62, -62, -62, -62, -62, -62, -62, -62
- },
-
- {
- 11, -63, -63, -63, -63, -63, -63, -63, -63, -63,
- -63, -63, -63, -63, -63, -63, -63, -63
- },
-
- } ;
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up zconftext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- zconfleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 37
-#define YY_END_OF_BUFFER 38
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[64] =
- { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 38, 5, 4, 2, 3, 7, 8, 6, 36, 33,
- 35, 28, 32, 31, 30, 26, 25, 21, 13, 20,
- 23, 26, 11, 12, 22, 18, 14, 19, 26, 26,
- 4, 2, 3, 3, 1, 6, 36, 33, 35, 34,
- 28, 27, 30, 29, 25, 15, 23, 9, 22, 16,
- 17, 24, 10
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,
- 10, 1, 1, 1, 11, 12, 12, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 1, 1, 13,
- 14, 15, 1, 1, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 1, 16, 1, 1, 11, 1, 11, 11, 11, 11,
-
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 1, 17, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-extern int zconf_flex_debug;
-int zconf_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *zconftext;
-#define YY_NO_INPUT 1
-
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "lkc.h"
-
-#define START_STRSIZE 16
-
-static struct {
- struct file *file;
- int lineno;
-} current_pos;
-
-static char *text;
-static int text_size, text_asize;
-
-struct buffer {
- struct buffer *parent;
- YY_BUFFER_STATE state;
-};
-
-struct buffer *current_buf;
-
-static int last_ts, first_ts;
-
-static void zconf_endhelp(void);
-static void zconf_endfile(void);
-
-static void new_string(void)
-{
- text = xmalloc(START_STRSIZE);
- text_asize = START_STRSIZE;
- text_size = 0;
- *text = 0;
-}
-
-static void append_string(const char *str, int size)
-{
- int new_size = text_size + size + 1;
- if (new_size > text_asize) {
- new_size += START_STRSIZE - 1;
- new_size &= -START_STRSIZE;
- text = realloc(text, new_size);
- text_asize = new_size;
- }
- memcpy(text + text_size, str, size);
- text_size += size;
- text[text_size] = 0;
-}
-
-static void alloc_string(const char *str, int size)
-{
- text = xmalloc(size + 1);
- memcpy(text, str, size);
- text[size] = 0;
-}
-
-static void warn_ignored_character(char chr)
-{
- fprintf(stderr,
- "%s:%d:warning: ignoring unsupported character '%c'\n",
- zconf_curname(), zconf_lineno(), chr);
-}
-
-#define INITIAL 0
-#define COMMAND 1
-#define HELP 2
-#define STRING 3
-#define PARAM 4
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int zconflex_destroy (void );
-
-int zconfget_debug (void );
-
-void zconfset_debug (int debug_flag );
-
-YY_EXTRA_TYPE zconfget_extra (void );
-
-void zconfset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *zconfget_in (void );
-
-void zconfset_in (FILE * in_str );
-
-FILE *zconfget_out (void );
-
-void zconfset_out (FILE * out_str );
-
-int zconfget_leng (void );
-
-char *zconfget_text (void );
-
-int zconfget_lineno (void );
-
-void zconfset_lineno (int line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int zconfwrap (void );
-#else
-extern int zconfwrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
-#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- errno=0; \
- while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(zconfin); \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int zconflex (void);
-
-#define YY_DECL int zconflex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after zconftext and zconfleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
- int str = 0;
- int ts, i;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! zconfin )
- zconfin = stdin;
-
- if ( ! zconfout )
- zconfout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- zconfensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- zconf_create_buffer(zconfin,YY_BUF_SIZE );
- }
-
- zconf_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of zconftext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
- ++yy_cp;
-
- yy_current_state = -yy_current_state;
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
-case 1:
-/* rule 1 can match eol */
-case 2:
-/* rule 2 can match eol */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- return T_EOL;
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-{
- BEGIN(COMMAND);
-}
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-{
- unput(zconftext[0]);
- BEGIN(COMMAND);
-}
- YY_BREAK
-
-case 6:
-YY_RULE_SETUP
-{
- const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
- BEGIN(PARAM);
- current_pos.file = current_file;
- current_pos.lineno = current_file->lineno;
- if (id && id->flags & TF_COMMAND) {
- zconflval.id = id;
- return id->token;
- }
- alloc_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD;
- }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-warn_ignored_character(*zconftext);
- YY_BREAK
-case 8:
-/* rule 8 can match eol */
-YY_RULE_SETUP
-{
- BEGIN(INITIAL);
- current_file->lineno++;
- return T_EOL;
- }
- YY_BREAK
-
-case 9:
-YY_RULE_SETUP
-return T_AND;
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-return T_OR;
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-return T_OPEN_PAREN;
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-return T_CLOSE_PAREN;
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-return T_NOT;
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-return T_EQUAL;
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-return T_UNEQUAL;
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-return T_LESS_EQUAL;
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-return T_GREATER_EQUAL;
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-return T_LESS;
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-return T_GREATER;
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-{
- str = zconftext[0];
- new_string();
- BEGIN(STRING);
- }
- YY_BREAK
-case 21:
-/* rule 21 can match eol */
-YY_RULE_SETUP
-BEGIN(INITIAL); current_file->lineno++; return T_EOL;
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-{
- const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
- if (id && id->flags & TF_PARAM) {
- zconflval.id = id;
- return id->token;
- }
- alloc_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD;
- }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-/* comment */
- YY_BREAK
-case 24:
-/* rule 24 can match eol */
-YY_RULE_SETUP
-current_file->lineno++;
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-warn_ignored_character(*zconftext);
- YY_BREAK
-case YY_STATE_EOF(PARAM):
-{
- BEGIN(INITIAL);
- }
- YY_BREAK
-
-case 27:
-/* rule 27 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- append_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD_QUOTE;
- }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-{
- append_string(zconftext, zconfleng);
- }
- YY_BREAK
-case 29:
-/* rule 29 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- append_string(zconftext + 1, zconfleng - 1);
- zconflval.string = text;
- return T_WORD_QUOTE;
- }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-{
- append_string(zconftext + 1, zconfleng - 1);
- }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-{
- if (str == zconftext[0]) {
- BEGIN(PARAM);
- zconflval.string = text;
- return T_WORD_QUOTE;
- } else
- append_string(zconftext, 1);
- }
- YY_BREAK
-case 32:
-/* rule 32 can match eol */
-YY_RULE_SETUP
-{
- printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
- current_file->lineno++;
- BEGIN(INITIAL);
- return T_EOL;
- }
- YY_BREAK
-case YY_STATE_EOF(STRING):
-{
- BEGIN(INITIAL);
- }
- YY_BREAK
-
-case 33:
-YY_RULE_SETUP
-{
- ts = 0;
- for (i = 0; i < zconfleng; i++) {
- if (zconftext[i] == '\t')
- ts = (ts & ~7) + 8;
- else
- ts++;
- }
- last_ts = ts;
- if (first_ts) {
- if (ts < first_ts) {
- zconf_endhelp();
- return T_HELPTEXT;
- }
- ts -= first_ts;
- while (ts > 8) {
- append_string(" ", 8);
- ts -= 8;
- }
- append_string(" ", ts);
- }
- }
- YY_BREAK
-case 34:
-/* rule 34 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- zconf_endhelp();
- return T_HELPTEXT;
- }
- YY_BREAK
-case 35:
-/* rule 35 can match eol */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- append_string("\n", 1);
- }
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-{
- while (zconfleng) {
- if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t'))
- break;
- zconfleng--;
- }
- append_string(zconftext, zconfleng);
- if (!first_ts)
- first_ts = last_ts;
- }
- YY_BREAK
-case YY_STATE_EOF(HELP):
-{
- zconf_endhelp();
- return T_HELPTEXT;
- }
- YY_BREAK
-
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(COMMAND):
-{
- if (current_file) {
- zconf_endfile();
- return T_EOL;
- }
- fclose(zconfin);
- yyterminate();
-}
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-YY_FATAL_ERROR( "flex scanner jammed" );
- YY_BREAK
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed zconfin at a new source and called
- * zconflex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( zconfwrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * zconftext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of zconflex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), (size_t) num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- zconfrestart(zconfin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
-
- yy_current_state = yy_nxt[yy_current_state][1];
- yy_is_jam = (yy_current_state <= 0);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up zconftext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- zconfrestart(zconfin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( zconfwrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve zconftext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void zconfrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- zconfensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- zconf_create_buffer(zconfin,YY_BUF_SIZE );
- }
-
- zconf_init_buffer(YY_CURRENT_BUFFER,input_file );
- zconf_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * zconfpop_buffer_state();
- * zconfpush_buffer_state(new_buffer);
- */
- zconfensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- zconf_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (zconfwrap()) processing, but the only time this flag
- * is looked at is after zconfwrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void zconf_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- zconf_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with zconf_create_buffer()
- *
- */
- void zconf_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- zconffree((void *) b->yy_ch_buf );
-
- zconffree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a zconfrestart() or at EOF.
- */
- static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- zconf_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then zconf_init_buffer was _probably_
- * called from zconfrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void zconf_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- zconf_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- zconfensure_buffer_stack();
-
- /* This block is copied from zconf_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from zconf_switch_to_buffer. */
- zconf_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void zconfpop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- zconf_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- zconf_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void zconfensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- zconf_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to zconflex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * zconf_scan_bytes() instead.
- */
-YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )
-{
-
- return zconf_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) zconfalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = zconf_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up zconftext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- zconftext[zconfleng] = (yy_hold_char); \
- (yy_c_buf_p) = zconftext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- zconfleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int zconfget_lineno (void)
-{
-
- return zconflineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *zconfget_in (void)
-{
- return zconfin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *zconfget_out (void)
-{
- return zconfout;
-}
-
-/** Get the length of the current token.
- *
- */
-int zconfget_leng (void)
-{
- return zconfleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *zconfget_text (void)
-{
- return zconftext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void zconfset_lineno (int line_number )
-{
-
- zconflineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see zconf_switch_to_buffer
- */
-void zconfset_in (FILE * in_str )
-{
- zconfin = in_str ;
-}
-
-void zconfset_out (FILE * out_str )
-{
- zconfout = out_str ;
-}
-
-int zconfget_debug (void)
-{
- return zconf_flex_debug;
-}
-
-void zconfset_debug (int bdebug )
-{
- zconf_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from zconflex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- zconfin = stdin;
- zconfout = stdout;
-#else
- zconfin = (FILE *) 0;
- zconfout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * zconflex_init()
- */
- return 0;
-}
-
-/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
-int zconflex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- zconf_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- zconfpop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- zconffree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * zconflex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *zconfalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *zconfrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void zconffree (void * ptr )
-{
- free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-void zconf_starthelp(void)
-{
- new_string();
- last_ts = first_ts = 0;
- BEGIN(HELP);
-}
-
-static void zconf_endhelp(void)
-{
- zconflval.string = text;
- BEGIN(INITIAL);
-}
-
-/*
- * Try to open specified file with following names:
- * ./name
- * $(srctree)/name
- * The latter is used when srctree is separate from objtree
- * when compiling the kernel.
- * Return NULL if file is not found.
- */
-FILE *zconf_fopen(const char *name)
-{
- char *env, fullname[PATH_MAX+1];
- FILE *f;
-
- f = fopen(name, "r");
- if (!f && name != NULL && name[0] != '/') {
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- f = fopen(fullname, "r");
- }
- }
- return f;
-}
-
-void zconf_initscan(const char *name)
-{
- zconfin = zconf_fopen(name);
- if (!zconfin) {
- printf("can't find file %s\n", name);
- exit(1);
- }
-
- current_buf = xmalloc(sizeof(*current_buf));
- memset(current_buf, 0, sizeof(*current_buf));
-
- current_file = file_lookup(name);
- current_file->lineno = 1;
-}
-
-void zconf_nextfile(const char *name)
-{
- struct file *iter;
- struct file *file = file_lookup(name);
- struct buffer *buf = xmalloc(sizeof(*buf));
- memset(buf, 0, sizeof(*buf));
-
- current_buf->state = YY_CURRENT_BUFFER;
- zconfin = zconf_fopen(file->name);
- if (!zconfin) {
- printf("%s:%d: can't open file \"%s\"\n",
- zconf_curname(), zconf_lineno(), file->name);
- exit(1);
- }
- zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
- buf->parent = current_buf;
- current_buf = buf;
-
- for (iter = current_file->parent; iter; iter = iter->parent ) {
- if (!strcmp(current_file->name,iter->name) ) {
- printf("%s:%d: recursive inclusion detected. "
- "Inclusion path:\n current file : '%s'\n",
- zconf_curname(), zconf_lineno(),
- zconf_curname());
- iter = current_file->parent;
- while (iter && \
- strcmp(iter->name,current_file->name)) {
- printf(" included from: '%s:%d'\n",
- iter->name, iter->lineno-1);
- iter = iter->parent;
- }
- if (iter)
- printf(" included from: '%s:%d'\n",
- iter->name, iter->lineno+1);
- exit(1);
- }
- }
- file->lineno = 1;
- file->parent = current_file;
- current_file = file;
-}
-
-static void zconf_endfile(void)
-{
- struct buffer *parent;
-
- current_file = current_file->parent;
-
- parent = current_buf->parent;
- if (parent) {
- fclose(zconfin);
- zconf_delete_buffer(YY_CURRENT_BUFFER);
- zconf_switch_to_buffer(parent->state);
- }
- free(current_buf);
- current_buf = parent;
-}
-
-int zconf_lineno(void)
-{
- return current_pos.lineno;
-}
-
-const char *zconf_curname(void)
-{
- return current_pos.file ? current_pos.file->name : "<none>";
-}
-
diff --git a/backport/kconf/zconf.tab.c b/backport/kconf/zconf.tab.c
deleted file mode 100644
index 65b7515a..00000000
--- a/backport/kconf/zconf.tab.c
+++ /dev/null
@@ -1,2471 +0,0 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
-
-/* Bison implementation for Yacc-like parsers in C
-
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Push parsers. */
-#define YYPUSH 0
-
-/* Pull parsers. */
-#define YYPULL 1
-
-
-/* Substitute the variable and function names. */
-#define yyparse zconfparse
-#define yylex zconflex
-#define yyerror zconferror
-#define yydebug zconfdebug
-#define yynerrs zconfnerrs
-
-#define yylval zconflval
-#define yychar zconfchar
-
-/* Copy the first part of user declarations. */
-
-
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-
-#include "lkc.h"
-
-#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
-
-#define PRINTD 0x0001
-#define DEBUG_PARSE 0x0002
-
-int cdebug = PRINTD;
-
-extern int zconflex(void);
-static void zconfprint(const char *err, ...);
-static void zconf_error(const char *err, ...);
-static void zconferror(const char *err);
-static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-
-struct symbol *symbol_hash[SYMBOL_HASHSIZE];
-
-static struct menu *current_menu, *current_entry;
-
-
-
-
-# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
-# else
-# define YY_NULLPTR 0
-# endif
-# endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-
-/* Debug traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 1
-#endif
-#if YYDEBUG
-extern int zconfdebug;
-#endif
-
-/* Token type. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- enum yytokentype
- {
- T_MAINMENU = 258,
- T_MENU = 259,
- T_ENDMENU = 260,
- T_SOURCE = 261,
- T_CHOICE = 262,
- T_ENDCHOICE = 263,
- T_COMMENT = 264,
- T_CONFIG = 265,
- T_MENUCONFIG = 266,
- T_HELP = 267,
- T_HELPTEXT = 268,
- T_IF = 269,
- T_ENDIF = 270,
- T_DEPENDS = 271,
- T_OPTIONAL = 272,
- T_PROMPT = 273,
- T_TYPE = 274,
- T_DEFAULT = 275,
- T_SELECT = 276,
- T_IMPLY = 277,
- T_RANGE = 278,
- T_VISIBLE = 279,
- T_OPTION = 280,
- T_ON = 281,
- T_WORD = 282,
- T_WORD_QUOTE = 283,
- T_UNEQUAL = 284,
- T_LESS = 285,
- T_LESS_EQUAL = 286,
- T_GREATER = 287,
- T_GREATER_EQUAL = 288,
- T_CLOSE_PAREN = 289,
- T_OPEN_PAREN = 290,
- T_EOL = 291,
- T_OR = 292,
- T_AND = 293,
- T_EQUAL = 294,
- T_NOT = 295
- };
-#endif
-
-/* Value type. */
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
-union YYSTYPE
-{
-
-
- char *string;
- struct file *file;
- struct symbol *symbol;
- struct expr *expr;
- struct menu *menu;
- const struct kconf_id *id;
-
-
-};
-
-typedef union YYSTYPE YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-extern YYSTYPE zconflval;
-
-int zconfparse (void);
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Include zconf.hash.c here so it can see the token constants. */
-#include "zconf.hash.c"
-
-
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#else
-typedef signed char yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(Msgid) Msgid
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__ \
- && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
- || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
-# else
-# define YY_ATTRIBUTE(Spec) /* empty */
-# endif
-#endif
-
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
-#endif
-
-#ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(E) ((void) (E))
-#else
-# define YYUSE(E) /* empty */
-#endif
-
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized. */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
- _Pragma ("GCC diagnostic push") \
- _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
- _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
- _Pragma ("GCC diagnostic pop")
-#else
-# define YY_INITIAL_VALUE(Value) Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
- /* Use EXIT_SUCCESS as a witness for stdlib.h. */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's 'empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined EXIT_SUCCESS \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined EXIT_SUCCESS
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined EXIT_SUCCESS
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss_alloc;
- YYSTYPE yyvs_alloc;
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-# define YYCOPY_NEEDED 1
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
- Stack = &yyptr->Stack_alloc; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
-/* Copy COUNT objects from SRC to DST. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(Dst, Src, Count) \
- __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
-# else
-# define YYCOPY(Dst, Src, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (Dst)[yyi] = (Src)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-#endif /* !YYCOPY_NEEDED */
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 11
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 301
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 41
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 50
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 124
-/* YYNSTATES -- Number of states. */
-#define YYNSTATES 204
-
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 295
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40
-};
-
-#if YYDEBUG
- /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 109, 109, 109, 111, 111, 113, 115, 116, 117,
- 118, 119, 120, 124, 128, 128, 128, 128, 128, 128,
- 128, 128, 128, 132, 133, 134, 135, 136, 137, 141,
- 142, 148, 156, 162, 170, 180, 182, 183, 184, 185,
- 186, 187, 190, 198, 204, 214, 220, 226, 232, 235,
- 237, 248, 249, 254, 263, 268, 276, 279, 281, 282,
- 283, 284, 285, 288, 294, 305, 311, 321, 323, 328,
- 336, 344, 347, 349, 350, 351, 356, 363, 370, 375,
- 383, 386, 388, 389, 390, 393, 401, 408, 415, 421,
- 428, 430, 431, 432, 435, 443, 445, 446, 449, 456,
- 458, 463, 464, 467, 468, 469, 473, 474, 477, 478,
- 481, 482, 483, 484, 485, 486, 487, 488, 489, 490,
- 491, 494, 495, 498, 499
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || 0
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
- "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
- "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
- "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_IMPLY",
- "T_RANGE", "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE",
- "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL",
- "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
- "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
- "common_stmt", "option_error", "config_entry_start", "config_stmt",
- "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
- "config_option", "symbol_option", "symbol_option_list",
- "symbol_option_arg", "choice", "choice_entry", "choice_end",
- "choice_stmt", "choice_option_list", "choice_option", "choice_block",
- "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
- "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
- "comment", "comment_stmt", "help_start", "help", "depends_list",
- "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
- "end", "nl", "if_expr", "expr", "symbol", "word_opt", YY_NULLPTR
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[NUM] -- (External) token number corresponding to the
- (internal) symbol number NUM (which must be that of a token). */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295
-};
-# endif
-
-#define YYPACT_NINF -92
-
-#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-92)))
-
-#define YYTABLE_NINF -88
-
-#define yytable_value_is_error(Yytable_value) \
- 0
-
- /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-static const yytype_int16 yypact[] =
-{
- 17, 41, -92, 15, -92, 150, -92, 19, -92, -92,
- -13, -92, 28, 41, 38, 41, 50, 47, 41, 79,
- 82, 44, 76, -92, -92, -92, -92, -92, -92, -92,
- -92, -92, 118, -92, 129, -92, -92, -92, -92, -92,
- -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
- -92, -92, 184, -92, -92, 107, -92, 111, -92, 113,
- -92, 116, -92, 139, 140, 151, -92, -92, 44, 44,
- 142, 256, -92, 160, 173, 27, 117, 80, 51, 255,
- -15, 255, 217, -92, -92, -92, -92, -92, -92, -8,
- -92, 44, 44, 107, 87, 87, 87, 87, 87, 87,
- -92, -92, 174, 176, 187, 41, 41, 44, 188, 189,
- 87, -92, 213, -92, -92, -92, -92, 206, -92, -92,
- 193, 41, 41, 203, -92, -92, -92, -92, -92, -92,
- -92, -92, -92, -92, -92, -92, -92, 229, -92, 241,
- -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
- 216, -92, -92, -92, -92, -92, -92, -92, -92, -92,
- 44, 229, 222, 229, 64, 229, 229, 87, 31, 231,
- -92, -92, 229, 236, 229, 44, -92, 145, 242, -92,
- -92, 243, 244, 245, 229, 251, -92, -92, 247, -92,
- 257, 125, -92, -92, -92, -92, -92, 260, 41, -92,
- -92, -92, -92, -92
-};
-
- /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
- Performed when YYTABLE does not specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 6, 0, 106, 0, 3, 0, 6, 6, 101, 102,
- 0, 1, 0, 0, 0, 0, 123, 0, 0, 0,
- 0, 0, 0, 14, 19, 15, 16, 21, 17, 18,
- 20, 22, 0, 23, 0, 7, 35, 26, 35, 27,
- 57, 67, 8, 72, 24, 95, 81, 9, 28, 90,
- 25, 10, 0, 107, 2, 76, 13, 0, 103, 0,
- 124, 0, 104, 0, 0, 0, 121, 122, 0, 0,
- 0, 110, 105, 0, 0, 0, 0, 0, 0, 0,
- 90, 0, 0, 77, 85, 53, 86, 31, 33, 0,
- 118, 0, 0, 69, 0, 0, 0, 0, 0, 0,
- 11, 12, 0, 0, 0, 0, 99, 0, 0, 0,
- 0, 49, 0, 41, 40, 36, 37, 0, 39, 38,
- 0, 0, 99, 0, 61, 62, 58, 60, 59, 68,
- 56, 55, 73, 75, 71, 74, 70, 108, 97, 0,
- 96, 82, 84, 80, 83, 79, 92, 93, 91, 117,
- 119, 120, 116, 111, 112, 113, 114, 115, 30, 88,
- 0, 108, 0, 108, 108, 108, 108, 0, 0, 0,
- 89, 65, 108, 0, 108, 0, 98, 0, 0, 42,
- 100, 0, 0, 0, 108, 51, 48, 29, 0, 64,
- 0, 109, 94, 43, 44, 45, 46, 0, 0, 50,
- 63, 66, 47, 52
-};
-
- /* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
-{
- -92, -92, 285, 291, -92, 32, -66, -92, -92, -92,
- -92, 261, -92, -92, -92, -92, -92, -92, -92, 1,
- -92, -92, -92, -92, -92, -92, -92, -92, -92, -92,
- -92, 24, -92, -92, -92, -92, -92, 221, 220, -64,
- -92, -92, 179, -1, 67, 0, 110, -67, -91, -92
-};
-
- /* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int16 yydefgoto[] =
-{
- -1, 3, 4, 5, 34, 35, 114, 36, 37, 38,
- 39, 75, 115, 116, 168, 199, 40, 41, 130, 42,
- 77, 126, 78, 43, 134, 44, 79, 6, 45, 46,
- 143, 47, 81, 48, 49, 50, 117, 118, 82, 119,
- 80, 140, 162, 163, 51, 7, 176, 70, 71, 61
-};
-
- /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule whose
- number is the opposite. If YYTABLE_NINF, syntax error. */
-static const yytype_int16 yytable[] =
-{
- 10, 89, 90, 152, 153, 154, 155, 156, 157, 137,
- 55, 125, 57, 128, 59, 11, 147, 63, 148, 167,
- 1, 138, 1, 2, 150, 151, 149, -32, 102, 91,
- 92, -32, -32, -32, -32, -32, -32, -32, -32, 103,
- 164, -32, -32, 104, -32, 105, 106, 107, 108, 109,
- 110, -32, 111, 2, 112, 53, 14, 15, 185, 17,
- 18, 19, 20, 113, 56, 21, 22, 186, 8, 9,
- 93, 66, 67, 147, 58, 148, 184, 60, 175, 68,
- 133, 102, 142, 62, 69, -54, -54, 33, -54, -54,
- -54, -54, 103, 177, -54, -54, 104, 120, 121, 122,
- 123, 91, 92, 135, 161, 144, 64, 112, 191, 65,
- 129, 132, 72, 141, 66, 67, 124, -34, 102, 73,
- 172, -34, -34, -34, -34, -34, -34, -34, -34, 103,
- 74, -34, -34, 104, -34, 105, 106, 107, 108, 109,
- 110, -34, 111, 53, 112, 131, 136, 83, 145, 84,
- -5, 12, 85, 113, 13, 14, 15, 16, 17, 18,
- 19, 20, 91, 92, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 86, 87, 32, 2, 91,
- 92, 192, 91, 92, -4, 12, 33, 88, 13, 14,
- 15, 16, 17, 18, 19, 20, 100, 203, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 101,
- 158, 32, 159, 160, 169, 165, 166, -87, 102, 170,
- 33, -87, -87, -87, -87, -87, -87, -87, -87, 171,
- 174, -87, -87, 104, -87, -87, -87, -87, -87, -87,
- -87, -87, 102, 175, 112, -78, -78, -78, -78, -78,
- -78, -78, -78, 146, 92, -78, -78, 104, 179, 13,
- 14, 15, 16, 17, 18, 19, 20, 187, 112, 21,
- 22, 178, 189, 180, 181, 182, 183, 146, 193, 194,
- 195, 196, 188, 200, 190, 94, 95, 96, 97, 98,
- 198, 33, 54, 201, 197, 99, 202, 52, 127, 76,
- 139, 173
-};
-
-static const yytype_uint8 yycheck[] =
-{
- 1, 68, 69, 94, 95, 96, 97, 98, 99, 24,
- 10, 77, 13, 77, 15, 0, 82, 18, 82, 110,
- 3, 36, 3, 36, 91, 92, 34, 0, 1, 37,
- 38, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 107, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 36, 27, 36, 5, 6, 27, 8,
- 9, 10, 11, 36, 36, 14, 15, 36, 27, 28,
- 70, 27, 28, 139, 36, 139, 167, 27, 14, 35,
- 79, 1, 81, 36, 40, 5, 6, 36, 8, 9,
- 10, 11, 12, 160, 14, 15, 16, 17, 18, 19,
- 20, 37, 38, 79, 105, 81, 27, 27, 175, 27,
- 78, 79, 36, 81, 27, 28, 36, 0, 1, 1,
- 121, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 1, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 36, 27, 78, 79, 36, 81, 36,
- 0, 1, 36, 36, 4, 5, 6, 7, 8, 9,
- 10, 11, 37, 38, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 36, 36, 27, 36, 37,
- 38, 36, 37, 38, 0, 1, 36, 36, 4, 5,
- 6, 7, 8, 9, 10, 11, 36, 198, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 36,
- 36, 27, 36, 26, 1, 27, 27, 0, 1, 13,
- 36, 4, 5, 6, 7, 8, 9, 10, 11, 36,
- 27, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 1, 14, 27, 4, 5, 6, 7, 8,
- 9, 10, 11, 36, 38, 14, 15, 16, 36, 4,
- 5, 6, 7, 8, 9, 10, 11, 36, 27, 14,
- 15, 161, 36, 163, 164, 165, 166, 36, 36, 36,
- 36, 36, 172, 36, 174, 29, 30, 31, 32, 33,
- 39, 36, 7, 36, 184, 39, 36, 6, 77, 38,
- 80, 122
-};
-
- /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 3, 36, 42, 43, 44, 68, 86, 27, 28,
- 84, 0, 1, 4, 5, 6, 7, 8, 9, 10,
- 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 27, 36, 45, 46, 48, 49, 50, 51,
- 57, 58, 60, 64, 66, 69, 70, 72, 74, 75,
- 76, 85, 44, 36, 43, 86, 36, 84, 36, 84,
- 27, 90, 36, 84, 27, 27, 27, 28, 35, 40,
- 88, 89, 36, 1, 1, 52, 52, 61, 63, 67,
- 81, 73, 79, 36, 36, 36, 36, 36, 36, 88,
- 88, 37, 38, 86, 29, 30, 31, 32, 33, 39,
- 36, 36, 1, 12, 16, 18, 19, 20, 21, 22,
- 23, 25, 27, 36, 47, 53, 54, 77, 78, 80,
- 17, 18, 19, 20, 36, 47, 62, 78, 80, 46,
- 59, 85, 46, 60, 65, 72, 85, 24, 36, 79,
- 82, 46, 60, 71, 72, 85, 36, 47, 80, 34,
- 88, 88, 89, 89, 89, 89, 89, 89, 36, 36,
- 26, 84, 83, 84, 88, 27, 27, 89, 55, 1,
- 13, 36, 84, 83, 27, 14, 87, 88, 87, 36,
- 87, 87, 87, 87, 89, 27, 36, 36, 87, 36,
- 87, 88, 36, 36, 36, 36, 36, 87, 39, 56,
- 36, 36, 36, 84
-};
-
- /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 41, 42, 42, 43, 43, 44, 44, 44, 44,
- 44, 44, 44, 44, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 46, 46, 46, 46, 46, 46, 47,
- 47, 48, 49, 50, 51, 52, 52, 52, 52, 52,
- 52, 52, 53, 53, 53, 53, 53, 53, 54, 55,
- 55, 56, 56, 57, 58, 59, 60, 61, 61, 61,
- 61, 61, 61, 62, 62, 62, 62, 63, 63, 64,
- 65, 66, 67, 67, 67, 67, 68, 69, 70, 71,
- 72, 73, 73, 73, 73, 74, 75, 76, 77, 78,
- 79, 79, 79, 79, 80, 81, 81, 81, 82, 83,
- 83, 84, 84, 85, 85, 85, 86, 86, 87, 87,
- 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
- 88, 89, 89, 90, 90
-};
-
- /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
- 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 2, 3, 2, 3, 2, 0, 2, 2, 2, 2,
- 2, 2, 3, 4, 4, 4, 4, 5, 3, 0,
- 3, 0, 2, 3, 2, 1, 3, 0, 2, 2,
- 2, 2, 2, 4, 3, 2, 4, 0, 2, 3,
- 1, 3, 0, 2, 2, 2, 3, 3, 3, 1,
- 3, 0, 2, 2, 2, 3, 3, 2, 2, 2,
- 0, 2, 2, 2, 4, 0, 2, 2, 2, 0,
- 2, 1, 1, 2, 2, 2, 1, 2, 0, 2,
- 1, 3, 3, 3, 3, 3, 3, 3, 2, 3,
- 3, 1, 1, 0, 1
-};
-
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
-
-/* Error token number */
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-
-/* This macro is provided for backward compatibility. */
-#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-#endif
-
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (0)
-
-
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
-
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- YYUSE (yytype);
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-{
- YYFPRINTF (yyoutput, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-{
- YYFPRINTF (stderr, "Stack now");
- for (; yybottom <= yytop; yybottom++)
- {
- int yybot = *yybottom;
- YYFPRINTF (stderr, " %d", yybot);
- }
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (0)
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
-{
- unsigned long int yylno = yyrline[yyrule];
- int yynrhs = yyr2[yyrule];
- int yyi;
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- YYFPRINTF (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr,
- yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- YYFPRINTF (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyssp, yyvsp, Rule); \
-} while (0)
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-yystrlen (const char *yystr)
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
- about the unexpected token YYTOKEN for the state stack whose top is
- YYSSP.
-
- Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
- not large enough to hold the message. In that case, also set
- *YYMSG_ALLOC to the required number of bytes. Return 2 if the
- required number of bytes is too large to store. */
-static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
- yytype_int16 *yyssp, int yytoken)
-{
- YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
- YYSIZE_T yysize = yysize0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *yyformat = YY_NULLPTR;
- /* Arguments of yyformat. */
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- /* Number of reported tokens (one for the "unexpected", one per
- "expected"). */
- int yycount = 0;
-
- /* There are many possibilities here to consider:
- - If this state is a consistent state with a default action, then
- the only way this function was invoked is if the default action
- is an error action. In that case, don't check for expected
- tokens because there are none.
- - The only way there can be no lookahead present (in yychar) is if
- this state is a consistent state with a default action. Thus,
- detecting the absence of a lookahead is sufficient to determine
- that there is no unexpected or expected token to report. In that
- case, just report a simple "syntax error".
- - Don't assume there isn't a lookahead just because this state is a
- consistent state with a default action. There might have been a
- previous inconsistent state, consistent state with a non-default
- action, or user semantic action that manipulated yychar.
- - Of course, the expected token list depends on states to have
- correct lookahead information, and it depends on the parser not
- to perform extra reductions after fetching a lookahead from the
- scanner and before detecting a syntax error. Thus, state merging
- (from LALR or IELR) and default reductions corrupt the expected
- token list. However, the list is correct for canonical LR with
- one exception: it will still contain any token that will not be
- accepted due to an error action in a later state.
- */
- if (yytoken != YYEMPTY)
- {
- int yyn = yypact[*yyssp];
- yyarg[yycount++] = yytname[yytoken];
- if (!yypact_value_is_default (yyn))
- {
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. In other words, skip the first -YYN actions for
- this state because they are default actions. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yyx;
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
- && !yytable_value_is_error (yytable[yyx + yyn]))
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- {
- YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
- }
- }
- }
-
- switch (yycount)
- {
-# define YYCASE_(N, S) \
- case N: \
- yyformat = S; \
- break
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
-# undef YYCASE_
- }
-
- {
- YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
- return 2;
- yysize = yysize1;
- }
-
- if (*yymsg_alloc < yysize)
- {
- *yymsg_alloc = 2 * yysize;
- if (! (yysize <= *yymsg_alloc
- && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
- *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
- return 1;
- }
-
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- {
- char *yyp = *yymsg;
- int yyi = 0;
- while ((*yyp = *yyformat) != '\0')
- if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyformat += 2;
- }
- else
- {
- yyp++;
- yyformat++;
- }
- }
- return 0;
-}
-#endif /* YYERROR_VERBOSE */
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-{
- YYUSE (yyvaluep);
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- switch (yytype)
- {
- case 58: /* choice_entry */
-
- {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
- if (current_menu == ((*yyvaluep).menu))
- menu_end_menu();
-}
-
- break;
-
- case 64: /* if_entry */
-
- {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
- if (current_menu == ((*yyvaluep).menu))
- menu_end_menu();
-}
-
- break;
-
- case 70: /* menu_entry */
-
- {
- fprintf(stderr, "%s:%d: missing end statement for this entry\n",
- ((*yyvaluep).menu)->file->name, ((*yyvaluep).menu)->lineno);
- if (current_menu == ((*yyvaluep).menu))
- menu_end_menu();
-}
-
- break;
-
-
- default:
- break;
- }
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-}
-
-
-
-
-/* The lookahead symbol. */
-int yychar;
-
-/* The semantic value of the lookahead symbol. */
-YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-int
-yyparse (void)
-{
- int yystate;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
-
- /* The stacks and their tools:
- 'yyss': related to states.
- 'yyvs': related to semantic values.
-
- Refer to the stacks through separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs;
- YYSTYPE *yyvsp;
-
- YYSIZE_T yystacksize;
-
- int yyn;
- int yyresult;
- /* Lookahead token as an internal (translated) token number. */
- int yytoken = 0;
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- yyssp = yyss = yyssa;
- yyvsp = yyvs = yyvsa;
- yystacksize = YYINITDEPTH;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss_alloc, yyss);
- YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- if (yystate == YYFINAL)
- YYACCEPT;
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- lookahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to lookahead token. */
- yyn = yypact[yystate];
- if (yypact_value_is_default (yyn))
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = yylex ();
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yytable_value_is_error (yyn))
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the lookahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token. */
- yychar = YYEMPTY;
-
- yystate = yyn;
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- '$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 10:
-
- { zconf_error("unexpected end statement"); }
-
- break;
-
- case 11:
-
- { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); }
-
- break;
-
- case 12:
-
- {
- zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name);
-}
-
- break;
-
- case 13:
-
- { zconf_error("invalid statement"); }
-
- break;
-
- case 29:
-
- { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); }
-
- break;
-
- case 30:
-
- { zconf_error("invalid option"); }
-
- break;
-
- case 31:
-
- {
- struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
- sym->flags |= SYMBOL_OPTIONAL;
- menu_add_entry(sym);
- printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
-}
-
- break;
-
- case 32:
-
- {
- menu_end_entry();
- printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 33:
-
- {
- struct symbol *sym = sym_lookup((yyvsp[-1].string), 0);
- sym->flags |= SYMBOL_OPTIONAL;
- menu_add_entry(sym);
- printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
-}
-
- break;
-
- case 34:
-
- {
- if (current_entry->prompt)
- current_entry->prompt->type = P_MENU;
- else
- zconfprint("warning: menuconfig statement without prompt");
- menu_end_entry();
- printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 42:
-
- {
- menu_set_type((yyvsp[-2].id)->stype);
- printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
- zconf_curname(), zconf_lineno(),
- (yyvsp[-2].id)->stype);
-}
-
- break;
-
- case 43:
-
- {
- menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 44:
-
- {
- menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr));
- if ((yyvsp[-3].id)->stype != S_UNKNOWN)
- menu_set_type((yyvsp[-3].id)->stype);
- printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
- zconf_curname(), zconf_lineno(),
- (yyvsp[-3].id)->stype);
-}
-
- break;
-
- case 45:
-
- {
- menu_add_symbol(P_SELECT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 46:
-
- {
- menu_add_symbol(P_IMPLY, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 47:
-
- {
- menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 50:
-
- {
- const struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string)));
- if (id && id->flags & TF_OPTION)
- menu_add_option(id->token, (yyvsp[0].string));
- else
- zconfprint("warning: ignoring unknown option %s", (yyvsp[-1].string));
- free((yyvsp[-1].string));
-}
-
- break;
-
- case 51:
-
- { (yyval.string) = NULL; }
-
- break;
-
- case 52:
-
- { (yyval.string) = (yyvsp[0].string); }
-
- break;
-
- case 53:
-
- {
- struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE);
- sym->flags |= SYMBOL_AUTO;
- menu_add_entry(sym);
- menu_add_expr(P_CHOICE, NULL, NULL);
- printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 54:
-
- {
- (yyval.menu) = menu_add_menu();
-}
-
- break;
-
- case 55:
-
- {
- if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
- }
-}
-
- break;
-
- case 63:
-
- {
- menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 64:
-
- {
- if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) {
- menu_set_type((yyvsp[-2].id)->stype);
- printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
- zconf_curname(), zconf_lineno(),
- (yyvsp[-2].id)->stype);
- } else
- YYERROR;
-}
-
- break;
-
- case 65:
-
- {
- current_entry->sym->flags |= SYMBOL_OPTIONAL;
- printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 66:
-
- {
- if ((yyvsp[-3].id)->stype == S_UNKNOWN) {
- menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:default\n",
- zconf_curname(), zconf_lineno());
- } else
- YYERROR;
-}
-
- break;
-
- case 69:
-
- {
- printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
- menu_add_entry(NULL);
- menu_add_dep((yyvsp[-1].expr));
- (yyval.menu) = menu_add_menu();
-}
-
- break;
-
- case 70:
-
- {
- if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
- }
-}
-
- break;
-
- case 76:
-
- {
- menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
-}
-
- break;
-
- case 77:
-
- {
- menu_add_entry(NULL);
- menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL);
- printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 78:
-
- {
- (yyval.menu) = menu_add_menu();
-}
-
- break;
-
- case 79:
-
- {
- if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) {
- menu_end_menu();
- printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
- }
-}
-
- break;
-
- case 85:
-
- {
- printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string));
- zconf_nextfile((yyvsp[-1].string));
-}
-
- break;
-
- case 86:
-
- {
- menu_add_entry(NULL);
- menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL);
- printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 87:
-
- {
- menu_end_entry();
-}
-
- break;
-
- case 88:
-
- {
- printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
- zconf_starthelp();
-}
-
- break;
-
- case 89:
-
- {
- current_entry->help = (yyvsp[0].string);
-}
-
- break;
-
- case 94:
-
- {
- menu_add_dep((yyvsp[-1].expr));
- printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
-}
-
- break;
-
- case 98:
-
- {
- menu_add_visibility((yyvsp[0].expr));
-}
-
- break;
-
- case 100:
-
- {
- menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr));
-}
-
- break;
-
- case 103:
-
- { (yyval.id) = (yyvsp[-1].id); }
-
- break;
-
- case 104:
-
- { (yyval.id) = (yyvsp[-1].id); }
-
- break;
-
- case 105:
-
- { (yyval.id) = (yyvsp[-1].id); }
-
- break;
-
- case 108:
-
- { (yyval.expr) = NULL; }
-
- break;
-
- case 109:
-
- { (yyval.expr) = (yyvsp[0].expr); }
-
- break;
-
- case 110:
-
- { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); }
-
- break;
-
- case 111:
-
- { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 112:
-
- { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 113:
-
- { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 114:
-
- { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 115:
-
- { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 116:
-
- { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); }
-
- break;
-
- case 117:
-
- { (yyval.expr) = (yyvsp[-1].expr); }
-
- break;
-
- case 118:
-
- { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); }
-
- break;
-
- case 119:
-
- { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); }
-
- break;
-
- case 120:
-
- { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); }
-
- break;
-
- case 121:
-
- { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); }
-
- break;
-
- case 122:
-
- { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); }
-
- break;
-
- case 123:
-
- { (yyval.string) = NULL; }
-
- break;
-
-
-
- default: break;
- }
- /* User semantic actions sometimes alter yychar, and that requires
- that yytoken be updated with the new translation. We take the
- approach of translating immediately before every use of yytoken.
- One alternative is translating here after every semantic action,
- but that translation would be missed if the semantic action invokes
- YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
- if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
- incorrect destructor might then be invoked immediately. In the
- case of YYERROR or YYBACKUP, subsequent parser actions might lead
- to an incorrect destructor call or verbose syntax error message
- before the lookahead is translated. */
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
- /* Now 'shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*--------------------------------------.
-| yyerrlab -- here on detecting error. |
-`--------------------------------------*/
-yyerrlab:
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
-
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
- yyssp, yytoken)
- {
- char const *yymsgp = YY_("syntax error");
- int yysyntax_error_status;
- yysyntax_error_status = YYSYNTAX_ERROR;
- if (yysyntax_error_status == 0)
- yymsgp = yymsg;
- else if (yysyntax_error_status == 1)
- {
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
- if (!yymsg)
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- yysyntax_error_status = 2;
- }
- else
- {
- yysyntax_error_status = YYSYNTAX_ERROR;
- yymsgp = yymsg;
- }
- }
- yyerror (yymsgp);
- if (yysyntax_error_status == 2)
- goto yyexhaustedlab;
- }
-# undef YYSYNTAX_ERROR
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (!yypact_value_is_default (yyn))
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
- *++yyvsp = yylval;
- YY_IGNORE_MAYBE_UNINITIALIZED_END
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#if !defined yyoverflow || YYERROR_VERBOSE
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEMPTY)
- {
- /* Make sure we have latest lookahead translation. See comments at
- user semantic actions for why this is necessary. */
- yytoken = YYTRANSLATE (yychar);
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- }
- /* Do not reclaim the symbols of the rule whose action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- return yyresult;
-}
-
-
-
-void conf_parse(const char *name)
-{
- struct symbol *sym;
- int i;
-
- zconf_initscan(name);
-
- sym_init();
- _menu_init();
- rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
-
- if (getenv("ZCONF_DEBUG"))
- zconfdebug = 1;
- zconfparse();
- if (zconfnerrs)
- exit(1);
- if (!modules_sym)
- modules_sym = sym_find( "n" );
-
- rootmenu.prompt->text = _(rootmenu.prompt->text);
- rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
-
- menu_finalize(&rootmenu);
- for_all_symbols(i, sym) {
- if (sym_check_deps(sym))
- zconfnerrs++;
- }
- if (zconfnerrs)
- exit(1);
- sym_set_change_count(1);
-}
-
-static const char *zconf_tokenname(int token)
-{
- switch (token) {
- case T_MENU: return "menu";
- case T_ENDMENU: return "endmenu";
- case T_CHOICE: return "choice";
- case T_ENDCHOICE: return "endchoice";
- case T_IF: return "if";
- case T_ENDIF: return "endif";
- case T_DEPENDS: return "depends";
- case T_VISIBLE: return "visible";
- }
- return "<token>";
-}
-
-static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
-{
- if (id->token != endtoken) {
- zconf_error("unexpected '%s' within %s block",
- kconf_id_strings + id->name, zconf_tokenname(starttoken));
- zconfnerrs++;
- return false;
- }
- if (current_menu->file != current_file) {
- zconf_error("'%s' in different file than '%s'",
- kconf_id_strings + id->name, zconf_tokenname(starttoken));
- fprintf(stderr, "%s:%d: location of the '%s'\n",
- current_menu->file->name, current_menu->lineno,
- zconf_tokenname(starttoken));
- zconfnerrs++;
- return false;
- }
- return true;
-}
-
-static void zconfprint(const char *err, ...)
-{
- va_list ap;
-
- fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
- va_start(ap, err);
- vfprintf(stderr, err, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-}
-
-static void zconf_error(const char *err, ...)
-{
- va_list ap;
-
- zconfnerrs++;
- fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
- va_start(ap, err);
- vfprintf(stderr, err, ap);
- va_end(ap);
- fprintf(stderr, "\n");
-}
-
-static void zconferror(const char *err)
-{
- fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-}
-
-static void print_quoted_string(FILE *out, const char *str)
-{
- const char *p;
- int len;
-
- putc('"', out);
- while ((p = strchr(str, '"'))) {
- len = p - str;
- if (len)
- fprintf(out, "%.*s", len, str);
- fputs("\\\"", out);
- str = p + 1;
- }
- fputs(str, out);
- putc('"', out);
-}
-
-static void print_symbol(FILE *out, struct menu *menu)
-{
- struct symbol *sym = menu->sym;
- struct property *prop;
-
- if (sym_is_choice(sym))
- fprintf(out, "\nchoice\n");
- else
- fprintf(out, "\nconfig %s\n", sym->name);
- switch (sym->type) {
- case S_BOOLEAN:
- fputs(" boolean\n", out);
- break;
- case S_TRISTATE:
- fputs(" tristate\n", out);
- break;
- case S_STRING:
- fputs(" string\n", out);
- break;
- case S_INT:
- fputs(" integer\n", out);
- break;
- case S_HEX:
- fputs(" hex\n", out);
- break;
- default:
- fputs(" ???\n", out);
- break;
- }
- for (prop = sym->prop; prop; prop = prop->next) {
- if (prop->menu != menu)
- continue;
- switch (prop->type) {
- case P_PROMPT:
- fputs(" prompt ", out);
- print_quoted_string(out, prop->text);
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" if ", out);
- expr_fprint(prop->visible.expr, out);
- }
- fputc('\n', out);
- break;
- case P_DEFAULT:
- fputs( " default ", out);
- expr_fprint(prop->expr, out);
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" if ", out);
- expr_fprint(prop->visible.expr, out);
- }
- fputc('\n', out);
- break;
- case P_CHOICE:
- fputs(" #choice value\n", out);
- break;
- case P_SELECT:
- fputs( " select ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_IMPLY:
- fputs( " imply ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_RANGE:
- fputs( " range ", out);
- expr_fprint(prop->expr, out);
- fputc('\n', out);
- break;
- case P_MENU:
- fputs( " menu ", out);
- print_quoted_string(out, prop->text);
- fputc('\n', out);
- break;
- default:
- fprintf(out, " unknown prop %d!\n", prop->type);
- break;
- }
- }
- if (menu->help) {
- int len = strlen(menu->help);
- while (menu->help[--len] == '\n')
- menu->help[len] = 0;
- fprintf(out, " help\n%s\n", menu->help);
- }
-}
-
-void zconfdump(FILE *out)
-{
- struct property *prop;
- struct symbol *sym;
- struct menu *menu;
-
- menu = rootmenu.list;
- while (menu) {
- if ((sym = menu->sym))
- print_symbol(out, menu);
- else if ((prop = menu->prompt)) {
- switch (prop->type) {
- case P_COMMENT:
- fputs("\ncomment ", out);
- print_quoted_string(out, prop->text);
- fputs("\n", out);
- break;
- case P_MENU:
- fputs("\nmenu ", out);
- print_quoted_string(out, prop->text);
- fputs("\n", out);
- break;
- default:
- ;
- }
- if (!expr_is_yes(prop->visible.expr)) {
- fputs(" depends ", out);
- expr_fprint(prop->visible.expr, out);
- fputc('\n', out);
- }
- }
-
- if (menu->list)
- menu = menu->list;
- else if (menu->next)
- menu = menu->next;
- else while ((menu = menu->parent)) {
- if (menu->prompt && menu->prompt->type == P_MENU)
- fputs("\nendmenu\n", out);
- if (menu->next) {
- menu = menu->next;
- break;
- }
- }
- }
-}
-
-#include "zconf.lex.c"
-#include "util.c"
-#include "confdata.c"
-#include "expr.c"
-#include "symbol.c"
-#include "menu.c"
diff --git a/backport/scripts/blacklist.sh b/backport/scripts/blacklist.sh
deleted file mode 100755
index f941c4a3..00000000
--- a/backport/scripts/blacklist.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-BLACKLIST_CONF="/etc/modprobe.d/backports.conf"
-BLACKLIST_MAP=".blacklist.map"
-
-MODULE_DIR=$1
-MODULE_UPDATES=$2
-
-if [[ ! -d $MODULE_DIR ]]; then
- exit
-fi
-
-if [[ ! -d $MODULE_UPDATES ]]; then
- exit
-fi
-
-mkdir -p $(dirname $BLACKLIST_CONF)
-rm -f $BLACKLIST_CONF
-
-echo "# To be used when using backported drivers" > $BLACKLIST_CONF
-
-for i in $(grep -v ^# $BLACKLIST_MAP | awk '{print $2}'); do
- MODULE="${i}.ko"
- MODULE_UPDATE="$(grep -v ^# $BLACKLIST_MAP | grep $i | awk '{print $1}' | head -1).ko"
-
- COUNT=$(find $MODULE_DIR -type f -name ${MODULE} -or -name ${MODULE}.gz | wc -l)
- COUNT_REPLACE=$(find $MODULE_UPDATES -type f -name ${MODULE_UPDATE} -or -name ${MODULE_UPDATE}.gz | wc -l)
-
- if [ $COUNT -ne 0 ]; then
- if [ $COUNT_REPLACE -ne 0 ]; then
- echo "Blacklisting $MODULE ..."
- echo blacklist $i >> $BLACKLIST_CONF
- fi
- fi
-done
diff --git a/backport/scripts/check_depmod.sh b/backport/scripts/check_depmod.sh
deleted file mode 100755
index 6123894a..00000000
--- a/backport/scripts/check_depmod.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/bash
-# Copyright 2009-2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
-#
-# Ensures your distribution likes to prefer updates/ over the kernel/
-# search updates built-in
-
-# Seems Mandriva has an $DEPMOD_DIR but it doesn't have any files,
-# so lets deal with those distributions.
-DEPMOD_CONF="/etc/depmod.conf"
-DEPMOD_CONF_TMP="$DEPMOD_CONF.backports.old"
-DEPMOD_DIR="/etc/depmod.d/"
-BACKPORT_DEPMOD_FILE="backports.conf"
-GREP_REGEX_UPDATES="^[[:space:]]*search.*[[:space:]]updates\([[:space:]]\|$\)"
-GREP_REGEX_SEARCH="^[[:space:]]*search[[:space:]].\+$"
-DEPMOD_CMD="depmod"
-
-function add_compat_depmod_conf {
- echo "NOTE: Your distribution lacks an $DEPMOD_DIR directory with "
- echo "updates/ directory being prioritized for modules, we're adding "
- echo "one for you."
- mkdir -p $DEPMOD_DIR
- FIRST_FILE=$(ls $DEPMOD_DIR|head -1)
- [ -n "$FIRST_FILE" ] && while [[ $FIRST_FILE < $BACKPORT_DEPMOD_FILE ]]; do
- BACKPORT_DEPMOD_FILE="0$BACKPORT_DEPMOD_FILE"
- done
- echo "search updates" > $DEPMOD_DIR/$BACKPORT_DEPMOD_FILE
-}
-
-function add_global_depmod_conf {
- echo "NOTE: Your distribution lacks updates/ directory being"
- echo "prioritized for modules, we're adding it to $DEPMOD_CONF."
- rm -f $DEPMOD_CONF_TMP
- [ -f $DEPMOD_CONF ] && cp -f $DEPMOD_CONF $DEPMOD_CONF_TMP
- echo "search updates" > $DEPMOD_CONF
- [ -f $DEPMOD_CONF_TMP ] && cat $DEPMOD_CONF_TMP >> $DEPMOD_CONF
-}
-
-function depmod_updates_ok {
- echo "depmod will prefer updates/ over kernel/ -- OK!"
-}
-
-function add_depmod_conf {
- if [ -f "$DEPMOD_CONF" ]; then
- add_global_depmod_conf
- else
- DEPMOD_VERSION=$($DEPMOD_CMD --version | cut -d" " -f2 | sed "s/\.//")
- if [[ $DEPMOD_VERSION -gt 36 ]]; then
- add_compat_depmod_conf
- else
- add_global_depmod_conf
- fi
- fi
-}
-
-GREP_FILES=""
-[ -f $DEPMOD_CONF ] && GREP_FILES="$DEPMOD_CONF"
-if [ -d $DEPMOD_DIR ]; then
- DEPMOD_FILE_COUNT=$(ls $DEPMOD_DIR | wc -l)
- [[ $DEPMOD_FILE_COUNT -gt 0 ]] && GREP_FILES="$GREP_FILES $DEPMOD_DIR/*"
-fi
-
-if [ -n "$GREP_FILES" ]; then
- grep -q "$GREP_REGEX_SEARCH" $GREP_FILES
- if [[ $? -eq 0 ]]; then
- grep -q "$GREP_REGEX_UPDATES" $GREP_FILES
- if [[ $? -eq 0 ]]; then
- depmod_updates_ok
- else
- add_depmod_conf
- fi
- else
- depmod_updates_ok
- fi
-else
- depmod_updates_ok
-fi
-
-exit 0
diff --git a/backport/scripts/compress_modules.sh b/backport/scripts/compress_modules.sh
deleted file mode 100755
index b2034c2c..00000000
--- a/backport/scripts/compress_modules.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-set -e
-
-source ./scripts/mod_helpers.sh
-
-if test "$(mod_filename mac80211)" = "mac80211.ko.gz" ; then
- for driver in $(find "$1" -type f -name *.ko); do
- echo COMPRESS $driver
- gzip -9 $driver
- done
-fi
diff --git a/backport/scripts/mod_helpers.sh b/backport/scripts/mod_helpers.sh
deleted file mode 100644
index 0845b3e3..00000000
--- a/backport/scripts/mod_helpers.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-function mod_filename()
-{
- which modinfo > /dev/null 2>&1
- if [[ $? -eq 0 ]]; then
- MOD_QUERY="modinfo -F filename"
- else
- MOD_QUERY="modprobe -l"
- fi
- mod_path="$($MOD_QUERY $1 | tail -1)"
- echo $(basename "$mod_path")
-}
diff --git a/backport/scripts/uninstall.sh b/backport/scripts/uninstall.sh
deleted file mode 100755
index 91a0fe62..00000000
--- a/backport/scripts/uninstall.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-set -e
-
-source ./scripts/mod_helpers.sh
-
-if test "$(mod_filename compat)" = "compat.ko.gz" ; then
- compr=".gz"
-elif test "$(mod_filename compat)" = "compat.ko.xz" ; then
- compr=".xz"
-else
- compr=""
-fi
-
-for driver in $(find ${BACKPORT_DIR} -type f -name *.ko); do
- mod_name=${driver/${BACKPORT_DIR}/${KLIB}${KMODDIR}}${compr}
- echo " uninstall" $mod_name
- rm -f $mod_name
-done
diff --git a/backport/scripts/update-initramfs.sh b/backport/scripts/update-initramfs.sh
deleted file mode 100755
index e0d7702d..00000000
--- a/backport/scripts/update-initramfs.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# Copyright 2009-2013 Luis R. Rodriguez <mcgrof@do-not-panic.com>
-#
-# Since we provide ssb, ethernet modules and most importantly
-# DRM drivers, people may want to update the initramfs image
-# of their distribution. This can also help people who may
-# want to wireless-boot their systems.
-
-KLIB="$1"
-ver=$(echo $KLIB | awk -F "/lib/modules/" '{print $2}' | awk -F"/" '{print $1}')
-dir=/boot/
-
-LSB_RED_ID=$(/usr/bin/lsb_release -i -s &> /dev/null)
-
-if [[ -z $LSB_RED_ID && -f "/etc/os-release" ]]; then
- # Let's try with os-release. Fedora doesn't have
- # lsb_release anymore.
- LSB_RED_ID=$(sed -n '/^NAME/ s/^NAME=\(.*\)$/\1/p' /etc/os-release)
-fi
-
-case $LSB_RED_ID in
-"Ubuntu")
- echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..."
- mkinitramfs -o $dir/initrd.img-$ver $ver
- echo "Will now run update-grub to ensure grub will find the new initramfs ..."
- update-grub
- ;;
-"Debian")
- echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..."
- mkinitramfs -o $dir/initrd.img-$ver $ver
- echo "Will now run update-grub to ensure grub will find the new initramfs ..."
- update-grub
- ;;
-"Fedora")
- # This adds a -compat-drivers suffixed initramfs with a new grub2
- # entry to not override distribution's default stuff.
- INITRAMFS=${dir}initramfs-$ver-compat-drivers.img
- KERNEL=${dir}vmlinuz-$ver
- GRUB_TITLE="Fedora ($ver) with compat-drivers"
-
- echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..."
- mkinitrd --force $INITRAMFS $ver
-
- # If a previous compat-drivers entry for the same kernel exists
- # do not add it again.
- grep -q "${GRUB_TITLE}" /etc/grub2.cfg &> /dev/null
- if [[ "$?" == "1" ]]; then
- echo "Will now run grubby to add a new kernel entry ..."
- # Add a new kernel entry
- grubby --grub2 --copy-default --add-kernel="$KERNEL" --initrd="$INITRAMFS" --title="$GRUB_TITLE"
- fi
- ;;
-*)
- echo "Note:"
- echo "You may or may not need to update your initramfs, you should if"
- echo "any of the modules installed are part of your initramfs. To add"
- echo "support for your distribution to do this automatically send a"
- echo "patch against \"$(basename $0)\". If your distribution does not"
- echo "require this send a patch with the '/usr/bin/lsb_release -i -s'"
- echo "($LSB_RED_ID) tag for your distribution to avoid this warning."
- ;;
-esac