Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp916427img; Tue, 26 Feb 2019 10:46:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbYR7Xt0IG0A3uFFEf85k4SeeHhBZHX7esXXLSi8m17tzlmeCDjUNWW7AdQoxDgMXe4gUNw X-Received: by 2002:a62:53c5:: with SMTP id h188mr26998951pfb.190.1551206785857; Tue, 26 Feb 2019 10:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551206785; cv=none; d=google.com; s=arc-20160816; b=iZE1zCLxmeiYNqfcs/Fg2xPDrO9sGJbrRqfgfXgE27OwvjHeIaouAx3bNe9lSA+wmd c2Ml/OfkgbPnTcfC1rpP2hg8QaNSgW6TiRh+qLE4SCrtpWAuTpgbzCkoxETasRGD5uJG d6K34GEMANZzOt987PoaNsQIQWgUIZyN/uonTaloArYYeTvcOySX4o4GMEZhYXta6w9Y fkRymDkKblCgt6PMzBoLXKYUTD91sKmeay5j/wsvvifsje0WBYuYtan6KthGM72dLQ+R 9v+7hMKMC9i/9tIfvCztOUGlIP0Pr46A/Z3VxAR2NT2ItfL3MPO1oZ4m/fZrrClkoexk /bUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=vh4OOhMU6ok0vvq2PqJyeTthaOPa3BEiM/kIMdfGy2A=; b=nwWjlmVUpXbx0XT2DmdRFeBA9+Eh05mYtzXQrT1Snkd8tlzz2EaiDWZYu3srODVU7a E3J2XBCIKuKEjc65xJIDVHJI7rJnrWOuV6Lss4qpkoMa+NCxtN2QwnpnwSP3zpOgL10p CbKQwj9EjdBUqTNa7NOp3C/ALPHXmkCXnRGQtyCOebXvEHMuGpBgQ7t0KtZddeLOY++/ vyIx10puGQK58xRoDEMrYyYuJQejShHfxAvST+wJZEI7FTSP1ztp1GMz3hDvtd+24Q0T /TvwPnP5oMzWS+n8u6rFbP2iCZCYUg4bK9848AOonAYCCVbXH6TbFdCyxR9h9NR1O4+g vXKQ== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p25si12202426pff.77.2019.02.26.10.46.10; Tue, 26 Feb 2019 10:46:25 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729105AbfBZSpt (ORCPT + 99 others); Tue, 26 Feb 2019 13:45:49 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45653 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728736AbfBZSpt (ORCPT ); Tue, 26 Feb 2019 13:45:49 -0500 Received: by mail-wr1-f67.google.com with SMTP id w17so15107531wrn.12 for ; Tue, 26 Feb 2019 10:45:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vh4OOhMU6ok0vvq2PqJyeTthaOPa3BEiM/kIMdfGy2A=; b=tHzXopSdD6AMUMtu03ZdUa3azxTTu2LF3tU8je5Lp0WvcQZXhy50GTvT7JpNVwrRmH GuBugG3e8xAjmk00FQ9RfZKXMWmjrP4oRW9XgAkwr/8NdRDhBnJ19B6VAZ1PCtOj7Vaw HOQGVoGUo1vTxLJnv7pQRjp6NIyZiBGt2DMtD/KfOPkTsqhmmEVpz+HT1AdrX1o+JoMH fSNyvwl7RsErr9YEpbarXajWQG9q12oCIf9bWyEBNor/i4scjQPTA+yifWQ8maWywPeF 2ghJbB/4Gh1LAh2M2l1pQ6Mxrgns5BtGPfLJqTd127T7ooe/pCl8Ux+AIzTUQ/3MxOmA aRzQ== X-Gm-Message-State: AHQUAuaSQXUozstRCZHMSNeRAbMfpSZ/PkH0l4A716hwnQSEQg+JvRlp eI8TLdKWMzgkdhcc2uRVaNivnA== X-Received: by 2002:adf:d08d:: with SMTP id y13mr15864728wrh.99.1551206747621; Tue, 26 Feb 2019 10:45:47 -0800 (PST) Received: from [192.168.1.37] (43.red-88-25-181.staticip.rima-tde.net. [88.25.181.43]) by smtp.gmail.com with ESMTPSA id z10sm108951wml.39.2019.02.26.10.45.46 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 10:45:47 -0800 (PST) Subject: Re: [Qemu-devel] [PATCH] fw_cfg: use __ATTR_RO_MODE to define rev sysfs To: Wei Yang , qemu-devel@nongnu.org, linux-kernel@vger.kernel.org Cc: somlo@cmu.edu, mst@redhat.com References: <20190226073159.13434-1-richardw.yang@linux.intel.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: Date: Tue, 26 Feb 2019 19:45:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190226073159.13434-1-richardw.yang@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wei, On 2/26/19 8:31 AM, 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); Why not keep S_IRUSR? > > /* fw_cfg_sysfs_entry type */ > struct fw_cfg_sysfs_entry { >