Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp78944rwb; Wed, 10 Aug 2022 15:13:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR4UYbjXfrMXv1+xNdz6kNota8FibJAaj6u+pHcQrK6SUAaZBMRnO3fXC5RrNAGjFSbzVCW+ X-Received: by 2002:a17:906:4bd3:b0:731:3bdf:b95c with SMTP id x19-20020a1709064bd300b007313bdfb95cmr14156301ejv.677.1660169616311; Wed, 10 Aug 2022 15:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660169616; cv=none; d=google.com; s=arc-20160816; b=hmT3IFCQjPIa5+Sf0NT6OHiQgaca3bjINrGHliTlQt8iJS7797j1iCQ33w0C/wfutf brjCQW6aPX3VtArVgRtgpt58XjAx8G569G/94931k1vm/1yoqtRC9v9e+S+OtMdZzYPf DS5FOsJaOKpArDwGRqv+Yer2fNe3pC3iLXQiK+IMaVvPywux1x9Ur+ss7iv8jCw+f6qP +dTfOYHZ3U1PSiMcUpQ8RjwhRvHT6ZK1IMaAzTAyEI3+045gvzAwl1GhtoP0u24UsU4v wnkr6HMAisxxsr6zU2SNJWR+3UOugfki72U5jhtes9+F3IZ1NndFkN/WG1hU5My9/RVP wJzQ== 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=mPT9n9q6nJ4yFRRCNrEaQmcmK6+6ARgdGxqRYdby07k=; b=KI7/PsFpJO3u8pAjPV8BTJuhAKoTv6GZoi1vsfpFG68RWTTW4qWHLedspA6OiS89Zt a4jG1/5nvUWaBMjEVYybdKJpkRjeMl8m5MCeLx33GQZj1hBRMdOyKsekdaB7wowQSN7E 7z3HzKGdGrxofumVkpVLaTU4pBxWfNZrX3UkbHAvVo32+fWPFEJcPwVRqUTFuSiYrf51 0fEu2Q0cwdaqjeDsk/u6POpMKPsqpJHcKIQeHomhYz2Hca9sdnvyobDoz+3nl9uS/mA4 V2V6Ru1ZC4Wlng3ChJzrRSGojelmv7NAzmnafZB4EAX32EhZgtOZm514jeftwjrRB7b/ QWvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=AestYAoV; 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 i5-20020a0564020f0500b0043bca9c457csi11636903eda.396.2022.08.10.15.13.09; Wed, 10 Aug 2022 15:13:36 -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=AestYAoV; 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 S233462AbiHJWHf (ORCPT + 99 others); Wed, 10 Aug 2022 18:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233209AbiHJWHP (ORCPT ); Wed, 10 Aug 2022 18:07:15 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9321284ED7 for ; Wed, 10 Aug 2022 15:07:14 -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 8C69D22256; Thu, 11 Aug 2022 00:07:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1660169231; 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=mPT9n9q6nJ4yFRRCNrEaQmcmK6+6ARgdGxqRYdby07k=; b=AestYAoV18zRkiZfPrntjjb/ZrFxiF0t0kU8pU+Df/bepk0elHQMH3h47qHqqmSwOTDPaM UyLhoM7lWtQGXomt+GDVCea2DoQFy8ZKWPDFap/vq/K6z1/7v+nWkFXJvKlQKs2caeIZ4C T8GhXFzjOtrbD+0tB1fSPXHXP+CbFRE= From: Michael Walle To: Tudor Ambarus , Pratyush Yadav Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Michael Walle , Takahiro Kuwano Subject: [PATCH v2 7/7] mtd: spi-nor: sysfs: print JEDEC ID for generic flash driver Date: Thu, 11 Aug 2022 00:06:54 +0200 Message-Id: <20220810220654.1297699-8-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220810220654.1297699-1-michael@walle.cc> References: <20220810220654.1297699-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 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 Reviewed-by: Takahiro Kuwano --- 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