From patchwork Sat May 15 12:39:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Novikov X-Patchwork-Id: 12259749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0283CC433ED for ; Sat, 15 May 2021 12:42:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0FB7613D1 for ; Sat, 15 May 2021 12:42:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0FB7613D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ispras.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=kUny/1Lvo+/VRlnDX9OokhwlnZyHtB6dNKaHriis5oA=; b=fJknX9AzpleIFTPx3z5GBOtG5l vy8b3tRJJK0nht/z7sAYz5P/iJiXxaCnNBMhjSLHuc1O5dlAJSojCDRNndSzmrJbyUpaRe4hYZfKC qNyFZ2NoCi4EVHeJM+wN0mA3U1OxTTFRowkpx0sLKo4VYZ3HN84OWNHb6iW6IBQ10/2MmX3oBh7jW xeP1qiuFNPh6/zP4OqlRLjEXprr5FAl4/XDz6Y9PeoxKc8eHIuajjiAB693YLEKJbCZEyzIDVHw4F n9jQmFz4PyNo7uyi6M1poPLvoYOit8JbMzb3KBREGqYubJ+GEvRr2JC59Z9f0d29lwCEcVapJVVSb W+oT+Aug==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhtaG-00AIix-Kn; Sat, 15 May 2021 12:40:01 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhtZy-00AIiF-9W for linux-arm-kernel@desiato.infradead.org; Sat, 15 May 2021 12:39:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=JBc/QQOaZyR1yjFcgfqvOgZfsUc4zbtjnoWSIdvYxOk=; b=0V+5cyUAyqasWfuFHtax4rEXVf Lmz88AixJIEw0ZJi+l5Gc5dkgriD5+IEA6tGJluokgqI3GJsUZ23+CeYrUEEzlMo0K2pfXGabW/C2 WSKi5eZZe4Y3YL6fRxMnW/IP9MoOIhhTAHwizY9vk0g7oj6fHfpCKrR0K8O7twgUcVjg5d2K393xY dBwa6tEHORUUq2U4zNWD0gfnqz6gC7yob7ziL5RYkw0iS+CesLmo8gaCQg3N76m8vpp5BGxRWJn/C ht8rJ8GvOjnmMF8s4BO32uWInDbtOUb7n6oiWaVAdZBN+3+MW1kQYRMHLtIXcy/be/ATG1fiL9qU0 y5pxquXQ==; Received: from mail.ispras.ru ([83.149.199.84]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhtZt-00CWpN-9X for linux-arm-kernel@lists.infradead.org; Sat, 15 May 2021 12:39:34 +0000 Received: from hellwig.intra.ispras.ru (unknown [10.10.2.182]) by mail.ispras.ru (Postfix) with ESMTPS id ACB4E40D403E; Sat, 15 May 2021 12:39:20 +0000 (UTC) From: Evgeny Novikov To: Patrice Chotard Cc: Evgeny Novikov , Sean Young , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] media: st_rc: Handle errors of clk_prepare_enable() Date: Sat, 15 May 2021 15:39:09 +0300 Message-Id: <20210515123909.5638-1-novikov@ispras.ru> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_053933_535738_D9A173C4 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hadle errors of clk_prepare_enable() in st_rc_hardware_init() and its callers. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Reviewed-by: Patrice Chotard --- drivers/media/rc/st_rc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c index 3237fef5d502..f524fcf55acf 100644 --- a/drivers/media/rc/st_rc.c +++ b/drivers/media/rc/st_rc.c @@ -157,8 +157,9 @@ static irqreturn_t st_rc_rx_interrupt(int irq, void *data) return IRQ_HANDLED; } -static void st_rc_hardware_init(struct st_rc_device *dev) +static int st_rc_hardware_init(struct st_rc_device *dev) { + int ret; int baseclock, freqdiff; unsigned int rx_max_symbol_per = MAX_SYMB_TIME; unsigned int rx_sampling_freq_div; @@ -166,7 +167,10 @@ static void st_rc_hardware_init(struct st_rc_device *dev) /* Enable the IP */ reset_control_deassert(dev->rstc); - clk_prepare_enable(dev->sys_clock); + ret = clk_prepare_enable(dev->sys_clock); + if (ret) + return ret; + baseclock = clk_get_rate(dev->sys_clock); /* IRB input pins are inverted internally from high to low. */ @@ -184,6 +188,8 @@ static void st_rc_hardware_init(struct st_rc_device *dev) } writel(rx_max_symbol_per, dev->rx_base + IRB_MAX_SYM_PERIOD); + + return 0; } static int st_rc_remove(struct platform_device *pdev) @@ -287,7 +293,9 @@ static int st_rc_probe(struct platform_device *pdev) rc_dev->dev = dev; platform_set_drvdata(pdev, rc_dev); - st_rc_hardware_init(rc_dev); + ret = st_rc_hardware_init(rc_dev); + if (ret) + goto err; rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; /* rx sampling rate is 10Mhz */ @@ -359,6 +367,7 @@ static int st_rc_suspend(struct device *dev) static int st_rc_resume(struct device *dev) { + int ret; struct st_rc_device *rc_dev = dev_get_drvdata(dev); struct rc_dev *rdev = rc_dev->rdev; @@ -367,7 +376,10 @@ static int st_rc_resume(struct device *dev) rc_dev->irq_wake = 0; } else { pinctrl_pm_select_default_state(dev); - st_rc_hardware_init(rc_dev); + ret = st_rc_hardware_init(rc_dev); + if (ret) + return ret; + if (rdev->users) { writel(IRB_RX_INTS, rc_dev->rx_base + IRB_RX_INT_EN); writel(0x01, rc_dev->rx_base + IRB_RX_EN);