Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp418637pxk; Sun, 30 Aug 2020 08:27:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyUiCUOdP1MX/FD+Fo+Zvj/WiQHAsv34oYT7LDwDoPEVW6Q7aeG7h5uJthUSj5ZklFBKGN X-Received: by 2002:a05:6402:1109:: with SMTP id u9mr7920322edv.74.1598801239017; Sun, 30 Aug 2020 08:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598801239; cv=none; d=google.com; s=arc-20160816; b=ApDL8yL2c0hkX2Q9scMSuoYwYT/alqoTO0RW0aJ78fZv2054eZCqXEy6ONtF4WPFxq /fQyJA6gOxYYU6qfrBY6AkTe6rRjh8n+a4px+vkqF625+t716V57ei257ieVg09njT5v 27gEEObDYY2ak5zjPliSTZs+8yDx2mLCne8/nYOZAN+h0mw/9lxxEcLsgYWwym71Du4/ +yTgaZ13QaeXVHis5JhytWiA1vHQmBwU+Qzjb8HIr87er8Sl9hp0eAJ5lYnnjE39XquL syDldUmhaJkLUrCoZ7xo7zdTn5sv3jYR4Pz16YIEFCt3kqWNKLNh6ARQ+yEP5nlotvkB gnkA== 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:subject:autocrypt:from:references:cc:to; bh=Pd4zXzfZcr1tE9EzCGg+mn8LFPog/wsKNp9bY0xAMII=; b=BcliMIKSxNBeCO7S0yfGPyH3GyMOo22AtQt9ve+3Lku46rV2IaBgcATy9gvgKAoVuV nOWYrGcLtcKJ+p0Y3GG4ji+uoTAaTPT5Y2yItVU6BP9bW7qGVL869a9L93l5ijsSBA1Q w3AhmBVyDHh4E1GsmQmVDJ0/81ItwSatW8J29hYa6nBrCGCnjyLI7W/J863amyXKK619 NJRi4R8xe3RgfZAjwY0f2j9PVvfF4Y2+R7zL78DbKQPQNoAKxiwSAXy2YILzbUOu/hsj mQPMpkIC6elf4hOR5O/Io1wJX7PrKZqvTjbw4CrhZs//Y76cvSw7KHdsEqgLxN5txbw/ JalA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w22si3768995ejk.590.2020.08.30.08.26.56; Sun, 30 Aug 2020 08:27:19 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726447AbgH3PZi (ORCPT + 99 others); Sun, 30 Aug 2020 11:25:38 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:38957 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgH3PZg (ORCPT ); Sun, 30 Aug 2020 11:25:36 -0400 Received: by mail-lf1-f67.google.com with SMTP id q8so2155020lfb.6; Sun, 30 Aug 2020 08:25:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Pd4zXzfZcr1tE9EzCGg+mn8LFPog/wsKNp9bY0xAMII=; b=rHxsfIY16BVksXrmkTS1u68lpoUV4r3bMS3Dnp17QKSX8f9lvr0zy+tBgDhj4Ys+sO 0QqrYZjk5WSoGAILry9kvJIqAXQ3TCG+mgv5QkG5WIRr7vzdptblhc6W13vYoQ3q0B3S QKKhgGvqX98nfKLce6y6vWk0/MbrC4v8gOV7spHWlR0vC2OPFXYZKULvfIQKibyWG/0Z /1lgZ7inf91Ly2l2LuFv65HzkB2dn0hezPpvFUzDLVtiEyxaWDZxPX0T4YL5Bbhj8gBE 2nQ3c7CxbO1mX8qmHzoDuplPFj/CX8rG7uKXPwOrdxAChBbQSDtxfH1QWLhtdhDg8bCJ C9hw== X-Gm-Message-State: AOAM531q3yxVEx3KLc0q08U+mYlzjZhN3EtwyYDpwBicnzuAM2wRMcjR wwQi6Shx4tE17P90/J9T3+fZC7QJvnu9uQ== X-Received: by 2002:a05:6512:3206:: with SMTP id d6mr3630239lfe.87.1598801132885; Sun, 30 Aug 2020 08:25:32 -0700 (PDT) Received: from [192.168.1.8] ([213.87.147.111]) by smtp.gmail.com with ESMTPSA id r1sm1297637lff.55.2020.08.30.08.25.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Aug 2020 08:25:32 -0700 (PDT) To: Joe Perches , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: Kees Cook , "Gustavo A . R . Silva" , Julia Lawall , Alex Dewar , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Denis Efremov Autocrypt: addr=efremov@linux.com; keydata= mQINBFsJUXwBEADDnzbOGE/X5ZdHqpK/kNmR7AY39b/rR+2Wm/VbQHV+jpGk8ZL07iOWnVe1 ZInSp3Ze+scB4ZK+y48z0YDvKUU3L85Nb31UASB2bgWIV+8tmW4kV8a2PosqIc4wp4/Qa2A/ Ip6q+bWurxOOjyJkfzt51p6Th4FTUsuoxINKRMjHrs/0y5oEc7Wt/1qk2ljmnSocg3fMxo8+ y6IxmXt5tYvt+FfBqx/1XwXuOSd0WOku+/jscYmBPwyrLdk/pMSnnld6a2Fp1zxWIKz+4VJm QEIlCTe5SO3h5sozpXeWS916VwwCuf8oov6706yC4MlmAqsQpBdoihQEA7zgh+pk10sCvviX FYM4gIcoMkKRex/NSqmeh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8BHqvfWyEhJT+CS3JJyP8BmmSgPa0Adlp6Do+pRsOO1YNNO78SYABhMi3fEa7X37 WxL31TrNCPnIauTgZtf/KCFQJpKaakC3ffEkPhyTjEl7oOE9xccNjccZraadi+2uHV0ULA1m ycHhb817A03n1I00QwLf2wOkckdqTqRbFFI/ik69hF9hemK/BmAHpShI+z1JsYT9cSs8D7wb aF/jQVy4URensgAPkgXsRiboqOj/rTz9F5mpd/gPU/IOUPFEMoo4TInt/+dEVECHioU3RRrW EahrGMfRngbdp/mKs9aBR56ECMfFFUPyI3VJsNbgpcIJjV/0N+JdJKQpJ/4uQ2zNm0wH/RU8 CRJvEwtKemX6fp/zLI36Gvz8zJIjSBIEqCb7vdgvWarksrhmi6/Jay5zRZ03+k6YwiqgX8t7 ANwvYa1h1dQ36OiTqm1cIxRCGl4wrypOVGx3OjCar7sBLD+NkwO4RaqFvdv0xuuy4x01VnOF Subject: Re: [PATCH V2] sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output Message-ID: <8b01dc3a-3642-bc12-ae4d-42b90ec208f1@linux.com> Date: Sun, 30 Aug 2020 18:25:29 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/20 3:43 AM, Joe Perches wrote: > $ cat sysfs_emit.cocci > @@ > identifier d_show =~ "^.*show.*$"; I think this additional pattern will allow to take more functions into the scope. @da@ identifier show, store; expression name, mode; @@ ( DEVICE_ATTR(name, mode, show, store) | DEVICE_ATTR_PREALLOC(name, mode, show, store) | DEVICE_ATTR_IGNORE_LOCKDEP(name, mode, show, store) ) @@ // I think device_show_ulong, device_show_int, device_show_bool // functions deserve explicit handling because they are somewhat // reference implementations. identifier d_show = { da.show, device_show_ulong, device_show_int, device_show_bool }; identifier dev, attr, buf; @@ * ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { ... } I tried also to handle DEVICE_ATTR_RW, but I failed to use fresh identifier. This doesn't work: @darw@ identifier name; @@ ( DEVICE_ATTR_RW(name) | DEVICE_ATTR_RO(name) | DEVICE_ATTR_WO(name) ) @@ identifier darw.name; fresh identifier d_show = name ## "_show"; // <== parse error identifier dev, attr, buf; @@ * ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { ... } Regards, Denis