From patchwork Fri Jul 26 13:18:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1137452 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; 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 [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45w8lx1C7Hz9s3l for ; Fri, 26 Jul 2019 23:18:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbfGZNST (ORCPT ); Fri, 26 Jul 2019 09:18:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:47740 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726001AbfGZNST (ORCPT ); Fri, 26 Jul 2019 09:18:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7950AAC8C; Fri, 26 Jul 2019 13:18:18 +0000 (UTC) Date: Fri, 26 Jul 2019 15:18:16 +0200 From: Jean Delvare To: Linux I2C Cc: Andrew Lunn , Srinivas Kandagatla , Greg Kroah-Hartman , Bartosz Golaszewski , Arnd Bergmann Subject: [PATCH] eeprom: at24: make spd world-readable again Message-ID: <20190726151816.66f2ff2f@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.3 (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 The integration of the at24 driver into the nvmem framework broke the world-readability of spd EEPROMs. Fix it. Signed-off-by: Jean Delvare Fixes: 57d155506dd5 ("eeprom: at24: extend driver to plug into the NVMEM framework") Cc: Andrew Lunn Cc: Srinivas Kandagatla Cc: Greg Kroah-Hartman Cc: Bartosz Golaszewski Cc: Arnd Bergmann --- drivers/misc/eeprom/at24.c | 2 +- drivers/nvmem/core.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) --- linux-5.1.orig/drivers/misc/eeprom/at24.c 2019-05-06 02:42:58.000000000 +0200 +++ linux-5.1/drivers/misc/eeprom/at24.c 2019-07-26 13:56:37.612197390 +0200 @@ -719,7 +719,7 @@ static int at24_probe(struct i2c_client nvmem_config.name = dev_name(dev); nvmem_config.dev = dev; nvmem_config.read_only = !writable; - nvmem_config.root_only = true; + nvmem_config.root_only = !(flags & AT24_FLAG_IRUGO); nvmem_config.owner = THIS_MODULE; nvmem_config.compat = true; nvmem_config.base_dev = dev; --- linux-5.1.orig/drivers/nvmem/core.c 2019-07-23 19:30:27.630099103 +0200 +++ linux-5.1/drivers/nvmem/core.c 2019-07-26 14:21:31.002908472 +0200 @@ -435,10 +435,17 @@ static int nvmem_setup_compat(struct nvm if (!config->base_dev) return -EINVAL; - if (nvmem->read_only) - nvmem->eeprom = bin_attr_ro_root_nvmem; - else - nvmem->eeprom = bin_attr_rw_root_nvmem; + if (nvmem->read_only) { + if (config->root_only) + nvmem->eeprom = bin_attr_ro_root_nvmem; + else + nvmem->eeprom = bin_attr_ro_nvmem; + } else { + if (config->root_only) + nvmem->eeprom = bin_attr_rw_root_nvmem; + else + nvmem->eeprom = bin_attr_rw_nvmem; + } nvmem->eeprom.attr.name = "eeprom"; nvmem->eeprom.size = nvmem->size; #ifdef CONFIG_DEBUG_LOCK_ALLOC