From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chin Liang See Date: Mon, 21 Jul 2014 05:49:28 -0500 Subject: [U-Boot] [PATCH] socfpga: cleanup socfpga_dw_mmc In-Reply-To: <20140721103035.GA13156@amd.pavel.ucw.cz> References: <20140716123422.GA8844@amd.pavel.ucw.cz> <20140716125238.CF3833804B5@gemini.denx.de> <20140721103035.GA13156@amd.pavel.ucw.cz> Message-ID: <1405939768.1969.1.camel@clsee-VirtualBox.altera.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Pavel, On Mon, 2014-07-21 at 12:30 +0200, ZY - pavel wrote: > Cleanups as suggested by wd on mailing list, plus I replaced > calloc(...,1) with malloc(). > > Signed-off-by: Pavel Machek > > --- a/drivers/mmc/socfpga_dw_mmc.c > +++ b/drivers/mmc/socfpga_dw_mmc.c > @@ -16,8 +16,6 @@ static const struct socfpga_clock_manager *clock_manager_base = > static const struct socfpga_system_manager *system_manager_base = > (void *)SOCFPGA_SYSMGR_ADDRESS; > > -static char *SOCFPGA_NAME = "SOCFPGA DWMMC"; > - > #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK (1 << 8) > > static void socfpga_dwmci_clksel(struct dwmci_host *host) > @@ -47,14 +45,15 @@ static void socfpga_dwmci_clksel(struct dwmci_host *host) > > int socfpga_dwmmc_init(u32 regbase, int bus_width, int index) > { > - struct dwmci_host *host = NULL; > - host = calloc(sizeof(struct dwmci_host), 1); > + struct dwmci_host *host; > + > + host = malloc(sizeof(struct dwmci_host)); We need calloc as it will initialize the allocated region. It will prevent errors due to NULL comparison against uninitialized structure member. Thanks Chin Liang > if (!host) { > printf("dwmci_host calloc fail!\n"); > return -1; > } > > - host->name = SOCFPGA_NAME; > + host->name = "SOCFPGA DWMMC"; > host->ioaddr = (void *)regbase; > host->buswidth = bus_width; > host->clksel = socfpga_dwmci_clksel; > >