From a6cd0209c2a00e0356fd19a4bb4b83d613f5dc45 Mon Sep 17 00:00:00 2001 From: surenyi Date: Thu, 24 Oct 2024 11:26:35 +0800 Subject: [PATCH] refine code Signed-off-by: surenyi --- vxbLfsLib.c | 76 +++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/vxbLfsLib.c b/vxbLfsLib.c index a3c8187..3fb8ec8 100644 --- a/vxbLfsLib.c +++ b/vxbLfsLib.c @@ -76,8 +76,50 @@ struct __lfs_drv_ctrl { lfs_t fsh; }; +/* {{{ vxBus methods */ +LOCAL void lfsDevInstInit(VXB_DEVICE_ID pDev); +LOCAL void lfsDevInstInit2(VXB_DEVICE_ID pDev); +LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev); +LOCAL void lfsDevShow(VXB_DEVICE_ID pDev, int verbose); +LOCAL STATUS lfsDevInstUnlink(VXB_DEVICE_ID pDev, void *unused); +/* }}} */ + +/* Publish the methods for the resources controlled with this file */ +/* clang-format off */ +LOCAL struct drvBusFuncs lfsDevFuncs = { + lfsDevInstInit, /* devInstanceInit */ + lfsDevInstInit2, /* devInstanceInit2 */ + lfsDevInstConnect /* devConnect */ +}; +LOCAL struct vxbDeviceMethod lfsDevMethods[] = { + DEVMETHOD(busDevShow , lfsDevShow), + DEVMETHOD(vxbDrvUnlink, lfsDevInstUnlink), + { 0, 0 } +}; + +LOCAL struct vxbSpiRegister lfsDevDriver = { + { + NULL, /* pNext */ + VXB_DEVID_DEVICE, /* devID */ + VXB_BUSID_PLB, /* busID */ + VXBUS_VERSION_5, /* vxbVersion */ + LFS_NAME, /* drvName */ + &lfsDevFuncs, /* pDrvBusFuncs */ + lfsDevMethods, /* pMethods */ + NULL, /* devProbe */ + NULL, /* pParamDefaults */ + }, +}; +/* clang-format on */ + LOCAL int __lfs_driver_node = -1; + +void lfsDevRegister(void) +{ + (void)vxbDevRegister((struct vxbDevRegInfo *)&lfsDevDriver); +} + /* {{{ lfsDevFuncs */ LOCAL void lfsDevInstInit(VXB_DEVICE_ID pDev) { @@ -509,12 +551,6 @@ LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev) } } } - -LOCAL struct drvBusFuncs lfsDevFuncs = { - lfsDevInstInit, /* devInstanceInit */ - lfsDevInstInit2, /* devInstanceInit2 */ - lfsDevInstConnect /* devConnect */ -}; /* }}} */ /* {{{ lfsMethods */ @@ -556,34 +592,6 @@ LOCAL STATUS lfsDevInstUnlink(VXB_DEVICE_ID pDev, void *unused) } /* }}} */ -/* Publish the methods for the resources controlled with this file */ -/* clang-format off */ -LOCAL struct vxbDeviceMethod lfsDevMethods[] = { - DEVMETHOD(busDevShow , lfsDevShow), - DEVMETHOD(vxbDrvUnlink, lfsDevInstUnlink), - { 0, 0 } -}; - -LOCAL struct vxbSpiRegister lfsDevDriver = { - { - NULL, /* pNext */ - VXB_DEVID_DEVICE, /* devID */ - VXB_BUSID_PLB, /* busID */ - VXBUS_VERSION_5, /* vxbVersion */ - LFS_NAME, /* drvName */ - &lfsDevFuncs, /* pDrvBusFuncs */ - lfsDevMethods, /* pMethods */ - NULL, /* devProbe */ - NULL, /* pParamDefaults */ - }, -}; -/* clang-format on */ - -void lfsDevRegister(void) -{ - (void)vxbDevRegister((struct vxbDevRegInfo *)&lfsDevDriver); -} - LOCAL lfsDrvCtrl * getLfsLowHandle(int unit) { VXB_DEVICE_ID pDev;