From patchwork Thu May 6 20:27:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 12243513 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,USER_AGENT_GIT autolearn=ham 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 6F943C43460 for ; Thu, 6 May 2021 20:32:25 +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 C21BF6112F for ; Thu, 6 May 2021 20:32:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C21BF6112F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.com 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:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=51tfhADRX3+AXMi0PiUooV3PtTrReBJ62WOVRHYuZVs=; b=gbh93JGSwkbuzbA4KXAjrrTBf zi8arZah2p6C/nPwUONwWMM5V4RjbYygDJQytEObLigF7Rj5woHqEQWZNjQTV7F19F93JrGdGqZw5 5P/ZUMLSjWhugve923KdUBsz/bmsiKstPLV3TzQCOsZulEnYVv+kZQxANYQOLJjF3P1ct/Qrsb5Vi LyRTRe7i/dpUmMzpAN1jCOlCy0bBMYV91IB/y+t8QEXWdkbs95O4dt0SHdz26MWpOski3DE3Vc4d7 74ll0aJ7EmNGC3T93NGMdtnPcW7+oX7O4m3msd4OAr/k7RwnhRDpsQwPlwnVsnwlNDWH5tHMEyalf Q6RgR5F3g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lekdJ-005FiT-Fn; Thu, 06 May 2021 20:30:05 +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 1lekcy-005Fh1-74 for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 20:29:44 +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:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Type:Content-ID:Content-Description; bh=i3wg2XN420azu/evG4iGtlbTYfEz7jreR3UbeD+i/T0=; b=W3IiXAaUYIejl4gaOYPR0fdXM9 DqK/ElRpMCyhDcuzbdcgLCMZ6C6bX1ZPbgdVJBnt3k7T4H0PTHy+7YCS+xlH/RH7stTTXJJBt9q5w 50E5/SDGsuWI1UGuDcwIRad/dxbPsn1TzocrD2Zqvt9BpF3ZtmwkVSL1z/iwW8l8P/ntt2+KCjP31 +WooytqC4GuE76xFzdnYGj+oh0k8UUlPVtrf9xFLFpgGOBgHzgw9c678kw9QdJvTnq/AkcMtPQT+a o1Qv1kcZF+u5QflIGQIryrYvTjt0BZeBivKg+tublR+qmHqY6u2KQcSi09KPqBsN/7CJGXosH33bT nyyZnGDw==; Received: from youngberry.canonical.com ([91.189.89.112]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lekcv-006N7Y-Lh for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 20:29:43 +0000 Received: from mail-qk1-f198.google.com ([209.85.222.198]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lekcs-0001cg-RV for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 20:29:38 +0000 Received: by mail-qk1-f198.google.com with SMTP id d15-20020a05620a136fb02902e9e93c69c8so4317308qkl.23 for ; Thu, 06 May 2021 13:29:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i3wg2XN420azu/evG4iGtlbTYfEz7jreR3UbeD+i/T0=; b=X1xzGtU2CXFP4nzmLZ/LLqKahzsU7jAnM8uem2vJXR3j6rlM67DhL7GHQ5kO+td3mU LeBJ/yuQBw4i0fkWuJoMoTiUYwpKt974qx3LJmWegCLxIY/hqaTur1i6x9HWWL/53Ugc Xwi6ZkeseuBRK/JP9OZTmpwgcEMhpfCkNW62yGzCc0W/QJqb8EUgKFPPx/hZYRb2dv50 rqMsl0dXZvmfEqSaAp/Wrm6DGnPOQ3FvTjOXenGiyr6PxY3/X3Rxkx15FYnqDIi0pqOA pbEXwYpJtqg4fzGgbt1jjX10LM1MVKnF85l/OUDMdbezSTzAGYWlSpp7NDTAg56kLixK ISKw== X-Gm-Message-State: AOAM530+COndhWEU8o5MV6AHp4aAvNG/mrx/UIViLRLsR9/OhmzBXsr1 b2r7bC+7kVrbxvb/OnlDsZNmCJquGsip0ipU6uAbR7ZpCdqaHF+0YJdwcczjLv+cFlr1vijQ35L OQzOPtkS664Qz0dzi7JOKviQSwfAH07dab7ok/DLayLxW2yKSlSzs X-Received: by 2002:ac8:5dce:: with SMTP id e14mr6047045qtx.385.1620332978031; Thu, 06 May 2021 13:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr/teC4fU26p0xkpWZj5KkZrm5frwONB63LY6ImAr+V1yN3mfqGPo04XbzbC5xzeeBkOr5Tg== X-Received: by 2002:ac8:5dce:: with SMTP id e14mr6047029qtx.385.1620332977866; Thu, 06 May 2021 13:29:37 -0700 (PDT) Received: from localhost.localdomain ([45.237.49.6]) by smtp.gmail.com with ESMTPSA id r9sm3151363qtf.62.2021.05.06.13.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 13:29:37 -0700 (PDT) From: Krzysztof Kozlowski To: Krzysztof Kozlowski , Daniel Lezcano , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 3/5] clocksource/drivers/samsung_pwm: Cleanup on init error Date: Thu, 6 May 2021 16:27:27 -0400 Message-Id: <20210506202729.157260-3-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210506202729.157260-1-krzysztof.kozlowski@canonical.com> References: <20210506202729.157260-1-krzysztof.kozlowski@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_132941_726292_497EDEB5 X-CRM114-Status: GOOD ( 16.90 ) 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 Failure of timer initialization is likely to be fatal for the system, so cleanup in such case is not strictly necessary. However the code might be refactored or reused, so better not to rely on such assumption that system won't continue init failure. Unmap the IO memory and put the clock on initialization failures from devicetree. Signed-off-by: Krzysztof Kozlowski --- Not marking as cc-stable and not adding Fixes tag, as this is not really a bug. --- drivers/clocksource/samsung_pwm_timer.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index bfad61b509f9..55e2f9fa2a15 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -421,7 +421,7 @@ static int __init samsung_pwm_alloc(struct device_node *np, struct property *prop; const __be32 *cur; u32 val; - int i; + int i, ret; memcpy(&pwm.variant, variant, sizeof(pwm.variant)); for (i = 0; i < SAMSUNG_PWM_NUM; ++i) @@ -444,10 +444,24 @@ static int __init samsung_pwm_alloc(struct device_node *np, pwm.timerclk = of_clk_get_by_name(np, "timers"); if (IS_ERR(pwm.timerclk)) { pr_crit("failed to get timers clock for timer\n"); - return PTR_ERR(pwm.timerclk); + ret = PTR_ERR(pwm.timerclk); + goto err_clk; } - return _samsung_pwm_clocksource_init(); + ret = _samsung_pwm_clocksource_init(); + if (ret) + goto err_clocksource; + + return 0; + +err_clocksource: + clk_put(pwm.timerclk); + pwm.timerclk = NULL; +err_clk: + iounmap(pwm.base); + pwm.base = NULL; + + return ret; } static const struct samsung_pwm_variant s3c24xx_variant = {