diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-25 08:06:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-25 08:06:22 +0200 |
commit | faddac631a0e521780854ecf9a53f96481a32716 (patch) | |
tree | 292c866315fd161df41d90f4bbde1572b14415d1 /include | |
parent | 1ab2e649dc0ccef7ee990b999e1d8f8c32e7cd24 (diff) | |
parent | 0d4d157cf0d42206491b7a1b417c9904a9abd553 (diff) | |
download | barebox-faddac631a0e521780854ecf9a53f96481a32716.tar.gz barebox-faddac631a0e521780854ecf9a53f96481a32716.tar.xz |
Merge branch 'for-next/net' into master
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 13 | ||||
-rw-r--r-- | include/fastboot.h | 20 | ||||
-rw-r--r-- | include/fastboot_net.h | 12 | ||||
-rw-r--r-- | include/globalvar.h | 5 | ||||
-rw-r--r-- | include/linux/phy.h | 38 | ||||
-rw-r--r-- | include/net.h | 10 | ||||
-rw-r--r-- | include/ratp_bb.h | 1 | ||||
-rw-r--r-- | include/slice.h | 46 | ||||
-rw-r--r-- | include/usb/usb.h | 8 | ||||
-rw-r--r-- | include/work.h | 42 |
10 files changed, 170 insertions, 25 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 8583d2425f..82b78261fc 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -34,4 +34,17 @@ unlikely(__ret_warn_on); \ }) #endif + +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) { \ + if (WARN(!__warned, format)) { \ + __warned = 1; \ + dump_stack(); \ + } \ + } \ + unlikely(__ret_warn_once); \ +}) #endif diff --git a/include/fastboot.h b/include/fastboot.h index d33f9d1851..2eab2dfe6a 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -5,6 +5,8 @@ #include <file-list.h> #include <net.h> +#define FASTBOOT_MAX_CMD_LEN 64 + /* * Return codes for the exec_cmd callback above: * @@ -51,8 +53,24 @@ enum fastboot_msg_type { FASTBOOT_MSG_FAIL, FASTBOOT_MSG_INFO, FASTBOOT_MSG_DATA, + FASTBOOT_MSG_NONE, }; +#ifdef CONFIG_FASTBOOT_BASE +bool get_fastboot_bbu(void); +const char *get_fastboot_partitions(void); +#else +static inline int get_fastboot_bbu(void) +{ + return false; +} + +static inline const char *get_fastboot_partitions(void) +{ + return NULL; +} +#endif + int fastboot_generic_init(struct fastboot *fb, bool export_bbu); void fastboot_generic_close(struct fastboot *fb); void fastboot_generic_free(struct fastboot *fb); @@ -63,4 +81,6 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type, void fastboot_start_download_generic(struct fastboot *fb); void fastboot_download_finished(struct fastboot *fb); void fastboot_exec_cmd(struct fastboot *fb, const char *cmdbuf); +void fastboot_abort(struct fastboot *fb); + #endif diff --git a/include/fastboot_net.h b/include/fastboot_net.h new file mode 100644 index 0000000000..e4b9d98091 --- /dev/null +++ b/include/fastboot_net.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef __FASTBOOT_NET__ +#define __FASTBOOT_NET__ + +#include <fastboot.h> + +struct fastboot_net; + +struct fastboot_net *fastboot_net_init(struct fastboot_opts *opts); +void fastboot_net_free(struct fastboot_net *fbn); + +#endif diff --git a/include/globalvar.h b/include/globalvar.h index face53d33f..84bee9102c 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -36,6 +36,7 @@ int nvvar_remove(const char *name); void globalvar_print(void); void dev_param_init_from_nv(struct device_d *dev, const char *name); +void globalvar_alias_deprecated(const char *newname, const char *oldname); #else static inline int globalvar_add_simple(const char *name, const char *value) @@ -118,6 +119,10 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name { } +static inline void globalvar_alias_deprecated(const char *newname, const char *oldname) +{ +} + #endif void nv_var_set_clean(void); diff --git a/include/linux/phy.h b/include/linux/phy.h index eec1332c9d..cdcb7c24f2 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -16,6 +16,7 @@ #define __PHY_H #include <driver.h> +#include <slice.h> #include <linux/list.h> #include <linux/ethtool.h> #include <linux/mii.h> @@ -116,9 +117,16 @@ struct mii_bus { struct list_head list; bool is_multiplexed; + + struct slice slice; }; #define to_mii_bus(d) container_of(d, struct mii_bus, dev) +static inline struct slice *mdiobus_slice(struct mii_bus *bus) +{ + return &bus->slice; +} + int mdiobus_register(struct mii_bus *bus); void mdiobus_unregister(struct mii_bus *bus); struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); @@ -134,28 +142,8 @@ struct mii_bus *mdiobus_get_bus(int busnum); struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np); -/** - * mdiobus_read - Convenience function for reading a given MII mgmt register - * @bus: the mii_bus struct - * @addr: the phy address - * @regnum: register number to read - */ -static inline int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum) -{ - return bus->read(bus, addr, regnum); -} - -/** - * mdiobus_write - Convenience function for writing a given MII mgmt register - * @bus: the mii_bus struct - * @addr: the phy address - * @regnum: register number to write - * @val: value to write to @regnum - */ -static inline int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val) -{ - return bus->write(bus, addr, regnum, val); -} +int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); +int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); /* phy_device: An instance of a PHY * @@ -397,11 +385,15 @@ int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask, int phy_register_fixup_for_id(const char *bus_id, int (*run)(struct phy_device *)); int phy_scan_fixups(struct phy_device *phydev); - int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad); void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, int devad, u16 data); +static inline bool phy_acquired(struct phy_device *phydev) +{ + return phydev && phydev->bus && slice_acquired(&phydev->bus->slice); +} + #ifdef CONFIG_PHYLIB int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask, int (*run)(struct phy_device *)); diff --git a/include/net.h b/include/net.h index 54db8a179a..aad28e4f4c 100644 --- a/include/net.h +++ b/include/net.h @@ -19,6 +19,7 @@ #include <stdlib.h> #include <clock.h> #include <led.h> +#include <slice.h> #include <xfuncs.h> #include <linux/phy.h> #include <linux/string.h> /* memcpy */ @@ -63,6 +64,10 @@ struct eth_device { char *bootarg; char *linuxdevname; + struct slice slice; + + struct list_head send_queue; + bool ifup; #define ETH_MODE_DHCP 0 #define ETH_MODE_STATIC 1 @@ -72,6 +77,11 @@ struct eth_device { #define dev_to_edev(d) container_of(d, struct eth_device, dev) +static inline struct slice *eth_device_slice(struct eth_device *edev) +{ + return &edev->slice; +} + static inline const char *eth_name(struct eth_device *edev) { return edev->devname; diff --git a/include/ratp_bb.h b/include/ratp_bb.h index a4f28c642c..b710f99bf9 100644 --- a/include/ratp_bb.h +++ b/include/ratp_bb.h @@ -41,7 +41,6 @@ struct ratp_bb_pkt { }; int barebox_ratp(struct console_device *cdev); -void barebox_ratp_command_run(void); int barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx); int barebox_ratp_fs_mount(const char *path); diff --git a/include/slice.h b/include/slice.h new file mode 100644 index 0000000000..b2d65b80cd --- /dev/null +++ b/include/slice.h @@ -0,0 +1,46 @@ +#ifndef __SLICE_H +#define __SLICE_H + +enum slice_action { + SLICE_ACQUIRE = 1, + SLICE_RELEASE = -1, + SLICE_TEST = 0, +}; + +struct slice { + int acquired; + struct list_head deps; + char *name; + struct list_head list; +}; + +struct slice_entry { + struct slice *slice; + struct list_head list; +}; + +void slice_acquire(struct slice *slice); +void slice_release(struct slice *slice); +bool slice_acquired(struct slice *slice); +void slice_depends_on(struct slice *slice, struct slice *dep); +void slice_init(struct slice *slice, const char *name); +void slice_exit(struct slice *slice); + +void slice_debug_acquired(struct slice *slice); + +extern struct slice command_slice; + +void command_slice_acquire(void); +void command_slice_release(void); + +extern int poller_active; + +#ifdef CONFIG_POLLER +#define assert_command_context() ({ \ + WARN_ONCE(poller_active, "%s called in poller\n", __func__); \ +}) +#else +#define assert_command_context() do { } while (0) +#endif + +#endif /* __SLICE_H */ diff --git a/include/usb/usb.h b/include/usb/usb.h index c2085eae87..39f4750916 100644 --- a/include/usb/usb.h +++ b/include/usb/usb.h @@ -20,6 +20,7 @@ #define _USB_H_ #include <driver.h> +#include <slice.h> #include <usb/ch9.h> #include <usb/ch11.h> #include <usb/usb_defs.h> @@ -163,13 +164,18 @@ struct usb_host { struct device_d *hw_dev; int busnum; struct usb_device *root_dev; - int sem; struct usb_phy *usbphy; + struct slice slice; }; int usb_register_host(struct usb_host *); void usb_unregister_host(struct usb_host *host); +static inline struct slice *usb_device_slice(struct usb_device *udev) +{ + return &udev->host->slice; +} + int usb_host_detect(struct usb_host *host); int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol); diff --git a/include/work.h b/include/work.h new file mode 100644 index 0000000000..0785bb3a88 --- /dev/null +++ b/include/work.h @@ -0,0 +1,42 @@ +#ifndef __WORK_H +#define __WORK_H + +#include <linux/list.h> +#include <clock.h> + +struct work_struct { + struct list_head list; + uint64_t timeout; + bool delayed; +}; + +struct work_queue { + void (*fn)(struct work_struct *work); + void (*cancel)(struct work_struct *work); + + struct list_head list; + struct list_head work; +}; + +static inline void wq_queue_work(struct work_queue *wq, struct work_struct *work) +{ + work->delayed = false; + list_add_tail(&work->list, &wq->work); +} + +static inline void wq_queue_delayed_work(struct work_queue *wq, + struct work_struct *work, + uint64_t delay_ns) +{ + work->timeout = get_time_ns() + delay_ns; + work->delayed = true; + list_add_tail(&work->list, &wq->work); +} + +void wq_register(struct work_queue *wq); +void wq_unregister(struct work_queue *wq); + +void wq_do_all_works(void); +void wq_cancel_work(struct work_queue *wq); + +#endif /* __WORK_H */ |