Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix null f_ops in kernel 4.1 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions src/os/linux/rt_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ void RTMP_QueryPacketInfo(
if (RTMP_GET_PKT_SG(pPacket)) {
struct sk_buff *skb = (struct sk_buff *)pPacket;
int i, nr_frags = skb_shinfo(skb)->nr_frags;

info->BufferCount = nr_frags + 1;
info->PhysicalBufferCount = info->BufferCount;
info->sg_list[0].data = (VOID *)GET_OS_PKT_DATAPTR(pPacket);
info->sg_list[0].len = skb_headlen(skb);
for (i = 0; i < nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];

info->sg_list[i+1].data = ((void *) page_address(frag->page) +
frag->page_offset);
info->sg_list[i+1].len = frag->size;
Expand Down Expand Up @@ -1161,18 +1161,20 @@ void RtmpOSFileSeek(RTMP_OS_FD osfd, int offset)

int RtmpOSFileRead(RTMP_OS_FD osfd, char *pDataPtr, int readLen)
{
return vfs_read(osfd, pDataPtr, readLen, &osfd->f_pos);
/* The object must have a read method */
if (osfd->f_op && osfd->f_op->read) {
return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos);
} else {
DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n"));
return -1;
}
// if (osfd->f_op && osfd->f_op->read) {
// return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos);
// } else {
// DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n"));
// return -1;
// }
}

int RtmpOSFileWrite(RTMP_OS_FD osfd, char *pDataPtr, int writeLen)
{
return osfd->f_op->write(osfd, pDataPtr, (size_t) writeLen, &osfd->f_pos);
return vfs_write(osfd, pDataPtr, writeLen, &osfd->f_pos);
//return osfd->f_op->write(osfd, pDataPtr, (size_t) writeLen, &osfd->f_pos);
}

static inline void __RtmpOSFSInfoChange(OS_FS_INFO * pOSFSInfo, BOOLEAN bSet)
Expand Down Expand Up @@ -1710,9 +1712,9 @@ PNET_DEV RtmpOSNetDevGetByName(PNET_DEV pNetDev, PSTRING pDevName)
void RtmpOSNetDeviceRefPut(PNET_DEV pNetDev)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
/*
every time dev_get_by_name is called, and it has returned a valid struct
net_device*, dev_put should be called afterwards, because otherwise the
/*
every time dev_get_by_name is called, and it has returned a valid struct
net_device*, dev_put should be called afterwards, because otherwise the
machine hangs when the device is unregistered (since dev->refcnt > 1).
*/
if (pNetDev)
Expand Down Expand Up @@ -1818,7 +1820,7 @@ int RtmpOSNetDevAttach(
pNetDev->ethtool_ops = &RALINK_Ethtool_Ops;
#endif

/* if you don't implement get_stats, just leave the callback function as NULL, a dummy
/* if you don't implement get_stats, just leave the callback function as NULL, a dummy
function will make kernel panic.
*/
if (pDevOpHook->get_stats)
Expand Down Expand Up @@ -1984,9 +1986,9 @@ UCHAR VLAN_8023_Header_Copy(
/* no VLAN tag is needed to insert */
memcpy(pData, pHeader802_3, HdrLen);
}

return VLAN_Size;
}
}
#endif /* CONFIG_AP_SUPPORT */


Expand Down Expand Up @@ -2064,7 +2066,7 @@ VOID RtmpDrvAllMacPrint(
os_alloc_mem(NULL, (UCHAR **)&msg, 1024);
if (!msg)
return;

orig_fs = get_fs();
set_fs(KERNEL_DS);

Expand Down Expand Up @@ -2115,10 +2117,10 @@ VOID RtmpDrvAllE2PPrint(
os_alloc_mem(NULL, (UCHAR **)&msg, 1024);
if (!msg)
return;

orig_fs = get_fs();
set_fs(KERNEL_DS);

/* open file */
file_w = filp_open(fileName, O_WRONLY | O_CREAT, 0);
if (IS_ERR(file_w)) {
Expand Down Expand Up @@ -2160,7 +2162,7 @@ VOID RtmpDrvAllRFPrint(
PSTRING fileName = "RFDump.txt";
mm_segment_t orig_fs;
UINT32 macAddr = 0, macValue = 0;

orig_fs = get_fs();
set_fs(KERNEL_DS);

Expand Down Expand Up @@ -2693,7 +2695,7 @@ VOID CFG80211OS_UnRegister(
Must unregister, or you will suffer problem when you change
regulatory domain by using iw.
*/

#ifdef RFKILL_HW_SUPPORT
wiphy_rfkill_stop_polling(pCfg80211_CB->pCfg80211_Wdev->wiphy);
#endif /* RFKILL_HW_SUPPORT */
Expand Down Expand Up @@ -3798,7 +3800,7 @@ VOID RTMP_OS_Add_Timer(NDIS_MINIPORT_TIMER *pTimerOrg, ULONG timeout)

__RTMP_OS_Add_Timer(pTimer, timeout);
}
}
}


VOID RTMP_OS_Mod_Timer(NDIS_MINIPORT_TIMER *pTimerOrg, ULONG timeout)
Expand Down Expand Up @@ -5274,7 +5276,7 @@ PUCHAR RtmpOsPktHeadBufExtend(PNDIS_PACKET pNetPkt, UINT Len)
/*
========================================================================
Routine Description:


Arguments:
pPkt - the packet
Expand Down Expand Up @@ -5585,4 +5587,3 @@ VOID RtmpOsTaskWakeUp(RTMP_OS_TASK *pTask)
}

#endif /* OS_ABL_FUNC_SUPPORT */