[PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
Andy Shevchenko
andy.shevchenko at gmail.com
Mon Jul 4 13:19:55 PDT 2022
On Mon, Jul 4, 2022 at 7:42 AM ChiaEn Wu <peterwu.pub at gmail.com> wrote:
>
> Add chip level mt6370 tcpci driver.
...
> +static const struct reg_sequence mt6370_reg_init[] = {
> + REG_SEQ(0xA0, 0x1, 1000),
> + REG_SEQ(0x81, 0x38, 0),
> + REG_SEQ(0x82, 0x82, 0),
> + REG_SEQ(0xBA, 0xFC, 0),
> + REG_SEQ(0xBB, 0x50, 0),
> + REG_SEQ(0x9E, 0x8F, 0),
> + REG_SEQ(0xA1, 0x5, 0),
> + REG_SEQ(0xA2, 0x4, 0),
> + REG_SEQ(0xA3, 0x4A, 0),
> + REG_SEQ(0xA4, 0x01, 0),
> + REG_SEQ(0x95, 0x01, 0),
> + REG_SEQ(0x80, 0x71, 0),
> + REG_SEQ(0x9B, 0x3A, 1000)
Keep a comma here in case something would be added later on.
> +};
...
> + if (ret && !source)
> + return regulator_disable(priv->vbus);
> + else if (!ret && source)
> + return regulator_enable(priv->vbus);
> + else
> + return 0;
'else' is redundant in both cases.
...
> +static int mt6370_check_vendor_info(struct mt6370_priv *priv)
> +{
> + struct regmap *regmap = priv->tcpci_data.regmap;
> + u16 vid;
> + int ret;
> +
> + ret = regmap_raw_read(regmap, TCPC_VENDOR_ID, &vid, sizeof(u16));
> + if (ret)
> + return ret;
> +
> + if (vid != MT6370_VENDOR_ID) {
> + dev_err(priv->dev, "Vendor ID not correct 0x%02x\n", vid);
> + return -ENODEV;
return dev_err_probe(...);
> + }
> +
> + return 0;
> +}
> +
> +static int mt6370_tcpc_probe(struct platform_device *pdev)
> +{
> + struct mt6370_priv *priv;
> + int ret;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = &pdev->dev;
> + platform_set_drvdata(pdev, priv);
> +
> + priv->tcpci_data.regmap = dev_get_regmap(pdev->dev.parent, NULL);
> + if (!priv->tcpci_data.regmap)
> + return dev_err_probe(&pdev->dev, -ENODEV,
> + "Failed to init regmap\n");
You may save some LoCs by introducing a temporary variable
struct device *dev = &pdev->dev;
and here on a single line
return dev_err_probe(dev, ...);
Ditto for the rest.
...
> + ret = mt6370_check_vendor_info(priv);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "Failed to check vendor info\n");
This duplicates (with less info given) the message from the callee.
...
> + { .compatible = "mediatek,mt6370-tcpc", },
Inner comma is not needed.
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list