From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaehoon Chung Date: Thu, 08 Sep 2016 22:46:44 +0900 Subject: [U-Boot] [PATCH v3 1/8] mmc: squash lines for immediate return In-Reply-To: <1473167860-27465-2-git-send-email-yamada.masahiro@socionext.com> References: <1473167860-27465-1-git-send-email-yamada.masahiro@socionext.com> <1473167860-27465-2-git-send-email-yamada.masahiro@socionext.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09/06/2016 10:17 PM, Masahiro Yamada wrote: > These functions can be much simpler by squashing lines for immediate > return. > > For *_bind() callbacks, they will be a simple wrapper function of an > upper-level bind API. > > For mmc_set_{boot_bus_width,part_conf}, they will be a wrapper of > mmc_switch(). > > Signed-off-by: Masahiro Yamada Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > > Changes in v3: None > > drivers/mmc/atmel_sdhci.c | 7 +------ > drivers/mmc/exynos_dw_mmc.c | 7 +------ > drivers/mmc/mmc_boot.c | 28 ++++++++-------------------- > drivers/mmc/msm_sdhci.c | 7 +------ > drivers/mmc/rockchip_dw_mmc.c | 7 +------ > drivers/mmc/rockchip_sdhci.c | 7 +------ > drivers/mmc/sandbox_mmc.c | 7 +------ > drivers/mmc/zynq_sdhci.c | 7 +------ > 8 files changed, 15 insertions(+), 62 deletions(-) > > diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c > index dd6bd33..d8f8087 100644 > --- a/drivers/mmc/atmel_sdhci.c > +++ b/drivers/mmc/atmel_sdhci.c > @@ -136,13 +136,8 @@ static int atmel_sdhci_probe(struct udevice *dev) > static int atmel_sdhci_bind(struct udevice *dev) > { > struct atmel_sdhci_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return sdhci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id atmel_sdhci_ids[] = { > diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c > index 57271f1..568fed7 100644 > --- a/drivers/mmc/exynos_dw_mmc.c > +++ b/drivers/mmc/exynos_dw_mmc.c > @@ -284,13 +284,8 @@ static int exynos_dwmmc_probe(struct udevice *dev) > static int exynos_dwmmc_bind(struct udevice *dev) > { > struct exynos_mmc_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return dwmci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id exynos_dwmmc_ids[] = { > diff --git a/drivers/mmc/mmc_boot.c b/drivers/mmc/mmc_boot.c > index 756a982..ac6f56f 100644 > --- a/drivers/mmc/mmc_boot.c > +++ b/drivers/mmc/mmc_boot.c > @@ -85,16 +85,10 @@ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize, > */ > int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode) > { > - int err; > - > - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH, > - EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) | > - EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) | > - EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width)); > - > - if (err) > - return err; > - return 0; > + return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH, > + EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) | > + EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) | > + EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width)); > } > > /* > @@ -106,16 +100,10 @@ int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode) > */ > int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access) > { > - int err; > - > - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, > - EXT_CSD_BOOT_ACK(ack) | > - EXT_CSD_BOOT_PART_NUM(part_num) | > - EXT_CSD_PARTITION_ACCESS(access)); > - > - if (err) > - return err; > - return 0; > + return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, > + EXT_CSD_BOOT_ACK(ack) | > + EXT_CSD_BOOT_PART_NUM(part_num) | > + EXT_CSD_PARTITION_ACCESS(access)); > } > > /* > diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c > index 8d4399e..1b82991 100644 > --- a/drivers/mmc/msm_sdhci.c > +++ b/drivers/mmc/msm_sdhci.c > @@ -190,13 +190,8 @@ static int msm_ofdata_to_platdata(struct udevice *dev) > static int msm_sdc_bind(struct udevice *dev) > { > struct msm_sdhc_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return sdhci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id msm_mmc_ids[] = { > diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c > index 020a59b..859760b 100644 > --- a/drivers/mmc/rockchip_dw_mmc.c > +++ b/drivers/mmc/rockchip_dw_mmc.c > @@ -142,13 +142,8 @@ static int rockchip_dwmmc_probe(struct udevice *dev) > static int rockchip_dwmmc_bind(struct udevice *dev) > { > struct rockchip_mmc_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return dwmci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id rockchip_dwmmc_ids[] = { > diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c > index 624029b..c56e1a3 100644 > --- a/drivers/mmc/rockchip_sdhci.c > +++ b/drivers/mmc/rockchip_sdhci.c > @@ -62,13 +62,8 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) > static int rockchip_sdhci_bind(struct udevice *dev) > { > struct rockchip_sdhc_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return sdhci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id arasan_sdhci_ids[] = { > diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c > index 5f1333b..fdb29a5 100644 > --- a/drivers/mmc/sandbox_mmc.c > +++ b/drivers/mmc/sandbox_mmc.c > @@ -112,7 +112,6 @@ int sandbox_mmc_bind(struct udevice *dev) > { > struct sandbox_mmc_plat *plat = dev_get_platdata(dev); > struct mmc_config *cfg = &plat->cfg; > - int ret; > > cfg->name = dev->name; > cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS | MMC_MODE_8BIT; > @@ -121,11 +120,7 @@ int sandbox_mmc_bind(struct udevice *dev) > cfg->f_max = 52000000; > cfg->b_max = U32_MAX; > > - ret = mmc_bind(dev, &plat->mmc, cfg); > - if (ret) > - return ret; > - > - return 0; > + return mmc_bind(dev, &plat->mmc, cfg); > } > > int sandbox_mmc_unbind(struct udevice *dev) > diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c > index 3815b94..b991102 100644 > --- a/drivers/mmc/zynq_sdhci.c > +++ b/drivers/mmc/zynq_sdhci.c > @@ -63,13 +63,8 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev) > static int arasan_sdhci_bind(struct udevice *dev) > { > struct arasan_sdhci_plat *plat = dev_get_platdata(dev); > - int ret; > > - ret = sdhci_bind(dev, &plat->mmc, &plat->cfg); > - if (ret) > - return ret; > - > - return 0; > + return sdhci_bind(dev, &plat->mmc, &plat->cfg); > } > > static const struct udevice_id arasan_sdhci_ids[] = { >