Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1544178pxa; Thu, 6 Aug 2020 09:55:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ8gSq4TIVUjvwhyzgAJvIIxNN976Ciya7TelZx7hm0V9YFI1sxzDEHC3IkLbb+yRC8dpc X-Received: by 2002:a05:6402:3135:: with SMTP id dd21mr5156277edb.123.1596732930443; Thu, 06 Aug 2020 09:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596732930; cv=none; d=google.com; s=arc-20160816; b=Tyw2CmULAgpISSP/Dxnm9W+QCtC2RzlGdR100dt2CSN6ON+qfXIU3N+5kOEyDpB3JV knobverY3ef2vWzzpHIj4+frQq4UUS8maTOs77O6Cq+ua1n/+0OYwcLw92YiXSKKFCmr pEUifewnme58Z+42EoKjTnjld2wc7S0nvVnCHLxpT3ztl5dk4VfNRi35RYz7aC95B2Iu LdHa8o3arOKmRj7wmV/co+1tRn3RltqD5qy0JIN9CYtnrazls8B1rW29nzGuB32lhNBm qKWkkkV8EkNNBPL8tWrAnd3GYSLlCvF1Sw7tjx5ZUk2E3IGDNVvbfJ5wK5j+57hV0RY/ +ECg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=TA50xo6IgAS3A5s1Mvlt9oYR8AHuJvVW3cujvShV5qo=; b=Q7e3505MK9Is5C100WYkZwHB1M8Ui+AxAAA2FDDD698aFG5dI699U4y9ALhIi7Z90+ oudr6Qt8lTloXYqrOBj2ndZyrgkPbw+cNvaLEUjyWexOJFqpGaL8AqvZRL1Ge2qCJDUC d4dKHRh+jX3PIFhl0LIIm/64w1HQxN5zQ3n8sZ6bNGqUcsXRpoURPMyV2dPsRqBZcAHh CxfB0UItSnAeLNb7CH71erDM+ilq26XWD2gy/u6+x7p7zi6VMhg5cQAXYYkMAAj5o9wN kbQ7ElPsx8Zh06DGQ7SO4zUi3/zaNMudYpp//3ezfYpGtnCMeEmWDWryhZJB5CyCVzgX qojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ilW+et5q; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si3803591ejc.560.2020.08.06.09.55.08; Thu, 06 Aug 2020 09:55:30 -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=fail header.i=@gmail.com header.s=20161025 header.b=ilW+et5q; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729775AbgHFQy5 (ORCPT + 99 others); Thu, 6 Aug 2020 12:54:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729557AbgHFQuN (ORCPT ); Thu, 6 Aug 2020 12:50:13 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5FCC0086AF; Thu, 6 Aug 2020 08:33:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id q17so27722716pls.9; Thu, 06 Aug 2020 08:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=TA50xo6IgAS3A5s1Mvlt9oYR8AHuJvVW3cujvShV5qo=; b=ilW+et5q4do3rnqHcfn4dodyp8p68vxF5XtEr6dtTGJsgefedL8UWq/Qlo6mg7h0Bn w9t2OaShgDXkK1V00XT1XfxNrjwmYMzLZjFAZrmzuDeBA3Qso3G1e1gGmzAzhBnEiZ7C yqFU+1fx0IJC/n0S8QJ+kriZ+rqPJNchtbWuvjFs0DgxS+YwDDJvfQvf/M7FLCVYwQVy QTUqoozqDWKjgo0OLVREsUejwa11NW3t5yQiuQa5zCPxswr5vfqky1jR38opkgbKad2a RSmoCqPzvqHnwBwFeYjjf2WKJuHFobbRHoTY+b1DiCV1tDKzLfzTFPTTdq3f7gfT6Fkc EQmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=TA50xo6IgAS3A5s1Mvlt9oYR8AHuJvVW3cujvShV5qo=; b=FNR+nhfmzDmTzpOEwySjjZ18E3djLKIXMXgnbMRvswtGoBAaJVj6A6Z3Maiv0VspLj HGa5KR32OVRKiBzefGFWPB1StTKwprfYCfgQe1WdHsXuq5RqCj6n53KqaappUoysoqIE QJT1eN5ea0zcHgZseXQbQwgyxZYUqIa0DnBew9MhRdQKgelij3buQIvxoK35E9dxmudr OdVxnjxnIdxdhZQoV3ib+Rtk2SK4UgEcWTKfPL++wI/4FXhVMtQYCF2TQ3hrGPah2Wwb LgTP52dmQfR4l3gasSuCGf99VsllzvO/HQPqPO2dlhNHtr4lDHQds3jxTnLLViJh5wta WjAg== X-Gm-Message-State: AOAM5333cAA/92O/vePkHiLiP2Xqa3Sdl9rucvymaI42r8Rw60rkFQG7 UeETo221CuialjtFwketwtQ= X-Received: by 2002:a17:90a:d56:: with SMTP id 22mr9080012pju.58.1596727990104; Thu, 06 Aug 2020 08:33:10 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 2sm4783536pfv.27.2020.08.06.08.33.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Aug 2020 08:33:09 -0700 (PDT) From: Guenter Roeck To: Enric Balletbo i Serra Cc: Jonathan Cameron , Benson Leung , Dmitry Torokhov , Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Lee Jones , Gwendal Grignou , Brian Norris , Yu-Hsuan Hsu , Prashant Malani , linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/7] platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes Date: Thu, 6 Aug 2020 08:33:01 -0700 Message-Id: <20200806153308.204605-1-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The EC reports a variety of error codes. Most of those, with the exception of EC_RES_INVALID_VERSION, are converted to -EPROTO. As result, the actual error code gets lost. In cros_ec_cmd_xfer_status(), convert all EC errors to Linux error codes to report a more meaningful error to the caller to aid debugging. To prepare for this change, handle error codes other than -EPROTO for all callers of cros_ec_cmd_xfer_status(). Specifically, no longer assume that -EPROTO reflects an error from the EC and all other error codes reflect a transfer error. v2: Add patches 1/4 to 3/4 to handle callers of cros_ec_cmd_xfer_status() v3: Add patches 4/6 and 5/6 to handle additional callers of cros_ec_cmd_xfer_status() Use -ENOPROTOOPT for EC_RES_INVALID_VERSION Implement function to convert error codes v4: Add coments describing the functionality of cros_ec_num_pwms(). Add patch 7/7 to clean up cros_ec_num_pwms() after the new error code support has been implemented. Rebased series to v5.8. ---------------------------------------------------------------- Guenter Roeck (7): iio: cros_ec: Accept -EOPNOTSUPP as 'not supported' error code cros_ec_lightbar: Accept more error codes from cros_ec_cmd_xfer_status platform/chrome: cros_ec_sysfs: Report range of error codes from EC pwm: cros-ec: Accept more error codes from cros_ec_cmd_xfer_status platform/input: cros_ec: Replace -ENOTSUPP with -ENOPROTOOPT platform/chrome: cros_ec_proto: Convert EC error codes to Linux error codes pwm: cros-ec: Simplify EC error handling .../iio/common/cros_ec_sensors/cros_ec_sensors.c | 2 +- drivers/input/keyboard/cros_ec_keyb.c | 2 +- drivers/platform/chrome/cros_ec_lightbar.c | 10 ++--- drivers/platform/chrome/cros_ec_proto.c | 52 +++++++++++++++++----- drivers/platform/chrome/cros_ec_sysfs.c | 24 ++++------ drivers/pwm/pwm-cros-ec.c | 37 +++++++-------- 6 files changed, 74 insertions(+), 53 deletions(-)