Re: [PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver

From
Andy Shevchenko <hidden>
Date
2022-07-04 20:20:37
Also in
dri-devel, linux-arm-kernel, linux-fbdev, linux-iio, linux-leds, linux-mediatek, linux-pm, linux-usb, lkml
Reply to
ChiaEn Wu, 2022-07-04
On Mon, Jul 4, 2022 at 7:42 AM ChiaEn Wu [off-list ref] wrote:
Add chip level mt6370 tcpci driver.
...
quoted hunk ↗ jump to hunk
+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.
+};
...
quoted hunk ↗ jump to hunk
+       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.

...
quoted hunk ↗ jump to hunk
+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(...);
quoted hunk ↗ jump to hunk
+       }
+
+       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
Thread (35 messages) 35 messages, 7 authors, last reply 2022-07-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help