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;