From patchwork Mon Aug 31 08:02:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1354173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bg2kX2BDjz9sRK for ; Mon, 31 Aug 2020 18:03:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbgHaIC7 (ORCPT ); Mon, 31 Aug 2020 04:02:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:46390 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbgHaIC6 (ORCPT ); Mon, 31 Aug 2020 04:02:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C3AC7ACA3; Mon, 31 Aug 2020 08:03:31 +0000 (UTC) Date: Mon, 31 Aug 2020 10:02:56 +0200 From: Jean Delvare To: Linux I2C Cc: Wolfram Sang Subject: [PATCH v2 1/3] There are several eeprom drivers Message-ID: <20200831100256.077ce253@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There used to be only 1 eeprom driver (named "eeprom") but now there are 3 and the legacy "eeprom" driver is not the preferred option. So list all 3 drivers in our documentation to prevent confusion. Signed-off-by: Jean Delvare Reviewed-by: Wolfram Sang --- README | 3 ++- eeprom/Module.mk | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) No changes since v1. --- i2c-tools.orig/README 2020-08-27 10:28:54.972629860 +0200 +++ i2c-tools/README 2020-08-27 10:41:42.169866472 +0200 @@ -20,7 +20,8 @@ The various tools included in this packa * eeprom Perl scripts for decoding different types of EEPROMs (SPD, EDID...) These - scripts rely on the "eeprom" kernel driver. They are installed by default. + scripts rely on the eeprom kernel drivers ("at24" and "ee1004", "eeprom" on + older kernels). They are installed by default. * eeprog, eepromer Tools for writing to EEPROMs. These tools rely on the "i2c-dev" kernel --- i2c-tools.orig/eeprom/Module.mk 2020-08-27 10:28:54.972629860 +0200 +++ i2c-tools/eeprom/Module.mk 2020-08-27 10:56:11.760402361 +0200 @@ -1,6 +1,6 @@ -# EEPROM decoding scripts for the Linux eeprom driver +# EEPROM decoding scripts for the Linux eeprom drivers # -# Copyright (C) 2007-2013 Jean Delvare +# Copyright (C) 2007-2020 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by From patchwork Mon Aug 31 08:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1354175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bg2rd0l7jz9sSJ for ; Mon, 31 Aug 2020 18:08:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725829AbgHaIIQ (ORCPT ); Mon, 31 Aug 2020 04:08:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:48510 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgHaIIP (ORCPT ); Mon, 31 Aug 2020 04:08:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6A296AC85; Mon, 31 Aug 2020 08:08:48 +0000 (UTC) Date: Mon, 31 Aug 2020 10:08:12 +0200 From: Jean Delvare To: Linux I2C Cc: Wolfram Sang Subject: [PATCH v2 2/3] decode-vaio: Add support for the at24 driver Message-ID: <20200831100812.7b189093@endymion> In-Reply-To: <20200831100256.077ce253@endymion> References: <20200831100256.077ce253@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org We have just added support for the VAIO EEPROM to the at24 kernel driver, so let this script handle it. Signed-off-by: Jean Delvare --- eeprom/decode-vaio | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) Changes since v1: * Move the increase of scanned i2c buses to a separate patch (suggested by Wolfram, thanks). * Explicitly skip devices that aren't driven by either at24 or eeprom. * Fix the failure error message when no VAIO EEPROM is found to mention the at24 driver. --- i2c-tools.orig/eeprom/decode-vaio 2020-08-31 09:55:34.195144542 +0200 +++ i2c-tools/eeprom/decode-vaio 2020-08-31 10:00:21.945292972 +0200 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# Copyright (C) 2002-2008 Jean Delvare +# Copyright (C) 2002-2020 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ # # EEPROM data decoding for Sony Vaio laptops. # -# The eeprom driver must be loaded. For kernels older than 2.6.0, the +# The at24 or eeprom driver must be loaded. For kernels older than 2.6.0, the # eeprom driver can be found in the lm-sensors package. # # Please note that this is a guess-only work. Sony support refused to help @@ -53,11 +53,39 @@ use strict; use Fcntl qw(:DEFAULT :seek); +use File::Basename; use vars qw($sysfs $found); -use constant VERSION => "1.6"; +use constant VERSION => "1.7"; use constant ONLYROOT => "Readable only by root"; +# From a sysfs device path and an attribute name, return the attribute +# value, or undef (stolen from sensors-detect) +sub sysfs_device_attribute +{ + my ($device, $attr) = @_; + my $value; + + open(local *FILE, "$device/$attr") or return ""; + $value = ; + close(FILE); + return unless defined $value; + + chomp($value); + return $value; +} + +# From a sysfs device path, return the driver name, or undef (stolen from +# sensors-detect) +sub sysfs_device_driver +{ + my $device = shift; + + my $link = readlink("$device/driver"); + return unless defined $link; + return basename($link); +} + sub print_item { my ($label,$value) = @_; @@ -213,6 +241,11 @@ for (my $i = 0, $found=0; $i <= 4 && !$f { if (-r "/sys/bus/i2c/devices/$i-0057/eeprom") { + my $driver = sysfs_device_driver("/sys/bus/i2c/devices/$i-0057"); + my $name = sysfs_device_attribute("/sys/bus/i2c/devices/$i-0057", "name"); + next unless ($driver eq "at24" || $driver eq "eeprom"); + next if ($driver eq "at24" && $name ne "24c02-vaio"); + $sysfs = 1; $found += vaio_decode($i, '57'); } @@ -233,5 +266,5 @@ for (my $i = 0, $found=0; $i <= 4 && !$f if (!$found) { - print("Vaio EEPROM not found. Please make sure that the eeprom module is loaded.\n"); + print("Vaio EEPROM not found. Please make sure that the at24 or eeprom module is loaded.\n"); } From patchwork Mon Aug 31 08:09:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1354177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Bg2sw6WCGz9sSJ for ; Mon, 31 Aug 2020 18:09:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbgHaIJX (ORCPT ); Mon, 31 Aug 2020 04:09:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:50724 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbgHaIJV (ORCPT ); Mon, 31 Aug 2020 04:09:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0018CAC85; Mon, 31 Aug 2020 08:09:54 +0000 (UTC) Date: Mon, 31 Aug 2020 10:09:19 +0200 From: Jean Delvare To: Linux I2C Cc: Wolfram Sang Subject: [PATCH v2 3/3] decode-vaio: Scan more i2c buses Message-ID: <20200831100919.519f66a6@endymion> In-Reply-To: <20200831100256.077ce253@endymion> References: <20200831100256.077ce253@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org While the laptop I originally developed decode-vaio on, only had 5 i2c buses, there could be more on other models, and there are definitely more on the system I use to test the script (using i2c-stub) these days. So look for the VAIO EEPROM on up to 32 i2c buses to be on the safe side. Signed-off-by: Jean Delvare --- eeprom/decode-vaio | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Changes since v1: New. --- i2c-tools.orig/eeprom/decode-vaio 2020-08-31 09:50:38.961927999 +0200 +++ i2c-tools/eeprom/decode-vaio 2020-08-31 09:51:02.085179645 +0200 @@ -237,7 +237,7 @@ END print("\n"); } -for (my $i = 0, $found=0; $i <= 4 && !$found; $i++) +for (my $i = 0, $found=0; $i <= 31 && !$found; $i++) { if (-r "/sys/bus/i2c/devices/$i-0057/eeprom") {