From patchwork Sun Jul 28 16:42:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 1138042 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 45xTCF483lz9s7T for ; Mon, 29 Jul 2019 02:43:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbfG1QnE (ORCPT ); Sun, 28 Jul 2019 12:43:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:49204 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726046AbfG1QnE (ORCPT ); Sun, 28 Jul 2019 12:43:04 -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 20CCAAD88; Sun, 28 Jul 2019 16:43:03 +0000 (UTC) Date: Sun, 28 Jul 2019 18:42:55 +0200 From: Jean Delvare To: Linux I2C Cc: Andrew Lunn , Srinivas Kandagatla , Greg Kroah-Hartman , Bartosz Golaszewski , Arnd Bergmann , LKML Subject: [PATCH v2 2/2] nvmem: Use the same permissions for eeprom as for nvmem Message-ID: <20190728184255.563332e6@endymion> In-Reply-To: <20190728184138.78afc30f@endymion> References: <20190728184138.78afc30f@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 compatibility "eeprom" attribute is currently root-only no matter what the configuration says. The "nvmem" attribute does respect the setting of the root_only configuration bit, so do the same for "eeprom". Signed-off-by: Jean Delvare Fixes: b6c217ab9be6 ("nvmem: Add backwards compatibility support for older EEPROM drivers.") Cc: Andrew Lunn Cc: Srinivas Kandagatla Cc: Greg Kroah-Hartman Cc: Bartosz Golaszewski Cc: Arnd Bergmann Reviewed-by: Bartosz Golaszewski --- Changes since V1: * Split into 2 patches, one to the at24 driver and one to the nvmem core. drivers/nvmem/nvmem-sysfs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- linux-5.2.orig/drivers/nvmem/nvmem-sysfs.c 2019-07-08 00:41:56.000000000 +0200 +++ linux-5.2/drivers/nvmem/nvmem-sysfs.c 2019-07-28 18:06:53.105140893 +0200 @@ -224,10 +224,17 @@ int nvmem_sysfs_setup_compat(struct nvme 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