Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2303264imm; Mon, 24 Sep 2018 01:48:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sRTMUGtpQPnih44qs1dUMsiif2Pb0tt8DM2t7XZImLwAV3DQtgV5GIvLuJZfjLyi2Ry7b X-Received: by 2002:a63:7f55:: with SMTP id p21-v6mr8556172pgn.285.1537778923867; Mon, 24 Sep 2018 01:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537778923; cv=none; d=google.com; s=arc-20160816; b=HmskhdtZIV+/b1MCJol/4bj80gFLChMsk8ZV36ZNcLKu7E2brWvkbjdwklfz4baSzQ Bj+8h8MaVIwQRtL51tOl3LQrEZFyPY8yh/pasHRg1/mNH7CAVp6mB2kdiN86ccoGFmu4 +PEbkGiE59SzdC6aInjMdxucNpE8LsTAPmuLDDomP/W4Z8+oqhcjbXzUU3r3ZkoY9k0U qJEhsPPZ3yX1SwevdGXFAv3io9p3mv/kNH0WWxVzQrEKaw/GWjl8p4h7/3JGILSdhreM 4uphHFFhCtrI4k+QhSLEZfg/O8+EPfTEagsAtbEzfkHSpjBTG9obMibakoE7AwkTPrOd qE1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature; bh=vNyYcOfN2D7fhj3KRZvlekPttTdom10ZzoLOvHzGNM4=; b=m2NT8zEXgkNFMl5MOe98FmtQnxrJF3SbdgHgdYyii2T9qWhB+svZLctnhdZLRGwq/i nIXRZss3IXq8PLttwgyAPOeSim/0fNrJUK5BytesD2DqZjaNt4P4Kjm3QMinTtRqaYlB JjXzVS7VRwYFamgnJFt3+UiqYoLwJEjVE6bjNNlLVPtbG6AW32eje3RcGg74BJynr9/C Yxp7zlQYUZ02Apj+gYNSa5LvKj/1Oqx62epMhF4qcDNbaUFZXEf8CCO6RZysdpp9HGSa w4RDeoklYGKhqVn6zwquPDGPkFzGly6y8jcEueSAAdvXL6V6CwqoXGTRLv+WJgGX5Rjc yyTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=huZFyatj; dkim=pass header.i=@codeaurora.org header.s=default header.b="oE4mDh/d"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34-v6si33757660pld.394.2018.09.24.01.48.28; Mon, 24 Sep 2018 01:48:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=huZFyatj; dkim=pass header.i=@codeaurora.org header.s=default header.b="oE4mDh/d"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728106AbeIXOtD (ORCPT + 99 others); Mon, 24 Sep 2018 10:49:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56062 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727525AbeIXOtD (ORCPT ); Mon, 24 Sep 2018 10:49:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 59EC0607A2; Mon, 24 Sep 2018 08:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537778883; bh=n7AITtKARulfNUSfXJtsqKnjsZjKQ9zhN/HqebvXRVc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=huZFyatjFiAACA8dkO0b503/C498iHXlBE3KOUxl0NTnr5CyhV+jlgv9bDEMozaZs UCK/kkLtavbHXW93v9Ac6NL+0Hbza1Oe3irp63lVclpPwPLtQxPS6M/vX+JTL6I5MK MAL0JaOkwgv/cd7y+n5dyiMsseCyRRCYzPFjcLJ4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.242.6.76] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sayalil@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A4061605FD; Mon, 24 Sep 2018 08:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1537778882; bh=n7AITtKARulfNUSfXJtsqKnjsZjKQ9zhN/HqebvXRVc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=oE4mDh/dybs2uebiNuVjYG9euIX5yFs7gYA1alkDBryTBo3YiCbHiq/rUEu2WZb0v oPx8fyHoBgzjOitFtotbFUinkGTIXMFb3fb7g86GzN07Bqi/D/QaucwHJYqeZx4rky uInTz7hdIgCXAcl96dE1D1sYHzliMMSbuu1EmZD4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A4061605FD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sayalil@codeaurora.org Subject: Re: [PATCH V14 1/2] scsi: ufs: set the device reference clock setting To: Avri Altman , "subhashj@codeaurora.org" , "cang@codeaurora.org" , "vivek.gautam@codeaurora.org" , "rnayak@codeaurora.org" , "vinholikatti@gmail.com" , "jejb@linux.vnet.ibm.com" , "martin.petersen@oracle.com" , "asutoshd@codeaurora.org" , "evgreen@chromium.org" , "riteshh@codeaurora.org" Cc: "stummala@codeaurora.org" , "adrian.hunter@intel.com" , "jlbec@evilplan.org" , "linux-scsi@vger.kernel.org" , open list References: <1537770516-28410-1-git-send-email-sayalil@codeaurora.org> <1537770516-28410-2-git-send-email-sayalil@codeaurora.org> From: Sayali Lokhande Message-ID: <0761c2c2-4366-0a20-6789-10c4c9498908@codeaurora.org> Date: Mon, 24 Sep 2018 14:17:54 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/24/2018 1:28 PM, Avri Altman wrote: >> +static struct ufs_ref_clk ufs_ref_clk_freqs[] = { >> + {19200000, REF_CLK_FREQ_19_2_MHZ}, >> + {26000000, REF_CLK_FREQ_26_MHZ}, >> + {38400000, REF_CLK_FREQ_38_4_MHZ}, >> + {52000000, REF_CLK_FREQ_52_MHZ}, >> + {0, REF_CLK_FREQ_INVAL}, >> +}; >> + >> +static inline enum ufs_ref_clk_freq >> +ufs_get_bref_clk_from_hz(u32 freq) >> +{ >> + int i = 0; >> + >> + while (ufs_ref_clk_freqs[i].freq_hz != freq) { >> + if (!ufs_ref_clk_freqs[i].freq_hz) >> + return REF_CLK_FREQ_INVAL; > Is the if clause really needed? > you will return REF_CLK_FREQ_INVAL anyway Yes. the if condition makes sure to return REF_CLK_FREQ_INVAL if freq is not what we expect. > >> + i++; > You might overrun here if freq is not what you've expected Above if condition "if (!ufs_ref_clk_freqs[i].freq_hz)" prevents such overrun as we will reach end of ufs_ref_clk_freqs[] (i.e upto  0, REF_CLK_FREQ_INVAL) when there is no match and thus we will return REF_CLK_FREQ_INVAL. >> + } >> + >> + return ufs_ref_clk_freqs[i].val; >> +}