From f553be3b6538322b782ef4e2716b98924109af95 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Thu, 1 Jun 2023 23:17:54 -0700 Subject: [PATCH] modules/mqnic: Assert reset during probe of platform device, if connected Signed-off-by: Alex Forencich --- modules/mqnic/mqnic_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/mqnic/mqnic_main.c b/modules/mqnic/mqnic_main.c index fd7054928..5411a58fe 100644 --- a/modules/mqnic/mqnic_main.c +++ b/modules/mqnic/mqnic_main.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) @@ -747,6 +748,7 @@ static int mqnic_platform_probe(struct platform_device *pdev) struct mqnic_dev *mqnic; struct device *dev = &pdev->dev; struct resource *res; + struct reset_control *rst; dev_info(dev, DRIVER_NAME " platform probe"); @@ -770,6 +772,17 @@ static int mqnic_platform_probe(struct platform_device *pdev) if (ret) goto fail; + // Reset device + rst = devm_reset_control_get(dev, NULL); + if (IS_ERR(rst)) { + dev_warn(dev, "Cannot control device reset"); + } else { + dev_info(dev, "Resetting device"); + reset_control_assert(rst); + udelay(2); + reset_control_deassert(rst); + } + // Reserve and map regions res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mqnic->hw_regs_size = resource_size(res);