Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp971819iob; Fri, 13 May 2022 18:09:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0ppRLeS3iqJHT2mS17xd0sbnlEJeVJHl7DkqONLHw1znY0k9M7f3E3dYqUq0Q8MIMQVIU X-Received: by 2002:a05:6000:1ac7:b0:20c:6c81:175d with SMTP id i7-20020a0560001ac700b0020c6c81175dmr5811728wry.262.1652490568510; Fri, 13 May 2022 18:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652490568; cv=none; d=google.com; s=arc-20160816; b=1HJkEABuAsWvB4cakm+2Ihswooc2SmK9X9qlIFEAeg640reupWCsVENvx2N7dPcGvp GCzxE7u2OKh6RM1UVSBgRD0BeCJxCe+Ar8GxpovBT8Ch6bj3VaRefmNRtkXH/EIdpaLY Kv3RYfKobUGnKZ7MpggrNgPxhZAgxhSLLbdhQOfxA8lSNeWz+IHg6cLAWaIMlxlc4JC4 mxbAl4EDM9zb/FIdcC8mGjdytKK/lI1K+sfRjBIoU1w8Num3hXTHKSHou5OH1mOwmL17 Pp1OtVAHRzXDGwvc1A0DfgXmD8juSe7Dl+Xhfwtq8v25gOUSTtPwlB7BmAOUXTu5Pqwf mNHg== 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=7SVQYJZn3MFW22DboTz0AGRIBdFV6caUuIlQOpfVNEM=; b=mnd0dfkoLxjHKxz6SFOT62vUbY63OS17igQDD3h5wwId0AsVA0YIprhNQY3STcvAQ1 dX0BKPpQ31DZq2oOoEE/dCygMD+5TuUo3Bsn9VmesgLCag14i/A2wGklvTH4zsaLXFbj lemrS7OlKiqmtHmjtP+Y1ozjMNnZl01YYmCUGZN+5HcFF8kja5HwKOEvOJ3cjXxUa2XG SBxhUlLhQG3phydSQ5C0j8nbm/uvYNMwn8cXwimC/rZdtVS6v6ytU5py49nRVb/ezebs 4z4pUOjRx7k2ra2bAaYNmvYqeO+k4b2NsxUO292GcJeU6Zltau84beSP9npEZYEalYU/ IUTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=OqgVcIKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b15-20020a7bc24f000000b0039444b380c8si6751338wmj.2.2022.05.13.18.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=OqgVcIKS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9CDF38EC83; Fri, 13 May 2022 16:41:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381600AbiEMNiQ (ORCPT + 99 others); Fri, 13 May 2022 09:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381356AbiEMNff (ORCPT ); Fri, 13 May 2022 09:35:35 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA67263B8 for ; Fri, 13 May 2022 06:35:33 -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 AD66022253; Fri, 13 May 2022 15:35:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1652448929; 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=7SVQYJZn3MFW22DboTz0AGRIBdFV6caUuIlQOpfVNEM=; b=OqgVcIKS9cWpiQSb6R55BgLtStx6Yx9vXWnqlEsYfTEm5DYWcLaRCzLRvv6cTYbrhFCvng hy7n5II+ilnbm8VrXTtcrzWBghu5e5J3dj/HsoXNSZVFJhDTZlnjfSjjnU8vQyHb86QlCg HlOfx8oSH8wmt9CvAPSNdXx5046yqXw= 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 6/6] mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver Date: Fri, 13 May 2022 15:35:20 +0200 Message-Id: <20220513133520.3945820-7-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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 We don't have a database entry for the generic SPI-NOR flash driver and thus we don't have a JEDEC ID to print. Print the (cached) JEDEC ID instead. Signed-off-by: Michael Walle --- drivers/mtd/spi-nor/sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 20563c1926f4..c09bb832b3b9 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -35,8 +35,10 @@ static ssize_t jedec_id_show(struct device *dev, struct spi_device *spi = to_spi_device(dev); struct spi_mem *spimem = spi_get_drvdata(spi); struct spi_nor *nor = spi_mem_get_drvdata(spimem); + const u8 *id = nor->info->id_len ? nor->info->id : nor->id; + u8 id_len = nor->info->id_len ?: SPI_NOR_MAX_ID_LEN; - return sysfs_emit(buf, "%*phN\n", nor->info->id_len, nor->info->id); + return sysfs_emit(buf, "%*phN\n", id_len, id); } static DEVICE_ATTR_RO(jedec_id); @@ -76,7 +78,7 @@ static umode_t spi_nor_sysfs_is_visible(struct kobject *kobj, if (attr == &dev_attr_manufacturer.attr && !nor->manufacturer) return 0; - if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len) + if (attr == &dev_attr_jedec_id.attr && !nor->info->id_len && !nor->id) return 0; return 0444; -- 2.30.2