Skip to content

Commit

Permalink
Fix Linux version check for ki_complete signature
Browse files Browse the repository at this point in the history
The commit upstream that changed the signature of ki_complete was
not introduced until v5.16-rc1.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b19b766e8f077f29cdb47da5003469a85bbfb9c

This change was backported to the RHEL kernel in 5.14.0-185.el9 so
we can check for RHEL v9.1 or higher.

Signed-off-by: Alexander Koskovich <[email protected]>
  • Loading branch information
AKoskovich authored and shashankarora07 committed Jan 27, 2025
1 parent 3746e31 commit 8e41706
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
35 changes: 20 additions & 15 deletions QdssDiag/qtiDiag.c
Original file line number Diff line number Diff line change
Expand Up @@ -1803,10 +1803,11 @@ static void aio_submit_read_worker(struct work_struct *work)
ret = aioDataCtx->mDataLen;
}

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, ret, 0);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, ret);
#else
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, ret, 0);
#endif

spin_unlock_irqrestore(&aioDataCtx->pDev->mBulkMemList.mReadMemLock, flags);
Expand Down Expand Up @@ -1865,10 +1866,11 @@ static void *io_async_complete(struct kiocb *kiocb, void *userData)
if (!io_data->buf) {
QC_LOG_ERR(pDev," Failed to allocate memory\n");
io_data->mActualLen = 0;
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
kiocb->ki_complete(kiocb, 0, -ENOMEM);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
kiocb->ki_complete(kiocb, -ENOMEM);
#else
kiocb->ki_complete(kiocb, 0, -ENOMEM);
#endif
usb_autopm_put_interface(io_data->pDev->interface);
return NULL;
Expand All @@ -1881,10 +1883,11 @@ static void *io_async_complete(struct kiocb *kiocb, void *userData)
}
}
else {
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
kiocb->ki_complete(kiocb, 0, -ETIMEDOUT);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
kiocb->ki_complete(kiocb, -ETIMEDOUT);
#else
kiocb->ki_complete(kiocb, 0, -ETIMEDOUT);
#endif
return NULL;
}
Expand Down Expand Up @@ -2297,17 +2300,19 @@ static void aio_submit_worker(struct work_struct *work)
submit_work);

if(aioDataCtx->mActualLen) {
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mActualLen, 0);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mActualLen);
#else
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mActualLen, 0);
#endif
}
else {
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mActualLen, aioDataCtx->mDataLen);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mDataLen);
#else
aioDataCtx->kiocb->ki_complete(aioDataCtx->kiocb, aioDataCtx->mActualLen, aioDataCtx->mDataLen);
#endif
}

Expand Down
42 changes: 24 additions & 18 deletions rmnet/QMIDevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -3277,10 +3277,11 @@ void WriteAsyncCallback( struct urb * pWriteURB )
kfree(pWriteURB->transfer_buffer);
usb_free_urb( pWriteURB );

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, 0, -EINVAL);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, -EINVAL);
#else
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, 0, -EINVAL);
#endif

return;
Expand All @@ -3304,10 +3305,11 @@ void WriteAsyncCallback( struct urb * pWriteURB )
AddToURBList( pDev, pFilpData->mClientID, pWriteURB, pFilpData->QMIDev );
spin_unlock_irqrestore( &pFilpData->QMIDev->mClientMemLock, flags );

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, 0, -EINVAL);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, 0);
#else
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, 0, -EINVAL);
#endif

return ;
Expand All @@ -3317,10 +3319,11 @@ void WriteAsyncCallback( struct urb * pWriteURB )
spin_unlock_irqrestore( &pFilpData->QMIDev->mClientMemLock, flags );

QC_LOG_DBG(GET_QMIDEV_QMIFILP(pFilpData), "Actual Write:\n" );
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, (pWriteURB->actual_length - QMUXHeaderSize()), pWriteURB->status);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, (pWriteURB->actual_length - QMUXHeaderSize()));
#else
pAioDataCtx->kiocb->ki_complete(pAioDataCtx->kiocb, (pWriteURB->actual_length - QMUXHeaderSize()), pWriteURB->status);
#endif

kfree(pWriteURB->transfer_buffer);
Expand All @@ -3341,10 +3344,11 @@ static void aio_cancel_worker(struct work_struct *work)

usb_kill_urb(io_data->urb);

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
io_data->kiocb->ki_complete(io_data->kiocb, -1, -ETIMEDOUT);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
io_data->kiocb->ki_complete(io_data->kiocb, -1);
#else
io_data->kiocb->ki_complete(io_data->kiocb, -1, -ETIMEDOUT);
#endif

return;
Expand Down Expand Up @@ -3675,10 +3679,11 @@ static void aio_read_copy_worker(struct work_struct *work)
status = 0;
}

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
kiocb->ki_complete(kiocb, ret, status); //Status = 0, in case of success
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
kiocb->ki_complete(kiocb, ret); // ret: number of bytes not copied
#else
kiocb->ki_complete(kiocb, ret, status); //Status = 0, in case of success
#endif

kfree(aioDataCtx);
Expand Down Expand Up @@ -3831,10 +3836,11 @@ static void aio_read_cancel_worker(struct work_struct *work)

spin_unlock_irqrestore( &QMIDev->mClientMemLock, flags);

#if (LINUX_VERSION_CODE <= KERNEL_VERSION(5,15,158))
kiocb->ki_complete(kiocb, 0, -ETIMEDOUT);
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)) || \
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 1))
kiocb->ki_complete(kiocb, 0);
#else
kiocb->ki_complete(kiocb, 0, -ETIMEDOUT);
#endif

QC_LOG_DBG(GET_QMIDEV_QMIFILP(pFilpData), "Done\n");
Expand Down
7 changes: 7 additions & 0 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
//---------------------------------------------------------------------------
#ifndef VERSION_H
#define VERSION_H

#define DRIVER_VERSION "1.0.4.25"

#ifndef RHEL_RELEASE_CODE
#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))
#define RHEL_RELEASE_CODE 0
#endif

#endif

0 comments on commit 8e41706

Please sign in to comment.