Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5554112pxj; Wed, 23 Jun 2021 04:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD9jIzmDXQa2JRCYQOuYhMcKMRKVzPm7MkGs8YwmuLXa3jw/+rdstWHGgj4O93DZDwif01 X-Received: by 2002:a17:906:a203:: with SMTP id r3mr9416534ejy.361.1624446097502; Wed, 23 Jun 2021 04:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624446097; cv=none; d=google.com; s=arc-20160816; b=t9vp75AYcvFPWyukH2RIxgqIXytQxXaZdzq8IbcSg99QueV8iJ5T+lfotRTMjKRFw0 rZD5+t/rlHRlXC9tPh6NSsIIykA/WSgREcx9VDNnLoV8VSn0+9sARHmNZrrOD8x/LZcJ EmSjLOwvfHbfWufD3eXAtcf8zV99KV5eAj056KyNFQn0/iSK5L+MP+UwOnbz8fDwjXwe zneyGY+slDWSQ13fF+jnQPqtneW6n0BQ8k9rnw6tFwDnE+HN8YYmfYGwSXFPeVN2oXqR cRZX+L0o/5WZ0kKueXinKO4DZwNKwnW6ABr0WBqtZ2USd/ievxwkFTclv65OTcDiHArW edmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dJGFJi2SWlwPX3gSxotAaJdmgPvABu9igSaT3WLpCGg=; b=BRBbil6JMCVarhUEPD197mRul9ivbR5NL3X5NHtbmV/zIUtIS8JY/lm4acNRITI40T AgtXoQJlfH5T2aHHGW+k4mQi88Gy8TBXDTut+TrKDE+OI9s05BQEHMCKdzlf2oUbFBXs aV220nUEasoM4SQZG1vXmV4U99uy3fAp8dFIl4uzXdITSExmlUDwt/5U0QRvuObUzT7B 4eQ16T4at8DsykhaQjionj/r78Wqgn+vkv/h58dkTInR6vnjwGpaeYiHP8nNnlhdk0rC 4ZDXXPvFOZp0cHtIRaPQFO+2vcV7hOqECncsBQMACJ8HOG30eLDuM2oh44l7WbeLJnWr DTAg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id er22si553388ejc.273.2021.06.23.04.01.14; Wed, 23 Jun 2021 04:01:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbhFWLCM (ORCPT + 99 others); Wed, 23 Jun 2021 07:02:12 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]:37432 "EHLO mail-wm1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbhFWLCL (ORCPT ); Wed, 23 Jun 2021 07:02:11 -0400 Received: by mail-wm1-f46.google.com with SMTP id f16-20020a05600c1550b02901b00c1be4abso3712395wmg.2; Wed, 23 Jun 2021 03:59:53 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=dJGFJi2SWlwPX3gSxotAaJdmgPvABu9igSaT3WLpCGg=; b=XXnX7uVTNeUCm7fU8JJk5RB8k/eRheauKRIs6JDVvrKFJj94CYVdtIa7BdVnIhGGt5 sHH3hNHwhhpSClRi6dadag5YNqpRajKIenHCFYnfXP9QDIG+Vbc6z0aKOxiDecCgiLuo MkNKH1h/hygZCT5bO2IBLfve2yJs84Jjn8aJUM0db4b1ZaDmKd+UtaOWIx2wePVIjpqN Ap2rFKd1LJ73mfFDloLfmH76uAPI2HdQq8+k4JHl6mKvFButLr3un3mEmFDy35FnIxgv wSTFkZXEtSTjfWmA96eQCpMVZQ5cTdL0mJ0iZFWaPEsT2iAmcxCKuCLealGsLrMgdoiK Af+w== X-Gm-Message-State: AOAM531HTlNwT5BGyKwep3PrIBK8/kLgkDOaR7vcPGlDAFfTFq0frAPU xQOTY5eb7DButFW7DcKJskNI+89rVyP8+A== X-Received: by 2002:a1c:de8a:: with SMTP id v132mr9834645wmg.27.1624445992655; Wed, 23 Jun 2021 03:59:52 -0700 (PDT) Received: from msft-t490s.. (mob-176-246-29-26.net.vodafone.it. [176.246.29.26]) by smtp.gmail.com with ESMTPSA id r2sm2659458wrv.39.2021.06.23.03.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 03:59:52 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe Cc: linux-kernel@vger.kernel.org, Lennart Poettering , Luca Boccassi , Alexander Viro , Damien Le Moal , Tejun Heo , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke , Matthew Wilcox , Christoph Hellwig , JeffleXu Subject: [PATCH v3 3/6] block: refactor sysfs code Date: Wed, 23 Jun 2021 12:58:55 +0200 Message-Id: <20210623105858.6978-4-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210623105858.6978-1-mcroce@linux.microsoft.com> References: <20210623105858.6978-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matteo Croce Move the sysfs register code from a function named disk_add_events() to a new function named disk_add_sysfs(). Also, rename the attribute list with a more generic name than disk_events_attrs. This is a prerequisite patch to export diskseq in sysfs later. Signed-off-by: Matteo Croce --- block/genhd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index c96b667136ee..610dd86fd4b6 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -39,6 +39,7 @@ static void disk_alloc_events(struct gendisk *disk); static void disk_add_events(struct gendisk *disk); static void disk_del_events(struct gendisk *disk); static void disk_release_events(struct gendisk *disk); +static void disk_add_sysfs(struct gendisk *disk); void set_capacity(struct gendisk *disk, sector_t sectors) { @@ -560,6 +561,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk, */ WARN_ON_ONCE(!blk_get_queue(disk->queue)); + disk_add_sysfs(disk); disk_add_events(disk); blk_integrity_add(disk); } @@ -1754,7 +1756,7 @@ static const DEVICE_ATTR(events_poll_msecs, 0644, disk_events_poll_msecs_show, disk_events_poll_msecs_store); -static const struct attribute *disk_events_attrs[] = { +static const struct attribute *disk_sysfs_attrs[] = { &dev_attr_events.attr, &dev_attr_events_async.attr, &dev_attr_events_poll_msecs.attr, @@ -1825,13 +1827,16 @@ static void disk_alloc_events(struct gendisk *disk) disk->ev = ev; } -static void disk_add_events(struct gendisk *disk) +static void disk_add_sysfs(struct gendisk *disk) { /* FIXME: error handling */ - if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0) + if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_sysfs_attrs) < 0) pr_warn("%s: failed to create sysfs files for events\n", disk->disk_name); +} +static void disk_add_events(struct gendisk *disk) +{ if (!disk->ev) return; @@ -1856,7 +1861,7 @@ static void disk_del_events(struct gendisk *disk) mutex_unlock(&disk_events_mutex); } - sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_events_attrs); + sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_sysfs_attrs); } static void disk_release_events(struct gendisk *disk) -- 2.31.1