Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3642217pxf; Mon, 15 Mar 2021 14:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh6bo0fdBz/XVf9daoPd1QH22KDB3x5lCd17qmuErzrchUYcTBUAB5+fSK/bLymZHla5QK X-Received: by 2002:a17:906:72d1:: with SMTP id m17mr25882078ejl.118.1615844708808; Mon, 15 Mar 2021 14:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615844708; cv=none; d=google.com; s=arc-20160816; b=jBma/ECuDjIPNArbf0NuMJngZmTCWIyRu2HoFcVMuofvRfpTYP3sArqzFMmxv6oiZ0 OF5l4INOxAWHi/C0Q4MTJ7dKv6TZ7TmU5WL9Qb8h8VEdCynnpnhO9sX/61V2Zd/+0MO1 7yX1q1Dev60l2kuP54dtuE513d0CFWFi0sCJ2tNhv6v+VEDXE+fn/APcQsgIyr7KjmTu KC4SIslWORtohK6kyajcuyCS347cz/vtho2mdWDEekYOe2QGphhI5uxR1LPjLVNySbx7 2yDGKHL9frz8adVjX+0e+Nx2TUUlQ6+Czxc63ZfpbIL269QlCd4j919Sktq1pzIjddhd b4zA== 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=unr0lspPbExoMGaeory8crjBzhS6zdKvWVCk960aOU8=; b=cUqhEBedXzaLxZauNnFRfDqokorxbF68ydTc3Ol3cbQJtIZBOhX2nphyTCx4UfZOTG NK3dVHGCNCMwXCObfCIg2q/Ff4LCcXSlsh7V9L+3xlPhYKGldfvp1ScUZ0RMxqdCzRy1 3hg946sog6CiFI7wzURmEyTv6TDoH6L224hHZNViyGXS7RH0mrvEtgx+r0lw65tLnL7Y sSfZM8OqKu2TMukuPngMrOXMy+TW/DCO/6V0utSWc8phvBU4zFXyvcJ2NsBjsZspf86V Y7TUi7uw9FQ6DNf/Q2N0M17BAk5Ubdb206ofmgb71E4mE5qIWXrBckfN27B7A17n+KWu BJkQ== 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 q2si10962160ejz.47.2021.03.15.14.44.46; Mon, 15 Mar 2021 14:45:08 -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 S234021AbhCOUDn (ORCPT + 99 others); Mon, 15 Mar 2021 16:03:43 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:33453 "EHLO mail-ed1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233951AbhCOUDY (ORCPT ); Mon, 15 Mar 2021 16:03:24 -0400 Received: by mail-ed1-f49.google.com with SMTP id w18so18833519edc.0; Mon, 15 Mar 2021 13:03:23 -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=unr0lspPbExoMGaeory8crjBzhS6zdKvWVCk960aOU8=; b=tHGuTWArVlnyWL96Q2qsOFW3yVRN6lP8hVWhh82OCtrYJ7KHsbrfwbYXpLHDs+mt8o uHN6V4WL0Vs23l1xsBxB3g9pscXIBJhoeqHkYU1KBydaYfg3OrtfHyVm/AsFEW46dwUh bGExCzkkcxMndbqOA9zrrCb78p9V+MJDeg/ZiEPSW3EZfBOwxlLlc6GSOXwI9tOZpiv1 LhYOkyiTsQtf33454f2flWelWsdarlrwjZZEE1iL4iRSBENubaEPiWEnsCkUr+FHZAXd I2Znj19xwfq9DbCu8ZGWpqUP350Au/nBo6v56leVhcHBf6AfgJgy9gjxU7fhGb6WeCHx gUcg== X-Gm-Message-State: AOAM5317WgsWDdvQHfHzIu9a4cHDoOb20/F6OmLSDCQ1ux2e5dRoiRTP DUib/onmhaD1mU9JquWqwDU0NoYbDc9GaA== X-Received: by 2002:a05:6402:5189:: with SMTP id q9mr31635414edd.168.1615838602881; Mon, 15 Mar 2021 13:03:22 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-188-216-41-250.cust.vodafonedsl.it. [188.216.41.250]) by smtp.gmail.com with ESMTPSA id x21sm8551210eds.53.2021.03.15.13.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 13:03:22 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lennart Poettering , Luca Boccassi , Jens Axboe , Alexander Viro , Damien Le Moal , Tejun Heo , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke Subject: [PATCH -next 3/5] block: refactor sysfs code Date: Mon, 15 Mar 2021 21:02:40 +0100 Message-Id: <20210315200242.67355-4-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315200242.67355-1-mcroce@linux.microsoft.com> References: <20210315200242.67355-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. 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 92debcb9e061..57d92ea7ae05 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -41,6 +41,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) { @@ -628,6 +629,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); } @@ -1838,7 +1840,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, @@ -1909,13 +1911,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; @@ -1940,7 +1945,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.30.2