Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp816537iob; Fri, 13 May 2022 13:26:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyftPQ3M+dV4W0igZN0FM4wEGJk6KpJq1dX2jtPK3L80emRPLiTEr6VhcKVTfXUcl8krpnn X-Received: by 2002:a05:6402:1d48:b0:427:dfa3:2272 with SMTP id dz8-20020a0564021d4800b00427dfa32272mr409969edb.333.1652473586324; Fri, 13 May 2022 13:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652473586; cv=none; d=google.com; s=arc-20160816; b=iQ6yAuox0sf2EnPLv2uGR4+PgSB/Xx27RVPOdmnFz2CNzhxUI+ad5E+zRc7uE7Qyja RjiFaO1uclZG9ciUCsje2/Zkq+SdJ/NfbgbRgjjowojNAylQFqg4Peq2Kngbz13H1aoG wu0RabbSYN/KgadfUFFwoTh8H3UPQDirjfOR8R6OZeOCFjg0UKmqlyi2RmfYcEhkB+ST q1VG8UYe1TN+0IPovtI07oMXLqxfek5EYDKqkBlqtsaak5ie2ffdee4jrL5g1OhKQpB+ NWWBkYW06w4v8TOyIvlqgNIFGVoG8RDYtQvRTS9cikF6ygTD02onVvPwaxP/rMYjFn5o nOZQ== 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=9ZoXseUxXDuBhnUU+CGsQXKX/xQuLPABnNgtpp1mC+U=; b=m3JwjkUQgS5c5iJwHuR80aIJ+iOCbckolUqVEot8UmduPdH+G/+ijjLrKlx47gol57 bMxBr3oKepidxBeZFcL4Vl1L5dJHiolERN6M4zIVUC8oXZ9r0liRx4oGWqgsa0G+jbxv mKb2WrRBPXLrwyu1Tj426KXs99cjjjU7XkIHik9dgOUsFwDcLyw4Zm+A9RCgw+x80CHn jDJIkfvHI+AxaDrLtBx8lPd1/3cSUpFEaBTWzrkdLclZSAi2qyAQqJKIvd9tQ20auYde PoCIfZwu2lofxtUydtccI8c2GCpqYygURzZh5UGAR8q1w1+7/1DBp7aE6GAhynYzi4LF eIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=YQJ0xJ6i; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp18-20020a1709071b1200b006f49fa26194si3527564ejc.409.2022.05.13.13.25.58; Fri, 13 May 2022 13:26:26 -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=@walle.cc header.s=mail2016061301 header.b=YQJ0xJ6i; 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 S1381561AbiEMNiF (ORCPT + 99 others); Fri, 13 May 2022 09:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381348AbiEMNfc (ORCPT ); Fri, 13 May 2022 09:35:32 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D194F5FCF for ; Fri, 13 May 2022 06:35:29 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id DFE65221D4; Fri, 13 May 2022 15:35:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1652448928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9ZoXseUxXDuBhnUU+CGsQXKX/xQuLPABnNgtpp1mC+U=; b=YQJ0xJ6ilUYAf2PtdFVg0FFO7xDDVImh8oloeDySiX/UTZmczh09vDOmjmGjqNbBy1W72O +xVqWrrrnVPOkQkd4SEjgEoE21WbuM4NfMKz+eueT95K9CghOTvA9jClPAsWO0H5K8rNqX MSzsMTjNPw/UxRUrSGu7Qj8oob+aiQI= From: Michael Walle To: Tudor Ambarus , Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH 1/6] mtd: spi-nor: hide jedec_id sysfs attribute if not present Date: Fri, 13 May 2022 15:35:15 +0200 Message-Id: <20220513133520.3945820-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220513133520.3945820-1-michael@walle.cc> References: <20220513133520.3945820-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Some non-jedec compliant flashes (like the Everspin flashes) don't have an ID at all. Hide the attribute in this case. Fixes: 36ac02286265 ("mtd: spi-nor: add initial sysfs support") Signed-off-by: Michael Walle --- .../ABI/testing/sysfs-bus-spi-devices-spi-nor | 3 +++ drivers/mtd/spi-nor/sysfs.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor index d76cd3946434..e9ef69aef20b 100644 --- a/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor +++ b/Documentation/ABI/testing/sysfs-bus-spi-devices-spi-nor @@ -5,6 +5,9 @@ Contact: linux-mtd@lists.infradead.org Description: (RO) The JEDEC ID of the SPI NOR flash as reported by the flash device. + The attribute is not present if the flash doesn't support + the "Read JEDEC ID" command (9Fh). This is the case for + non-JEDEC compliant flashes. What: /sys/bus/spi/devices/.../spi-nor/manufacturer Date: April 2021 diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 9aec9d8a98ad..4c3b351aef24 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -67,6 +67,19 @@ static struct bin_attribute *spi_nor_sysfs_bin_entries[] = { NULL }; +static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct spi_device *spi = to_spi_device(kobj_to_dev(kobj)); + struct spi_mem *spimem = spi_get_drvdata(spi); + struct spi_nor *nor = spi_mem_get_drvdata(spimem); + + if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len) + return 0; + + return 0444; +} + static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj, struct bin_attribute *attr, int n) { @@ -82,6 +95,7 @@ static umode_t spi_nor_sysfs_is_bin_visible(struct kobject *kobj, static const struct attribute_group spi_nor_sysfs_group = { .name = "spi-nor", + .is_visible = spi_nor_sysfs_is_visible, .is_bin_visible = spi_nor_sysfs_is_bin_visible, .attrs = spi_nor_sysfs_entries, .bin_attrs = spi_nor_sysfs_bin_entries, -- 2.30.2