drivers: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, one missing k_work_delayable_from_work
conversion and few cases where the target should be pointing at the
first element explicitly.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
diff --git a/drivers/disk/nvme/nvme_disk.c b/drivers/disk/nvme/nvme_disk.c
index 3678859..ff22e3b 100644
--- a/drivers/disk/nvme/nvme_disk.c
+++ b/drivers/disk/nvme/nvme_disk.c
@@ -27,7 +27,7 @@
uint32_t num_sector)
{
struct nvme_namespace *ns = CONTAINER_OF(disk->name,
- struct nvme_namespace, name);
+ struct nvme_namespace, name[0]);
struct nvme_completion_poll_status status =
NVME_CPL_STATUS_POLL_INIT(status);
struct nvme_request *request;
@@ -70,7 +70,7 @@
uint32_t num_sector)
{
struct nvme_namespace *ns = CONTAINER_OF(disk->name,
- struct nvme_namespace, name);
+ struct nvme_namespace, name[0]);
struct nvme_completion_poll_status status =
NVME_CPL_STATUS_POLL_INIT(status);
struct nvme_request *request;
@@ -137,7 +137,7 @@
static int nvme_disk_ioctl(struct disk_info *disk, uint8_t cmd, void *buff)
{
struct nvme_namespace *ns = CONTAINER_OF(disk->name,
- struct nvme_namespace, name);
+ struct nvme_namespace, name[0]);
int ret = 0;
nvme_lock(disk->dev);
diff --git a/drivers/ethernet/dsa_ksz8xxx.c b/drivers/ethernet/dsa_ksz8xxx.c
index f47009e..0a6bb0a 100644
--- a/drivers/ethernet/dsa_ksz8xxx.c
+++ b/drivers/ethernet/dsa_ksz8xxx.c
@@ -712,8 +712,9 @@
static void dsa_delayed_work(struct k_work *item)
{
+ struct k_work_delayable *dwork = k_work_delayable_from_work(item);
struct dsa_context *context =
- CONTAINER_OF(item, struct dsa_context, dsa_work);
+ CONTAINER_OF(dwork, struct dsa_context, dsa_work);
struct ksz8xxx_data *pdev = PRV_DATA(context);
bool link_state;
uint8_t i;
diff --git a/drivers/net/ppp.c b/drivers/net/ppp.c
index f2e0ed7..c8d06fa 100644
--- a/drivers/net/ppp.c
+++ b/drivers/net/ppp.c
@@ -610,7 +610,7 @@
static uint8_t *ppp_recv_cb(uint8_t *buf, size_t *off)
{
struct ppp_driver_context *ppp =
- CONTAINER_OF(buf, struct ppp_driver_context, buf);
+ CONTAINER_OF(buf, struct ppp_driver_context, buf[0]);
size_t i, len = *off;
for (i = 0; i < *off; i++) {
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 5bed4c5..ba9bdd2 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -302,7 +302,7 @@
static uint8_t *recv_cb(uint8_t *buf, size_t *off)
{
struct slip_context *slip =
- CONTAINER_OF(buf, struct slip_context, buf);
+ CONTAINER_OF(buf, struct slip_context, buf[0]);
size_t i;
if (!slip->init_done) {
diff --git a/drivers/wifi/esp_at/esp.h b/drivers/wifi/esp_at/esp.h
index b4fd69a..bda67cb 100644
--- a/drivers/wifi/esp_at/esp.h
+++ b/drivers/wifi/esp_at/esp.h
@@ -344,7 +344,7 @@
static inline struct esp_data *esp_socket_to_dev(struct esp_socket *sock)
{
- return CONTAINER_OF(sock - sock->idx, struct esp_data, sockets);
+ return CONTAINER_OF(sock - sock->idx, struct esp_data, sockets[0]);
}
static inline void __esp_socket_work_submit(struct esp_socket *sock,
diff --git a/drivers/wifi/eswifi/eswifi.h b/drivers/wifi/eswifi/eswifi.h
index 4a9cf05..447b4b2 100644
--- a/drivers/wifi/eswifi/eswifi.h
+++ b/drivers/wifi/eswifi/eswifi.h
@@ -121,7 +121,7 @@
static inline
struct eswifi_dev *eswifi_socket_to_dev(struct eswifi_off_socket *socket)
{
- return CONTAINER_OF(socket - socket->index, struct eswifi_dev, socket);
+ return CONTAINER_OF(socket - socket->index, struct eswifi_dev, socket[0]);
}
struct eswifi_bus_ops *eswifi_get_bus(void);