From nobody Mon Sep 8 07:56:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DEF5EE57EF for ; Fri, 8 Sep 2023 10:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242938AbjIHKSw (ORCPT ); Fri, 8 Sep 2023 06:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237864AbjIHKSr (ORCPT ); Fri, 8 Sep 2023 06:18:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913A41FD2 for ; Fri, 8 Sep 2023 03:18:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19E15C433C9; Fri, 8 Sep 2023 10:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694168220; bh=QWKOHqqURgmtO3ZvDYmsY240tss0yR6QDXZ96fNjlXU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=skfPeefwmRhzrds/Mozc7/ifU/aaLyLbOonFKcLqsZf1LtN3Sp5qCY8NKNfWnWTnV 2QKhKXPtyRtLpPv/K209EMHIPWNRE0GJeze3RSVgtgKFfUQQLMfEOHSvyqb4oBClPs Cb3Gb+igO7NP4IKAaZ46wW2QfspiFhr2xymoScXwE/AE1HgGW7SX5umsZRs4gMQGV6 LkMChMOKWf6h+BV/7+Puj6sSQgitFoCYNIJ4bGvg2CG+VerdyUdX0Oa77/kI8t+xcU bjIaZu5xykVuDWL+bVUbHfGXx/AB+th+ne6Y6q2Vieg2ostCUPOnXgA53TrKZGEfX+ QgNsQmtot4/AA== From: Michael Walle Date: Fri, 08 Sep 2023 12:16:33 +0200 Subject: [PATCH v3 15/41] mtd: spi-nor: add SNOR_ID() and SNOR_OTP() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230807-mtd-flash-info-db-rework-v3-15-e60548861b10@kernel.org> References: <20230807-mtd-flash-info-db-rework-v3-0-e60548861b10@kernel.org> In-Reply-To: <20230807-mtd-flash-info-db-rework-v3-0-e60548861b10@kernel.org> To: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Michael Walle X-Mailer: b4 0.12.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After all the preparation, it is now time to introduce the new macros to specify flashes in our database: SNOR_ID() and SNOR_OTP(). An flash_info entry might now look like: { .id =3D SNOR_ID(0xef, 0x60, 0x16), .otp =3D SNOR_OTP(256, 3, 0x1000, 0x1000), .flags =3D SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB, } Signed-off-by: Michael Walle Reviewed-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 6d1870d5484d..14c1aa63bc51 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -561,6 +561,20 @@ struct flash_info { const struct spi_nor_fixups *fixups; }; =20 +#define SNOR_ID(...) \ + (&(const struct spi_nor_id){ \ + .bytes =3D (const u8[]){ __VA_ARGS__ }, \ + .len =3D sizeof((u8[]){ __VA_ARGS__ }), \ + }) + +#define SNOR_OTP(_len, _n_regions, _base, _offset) \ + (&(const struct spi_nor_otp_organization){ \ + .len =3D (_len), \ + .base =3D (_base), \ + .offset =3D (_offset), \ + .n_regions =3D (_n_regions), \ + }) + #define SPI_NOR_ID_2ITEMS(_id) ((_id) >> 8) & 0xff, (_id) & 0xff #define SPI_NOR_ID_3ITEMS(_id) ((_id) >> 16) & 0xff, SPI_NOR_ID_2ITEMS(_id) =20 --=20 2.39.2