Received: by 10.192.165.156 with SMTP id m28csp329881imm; Tue, 17 Apr 2018 10:49:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mS0DVvcXt41Mr50VHyneNA6GOS9876RrDyfIb8mEYDV36IxA8GdEtlqgnYiSL91ObEE0I X-Received: by 10.99.191.12 with SMTP id v12mr2569885pgf.54.1523987390972; Tue, 17 Apr 2018 10:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523987390; cv=none; d=google.com; s=arc-20160816; b=HR0ydntsoKuu9EwfblUxjcff6hxq5E4V/pc4GyYimvKpyNEo/S3/nniDyIvvyHKEIh oATLxLLh0wEAQXSc6cjRj2NrKv51nP38lUK7gwZ4liW3LUKLtDo+O6FoA9bJVh5D0RZ/ RVM22XgNQVMimFhm5jLEf3s+entx3dVWzcsyvoYWoMq4gx2WGVv1svoBJRNZVF1Evr90 uI5SGQd0+zL0Hh/havKH15zh3KvYzs4dIHVqwS5ei68JDSWVK0OyA/P/NjowkEg74Ui2 qzuvBRSlgDXDOLqwDMs9PHrDT7RSk8GLY5YLLwTsCDy1yqw+aP8eP8d8faYwjxZOslNf CW7w== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=eYGBapEuyriqoVTcwS5eXsWvEyeFqsDiPuxrFjo/0XI=; b=lIi4VUI4K2vPPt2iaM2NdMh5jMa5/EYu4nFeIgW2kJYuvkbRBbawANrS5Lvp6e85SG QzolPF97T+41Zx3W4CRDRVmStzLadyxZIaqyGkHZgeUV8av3eww9CbpIEzyAKPdujs/N 3LeQt84vYXd/aLmwqb8cjeCX1tqwWXWu7AYoD+K3/wUdwIwpQxE+QniOfZ1t7kzvaLjl l3WgJ55UeToc3yy/jWmmwiqHhCLO/oHW5XuyhqCkdz6Kvrv+yDPHomlQEErhwpopXZ36 Dncvii1tmktTaA5cXWJ+nYWJ+l9OmjVdK6lNZuwsZayOq9YZ4JiwLQgET0Z2Q/TfYdIY s8Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dowhile0-org.20150623.gappssmtp.com header.s=20150623 header.b=Lw744Zly; 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 d21-v6si14254834pll.460.2018.04.17.10.49.36; Tue, 17 Apr 2018 10:49:50 -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=@dowhile0-org.20150623.gappssmtp.com header.s=20150623 header.b=Lw744Zly; 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 S1753170AbeDQRs1 (ORCPT + 99 others); Tue, 17 Apr 2018 13:48:27 -0400 Received: from mail-io0-f169.google.com ([209.85.223.169]:44491 "EHLO mail-io0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752887AbeDQRsY (ORCPT ); Tue, 17 Apr 2018 13:48:24 -0400 Received: by mail-io0-f169.google.com with SMTP id g9so4635869iob.11 for ; Tue, 17 Apr 2018 10:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dowhile0-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eYGBapEuyriqoVTcwS5eXsWvEyeFqsDiPuxrFjo/0XI=; b=Lw744Zlyti8cAXCXFFRkvcMQc/c2YcQpM13rV7b5exwwFSej9ZuYwFDNFhVp6JCmla xq9xWXJyhBjGzV7xZ6CIVSUeDPIa/rnnSCQVJKlrl4iZFCZE5oXBhUHiYQQ798L2VnUq 12c/wqGOp1qqKtGnfvZez19QZ+OtHv5Yt9r7ZCyhBAYK6WmddYHRB0nxI1ydZaDl5+DJ J1FVsvl7bwD8Wn/Ug3ncsz3DnPUEoWZy4o8RS7q1ybh2wTB7Jtv+l4H8Pe0f0JblqwqH Ki6H6MrARQzpXkHvMDx32oQ8Ei3q5tRMVojfKQrDaos8NJ/27D+A1i5KxliMJUi5rAVq CT3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eYGBapEuyriqoVTcwS5eXsWvEyeFqsDiPuxrFjo/0XI=; b=Mba5VLN8jbqv/ZibrmtJac+Sb/8vHIZbae58M//xxSvIK1Eg00WMVT8TKmIWMTK5vf 4Za6UUoe64CcrYnt3lEOZQMd5vZ6hAMALKjbvVHVEjnDomDh0OaQ5MfLqZSdkV2PQpsh OSFvW+jBx5VZS82v4Z1hKbckZ9e6rPDIiunI3cv7D4ikC2UyYzaQDYy5ThQlo9fTNmd0 YLCZct9xIhssKp85F+Xx4GPKKiPnA6IFndKIjWElUmGd6l6oq+bQ1z1jibr+rseu+8nt UJ+V2DXuPYP88cSI1ttcWapXeeDxZBqGDMv9YDdfjvyRZSzKvJwehEH6ngeou0/Q5qEg xpYg== X-Gm-Message-State: ALQs6tD04QKrmzQTvWsZTNq+hUAavVBDkCPpfqjuU4ReiCvkHjdAoc5u rL/MaAu/nLTovh7YzQqBK7qVQUOw7gL3K7FXmvGvUQ== X-Received: by 10.107.88.6 with SMTP id m6mr2904267iob.167.1523987303439; Tue, 17 Apr 2018 10:48:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:c70c:0:0:0:0:0 with HTTP; Tue, 17 Apr 2018 10:48:22 -0700 (PDT) X-Originating-IP: [90.77.100.34] In-Reply-To: <20180417172229.GK8973@sirena.org.uk> References: <20180417171204.259146-1-dianders@chromium.org> <20180417172229.GK8973@sirena.org.uk> From: Javier Martinez Canillas Date: Tue, 17 Apr 2018 19:48:22 +0200 Message-ID: Subject: Re: [PATCH] regulator: Fix return type of of_map_mode() To: Mark Brown Cc: Douglas Anderson , David Collins , evgreen@chromium.org, swboyd@chromium.org, Linux Kernel , Liam Girdwood , Tony Lindgren , linux-omap@vger.kernel.org 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, Apr 17, 2018 at 7:22 PM, Mark Brown wrote: > On Tue, Apr 17, 2018 at 10:12:04AM -0700, Douglas Anderson wrote: >> In of_get_regulation_constraints() it can clearly be seen that the >> return value of of_map_mode() is assigned to a signed integer. This >> is important because the first thing the regulator core does with this >> value is to compare it to -EINVAL. >> Sorry about that, as Mark mentioned both the regulator device specific and standard modes are a bitmap, and that's why I used an unsigned int as return type. IIRC, at some point in the review someone mentioned error handling and I just blindly added a check for -EINVAL assuming the drivers would return that, but forgot about the return type :( >> Let's fix the return type of all of the current of_map_mode() >> functions. While we're at it, we'll remove one pointless "inline". > > Ah, I see... the thing here is that the mode is always an unsigned int > since it's a bitmask - this goes out beying the use in of_map_mode() and > into all the other APIs. We only actually use 4 bits currently so I > think there's no problem switching to int but it seems we should > probably do that consistently throughout the API so that things don't > get missed later on. Maybe another option could be to add a REGULATOR_MODE_INVALID with value 0x0, and fix the drivers that are returning -EINVAL to return that instead? In of_get_regulation_constraints() we could check for that and propagate -EINVAL. Best regards, Javier