Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1585166pxa; Thu, 6 Aug 2020 10:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHyoxbODUrjgHICGxW/UN9Y3bIJPWDwmjY0ePu49LgGDGz980+UK5YXv4NNYsoZ3opGJZZ X-Received: by 2002:a50:e848:: with SMTP id k8mr5242730edn.192.1596736401101; Thu, 06 Aug 2020 10:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596736401; cv=none; d=google.com; s=arc-20160816; b=uz6UfjWkC8BEgoQeaAzmqGZV7Jg9FO9oClWRJ3EABvGF9R8VBSBF/VY/ucuktS960v MBr57jmMrU90/bO0cEYqY359v6noHXMYr6+Yd4qB90Gy/zTaMsEMyMstnswr+PauBJNd LOKq84pU1CK6juXG0aTu8wGKVr4kycR68CNxD7HbF0mybihq8pWPZBCWUO/ytTR6nBp7 oeWZ6t4EnyLr9+w3POD0k1VVm6jXnG2HYGNMtsbRGT1nKk7UdRC/vRR7nr/9e77RdGfn F4X2WgeDFoAHCnLaAgkGuaPAkGRU95fe/Qur/mqCHMMbZJf6XnxSfPrFWa/lGXDWbHpp w+/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=MCX60fyTBSg8KkL54ctAxW103ZXXD3LynPUYjsLj3jM=; b=HyrMcQJ77kpCaor8f4j5YP34F/a3Fhy5BVJZhWEEYWTbpHNnbyXXKmudQaNbyikk3Y +A1o4go4gTVW9NY8kNLHlA5vBZ0Y7awWmFk568Kc7mTICv7U5tfPbPmRj6/wviK9PyeK Au9cNupCELY/LFoHWBB/wiFnrW+4HYaO63IoNdtIPNRMCG2+y2NiyfvMBqy8O09wwbJp +yPbeEL8IjIXzXOk55Haq67P+nsT0pwZ15UHm1+yX9n3u2nFZDupwHR9oHg8VdoFxgSt MU5zrws/Tn7mpkHkjs4wlPU260o20b9Et+5qQx4yu/X7oPReWnQNeD9jEKiVq8uJZL/e F9CA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si3745057ejx.745.2020.08.06.10.52.58; Thu, 06 Aug 2020 10:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgHFRu6 (ORCPT + 99 others); Thu, 6 Aug 2020 13:50:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:49582 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728225AbgHFQdo (ORCPT ); Thu, 6 Aug 2020 12:33:44 -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 47FBDAD4D; Thu, 6 Aug 2020 12:14:55 +0000 (UTC) Date: Thu, 6 Aug 2020 14:14:36 +0200 From: Jean Delvare To: Bartosz Golaszewski Cc: LKML , Linux I2C , Bartosz Golaszewski , Arnd Bergmann , Greg Kroah-Hartman Subject: Re: VAIO EEPROM support in at24 Message-ID: <20200806141436.4dcdfe08@endymion> In-Reply-To: References: <20200317151409.7940926c@endymion> <20200805163655.6cfa6e17@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 5 Aug 2020 20:14:28 +0200, Bartosz Golaszewski wrote: > On Wed, Aug 5, 2020 at 4:36 PM Jean Delvare wrote: > > I finally found the time to give it a try. Here's what my (tested) > > prototype looks like: > > Hi Jean, > > this looks good at first glance. > > > --- a/drivers/misc/eeprom/at24.c > > +++ b/drivers/misc/eeprom/at24.c > > (...) > > @@ -427,6 +450,15 @@ static int at24_read(void *priv, unsigne > > > > pm_runtime_put(dev); > > > > + if ((at24->flags & AT24_FLAG_MASKED_RANGE) && !capable(CAP_SYS_ADMIN)) { > > Maybe use unlikely() here? It's not necessarily a hotpath but at least > it would be obvious it's a corner case. Sure. > > (...) > > 1* Do we actually need to use a struct resource? With the current > > requirements, that looks overkill to me. We really only need the > > start and end offsets of the masked area (or start and length). Or > > do you plan to ever support multiple masked ranges, and > > resource.child would be used to daisy-chain these ranges? Personally > > I would wait until the need exists. > > Yes, since this change doesn't seem to commit to any stable ABI, I'd > say we can drop the reference to struct resource and possibly add it > in the future. This just was the first thing that came to mind when I > suggested it. OK, I changed it to simple integers for now. > > Note that if we would just store mstart and mlen in struct > > at24_chip_data then we could even get rid of AT24_FLAG_MASKED_RANGE, > > as mlen > 0 would imply a masked range. > > Makes sense. Done. > > 2* I chose the name "eeprom-vaio" because "vaio" would be too generic. > > I'm open to suggestions if you don't like that name. > > Are you sure there won't be any different models of vaio eeproms? How > about '24c02-vaio' or 'eeprom-vaio-24c02'? All I've seen were 24C02 but last time was a decade ago. I have no idea if recent Vaio laptops still have this EEPROM, at this address, of that size. 'eeprom-vaio-24c02' is too long to my taste, and kind of redundant as '24c02' implies 'eeprom'. I like '24c02-vaio' very much though, it is both concise and accurate, and is future-proof too. I'll go for that, thanks for the suggestion. > > 3* at24_read() was pretty elegant before my changes, but with the need > > to remember the original value of many parameters, it no longer is. > > I'm considering rewriting it in a way that does not modify the > > parameters needed to process the masked range, either as part of > > this patch or as a subsequent clean-up patch. That would hopefully > > make the code elegant again. > > All clean-ups are welcome. OK, I'll give it a try and see if I can tidy it up. > > 4* I made the masking active only for non-root users as this is what > > the legacy eeprom driver was doing. I hope that's OK with you. > > > > Yes, it's fine with me. If more fine-grained control is needed we can > probably extend it. OK :-) I have a patch almost ready, I'll submit v2 later today. -- Jean Delvare SUSE L3 Support