From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07328C433DB for ; Wed, 27 Jan 2021 08:10:54 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3ED4720724 for ; Wed, 27 Jan 2021 08:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3ED4720724 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kroah.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1l4fuI-0001LD-Cv; Wed, 27 Jan 2021 03:10:30 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1l4fuF-0001Jm-Vl for kernelnewbies@kernelnewbies.org; Wed, 27 Jan 2021 03:10:28 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 575B5ABD; Wed, 27 Jan 2021 03:10:24 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 27 Jan 2021 03:10:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=jpdgxCRV0lrp+3wPRdLJSA/WNvZ 6wIMa1MbUGKJiGno=; b=XfRif+lFWfK23SLfuVMPwvnT1SWj5FawHEJ0EpM6rGv V5KPnyJfK6YTYITIgahO+PirlPdRvERgeIKksJ1kZ0eMC+dD79rQfZ67+W7L4pTc PSGfcSmnKrHjRAJDEFjt1XIUanG38v84Yk/grosnR1G0tNDVAEBVpV77ZKf2xlnU cw6xKBWC4bd+nDiasPpx2iig6qax354ckVWqjUQJxO3Qs1RJQPYN+76jdiiFs+bj rY9DFttBF5i/D4uoeFwMuuySstuCHu0KFiYve5lm8AElKI1qIp0OEq6JcAxW7jsE UoXa65aVbqJaxkEEvR4y0WiKUpWzm0tw/ynxwjHD/dA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=jpdgxC RV0lrp+3wPRdLJSA/WNvZ6wIMa1MbUGKJiGno=; b=in0Or4yxKrYsER/5FwAe2j s0ogLpeeHBtk1WLjkjkmdQjULlx8QpEvkJzCnGOe3dT0p+Pa1byXeQdMs1RJOi3L E+3zl9+adB2HfXmzh293sn+vGQZlP156CLd3QEb30HRzZ2C4aF5U5Z4vIf7/VvtR iJ7bGjgqKJvH2oq2WwOmoMzAMyuHNAgJM43PX6DCXPm4QlH+g9eKSKGtfzcm1uQy xYEzVL0s4hcW70iYgm/g17rfWZQ/k2cmhAJhD8FB5x1IyfcpPzHEL1Cl4USQGTIG pyMvKDl78BGS+TzLc8FC/zo7iCNr0aACVssDJmjIGE6INpcHQCJv8CE5nae6RhUw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdejgdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheq necuggftrfgrthhtvghrnhepgffhfeefieelvddtvddvfeeuuedukefhgfegveehgfetff egvdektedugefhtdefnecuffhomhgrihhnpehrshhtrdhithenucfkphepkeefrdekiedr jeegrdeigeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehgrhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id 784971080063; Wed, 27 Jan 2021 03:10:23 -0500 (EST) Date: Wed, 27 Jan 2021 09:10:20 +0100 From: Greg KH To: Mohana Datta Yelugoti Subject: Re: Doubt on show() function of sysfs attribute Message-ID: References: <98fe87f5-19ac-dfa7-41eb-2e00d7415021@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <98fe87f5-19ac-dfa7-41eb-2e00d7415021@gmail.com> Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Tue, Jan 26, 2021 at 11:07:24PM +0530, Mohana Datta Yelugoti wrote: > Hello everyone, > > I am going through Documentation/filesystems/sysfs.rst. > > It says that sysfs allocates a buffer of size PAGE_SIZE and > passes it to the show/store functions of the attribute. On > read(), the show() method should fill the entire buffer[0]. No, that's not the case. Please only fill in what you need sent back to userspace and return the number of bytes you used. A simple call to sprintf() or better yet, sysfs_emit(), as a return statement is all you need to do. See the thousands of examples in the kernel of this if you need proof :) thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies