Received: by 10.192.165.156 with SMTP id m28csp687986imm; Fri, 13 Apr 2018 06:13:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+BdgkYKGyVW/63mzkgNlogkdmXgAde8rhP4pMgyvpwV+KUlml2G02Fm3vsn/LabHrdBvZf X-Received: by 10.98.194.195 with SMTP id w64mr11489717pfk.83.1523625222762; Fri, 13 Apr 2018 06:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523625222; cv=none; d=google.com; s=arc-20160816; b=Y7Ic68UVlOWrQdGlUc52NrPwsjHRql/zq/7GhMNQiFkJuVuQcJ9DiJxP0OcfxPOK7u AhJ+Ea73XgbG9KXGDgI/q6U95eVvk0R76Yq2O2vx7qaC+gjWIAl/nscfzlqsuyaPeltn Pmuadan1pAbMpOPD+rYn9y4zp+9pGtEF5hwX+epTSJd372q28t6AHyt09mOoJHgKKixU A1skIWHGv53KQ3rDEqwzp5Iyc652K0NdIDy6NiVSQww4kb4w9JSYxUVtzUsLC7NAYdPF qI9Kpznv1fPZN0zIw2K0nvtrWt8BpOVgaJI6Uf/4O43XBJL3T46oubO/tSxhGAvc1+/+ hiPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:mime-version:in-reply-to:user-agent :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=BcNgvm2p8PXBooo3MBV6OxqXc2clblbTgBRmrgr4OYs=; b=JFgsv4H8OB6B19OvYwH0C3/oeFmIvVClaBpRTQS6QdofvyhzllIwVP2F+6h7dq0xq9 xj3vmkQ1xLavSZm6WZu7dXNt6MsKHvhjUE4lW2lMCGQftxo5aeyfOo1MB++/mygvC9CJ Pj4/+L9xu2UnQIv8WG8EAg0dRKFLVryKWrNhTJMW9ruf7DQkCmvF9CTpG0JOFfAombN7 GdA9ypf/SB/1uz9SaUeQXGuEkb0m4liTedC+OZ8BtYr0CAkjbPxE86xpVTiAfaVzcVtd 7qylUC1/YzHHB5uq3KVFyAR6tk9OeiuA22Q30unckh+OFi+vV+LDRCe2RYiyht0RwJlI gWfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BKpfUBWZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2-v6si5544241pli.242.2018.04.13.06.13.28; Fri, 13 Apr 2018 06:13:42 -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=@samsung.com header.s=mail20170921 header.b=BKpfUBWZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbeDMLIo (ORCPT + 99 others); Fri, 13 Apr 2018 07:08:44 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:31408 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751827AbeDMLIl (ORCPT ); Fri, 13 Apr 2018 07:08:41 -0400 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180413110839epoutp037dc3c7ab83dbc8ca5e3c21d7702bb4f9~k_j5NyTgM1122411224epoutp03Y; Fri, 13 Apr 2018 11:08:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180413110839epoutp037dc3c7ab83dbc8ca5e3c21d7702bb4f9~k_j5NyTgM1122411224epoutp03Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523617719; bh=BcNgvm2p8PXBooo3MBV6OxqXc2clblbTgBRmrgr4OYs=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=BKpfUBWZ+mar+3AeOwh7Cj/yoZJic9xz4NvyFtxhYm4B2msNE5TSonLJCoE7UDPMk KVJuRPJ6Mf1P48ivHXqlJW+Kql56wl19hnr6gNyRb7cc6JGnHPaU3j6F2AJnyVcFN8 yx5NYVDFwPv7qDo12FyV5hKtA5vfudlO/qx1YFFo= Received: from epsmges2p1.samsung.com (unknown [182.195.42.69]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180413110838epcas2p3ba7d7e2c39d2f2756d373aacea096668~k_j4ApI-e0534705347epcas2p3z; Fri, 13 Apr 2018 11:08:38 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id D2.5B.04068.6BF80DA5; Fri, 13 Apr 2018 20:08:38 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180413110837epcas2p1c79b95afdf5f9139fb4b0307a704cae1~k_j3o6CmR1772417724epcas2p1s; Fri, 13 Apr 2018 11:08:37 +0000 (GMT) X-AuditID: b6c32a45-6ebff70000000fe4-c1-5ad08fb64b7c Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 75.3B.03827.5BF80DA5; Fri, 13 Apr 2018 20:08:37 +0900 (KST) Received: from amdc3058.localnet ([106.120.53.102]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P74001B5EYCY450@mmp1.samsung.com>; Fri, 13 Apr 2018 20:08:37 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Daniel Lezcano Cc: edubezval@gmail.com, rui.zhang@intel.com, philip.li@intel.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Kukjin Kim , Krzysztof Kozlowski , "open list:SAMSUNG THERMAL DRIVER" , "moderated list:ARM/SAMSUNG EXYNOS ARM ARCHITECTURES" Subject: Re: [PATCH] thermal/drivers/exynos_tmu: Fix warnings in temp_to_code / code_to_temp Date: Fri, 13 Apr 2018 13:08:35 +0200 Message-id: <11044079.DdDvlFD91s@amdc3058> User-Agent: KMail/4.13.3 (Linux/3.13.0-96-generic; KDE/4.13.3; x86_64; ; ) In-reply-to: <1523617209-1730-1-git-send-email-daniel.lezcano@linaro.org> MIME-version: 1.0 Content-transfer-encoding: quoted-printable Content-type: text/plain; charset="utf-8" X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42LZdljTQndb/4Uog0/T2CzmfZa1mH/lGqtF /+PXzBbnz29gt9j0GMi9vGsOm8Xn3iOMFjPO72OyuHToIpPFk4d9bA5cHjtn3WX3WLznJZPH plWdbB53ru1h89i8pN7j8ya5ALYoLpuU1JzMstQifbsErozdWw6wFcxRqtjc/ZGtgfGyTBcj B4eEgInEgoP5XYxcHEICOxglFt7dxgLhfGeU6PhwhwmmaHq7I0R8N6PEgwU/mSGcr4wSHx6v Z+xi5ORgE7CSmNi+CswWEdCTaHzfxgRSxCzwnkli79M1bCAJYYE4iblHOphAbBYBVYmWLz1g DbwCWhIXrh5jAbFFBbwktuxrB6vhFPCUOLRvCTtEjaDEj8n3wGqYBbQlnry7wApha0q8+DIJ 7GwJgdtsEnMXTQBbJiHgIrH0w2YoW1ji1fEt7BC2tMSzVRsZIRqaGSW+7djDDJGYwCixZ70Q hG0tcfj4RagNfBIdh/+yQ8KCV6KjDarEQ6Jj+WlWCNtRYvP++4yQYNnLKNFz8gjbBEbZWUgO n4Xk8FlIDl/AyLyKUSy1oDg3PbXYqMBQrzgxt7g0L10vOT93EyM4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Pe/Ya/6M+0vbonUmpzf6bo3i++M378puJZbijERDLeai4kQA 67jwMncCAAA= X-CMS-MailID: 20180413110837epcas2p1c79b95afdf5f9139fb4b0307a704cae1 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180413110032epcas4p3e0ef781eecb771b1294b7992d2ee6e6d X-RootMTR: 20180413110032epcas4p3e0ef781eecb771b1294b7992d2ee6e6d References: <10298074.ogKH1ypqfx@amdc3058> <1523617209-1730-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, April 13, 2018 01:00:09 PM Daniel Lezcano wrote: > The latest driver cleanup introduced a compilation warning >=20 > drivers/thermal/samsung/exynos_tmu.c: In function =E2=80=98exynos_ge= t_temp=E2=80=99: > drivers/thermal/samsung/exynos_tmu.c:931:37: warning: =E2=80=98temp=E2= =80=99 may be used uninitialized in this function [-Wmaybe-uninitialize= d] > *temp =3D code_to_temp(data, value) * MCELSIUS; > ^ >=20 > drivers/thermal/samsung/exynos_tmu.c: In function =E2=80=98temp_to_c= ode=E2=80=99 > drivers/thermal/samsung/exynos_tmu.c:304:9: warning: =E2=80=98temp_c= ode=E2=80=99 may be used uninitialized in this function [-Wmaybe-uninit= ialized] > =09=09=09=09=09 return temp_code; > =09=09=09=09=09 ^~~~~~~~~ >=20 > The compiler gives a warning because semantically speaking the > function has no default value. However the code path, were the > variable is never initialized is a dead branch because the switch > statement always choose one of the two cases as the data->cal_type is= > initialized in the init function to one of both values. >=20 > This is unclear as it adds a dependency on the initialization functio= n > and it is prone to error. Make things clearer by converting the > functions with if ... return statements, thus showing we are expectin= g > the values to be correctly filled before calling this function. >=20 > This change fixes the couple of function warnings. >=20 > Signed-off-by: Daniel Lezcano Thanks Daniel, this is much better fix. Acked-by: Bartlomiej Zolnierkiewicz > --- > drivers/thermal/samsung/exynos_tmu.c | 46 ++++++++++----------------= ---------- > 1 file changed, 12 insertions(+), 34 deletions(-) >=20 > diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/s= amsung/exynos_tmu.c > index 2ec8548..197f267 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -284,24 +284,13 @@ static void exynos_report_trigger(struct exynos= _tmu_data *p) > */ > static int temp_to_code(struct exynos_tmu_data *data, u8 temp) > { > -=09int temp_code; > - > -=09switch (data->cal_type) { > -=09case TYPE_TWO_POINT_TRIMMING: > -=09=09temp_code =3D (temp - EXYNOS_FIRST_POINT_TRIM) * > -=09=09=09(data->temp_error2 - data->temp_error1) / > -=09=09=09(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) + > -=09=09=09data->temp_error1; > -=09=09break; > -=09case TYPE_ONE_POINT_TRIMMING: > -=09=09temp_code =3D temp + data->temp_error1 - EXYNOS_FIRST_POINT_TR= IM; > -=09=09break; > -=09default: > -=09=09WARN_ON(1); > -=09=09break; > -=09} > +=09if (data->cal_type =3D=3D TYPE_ONE_POINT_TRIMMING) > +=09=09return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM; > =20 > -=09return temp_code; > +=09return (temp - EXYNOS_FIRST_POINT_TRIM) * > +=09=09(data->temp_error2 - data->temp_error1) / > +=09=09(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) + > +=09=09data->temp_error1; > } > =20 > /* > @@ -310,24 +299,13 @@ static int temp_to_code(struct exynos_tmu_data = *data, u8 temp) > */ > static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)= > { > -=09int temp; > - > -=09switch (data->cal_type) { > -=09case TYPE_TWO_POINT_TRIMMING: > -=09=09temp =3D (temp_code - data->temp_error1) * > -=09=09=09(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) / > -=09=09=09(data->temp_error2 - data->temp_error1) + > -=09=09=09EXYNOS_FIRST_POINT_TRIM; > -=09=09break; > -=09case TYPE_ONE_POINT_TRIMMING: > -=09=09temp =3D temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TR= IM; > -=09=09break; > -=09default: > -=09=09WARN_ON(1); > -=09=09break; > -=09} > +=09if (data->cal_type =3D=3D TYPE_ONE_POINT_TRIMMING) > +=09=09return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM= ; > =20 > -=09return temp; > +=09return (temp_code - data->temp_error1) * > +=09=09(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) / > +=09=09(data->temp_error2 - data->temp_error1) + > +=09=09EXYNOS_FIRST_POINT_TRIM; > } > =20 > static void sanitize_temp_error(struct exynos_tmu_data *data, u32 tr= im_info) Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics