From 4a3bc6b1b4bcd1b5c61eeb216b4782fb692d7182 Mon Sep 17 00:00:00 2001 From: fengsheng Date: Fri, 31 May 2019 20:09:34 +0800 Subject: [PATCH] sfc: fix bug sfc can not rmmod. driver inclusion category: feature bugzilla: NA CVE: NA fix bug:fix bug can not rmmod. Signed-off-by: fengsheng Reviewed-by: linsiwei Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c | 10 ++-- drivers/mtd/hisilicon/sfc/hrd_sflash_driver.c | 1 - drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c | 4 +- drivers/mtd/hisilicon/sfc/lbc.h | 59 ------------------- 4 files changed, 8 insertions(+), 66 deletions(-) delete mode 100644 drivers/mtd/hisilicon/sfc/lbc.h diff --git a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c index 732cb5f1b11e..36796270d5bf 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c +++ b/drivers/mtd/hisilicon/sfc/hrd_sfc_driver.c @@ -27,9 +27,8 @@ #include #include "hrdCommon.h" #include "hrd_sflash_driver.h" -#include "hrd_sflash_hal.h" -#define SFC_DRIVER_VERSION "1.7.8.0" +#define SFC_DRIVER_VERSION "1.7.9.0" static const char *sflashMtdList[] = { "sflash", NULL }; @@ -147,6 +146,10 @@ static unsigned int flash_map_init(struct platform_device *pdev) sfc_regres = platform_get_resource(pdev, IORESOURCE_MEM, 0); flash_iores = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!sfc_regres || !flash_iores) { + return -EFAULT; + } + if (sfc_regres->end <= sfc_regres->start) { pr_err("ERROR: sfc register error\n"); return -EFAULT; @@ -193,7 +196,6 @@ static void __exit flash_map_exit(struct platform_device *pdev) for (i = 0; i < host->mapsNum; i++) { if (host->maps[i].mtdInfo) { (void)mtd_device_unregister(host->maps[i].mtdInfo); - map_destroy(host->maps[i].mtdInfo); } if (host->maps[i].mapInfo.virt) { @@ -201,7 +203,7 @@ static void __exit flash_map_exit(struct platform_device *pdev) host->maps[i].mapInfo.virt = 0; } - if (host->maps[i].mtdInfo) { + if (host->maps[i].mtdInfo) { sflash_destroy(host->maps[i].mtdInfo); } } diff --git a/drivers/mtd/hisilicon/sfc/hrd_sflash_driver.c b/drivers/mtd/hisilicon/sfc/hrd_sflash_driver.c index 636d2c48e623..659dbe1eccc3 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sflash_driver.c +++ b/drivers/mtd/hisilicon/sfc/hrd_sflash_driver.c @@ -164,7 +164,6 @@ struct mtd_info *sflash_probe(struct map_info *map, struct resource *sfc_regres) ((sflash->sectorNumber * sflash->sectorSize) / 1024), sflash->sectorNumber, (sflash->sectorSize / 1024)); - __module_get(THIS_MODULE); return mtd; exit0: diff --git a/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c b/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c index 1a2bb3a783de..c30600512db2 100644 --- a/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c +++ b/drivers/mtd/hisilicon/sfc/hrd_sflash_hal.c @@ -999,7 +999,7 @@ static s32 SFC_RegWordAlignRead(struct SFC_SFLASH_INFO *sflash, } for (i = 0; i < ulDataCnt; i++) { - pulData[i] = SFC_RegisterRead(sflash->sfc_reg_base + DATABUFFER1 + 4*i); + pulData[i] = SFC_RegisterRead(sflash->sfc_reg_base + DATABUFFER1 + (u32)(4*i)); } return ulRet; @@ -1069,7 +1069,7 @@ static s32 SFC_RegWordAlignWrite(struct SFC_SFLASH_INFO *sflash, ulDataCnt = ulWriteLen>>2; for (i = 0; i < ulDataCnt; i++) { - SFC_RegisterWrite(sflash->sfc_reg_base + DATABUFFER1+4*i, ulData[i]); + SFC_RegisterWrite(sflash->sfc_reg_base + DATABUFFER1 + (u32)(4*i), ulData[i]); } SFC_RegisterWrite(sflash->sfc_reg_base + CMD_ADDR, ulOffsetAddr); diff --git a/drivers/mtd/hisilicon/sfc/lbc.h b/drivers/mtd/hisilicon/sfc/lbc.h deleted file mode 100644 index 4bf1592661e2..000000000000 --- a/drivers/mtd/hisilicon/sfc/lbc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2019 Hisilicon Limited, All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see