From 585475991cc9711efb41ae0dde17679117949f63 Mon Sep 17 00:00:00 2001 From: yuht Date: Wed, 6 Jan 2016 09:54:39 +0800 Subject: [PATCH] =?UTF-8?q?update=20get=20=E2=80=9Cgeometry=E2=80=9D=20sou?= =?UTF-8?q?rce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in function internal,get "geometry" form paramater "dev->user_data", not use public variable "SDCfg" --- bsp/lpc176x/drivers/sd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bsp/lpc176x/drivers/sd.c b/bsp/lpc176x/drivers/sd.c index 018c4d411..08eb2201f 100644 --- a/bsp/lpc176x/drivers/sd.c +++ b/bsp/lpc176x/drivers/sd.c @@ -461,11 +461,13 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, rt_uint8_t cmd, void *args) struct rt_device_blk_geometry *geometry; geometry = (struct rt_device_blk_geometry *)args; + if (geometry == RT_NULL) return -RT_ERROR; - - geometry->bytes_per_sector = SDCfg.sectorsize; - geometry->block_size = SDCfg.blocksize; - geometry->sector_count = SDCfg.sectorcnt; + if (dev->user_data == RT_NULL) return -RT_ERROR; + + geometry->bytes_per_sector = ((SDCFG *)dev->user_data)->sectorsize; + geometry->block_size = ((SDCFG *)dev->user_data)->blocksize; + geometry->sector_count = ((SDCFG *)dev->user_data)->sectorcnt; } return RT_EOK;