Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1240398pxa; Thu, 13 Aug 2020 04:22:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0pqHNRCFwCRUs0GeZ/Q17GaBPOox6sRgQR74TADeFUYXpi0AwE3epNx7wK8I9l0gKLnL7 X-Received: by 2002:a05:6402:7d5:: with SMTP id u21mr4345189edy.341.1597317733342; Thu, 13 Aug 2020 04:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597317733; cv=none; d=google.com; s=arc-20160816; b=l1hMUEmNelX2bh2iqjtqpo/l0tVPUAwfMEynCH/6/pGR/yFkLe1az8q3CYFael7Qf3 Mwgz/bQd2YFuJnHTcmm+YOMJ2wrfR8WLkGjKMy7VV2f7ERkyLAu3hFsMd7gFbZ1tHnSB VU4euBPgiHHtP0bgNA/9TOCAxqX5yvrU1fWzwzQj3vvf4KM+oI8PPsZ1k5ybzHuyhH5E PYYiZrh/2kjtJ6F2+blAXA0LtmC1LcW9BgooecL40NoTnDk28I3OGx9cu70H6M2MPYZE nRmzKZGhVfImb6AGbldRaHamKzEcZA6QhSChRqotkaaNQTd+KkpNI4NbVHWerg7dFAE7 rHxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qcVxyjLOc1XVQD85n/+izIou9HNM43cYVLg/SeyZZMI=; b=LjWd+MOtFMno0cJq62VfYAWj5HGFP1yli4YJ7u96tKzySsyYWwl3CgI/lFuKfzOKMB ctyBozyatqaiQgS8afC0JyMMfCwIUI/AWkIOIc/xURzv8xFYHe8GDfv651nHAA2suekZ bQw4R/jiklpWPrdZLhoBIVp6YmqexwCoEpiT61WlMjUAOAwMji84iQxjxxG9Dp6JVaqi pxJd0z7yzvxXSoGMXtyxNIuxwCfjRLt2PkcmDHv4D8BfN9un3t4XsVAQINwDywbzYPiL x0JNEwxpF5TwK32nt4qNXilzuO83BfHT0Plxr4BFg82ERroJQ0BZWVaSZHDVDQSDoHKB GrXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bNUdBuTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si3142734ejz.730.2020.08.13.04.21.50; Thu, 13 Aug 2020 04:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bNUdBuTw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbgHMLTL (ORCPT + 99 others); Thu, 13 Aug 2020 07:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbgHMLTI (ORCPT ); Thu, 13 Aug 2020 07:19:08 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C213C061383 for ; Thu, 13 Aug 2020 04:19:08 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id w25so5714544ljo.12 for ; Thu, 13 Aug 2020 04:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qcVxyjLOc1XVQD85n/+izIou9HNM43cYVLg/SeyZZMI=; b=bNUdBuTwV/3TZ/Z2ohABO3rXzw8ixSfjeDWsfXjjDrX20nyzrlw+kFWqi3ovJUynzQ T1jyIFdxNfWCxLqjjyxSHXr5s0oW5LxFuvCml7jlfGz/Es56tr8LGQJ0Ayd8iqZPt9ZY PsDEcqKEmN8WW+xd7XLaSVnCibx6LBsuymT1hEUj+XD/gGeGo2ourVChPri6ZJkqQOVR ceDCAPqSkGUMysZ8x4Jtlz5llwNp3sqtR86ChhD8zQbr6L7twY6lDI+UEQ3DiEXxQa/F 8Qku+cOjt+2i4dOy7CD3axyIFL6EvdiknM+KuArG/9J4BcsypOjwY3z7KRAA02hS0wBv 06Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qcVxyjLOc1XVQD85n/+izIou9HNM43cYVLg/SeyZZMI=; b=DU7ck+OqjfrgzQ/kawOk8ohG9G7xgPRej2QIxSqWZCl9UO66x9TFV0R/HiWVtLHiHB Gun+CWKoCmU03AyGN5ssC4avpcpYyDaYa64FQzxW+aS2QOgahuzrH5fd0mZXnKBNEqOR 5qbyDbyxxj3Sqbl5ckEYqCQ6q+hlOgbOQX2EBPmmB4lG5fy6mknwoJtI5mbEqQW/JPIf 8q50pqO5mAOTLlGg6d+E7wAgpYjZ1wIgKw7Q2Uwo8skEvcBhsVaHRy2VR24VW48QXggi VH2icO6/CRntHzRz3asb8IcS9xrWTEOlcy2CZBGQ93WGm6v7p6Djcq1qELzzrfcWAY+u W5EQ== X-Gm-Message-State: AOAM531zFbneRAO/bi/1Cb3nGn9lmaTnp8m8ycp3EM3fZdHJ/0d+xzF9 Toaj+Aoyd9KkUJRnTBAZtoSWoMb9ZaGjWm6vLSfZJg== X-Received: by 2002:a05:651c:91:: with SMTP id 17mr1857137ljq.173.1597317546530; Thu, 13 Aug 2020 04:19:06 -0700 (PDT) MIME-Version: 1.0 References: <20200725181404.18951-1-ansuelsmth@gmail.com> <20200725181404.18951-2-ansuelsmth@gmail.com> <006f01d66fe1$e6c0d450$b4427cf0$@gmail.com> In-Reply-To: <006f01d66fe1$e6c0d450$b4427cf0$@gmail.com> From: Amit Kucheria Date: Thu, 13 Aug 2020 16:48:55 +0530 Message-ID: Subject: Re: [RFC PATCH v5 1/7] drivers: thermal: tsens: Add VER_0 tsens version To: Ansuel Smith Cc: Andy Gross , Bjorn Andersson , Zhang Rui , Daniel Lezcano , Rob Herring , Linux PM list , linux-arm-msm , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 11, 2020 at 6:48 PM wrote: > > > > > -----Messaggio originale----- > > Da: Amit Kucheria > > > > > if (IS_ERR(priv->rf[i])) > > > return PTR_ERR(priv->rf[i]); > > > } > > > @@ -775,12 +800,80 @@ int __init init_common(struct tsens_priv > > *priv) > > > goto err_put_device; > > > } > > > > > > - priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map, > > > - priv->fields[TSENS_EN]); > > > - if (IS_ERR(priv->rf[TSENS_EN])) { > > > - ret = PTR_ERR(priv->rf[TSENS_EN]); > > > - goto err_put_device; > > > + if (tsens_version(priv) >= VER_0_1) { > > > + priv->rf[TSENS_EN] = devm_regmap_field_alloc( > > > + dev, priv->srot_map, priv->fields[TSENS_EN]); > > > + if (IS_ERR(priv->rf[TSENS_EN])) { > > > + ret = PTR_ERR(priv->rf[TSENS_EN]); > > > + goto err_put_device; > > > + } > > > + > > > + priv->rf[SENSOR_EN] = devm_regmap_field_alloc( > > > + dev, priv->srot_map, priv->fields[SENSOR_EN]); > > > + if (IS_ERR(priv->rf[SENSOR_EN])) { > > > + ret = PTR_ERR(priv->rf[SENSOR_EN]); > > > + goto err_put_device; > > > + } > > > + priv->rf[INT_EN] = devm_regmap_field_alloc( > > > + dev, priv->tm_map, priv->fields[INT_EN]); > > > + if (IS_ERR(priv->rf[INT_EN])) { > > > + ret = PTR_ERR(priv->rf[INT_EN]); > > > + goto err_put_device; > > > + } > > > + } else { > > > > Let's not create two big sections with if-else for 8960 and everything > > else. For example, what is wrong with using common code for TSENS_EN? > > > > If the concern is memory wasted trying to allocate fields not present > > on this older platform, perhaps consider adding a check in the loop to > > break early in case of 8960? > > > > About TSENS_EN the old platform doesn't have SROT so I need to use TM_MAP. > Should I set the srot map to match the tm map so we can use the common function? > Aside from this problem, I will try to remove the big if-else. Ick. I guess srot_map and tm_map pointing to the same region is the lesser of two evils? It makes it so this will be constrained to a single place in init_common().