Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp380381lqg; Thu, 11 Apr 2024 06:07:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjMhkX3KCYeWPkJExmtLganZRYrExCbEvIRmQimuf9IN1B0j+ZRAwL5MYqAapATQYdIjnbQjzFiN2yYN16WzL3gBc9aMxjDFVyjFHV6g== X-Google-Smtp-Source: AGHT+IE6R5SOZlddBicySAT45lewcDgOYkcgZTNVwRM2v7MI4rZnxN3FsXSov5F/TmWpmf7r1OXT X-Received: by 2002:a05:6359:4e92:b0:17e:b5c1:35ac with SMTP id os18-20020a0563594e9200b0017eb5c135acmr6251613rwb.1.1712840846114; Thu, 11 Apr 2024 06:07:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712840846; cv=pass; d=google.com; s=arc-20160816; b=sEnwp/zyXqJv4j79S+39TUMXqiFfGgiuoQDYyJO/x7AAOx7uGdosCVdU51fY7Ps8/o Lhsm7gDMqdYDW5RTtqtxaH1EpINz8R8v8FzKUokvKro05D1ed3y16I5UhtKMpgSR0ZH0 7HBScVTyiI8ZmlPV8GYU1/8/+wSq+A91cYKcnHnF9cYWCoGR6HI8L4X0cY+eXkCw5Dem tHTC5eEnEwH0MlNzpCB/IBl0rb5GDA87pK5faSTBWiofcS9Wydf8NCehESwTKNnTNT/a PFdWnVSKwHwnTkT3zgUVUgMOwHzAr5qcckzSnR+RVzJkpf+e7nbywZ4zyhanRRTlsiT+ 9Vlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2q1rA0uf2uIPts1ffT8ttA8lwbl9PEYwMBUDSMGqZ8k=; fh=nlwX56W0vJ3fIyNWHsaqUcGbPrJk+LWWeZVmtHPIqiI=; b=xAh6LfMquGS3sFcR5NBbwnASzkf2RT1UsoanXbH6gVwbKOHosE0ZKHg77ohrfVaNYc JHQ2/nTAI6kRAsHDXQvqr/r7HzEU8GhuGgDXXwH3RWObO524F+CH5khh28copq1S6BAv SKUMz+vxG4c+tmuWFz6jwG2RHpkiDmXnHzuTynxJCTSXPaGFgVW0ZQWA4/IVBCqMYhnv EvVxLvQFVOhjupC6xG0K+RYSN6Z3p6JFqDODYcNA26QnwHFK2qMlaEeQLXvmhxNlYyBS j3FIsvF279tR7P27dapiiW1fjgAR4Jd0d3h3CcPpWVjyhCdlQEorqfv0jvJqiF4E7NEo t2Yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nEAigv/e"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-140481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ch40-20020a05612231a800b004ca78d6c9ddsi144461vkb.184.2024.04.11.06.07.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 06:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nEAigv/e"; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-140481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B4771C21E6D for ; Thu, 11 Apr 2024 13:07:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 040EC14BFA5; Thu, 11 Apr 2024 13:07:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nEAigv/e" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ED4E624; Thu, 11 Apr 2024 13:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712840832; cv=none; b=jTRROlBLjTqtI+XIGAUHjzKT/B6pTXhaoUXc4XtfxN031ETZoBR5WYkl5f8SbDD0oE/mkN2sIw/OQ6LGe3PmdFvMBR60d4W9H3YZi+MXnP+Hef9azCgHHSSSHSzUCHPqLaOUCGaCW88qWoLCjtTNoMB/DTNBdaj0zjpwmnF9QNo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712840832; c=relaxed/simple; bh=jBDcfNa+ZA0GhG6LAA8y9wdXr1NILjkk4RiSds6k6CM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tkm2fj45aTYSGpaxqfuJr6ELhATaGnQpD3MVIg6zV9j9NLHeyDRpatXTgSHQ6wMvL7+SbBgIN3ea/BniRwDF9FGjXtS6R0HThBLmdkM0Y3DgX1xcXqhBN8/sY8+5/CaXUGtTmf7i9gKFUxDdfcOjSpa5JIn21O/Zg/QDtEpCEMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nEAigv/e; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 171F6C433F1; Thu, 11 Apr 2024 13:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712840831; bh=jBDcfNa+ZA0GhG6LAA8y9wdXr1NILjkk4RiSds6k6CM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nEAigv/eqYtD+nsLaUlG13p5KlC4W5zHhp72SVBIi+SAijs3tSDYQHkjOz8atq0vF YHn+MDCqfVqEJm7JLB4lMHJtirV0VLuYgEmqShGnDjWGqMR5VUT0324OZlMJaDNg8P efibU29MYTA1wtA6bod9kF/GFyaPmhRldp5GKdYI= Date: Thu, 11 Apr 2024 15:07:08 +0200 From: Greg Kroah-Hartman To: Lukas Wunner Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, Jean Delvare , Ard Biesheuvel , linux-efi@vger.kernel.org, Zhenyu Wang , Zhi Wang , intel-gvt-dev@lists.freedesktop.org, Daniel Lezcano , linux-pm@vger.kernel.org, Luis Chamberlain , linux-modules@vger.kernel.org Subject: Re: [PATCH 1/2] sysfs: Add sysfs_bin_attr_simple_read() helper Message-ID: <2024041101-haggler-devouring-9dcf@gregkh> References: <5ed62b197a442ec6db53d8746d9d806dd0576e2d.1712410202.git.lukas@wunner.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ed62b197a442ec6db53d8746d9d806dd0576e2d.1712410202.git.lukas@wunner.de> On Sat, Apr 06, 2024 at 03:52:01PM +0200, Lukas Wunner wrote: > When drivers expose a bin_attribute in sysfs which is backed by a buffer > in memory, a common pattern is to set the @private and @size members in > struct bin_attribute to the buffer's location and size. > > The ->read() callback then merely consists of a single memcpy() call. > It's not even necessary to perform bounds checks as these are already > handled by sysfs_kf_bin_read(). > > However each driver is so far providing its own ->read() implementation. > The pattern is sufficiently frequent to merit a public helper, so add > sysfs_bin_attr_simple_read() as well as BIN_ATTR_SIMPLE_RO() and > BIN_ATTR_SIMPLE_ADMIN_RO() macros to ease declaration of such > bin_attributes and reduce LoC and .text section size. > > Signed-off-by: Lukas Wunner > --- > fs/sysfs/file.c | 27 +++++++++++++++++++++++++++ > include/linux/sysfs.h | 15 +++++++++++++++ > 2 files changed, 42 insertions(+) Reviewed-by: Greg Kroah-Hartman