From patchwork Wed Jan 17 06:01:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 124781 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1269250lje; Tue, 16 Jan 2018 22:07:55 -0800 (PST) X-Google-Smtp-Source: ACJfBovqMz86VGcrhGXllV/Uxf7BPx22N55uaBx6R/N641TrTrnHIBMSYxnWNkMP36xMtf4FBmtR X-Received: by 10.101.74.129 with SMTP id b1mr10125711pgu.317.1516169275409; Tue, 16 Jan 2018 22:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516169275; cv=none; d=google.com; s=arc-20160816; b=nclJB0kzpT50puwk4vfkOUNMioGaJ4ritUomtK1ic3i+2brxHWdowf9uG1QymwSFIG gi09gMWbA5f1L+zcL90VXUbVVcvZYBPmVvuJKbPYMuw4BX6lVFbgXki2GZ5FZ19sPB48 m+vcVF3SvYKKddCZqlvIH7KG/z5GggJ6Y5/kBOPhrHAqc1PedxtwDrYXlMSmSObVeeML ELE3MPiWh+hPOS4OX1oiWnSeJcuVrWj1JbxoEfOM7PJhGDgMGJDscTAn2I4CuIcaDygZ QN5M45xfDlgov8w+voKnSW5TLQNtHgepiGvT3TX+vdJ9NROSClIjPVhIJ/oNQgGSveJd tsAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=oYNd3JSJl4w5Bm5bnNm1RPeQFkLJJmutNWPQIw1IUoA=; b=OQo7zVn94bZwGoOQtvOWPUv4hE1ivwC/on2elHBkDCgnkNP+LihR9igwZ54ewjblp6 3Qa6ioNDNU6gjB9rIfGALqAUIYvu63p7L7baebSB9zDaytI/WPgK8meR3tXF1U0mO0xQ zC87sg2mpNN4m4aiqU7tgIDCKg5mVqAl8K0qUM1xm+NmvR+RevtK3Rsb7mgh7jDPmzSv AmCkwrfKN5AgYsBY72qwe9ijbnLWralM818p0WpqCKD0ujgwtHaGyTwxcs2LqxMJSOn0 frR41GoqjdCwLCBZabbkeCorpfA+gmeg5SOZIf8q1DmDtAPBQJtaKF+alSTIdv41YzaJ s4yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qp80TGBh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si3643956plo.2.2018.01.16.22.07.55; Tue, 16 Jan 2018 22:07:55 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Qp80TGBh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbeAQGHx (ORCPT + 28 others); Wed, 17 Jan 2018 01:07:53 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43017 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbeAQGHp (ORCPT ); Wed, 17 Jan 2018 01:07:45 -0500 Received: by mail-pg0-f67.google.com with SMTP id n17so3170629pgf.10 for ; Tue, 16 Jan 2018 22:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oYNd3JSJl4w5Bm5bnNm1RPeQFkLJJmutNWPQIw1IUoA=; b=Qp80TGBhoSY2jH83uwUeMmbLhZSJXXviWeSCXPxmPMtd2jAPpxltIdJaPAJ3jvel7M W7DNgRDcC6AiDmSM8ITKDcTdo3PfFb2FOaeeypvkkfC97jcS6J/ksJWRBlqkkv9AQeqy Uw22MxtrqiqtnY4h1+au9L4Chjnd8iXrM9t3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=oYNd3JSJl4w5Bm5bnNm1RPeQFkLJJmutNWPQIw1IUoA=; b=mq+ygszm2kzfvPyMQGf9ga6MWRtsGsHLtxfxkmN0RmG7FrY4Nd+OhhOkTHg15vkps2 DU7drOUla/p0zfoNqsyWnlOtkW/Xm9tT4uufvYnl0JihdVKwTHgclgeOFVfaKU2zi7OO +5t2STLx8kBGpYsBdQ2EwINJU2itq2n3es8lPbf6Te5LeZ4G05NW442T4lIKHVq9D2ps TQEWW94+evPIJdZYCQqfZMn0OL5GqdKvq8gS1qWTuex3g5i2JVcvBiecUPWjT+3dmitt p/SPcaseoGJhF3XaBs+8lkkCjWh9BI33hmi88wXdbz4BZz/PblEGctKhIswAXojq5FHE vBYg== X-Gm-Message-State: AKGB3mIDK0Gs0KyFBud1Pm9gPeeEXMKT8O48ZWueyShu8z1iJp/n56PF +l7+a3yMr93myQpj/iabXybAyw== X-Received: by 10.99.116.88 with SMTP id e24mr24100235pgn.279.1516169264633; Tue, 16 Jan 2018 22:07:44 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id n66sm5987418pfn.64.2018.01.16.22.06.16 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 22:07:44 -0800 (PST) From: Baolin Wang To: john.stultz@linaro.org, tglx@linutronix.de, sboyd@codeaurora.org Cc: broonie@kernel.org, arnd@arndb.de, baolin.wang@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] clocksource: Use ATTRIBUTE_GROUPS macro Date: Wed, 17 Jan 2018 14:01:30 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <069ce2a605546bcad6552968cff755f0a03f9f10.1516167691.git.baolin.wang@linaro.org> References: <069ce2a605546bcad6552968cff755f0a03f9f10.1516167691.git.baolin.wang@linaro.org> In-Reply-To: <069ce2a605546bcad6552968cff755f0a03f9f10.1516167691.git.baolin.wang@linaro.org> References: <069ce2a605546bcad6552968cff755f0a03f9f10.1516167691.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert to use ATTRIBUTE_GROUPS to define one attribute group pointed by 'groups' of the device, which can avoid issuing device_create_file() many times. Signed-off-by: Baolin Wang --- kernel/time/clocksource.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 1.7.9.5 diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 7ce5346..0e974cf 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -993,6 +993,14 @@ static ssize_t available_clocksource_show(struct device *dev, } static DEVICE_ATTR_RO(available_clocksource); +static struct attribute *clocksource_attrs[] = { + &dev_attr_current_clocksource.attr, + &dev_attr_unbind_clocksource.attr, + &dev_attr_available_clocksource.attr, + NULL +}; +ATTRIBUTE_GROUPS(clocksource); + static struct bus_type clocksource_subsys = { .name = "clocksource", .dev_name = "clocksource", @@ -1001,6 +1009,7 @@ static ssize_t available_clocksource_show(struct device *dev, static struct device device_clocksource = { .id = 0, .bus = &clocksource_subsys, + .groups = clocksource_groups, }; static int __init init_clocksource_sysfs(void) @@ -1009,17 +1018,7 @@ static int __init init_clocksource_sysfs(void) if (!error) error = device_register(&device_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_current_clocksource); - if (!error) - error = device_create_file(&device_clocksource, - &dev_attr_unbind_clocksource); - if (!error) - error = device_create_file( - &device_clocksource, - &dev_attr_available_clocksource); + return error; }