lkml.org 
[lkml]   [2020]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 06/12] soc: aspeed: Add XDMA Engine Driver


On Fri, 3 Jan 2020, at 05:57, Eddie James wrote:
> +static int aspeed_xdma_init_scu(struct aspeed_xdma *ctx, struct device *dev)
> +{
> + struct regmap *scu = syscon_regmap_lookup_by_phandle(dev->of_node,
> + "aspeed,scu");
> +
> + if (!IS_ERR(scu)) {
> + u32 selection;
> + bool pcie_device_bmc = true;
> + const u32 bmc = SCU_PCIE_CONF_BMC_EN |
> + SCU_PCIE_CONF_BMC_EN_MSI | SCU_PCIE_CONF_BMC_EN_IRQ |
> + SCU_PCIE_CONF_BMC_EN_DMA;
> + const u32 vga = SCU_PCIE_CONF_VGA_EN |
> + SCU_PCIE_CONF_VGA_EN_MSI | SCU_PCIE_CONF_VGA_EN_IRQ |
> + SCU_PCIE_CONF_VGA_EN_DMA;
> + const char *pcie = NULL;
> +
> + if (!of_property_read_string(dev->of_node, "pcie-device",
> + &pcie)) {
> + if (!strcmp(pcie, "vga")) {
> + pcie_device_bmc = false;
> + } else if (strcmp(pcie, "bmc")) {
> + dev_err(dev,
> + "Invalid pcie-device property %s.\n",
> + pcie);
> + return -EINVAL;
> + }
> + }
> +
> + if (pcie_device_bmc) {
> + selection = bmc;
> + regmap_write(scu, ctx->chip->scu_bmc_class,
> + SCU_BMC_CLASS_REV_XDMA);
> + } else {
> + selection = vga;
> + }
> +
> + regmap_update_bits(scu, ctx->chip->scu_pcie_conf, bmc | vga,
> + selection);
> + } else {
> + dev_warn(dev, "Unable to configure PCIe; continuing.\n");
> + }

Not something you need to fix but generally I'd structure this as a early-return:

if (IS_ERR(scu)) {
dev_warn(dev, "Unable to configure PCIe; continuing.\n");
return 0;
}
...

Could probably also improve the warning message to say what caused the
failure, but again, something that can be changed later.

\
 
 \ /
  Last update: 2020-01-09 06:06    [W:0.099 / U:4.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site