Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1900156img; Wed, 27 Feb 2019 07:19:19 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibv5IhnRBkUjT6vDwKvlGR4uRvprgAUZLQDSGiPuAv06OAwNWm307uMLVakW1OiDiqCjQMu X-Received: by 2002:a65:468f:: with SMTP id h15mr3465027pgr.391.1551280758891; Wed, 27 Feb 2019 07:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551280758; cv=none; d=google.com; s=arc-20160816; b=pvLko19T1LSKbrXxk52vayUIqBYVozbnBRIaTFJwWddL3mU1I6YqVeB+9521NWhW31 JNt6E4R7MtpVNT6FPGAcQNVHuLtpFyVPQAUPIWSdATIk1s/n5uaYX745iASnmglOBPwu p4UE1aTUMchkudH7rv+X+VLDJLiqgQX0RGU+xttED6oQ7hEgOjN5/CJyOQEc1nOor5wl Oy4q1WbfQxEnl12bYnxRSMGYGQK7jkOYljbV6fFOJ4sNWgowIAiBHNwMT2mYMcs3gVKG MMoxx3gHZoUKmhUkS0V2Qu+j1H9T5BU5e9X9GkUokGVTYoIBlIHZjpRv8I4wGxjGf1w+ RG7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=vlK1GWcdIPlzxKouEhuPLcTndvXXr/ukgje/AbBtDVI=; b=X9ncuppiaxp4ihGQRGK4zCPCwWoOsQOLNgcvUwk8jm9AIUR7oJFS6G6Fg7c6G/XoLk lLrkCpHVIHKK5knFQz/x1Jtf0+UNq1sJk8lUyF3dTEF86fxzw9hsd9Wht4LJGZkbvMz+ 6j02owrNEA2NNFY6F/m7mBLiUihrJYcwtrqS/fzgg0gMzGgtv3kXSATtd9EcUWyypHup sAwd5ZfnVJ9z3HnmLHnljr70fLgHLM9X1bi7mIc2FlpVJZJ8tgho/xnBmUMVG2rugyfJ 0sMUHKDVjGG7e3zW14zyM6FNcxFnYoRsYFpRt0lqu0fMp4IuV/S8CKqnsrbkVHyshWME daOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T36QOp7A; 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 g8si16162123plb.146.2019.02.27.07.19.01; Wed, 27 Feb 2019 07:19:18 -0800 (PST) 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=T36QOp7A; 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 S1730625AbfB0O0z (ORCPT + 99 others); Wed, 27 Feb 2019 09:26:55 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40029 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730070AbfB0O0z (ORCPT ); Wed, 27 Feb 2019 09:26:55 -0500 Received: by mail-ed1-f67.google.com with SMTP id 10so14037822eds.7 for ; Wed, 27 Feb 2019 06:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vlK1GWcdIPlzxKouEhuPLcTndvXXr/ukgje/AbBtDVI=; b=T36QOp7ACggUv5Bp3/PTGcNwyXlTs9l76UnX3SOWlInXdkK3Juvy7g7GEaUP4I16c1 QnrtUJFgXWUaaEjl1ha1qDiwtgeZbtkzcNu3N7jffuSyWVnfvS5D+d1LJaN7Xcow/PN/ ksRZ9yP0vlvY8yCvDF3BYhOcN6gRpEVoUO/8LqNml1K5G/9kc4Qnm2UzOtHHZj1alXc2 cUEpMNR7wRR/SdHT+hyKJS0ovS/xncEkewh79RnWoq4R0cD9ppXMtmVQF9lFFnzDYEAZ XfFbSRfgBWUHjZxHOtGiH+6Zzsd8J9878pJsQyAvToUNf4+qy1AOZgxhkHO4Zrdg2VJJ zebA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=vlK1GWcdIPlzxKouEhuPLcTndvXXr/ukgje/AbBtDVI=; b=nO7t1Xb5/xX3RFyw+5oF7ifbeVFf3UOwbZ8xNUJwP9iyHL8J4L/fgXm01jnnX0GYRg x9UHJoUUFS4CQcc8ZS4cvBNKTlOmpNhxx9BO0lBCMH/kvU5wYz2arZPg7t+LtPdSRtgv Xt08eVVSdyb5LEHrDMOPgrzBUB6vs3zqcLfZasGTAdaKkU09iaLgTFWtoeGqo782ctYt zm/szjBwTSv0AbUDZogDGHwKlFIuTcmVa24i2SX8HB04UmYeoaM9zdIJB0AHFCY/68Kv i6Gx78SWVE+KvB1mMt2Lt1W0sa46GErSejSU+GF32sfm4qnhx3gMI+mBHR0/O/e20ujt 6zbA== X-Gm-Message-State: AHQUAubCLTplIWw9kqC//lDxBIFKz+hibItct0tNyqeop9/6/r9r3ciM Ad2ut2Ll/5b5uAxva0N5STGBEJYw X-Received: by 2002:a17:906:4ec6:: with SMTP id i6mr1787295ejv.56.1551277613261; Wed, 27 Feb 2019 06:26:53 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id d17sm2736063ejm.35.2019.02.27.06.26.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 06:26:52 -0800 (PST) Date: Wed, 27 Feb 2019 14:26:51 +0000 From: Wei Yang To: "Michael S. Tsirkin" Cc: Wei Yang , somlo@cmu.edu, qemu-devel@nongnu.org, linux-kernel@vger.kernel.org Subject: Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs Message-ID: <20190227142651.3enr2eey5bn2v6ls@master> Reply-To: Wei Yang References: <20190226073159.13434-1-richardw.yang@linux.intel.com> <20190226110934-mutt-send-email-mst@kernel.org> <20190227053319.GB5449@richard> <20190227084843-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190227084843-mutt-send-email-mst@kernel.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 27, 2019 at 08:51:11AM -0500, Michael S. Tsirkin wrote: >On Wed, Feb 27, 2019 at 01:33:19PM +0800, Wei Yang wrote: >> On Tue, Feb 26, 2019 at 11:10:06AM -0500, Michael S. Tsirkin wrote: >> >On Tue, Feb 26, 2019 at 03:31:59PM +0800, Wei Yang wrote: >> >> Leverage __ATTR_RO_MODE to define rev sysfs instead of using open code >> >> to define the attribute. >> >> >> >> Signed-off-by: Wei Yang >> >> --- >> >> drivers/firmware/qemu_fw_cfg.c | 13 ++++--------- >> >> 1 file changed, 4 insertions(+), 9 deletions(-) >> >> >> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c >> >> index 039e0f91dba8..a1293cbd7adb 100644 >> >> --- a/drivers/firmware/qemu_fw_cfg.c >> >> +++ b/drivers/firmware/qemu_fw_cfg.c >> >> @@ -296,18 +296,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev) >> >> return 0; >> >> } >> >> >> >> -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf) >> >> +static ssize_t fw_cfg_rev_show(struct kobject *k, struct kobj_attribute *a, >> >> + char *buf) >> >> { >> >> return sprintf(buf, "%u\n", fw_cfg_rev); >> >> } >> >> - >> >> -static const struct { >> >> - struct attribute attr; >> >> - ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf); >> >> -} fw_cfg_rev_attr = { >> >> - .attr = { .name = "rev", .mode = S_IRUSR }, >> >> - .show = fw_cfg_showrev, >> >> -}; >> >> +static const struct kobj_attribute fw_cfg_rev_attr = >> >> + __ATTR_RO_MODE(fw_cfg_rev, 0400); >> >> >> >> /* fw_cfg_sysfs_entry type */ >> >> struct fw_cfg_sysfs_entry { >> > >> > >> >Looks like this will change the name from "rev" to "fw_cfg_rev". >> >That's a userspace visible change which we should not do lightly. >> >> You are right, I should keep the interface untouched. >> >> To keep it user un-visible, we could change like below: >> >> - __ATTR_RO(fw_cfg_rev); >> + __ATTR_RO(rev); >> >> Is this better for you? > > >Also why use 0400 and not S_IRUSR? > This is interesting. The scripts/checkpatch.pl suggest to use 0400. I am not sure why the script give this suggestion. Maybe we need to fix the script? >> >> -- >> >> 2.19.1 >> >> -- >> Wei Yang >> Help you, Help me -- Wei Yang Help you, Help me