From patchwork Thu Jun 1 08:52:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9758867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E9D06038E for ; Thu, 1 Jun 2017 08:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0FF127F88 for ; Thu, 1 Jun 2017 08:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5E2D284FE; Thu, 1 Jun 2017 08:53:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 80D6627F88 for ; Thu, 1 Jun 2017 08:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject: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=xWr0fWuwCQ/rHGsNxbdX3duX2PPb8IPFWxgH3reAVsM=; b=Kf1 ZptH5xjapuyZWEK//s1Iu7pbt531KyTnQActX504Or/WobGxbqx4TMYBhIW3VArCgp/QIF4n2DmXE lV9BP7enaAvCjrEaY69OsUWzDaVdTmMAUEWY6uu8XEWY4Kf2b5tPK/QqRdqga4DV4F0kejawSgU3X lhcrf/F9YY3MFt5Xp54yAoAgeHwrR6TjX2DgEjJcJe0h/6+eOxivNBo31j/HNgyKvw9Fr5XtI48Pk amJEDh4dBdfBDJ3+/ofenqT99dm+3S3apxIPL+fgDhyVc5HkDLEi5OZkyrfQ4RRpLkBWUoSSjbDTJ JN1pjmDellSwdmB8JIwXgTm2g5uJ4sA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dGLqq-0006ho-Bu; Thu, 01 Jun 2017 08:53:04 +0000 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGLqn-0006eD-3A for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2017 08:53:02 +0000 Received: by mail-it0-x244.google.com with SMTP id i206so4667385ita.3 for ; Thu, 01 Jun 2017 01:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k0WrMjyJBqzJbGJYurYRECS9lBEavMsMouxg27g0oTk=; b=M2k+aZRtAZFLtaA3msfeD7XVres2QJD4Icg1QR8lRhV+rmNsWBvPs5ehne1Wizlt2J M9uT7/XTc6Hi/lHbgDzSf2++IPAXc+VzrpKOqP9ZPPAq+XhDr/qHzOkgkpAOyj552j7i OX/ObwbdRq8gia7VmlhrcGodBs9jsCGR+vIeoQaREbSDPE3Upim0FMlQJ76Uf6InTiYS jO8Iz1MpUQANldgO5pYxIojFArhOEvDzqZ4fNgt9I4pBNdrme8zK3sbRzSAqVNQoFmMV vAZAPrVOlBLJ3a4jrFhnS4UnXb7bfl9HQU1ZYCY2PANo51hihW4n5RMupOaVfQXPxDnW T8cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k0WrMjyJBqzJbGJYurYRECS9lBEavMsMouxg27g0oTk=; b=H5xebOHOBoPNZZPYKvKNRxdv9BGc3a38tH185UFh9DfhZExn68X77K4Toy3Z2Q43Rn 8fU91GAzljOBEW+drvDwAMIYHkKaLjnfIL5z5CiJ3lobn0FaR75gwGrE8p2W+3n3V/fs lIdzhz5cgHWU6UxOIetFBxKbJh9/RccKEZ+8/cRR3pc06n82L1xmgmVbaGPAbo/+FBhQ CnFQPRFzPlLDrraH4Vj8Agbx/Sl2u3oLOwjZp4p7g0C//ylkjn1xvqw7kI9/etcvTR2e InY09njmHTyA5CWA0NmPC2ObqPqF53X1JzD+NOgmZp3n7yGZOa1h6YadRUSwgSXjYgn4 u4/Q== X-Gm-Message-State: AODbwcBI8EX67QsaPz/jrtomLbUrvZOqV7lutDC3L4JYYtl9X8R8Iz+H KNt6nk7BrEHi0Q== X-Received: by 10.101.85.196 with SMTP id k4mr229642pgs.172.1496307159384; Thu, 01 Jun 2017 01:52:39 -0700 (PDT) Received: from symbol-HP-Z420-Workstation.zebra.lan ([223.31.70.102]) by smtp.googlemail.com with ESMTPSA id d75sm34723620pfj.75.2017.06.01.01.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 01:52:38 -0700 (PDT) From: Arvind Yadav To: gregkh@linuxfoundation.org, nicolas.ferre@microchip.com Subject: [PATCH] misc: atmel-ssc: Handle return value of clk_prepare_enable and clk_prepare Date: Thu, 1 Jun 2017 14:22:28 +0530 Message-Id: X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170601_015301_175859_91A3092A X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP clk_prepare_enable() and clk_prepare() can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/misc/atmel-ssc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index b2a0340..4d2b090 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -30,6 +30,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num) { int ssc_valid = 0; struct ssc_device *ssc; + int ret; spin_lock(&user_lock); list_for_each_entry(ssc, &ssc_list, list) { @@ -60,7 +61,11 @@ struct ssc_device *ssc_request(unsigned int ssc_num) ssc->user++; spin_unlock(&user_lock); - clk_prepare(ssc->clk); + ret = clk_prepare(ssc->clk); + if (ret) { + pr_err("Failed to prepare clock\n"); + return ret; + } return ssc; } @@ -195,6 +200,7 @@ static int ssc_probe(struct platform_device *pdev) struct resource *regs; struct ssc_device *ssc; const struct atmel_ssc_platform_data *plat_dat; + int ret; ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL); if (!ssc) { @@ -229,7 +235,9 @@ static int ssc_probe(struct platform_device *pdev) } /* disable all interrupts */ - clk_prepare_enable(ssc->clk); + ret = clk_prepare_enable(ssc->clk); + if (ret) + return ret; ssc_writel(ssc->regs, IDR, -1); ssc_readl(ssc->regs, SR); clk_disable_unprepare(ssc->clk);