Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp515563pxb; Wed, 27 Jan 2021 13:35:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwI4EJf2Dw+Q3/w9uKdpXkm6RLcFryfVg+ye53E1ovJ3RpleovJBcJWfoqrH7wjfi75pSiG X-Received: by 2002:a17:906:2ccb:: with SMTP id r11mr8409007ejr.39.1611783330357; Wed, 27 Jan 2021 13:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611783330; cv=none; d=google.com; s=arc-20160816; b=jk2/+Q3840F5hExEcTKSzXQV6rAz9KNW5tBoueEMxH1vs50S/IrG57HPFg+yCNggIj bUTTic0vG1pnMxMgVtVtd7I0q/BEnNLJcVm+X4P3116Lp6CzXbEDkl+nLRRgbJWLY4xt 0FMly0hCQWbTJhAn4KPt05tpo5/Cowj2q29x++WDAmBDOA34gyFcnao6TTPcY4MaJg8o 1hkIifgqZm9xpNmowtkr2+X7daj/oYTkhK+NlzBuflalx7FwnVgLBWi3MdJQSb9zRAFg V6uLTfJsvzd74LbTa262d9XR/vV4lKB/a67FNnzT15VVMcBwqoHxeTWexu2Xw2l/XImS /LoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Piqc9f/BBZRDuw7YExZpRwux8wTLUHsMGi/Zy9qXgEg=; b=dbri0oTuLiqflLPJjQ6+F22QBDoswRqHPDBJ+xNx9pD9ZpLHrCOCTqyMDkKIrCuRxn cw5rebn56QbfPbufa7aAHcMs3zmu31oyHGRt77j6dqcIVTDDhftQgj4k8zOwErWUWIRY iz5wB5KSkoA9lCJfy+hsNdbnqytnJm852qGAEAbj080l1DUbKrXL7xBCZL79Jhz1SH9m jvCbHI7ei5ca0jaETd4eeR+ol/4Erdo2UDInaaPwJ2xRsJXr0wfmzZkzAfYIWM84uoke t2Wg2cRkOv1szfu4RAyH3Clt1FGztdt+rjyL6pDD20mXtM2m0g6S9ZgBndqWR6Bk/9LD BSXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n3bvzBqc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg12si1672790edb.439.2021.01.27.13.35.04; Wed, 27 Jan 2021 13:35:30 -0800 (PST) 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=pass header.i=@linuxfoundation.org header.s=korg header.b=n3bvzBqc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbhA0HxP (ORCPT + 99 others); Wed, 27 Jan 2021 02:53:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:52590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbhA0HvM (ORCPT ); Wed, 27 Jan 2021 02:51:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61F312074D; Wed, 27 Jan 2021 07:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611733832; bh=yIs3OZHTJiiiSOQYkGjk7LcLfBtlVTwr9Qy0+2JGkHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n3bvzBqcQyxN4PZHN+iNOjpgx1aT2nXg9/BaImVGkzH+86LMxRDKHNb2MJ6dpc6FZ x88jluRsiQe28G2bOujetTD+eCUWY0yEsnM+iQxnHtRGpjxi8p8skmPPG6zLbzp9Ne qVUsKeroQnjJQNtuQpn3h6pnQfUl6ExxWZt8mIQY= Date: Wed, 27 Jan 2021 08:50:28 +0100 From: Greg Kroah-Hartman To: Orson Zhai Cc: Jonathan Corbet , Mauro Carvalho Chehab , Joe Perches , Denis Efremov , "David S. Miller" , Christian Brauner , Dan Williams , Sourabh Jain , Orson Zhai , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] include: sysfs: Add macro to assign show for RO attributes Message-ID: References: <1611721162-29982-1-git-send-email-orsonzhai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1611721162-29982-1-git-send-email-orsonzhai@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 12:19:22PM +0800, Orson Zhai wrote: > In some circumstances, multiple __ATTR_RO attributes need to be assigned > with a single show function. > > Add this macro to make life easier with simple code. > > Signed-off-by: Orson Zhai > --- > Documentation/filesystems/sysfs.rst | 2 ++ > include/linux/sysfs.h | 5 +++++ > 2 files changed, 7 insertions(+) > > diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst > index 004d490..0e2274a 100644 > --- a/Documentation/filesystems/sysfs.rst > +++ b/Documentation/filesystems/sysfs.rst > @@ -141,6 +141,8 @@ __ATTR_RO_MODE(name, mode): > fore more restrictive RO access currently > only use case is the EFI System Resource Table > (see drivers/firmware/efi/esrt.c) > +__ATTR_RO_SHOW(name, show): > + assumes default mode 0444 with specified show. > __ATTR_RW(name): > assumes default name_show, name_store and setting > mode to 0644. > diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h > index 2caa34c..c851592 100644 > --- a/include/linux/sysfs.h > +++ b/include/linux/sysfs.h > @@ -117,6 +117,11 @@ struct attribute_group { > .show = _name##_show, \ > } > > +#define __ATTR_RO_SHOW(_name, _show) { \ > + .attr = { .name = __stringify(_name), .mode = 0444 }, \ > + .show = _show, \ > +} Do you have a real user for this? Using "raw" kobject attributes is rare and should not be used often, so who needs this? thanks, greg k-h