From patchwork Mon May 2 14:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josua Mayer X-Patchwork-Id: 1625115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=solid-run-com.20210112.gappssmtp.com header.i=@solid-run-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=ZwndfGKW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KsQFM47tQz9sFr for ; Tue, 3 May 2022 00:19:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9241A83937; Mon, 2 May 2022 16:18:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=solid-run.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=solid-run-com.20210112.gappssmtp.com header.i=@solid-run-com.20210112.gappssmtp.com header.b="ZwndfGKW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 75A7783DCA; Mon, 2 May 2022 16:18:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8CE0B801CA for ; Mon, 2 May 2022 16:18:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=solid-run.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=josua@solid-run.com Received: by mail-wm1-x336.google.com with SMTP id r1-20020a1c2b01000000b00394398c5d51so1612348wmr.2 for ; Mon, 02 May 2022 07:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=solid-run-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=COLqXWuVlqWGDNyPkeBRjk+OR9nESJB/La4mu4469BY=; b=ZwndfGKWeeZHzqr2EO4+iMNjzb9daOxj1kIFHxir/dtOXTvbm3yBFXrxgGMTp+8Z5x jAolwugNR1qEfNpLCWV3+r2HBcxpVZUoU74q7MtxnFLFpgKAMr/Y5NZTvsAiWPt/kIcu zG4SfLRuZAgiY4P37fJNefV/6g0ezpeORMc2NlZP7/Y/eF081x2LZ5Qj6IPdo0lYdxsK TvsOUde2hWIEmgAUsLPPqr2aOnD5vpE1bMyFskx2RSdL4+uHok5SOaTzottJG9tlIm2y TCQqyEBbyMOEh8vs8BDXDaxR85470F2wFT37CFFM/yHDNm/pH7TuZhJzAypZ5VGRldog bjaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=COLqXWuVlqWGDNyPkeBRjk+OR9nESJB/La4mu4469BY=; b=01qull2uwLiaUa9WLgWgRMF7rqNGbE7JLHVWCOk+gtutqzfV2K8Hxab9Jo+UleCddu tm7hEG09hiElhRVqlSsORdLLYkhrPYbVomOIsDXvvuBq2HY72j+YWA9zeCAGpN1pNrI3 1H9Vbh0YKAOUM5O71WuOOqiWTgPw6sm9VDAI8Dm2IZiCi0GBDCoYmMnrrSDhBfh26kYl 5Ddm0YmV/LII9c7Tj7vjlJcrf9DhVYjOigKK/FrfRykjHFBAtvnFHYaXY48GX8rSwV6v xRYNYGUDRXOSWS8tfQ8HruZpuW8Tamdr8yGIZdeHHu41Ksz4gTH8o3MIBXWfZJD0h1BT 4tZg== X-Gm-Message-State: AOAM533a4wJ1M+zflBVh6ybCPB8s8bE9H83C2d8qvXNePh73h8SEtMLO DUHouONCXXlB695gxrGbQdw2LMVeN+4H2A== X-Google-Smtp-Source: ABdhPJw04QzzpSVx69fjZsfA0ZE6EOHm3q0iDjIuvRCXArRSljvYthEC+G5ncSqFzvxI9yuLG/xsAA== X-Received: by 2002:a05:600c:ada:b0:394:30f0:5b24 with SMTP id c26-20020a05600c0ada00b0039430f05b24mr8752986wmr.57.1651501123759; Mon, 02 May 2022 07:18:43 -0700 (PDT) Received: from josua-work.lan (bzq-82-81-222-124.cablep.bezeqint.net. [82.81.222.124]) by smtp.gmail.com with ESMTPSA id t1-20020adfba41000000b0020c6fa5a797sm940035wrg.91.2022.05.02.07.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 07:18:42 -0700 (PDT) From: Josua Mayer To: u-boot@lists.denx.de Cc: Josua Mayer , Jon Nettleton Subject: [PATCH 00/12] split tlv_eeprom command into a separate library Date: Mon, 2 May 2022 17:18:26 +0300 Message-Id: <20220502141838.15912-1-josua@solid-run.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The tlv_eeprom command provides much more than just a cli command: - de- and encoding tlv format - for reading and writing eeprom - setting the eth?addr environment variable - setting the serial# environment variable One device (Clearfog) is already using the decoding functionality to choose the correct memory size based on eeprom data. This patchset massages the implementation in many places removing stateful behaviour and global variables as much as possible and changing some functions to be usable as a library. Then finally everything but the handling of the cli command is split off into a separate tlv library that can be used independently from the command. SolidRun is starting to flash more devices with tlv data at the factory, and we plan to use this information for device identification purposes in future board files. This refactoring will make those implementations easier and reduce the amount of duplicate code to carry around. Josua Mayer (12): cmd: tlv_eeprom: remove use of global variable current_dev cmd: tlv_eeprom: remove use of global variable has_been_read cmd: tlv_eeprom: do_tlv_eeprom: stop using non-api read_eeprom function cmd: tlv_eeprom: convert functions used by command to api functions cmd: tlv_eeprom: remove empty function implementations from header cmd: tlv_eeprom: move missing declarations and defines to header cmd: tlv_eeprom: hide access to static tlv_devices array behind accessor cmd: tlv_eeprom: clean up two defines for one thing cmd: tlv_eeprom: add my copyright cmd: tlv_eeprom: split off tlv library from command arm: mvebu: clearfog: enable tlv library for spl in favour of eeprom cmd lib: tlv_eeprom: add function for reading one entry into a C string cmd/Kconfig | 2 + cmd/tlv_eeprom.c | 817 ++----------------------------------- configs/clearfog_defconfig | 3 +- include/tlv_eeprom.h | 122 +++++- lib/Kconfig | 2 + lib/Makefile | 2 + lib/tlv/Kconfig | 15 + lib/tlv/Makefile | 5 + lib/tlv/tlv_eeprom.c | 775 +++++++++++++++++++++++++++++++++++ 9 files changed, 944 insertions(+), 799 deletions(-) create mode 100644 lib/tlv/Kconfig create mode 100644 lib/tlv/Makefile create mode 100644 lib/tlv/tlv_eeprom.c Cc: Jon Nettleton