From patchwork Tue Oct 18 18:16:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 4287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2097487wrs; Tue, 18 Oct 2022 11:18:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MroLf6pCC9j9cmZonEEldhL6YgT9UVu7xnYl4Pc8aTczyvu/n8c+BDA5p7a7sEJcF1/l7 X-Received: by 2002:a17:90b:1b06:b0:20d:3b10:3817 with SMTP id nu6-20020a17090b1b0600b0020d3b103817mr5072419pjb.43.1666117127886; Tue, 18 Oct 2022 11:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666117127; cv=none; d=google.com; s=arc-20160816; b=n6Vp50nlEZrGj/l7JgfYMy2NZ529H9XkGzcF7qChPL/5YTraYahpDb6x1VY2QkiQVQ IgFdec2M8TkUeHXHCDi3NGFfckL7e4v/QK67VicRSA6TR0ea2fq3pSOmixEi5EUYcK5g HvJTZenxsb8xelyR5+sGMX5X7Y1Dukoh5alJpSOee1f2501D6FZK9SOtEYxbZC+AUfed IBCFUjZawBgW7mLRthAy6Qfnm+W+0S4u7sK4WOn3fl8yHjTBPHK7sh0HOps1byjLCTYX vhWntAh6CP9w9PcXyvJe+59g1L8ISL/hRWxaxU6O4uSPDJqa2h83o08kwD/V+wn+rCgY ga4A== 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 :dkim-signature; bh=fWQgbZey9us7ESK6PQD6XKaBy+xKVXDQ/LVBroNYgfI=; b=LSpT5NmpRqfvdYc12f7lGEfguV2LhcL3fFMOto1ag3O9sLMUZV1/5waYw18XB7quDq hchpCoxN6LarAgZVSuP/LXceQwbMstOPXaOxZT+VMPbDs+rY1YuWjMfSgAXW5MEAYMd5 rOhsWFnVH25uWoYnfiPIKD+aG7ND5ExcBi0DX5BHIjFh6nYngSSJk1bWahVG/vi5P7Mq aylBcBF96hBalOGuSjxA6dnDMJUB2hv4zRtTLYVQA/0PoYgmqisx4sVldPbW+RQaNotc EA1XYVmgAHOZHLNq4D5uGmr4qxlrb1s7UDjm+gf9SVv62accCED/RwVSq67A9buYrizI uADw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=EqMm5bHB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63f110000000b0045fd05b2ce9si12613256pgi.521.2022.10.18.11.18.34; Tue, 18 Oct 2022 11:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=EqMm5bHB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbiJRSQw (ORCPT + 99 others); Tue, 18 Oct 2022 14:16:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiJRSQr (ORCPT ); Tue, 18 Oct 2022 14:16:47 -0400 Received: from mo4-p02-ob.smtp.rzone.de (mo4-p02-ob.smtp.rzone.de [85.215.255.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26DD7D1F4; Tue, 18 Oct 2022 11:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1666117000; s=strato-dkim-0002; d=iokpp.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=fWQgbZey9us7ESK6PQD6XKaBy+xKVXDQ/LVBroNYgfI=; b=EqMm5bHB0hlVXQl3bSuYXsPhoCM3mhe6EfGhSUfrFKwbyM4j2B8FwR/itIx/6yN0WQ cYTD5pfb5hZ/IivG25IxST+SJWiu7YFr6b/lB0qNdWYqv2vVXxGXKJLS0XiD5/ME6rvB OxoP5flgNUi4CXwGm0A/t3fuXi+FyTE5J/TjP62sTvoNIPkCHaC9iy9UK/0r9n+gvEsB mZxRkdthKFYcaUmU2B2izILiuKJAaruOD36/wKhLahkPRP/qf+L8MCZXcXszyjBKKBmU ZrEAtu2KHAOmpOMTogfRDi6mr9YNYp6V88LZ2NvQHE3gg8GRIXYShcXRTzW4opOgaB21 f4dw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":LmkFe0i9dN8c2t4QQyGBB/NDXvjDB6pBSedrgBzPc9DUyubU4DD2QzemV2tdlNlNRZBXiUw=" X-RZG-CLASS-ID: mo02 Received: from linux.micron.com by smtp.strato.de (RZmta 48.2.0 AUTH) with ESMTPSA id zad98cy9IIGdYSV (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 18 Oct 2022 20:16:39 +0200 (CEST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org, daejun7.park@samsung.com, huobean@gmail.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] scsi: ufs: core: Use is_visible to control UFS unit descriptor sysfs nodes Date: Tue, 18 Oct 2022 20:16:27 +0200 Message-Id: <20221018181627.326657-4-beanhuo@iokpp.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018181627.326657-1-beanhuo@iokpp.de> References: <20221018181627.326657-1-beanhuo@iokpp.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747050433472257398?= X-GMAIL-MSGID: =?utf-8?q?1747050433472257398?= From: Bean Huo UFS Boot and Device W-LUs do not have unit descriptors, and PRMB does not support WB, we can use is_visible() to control which nodes are visible and which are not. Signed-off-by: Bean Huo Reviewed-by: Bart Van Assche --- drivers/ufs/core/ufs-sysfs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index eb6b278c4e79..883f0e44b54e 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -1285,9 +1285,27 @@ static struct attribute *ufs_sysfs_unit_descriptor[] = { NULL, }; +static umode_t ufs_unit_descriptor_is_visible(struct kobject *kobj, struct attribute *attr, int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct scsi_device *sdev = to_scsi_device(dev); + u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); + umode_t mode = attr->mode; + + if (lun == UFS_UPIU_BOOT_WLUN || lun == UFS_UPIU_UFS_DEVICE_WLUN) + /* Boot and device WLUN have no unit descriptors */ + mode = 0; + if (lun == UFS_UPIU_RPMB_WLUN && attr == &dev_attr_wb_buf_alloc_units.attr) + mode = 0; + + return mode; +} + + const struct attribute_group ufs_sysfs_unit_descriptor_group = { .name = "unit_descriptor", .attrs = ufs_sysfs_unit_descriptor, + .is_visible = ufs_unit_descriptor_is_visible, }; static ssize_t dyn_cap_needed_attribute_show(struct device *dev,