Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4635151imm; Wed, 30 May 2018 09:05:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLa7BVu//k/2DIErEa9jqWPj+N5GXu0ghYoXzIew+8scHM+T+AzMd37wTSrp7CZMpMKdYO9 X-Received: by 2002:a62:e710:: with SMTP id s16-v6mr3301665pfh.227.1527696325898; Wed, 30 May 2018 09:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527696325; cv=none; d=google.com; s=arc-20160816; b=QvOScUQ/G6bpfkBb1S+vHJp6Iu4u/ipYi8qpWERgbifi/VLSuIFvtjAGTap/EwhEx1 +71IRQN3zC1/aBdg2guImbUYMnO8jEcL/Uu4Jo3ChiMYeDP3vpor7JkIPzQmXuIadZo+ H9xOzgyJ/8dzlQ7Mv7/z9keNsFWdLReJp6BWXJiy0jRKMHBY3u0d/gJoosB6cdAvh0Mm enmI6AZ7dMG0i3mX7soqQxNeuDeN/5NTPq5L51QgQyOd6NaLehhFAnY8pqi2m81r4hqC NLwSRL1AjyB//n2etqPDZSGEK4h4S7pv1T8hnNZJrgpfqPxM1UB2wp8mGMlVlHUmssSh P1Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=omL6GCzlB5mc0HWqOfUaLudCjsL0CzreHk5rtLtWYbo=; b=tI4RdaxJh+1zwKIbUb2j61UhLA0OfHcgo74+/xkwNaDw60ry7O/2if4xZlTG/yUaD2 kZzvncprq2XFGL/1jqkfq0NmwWSrYafMhCaNiNu76LYGK4Rww7J4GiD3CZu5X9EQhL4m sm1JASshgUo29X4wUAg/6Hstbtgd9kf5RBEwkLGyz9+mJi8XQ9Vy29wIYbvg72lWWr3n c/j1QTXOQRLsHgRGnJQVWoST54Ni8vW4biU+1s5Fy18/mlKkppvaSbftM2w4xc3guhpY 7Q+e0nSOQ+8nyV5k/HAL0UVWY8u6xYzIgDlrDtgM6XGH8y4lLoBXJPCCq+nwWa9pO0C1 oXhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=N5svFVon; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14-v6si27097564pgc.664.2018.05.30.09.05.11; Wed, 30 May 2018 09:05:25 -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=fail header.i=@google.com header.s=20161025 header.b=N5svFVon; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753903AbeE3QE3 (ORCPT + 99 others); Wed, 30 May 2018 12:04:29 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37892 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbeE3QE1 (ORCPT ); Wed, 30 May 2018 12:04:27 -0400 Received: by mail-pf0-f195.google.com with SMTP id b74-v6so5799787pfl.5 for ; Wed, 30 May 2018 09:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=omL6GCzlB5mc0HWqOfUaLudCjsL0CzreHk5rtLtWYbo=; b=N5svFVonocAbLGi1asekQV/sv6+JOpMD9JVwt1CDVISJI0eYknNSeHyxWVIQ87A9No qFOCeZFI1xcTFRt+ZP1WWpFndSfn+MQxP3jAJ0ZFwwj2y9JLIqWTNxS8onAj4rxB8XrX wQY4yzX+D1fINCcsfnqZ7OBaVsEVZM6BTJKSbUh3gzoLmEyRmj3N9JMZyDoPID6sEB8j OubOL/jsjtJ9SiiDC3G2tFZw1IYOWTuDojvh5Sn7gy+ADGr+C8Gh6N1tdMlCTlWAx55m FNyDN/yKzx2i7gNMz5BFh72zCuBcSg4WOdIIk39/fdzxc1tPnG5u2i4VJyKK7g0cax9K 8tzQ== 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 :in-reply-to:references; bh=omL6GCzlB5mc0HWqOfUaLudCjsL0CzreHk5rtLtWYbo=; b=dIMJPFwcgYPcQzFgukky6TMpHTf1QyKhBsbqfEJ4D8/7xmTleRbuOJGLq659p8Wv+J Apq3Ie8w7OBK5nLCkHz24XiDARcP5O+so0w/ugzxy0uBxQwV0Lq/bR9bSXlp6K4bPvXY oHfv2uO/t7/4DYDtCeQUUNfxoYCeBIgh2BwxZS6i97Qq8TLbvZL6JuW4eBDgisNJwpiR 3qbiD48pzJobkjWKr2vblHL4p4kcZBuDTkuK3VKQPTztk3uVNEtcrK6w5ISljJ1zofc3 iolZlO68Y6jjvNQYB7fOESWX5zE2LUpqcAl14CgZopCmtZcpo10fbLOcED2dY5pGbdkf 6pAg== X-Gm-Message-State: ALKqPweUzTBeI5SAIlT6soyoqmMsgslrtHzGMCiNBjeGEx1G8W4GTQJU sn1voiNyDnwvlWd/ddjDFYKRpQ== X-Received: by 2002:a65:534d:: with SMTP id w13-v6mr2642950pgr.178.1527696266750; Wed, 30 May 2018 09:04:26 -0700 (PDT) Received: from gwendal.mtv.corp.google.com ([2620:0:1000:1501:9406:7677:5956:5d46]) by smtp.gmail.com with ESMTPSA id z127-v6sm48523769pgb.31.2018.05.30.09.04.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 09:04:25 -0700 (PDT) From: Gwendal Grignou To: bleung@chromium.org, eballetbo@gmail.com, lee.jones@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] platform/chrome: Use to_cros_ec_dev more broadly Date: Wed, 30 May 2018 09:04:13 -0700 Message-Id: <20180530160413.33612-1-gwendal@chromium.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move to_cros_ec_dev macro to cros_ec.h and use it when the private ec object is needed from device object. Signed-off-by: Gwendal Grignou --- Change since v1: Remove changes in cros_ec_dev.c to avoid inter-dependencies. drivers/platform/chrome/cros_ec_lightbar.c | 21 +++++++-------------- drivers/platform/chrome/cros_ec_sysfs.c | 2 -- drivers/platform/chrome/cros_ec_vbc.c | 9 +++------ include/linux/mfd/cros_ec.h | 2 ++ 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index 6ea79d495aa2..68193bb53383 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -170,8 +170,7 @@ static ssize_t version_show(struct device *dev, struct device_attribute *attr, char *buf) { uint32_t version = 0, flags = 0; - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); int ret; ret = lb_throttle(); @@ -193,8 +192,7 @@ static ssize_t brightness_store(struct device *dev, struct cros_ec_command *msg; int ret; unsigned int val; - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); if (kstrtouint(buf, 0, &val)) return -EINVAL; @@ -238,8 +236,7 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr, { struct ec_params_lightbar *param; struct cros_ec_command *msg; - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); unsigned int val[4]; int ret, i = 0, j = 0, ok = 0; @@ -311,8 +308,7 @@ static ssize_t sequence_show(struct device *dev, struct ec_response_lightbar *resp; struct cros_ec_command *msg; int ret; - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); msg = alloc_lightbar_cmd_msg(ec); if (!msg) @@ -439,8 +435,7 @@ static ssize_t sequence_store(struct device *dev, struct device_attribute *attr, struct cros_ec_command *msg; unsigned int num; int ret, len; - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); for (len = 0; len < count; len++) if (!isalnum(buf[len])) @@ -488,8 +483,7 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr, int extra_bytes, max_size, ret; struct ec_params_lightbar *param; struct cros_ec_command *msg; - struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, - class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); /* * We might need to reject the program for size reasons. The EC @@ -599,8 +593,7 @@ static umode_t cros_ec_lightbar_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct cros_ec_dev *ec = container_of(dev, - struct cros_ec_dev, class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); struct platform_device *pdev = to_platform_device(ec->dev); struct cros_ec_platform *pdata = pdev->dev.platform_data; int is_cros_ec; diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index 5a6db3fe213a..f34a50121064 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -34,8 +34,6 @@ #include #include -#define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev) - /* Accessor functions */ static ssize_t reboot_show(struct device *dev, diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c index 6d38e6b08334..5356f26bc022 100644 --- a/drivers/platform/chrome/cros_ec_vbc.c +++ b/drivers/platform/chrome/cros_ec_vbc.c @@ -29,8 +29,7 @@ static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj, loff_t pos, size_t count) { struct device *dev = container_of(kobj, struct device, kobj); - struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, - class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); struct cros_ec_device *ecdev = ec->ec_dev; struct ec_params_vbnvcontext *params; struct cros_ec_command *msg; @@ -70,8 +69,7 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj, loff_t pos, size_t count) { struct device *dev = container_of(kobj, struct device, kobj); - struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, - class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); struct cros_ec_device *ecdev = ec->ec_dev; struct ec_params_vbnvcontext *params; struct cros_ec_command *msg; @@ -111,8 +109,7 @@ static umode_t cros_ec_vbc_is_visible(struct kobject *kobj, struct bin_attribute *a, int n) { struct device *dev = container_of(kobj, struct device, kobj); - struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev, - class_dev); + struct cros_ec_dev *ec = to_cros_ec_dev(dev); struct device_node *np = ec->ec_dev->dev->of_node; if (IS_ENABLED(CONFIG_OF) && np) { diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 4ff0cec979b0..4270972adb94 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h @@ -197,6 +197,8 @@ struct cros_ec_dev { u32 features[2]; }; +#define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev) + /** * cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device * -- 2.17.0.921.gf22659ad46-goog