Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4673839imm; Wed, 30 May 2018 09:45:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJMSmsiBDBhwbMMVC4JMhdSSGVaetbQx4XD+lmqwjgFyvInzUKJFlDpl6OUTK/cpS+WLAxs X-Received: by 2002:a63:7255:: with SMTP id c21-v6mr2698747pgn.99.1527698755820; Wed, 30 May 2018 09:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527698755; cv=none; d=google.com; s=arc-20160816; b=f6qNUP7yuKpwn94DLiveJ3Doje7pbmWDiAXo2wXoWTqAZEbH/iIXkkJ67tmISFsbu1 bKOH4HRR/He0feeYdYhVvojwA+nKF6jdFU96+sysDz572c1iQ0O8F5+Wh6sb0c5ZiAqJ H5+hnhe12zd2DF5+9Y17Z9fGZCAH6rLg8mq2XxM65N1SEzABU3LxJIy+JWpGwMsZOwTE Mpv5MlqRhZoyxfroTiO7+zV26CLmDVl5XY/1AEjaINWNrLqJ5I6BIQwa8Z1Ud9alyd4D bgsaNt53iehLEWpnuwRW0JX5tayH4oyNzKzqDc6VsQehOUX/LUwGc/9+ShkYkr7ewlVS tx/g== 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=Ckg6AilTHGqDzGCgSgS/7WfMX2UN5SojCfanhKmQiuE=; b=sXo0Z6x3nMLpH1kBzxuoYats3kGYWqHt8bRFoG/d3hpII4pdXt//XMF4SIF5CeUOa6 9WmDqEkWK6U1daLHwhC4R3p2AIYUlXZOTH67lY1u3+BvJab+mBUSL1n3K2y0dsSdXxQ2 XjK1lCfIL7CgXH0EkQtgh3dwdWlyAqkPfd5Mbqa7sgf6oGlrolC7UnIz5lwIbzb8yya0 s/D3Pv1ixbcG02GmokjX052etNO01PA3OjIkYfnRYtFVIqUq04mJQTmoWqoU0BGrPHLs IlLgLbfMiUmItURRgLaaJOeiTikeAtKh/6vOt0xrRMDPuuQYV1maciD+52sBRTSYyPyu jJjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PRpMiRJr; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si34762924pla.194.2018.05.30.09.45.41; Wed, 30 May 2018 09:45:55 -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=@gmail.com header.s=20161025 header.b=PRpMiRJr; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753736AbeE3Qnb (ORCPT + 99 others); Wed, 30 May 2018 12:43:31 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:45824 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753238AbeE3Qn3 (ORCPT ); Wed, 30 May 2018 12:43:29 -0400 Received: by mail-qt0-f195.google.com with SMTP id i18-v6so13409830qtp.12 for ; Wed, 30 May 2018 09:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ckg6AilTHGqDzGCgSgS/7WfMX2UN5SojCfanhKmQiuE=; b=PRpMiRJr4Tr1PZtpeTPjzbJvKt2DKHk033/4fYgYfDvl13D501+RqBDBx1gqVl+Kdf Q9mIgO9UBKAW2MP7P3GFXf5ni9OBFUJoHx76Q1gBkc/sdriRZ8MLKzNp32bMYI+sc1xu JSg2p/WxLPM51Q8/qV4BPKmIWK92SeaGW9HInSMCgjCrtqX78XM3CZSYtgTnZHWR5YaM pfoCfUC+cGAq4ru16OKe0dSumGM4DF8J+iyY9+yQGTVfe5OyTw+2KzuGesmMEm0VgIyy iOxLHwEIrvC3P6ODXju7Qw9m5C6Gpjc6FmkxFYFRRuZXOymNGCwSWwQMJkW0y6WVtWVP 5aLg== 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=Ckg6AilTHGqDzGCgSgS/7WfMX2UN5SojCfanhKmQiuE=; b=F2GybhZdrdKWYSee9SIihoBRey4aInPFsGBjj/6ReAHOynfReiIfcbMSw+wbPmV7qM kRB8Th3IPCdBApEfzBxm3Vc9PlHsuqMan3oAildZCJcNbliVNAzInRuDjlbzE4Bhn37z fTpJuceGjf8zKuHvOEdgwwPoeucVZP/v7cK8cP3JqkFWBeLgNbXIKsOVjU+5ohdtRX62 aqdVmopAKNXDCNmvJidFbg89MfMNtouMb8P38d4vqN3segPBnIfn5+304YGU1FX2tl0v cxXXux98dwc8sQmdNhnoO+foRNZi8JBGddiAUuyynLWZ1lHJ2flTPXle5+y6+l+PaeF/ 2zxA== X-Gm-Message-State: APt69E1U0L+QgSK51PIzma1HaF9PfvAQ2Gwk5oArGb00nlQXlNfy7ap/ BBhKUIG55F8+TIDrXFUsT0vVq0JY0nYcl4Nbtg4= X-Received: by 2002:ac8:4106:: with SMTP id q6-v6mr3373598qtl.267.1527698608230; Wed, 30 May 2018 09:43:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:41c8:0:0:0:0:0 with HTTP; Wed, 30 May 2018 09:43:27 -0700 (PDT) In-Reply-To: <20180530160413.33612-1-gwendal@chromium.org> References: <20180530160413.33612-1-gwendal@chromium.org> From: Enric Balletbo Serra Date: Wed, 30 May 2018 18:43:27 +0200 Message-ID: Subject: Re: [PATCH v2] platform/chrome: Use to_cros_ec_dev more broadly To: Gwendal Grignou Cc: Benson Leung , Lee Jones , linux-kernel 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 Hi Gwendal, 2018-05-30 18:04 GMT+02:00 Gwendal Grignou : > 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 > The patch looks good to me. Reviewed-by: Enric Balletbo i Serra Thanks, Enric