Re: [v3 3/3] hwmon: Add Aspeed ast2600 TACH support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 02/11/2022 à 09:36, Billy Tsai a écrit :
This patch add the support of Tachometer which can use to monitor the
frequency of the input. The tach supports up to 16 channels and it's part
function of multi-function device "pwm-tach controller".

Signed-off-by: Billy Tsai <billy_tsai@xxxxxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
---
  Documentation/hwmon/index.rst               |   1 +
  Documentation/hwmon/tach-aspeed-ast2600.rst |  28 ++
  drivers/hwmon/Kconfig                       |   9 +
  drivers/hwmon/Makefile                      |   1 +
  drivers/hwmon/tach-aspeed-ast2600.c         | 476 ++++++++++++++++++++
  5 files changed, 515 insertions(+)
  create mode 100644 Documentation/hwmon/tach-aspeed-ast2600.rst
  create mode 100644 drivers/hwmon/tach-aspeed-ast2600.c


[...]

+static int aspeed_tach_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np, *child;
+	struct aspeed_tach_data *priv;
+	struct device *hwmon;
+	struct platform_device *parent_dev;
+	int ret;
+
+	np = dev->parent->of_node;
+	if (!of_device_is_compatible(np, "aspeed,ast2600-pwm-tach"))
+		return dev_err_probe(dev, -ENODEV,
+				     "Unsupported tach device binding\n");
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	priv->dev = &pdev->dev;
+	priv->tach_channel =
+		devm_kcalloc(dev, TACH_ASPEED_NR_TACHS,
+			     sizeof(*priv->tach_channel), GFP_KERNEL);

Hi,
the error handling is still missing:

	if (!priv->tach_channel)
		return -ENOMEM;

CJ

+
+	priv->regmap = syscon_node_to_regmap(np);
+	if (IS_ERR(priv->regmap))
+		return dev_err_probe(dev, PTR_ERR(priv->regmap),
+				     "Couldn't get regmap\n");
+	parent_dev = of_find_device_by_node(np);
+	priv->clk = devm_clk_get_enabled(&parent_dev->dev, NULL);
+	if (IS_ERR(priv->clk))
+		return dev_err_probe(dev, PTR_ERR(priv->clk),
+				     "Couldn't get clock\n");
+

[...]




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux