Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2989127imu; Sun, 6 Jan 2019 15:37:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qEM060tayoJuLnFVUUQOM7xuRO4hcNMvidTe1O2wyaFMus6mhCcZtX6mBh5Jx6YCMLpbG X-Received: by 2002:a17:902:292b:: with SMTP id g40mr59811396plb.82.1546817835691; Sun, 06 Jan 2019 15:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546817835; cv=none; d=google.com; s=arc-20160816; b=M5GUK3i7JDF6pWIIEBvPk8j6ER7WopWTjnBlgMXzfMPsJq5iH03VkzS/vLyLrFFSpX V4PhBZuNzuzGzTH2qBfJNknVhqIRw28WDw9ZNpC0CV/pQ9sLrVMZfPKrsl4IE8gN3qGE MgLhun+uleXfwRyyWGC3NSOwRlcwGQSqDN0cu/ZlmCTT9dgMkQ1YTFlfldK1gslT78eO 8aYH3JAfxbZJVQqht0XwVGl6wlHGSpamSfE53C9AMhw1zWjlZJb3zA8RvvAEWDGagHOw x6nfAutjoscl+AagOBz+LPrqPX22krYDOMqdaLssbqvSdXgY+jw23b1wFAMIz63guFNj I3Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=o4t0+TWpKLSIvnQagq/M09RLVxeLZ01UUyfe5/JDKss=; b=ohUKApdkG92bxNeJWkACHqYxspPlY1EGg5Z6wlMHXVDI74+9jG6Gb+L2sFra87x/Z8 wpvFW9pplNu0KPzs4D11uB+pyUEInIX226x+1+Zye28MxRVNm+iYClYXJwWVgjvbKkTh aSCQeK72nZ6hNxo10MMvHdorIWxvJYRu6ZN/xyBtkIaje/E/jGSXatom91aOS4CUQo1n tAGmhIgmwPsksJPQx/8tbZG9UKCxvMjmOmlZXZW2eR/x/qqc0ZhIL/KEJFlgHFW9MbYV w1mv4xF3tIuUd4J/eD+pVMsavJISC1kaP7km/Sgd3iMM+hWvYp3Lml6p0k3ERJwv1Fo/ iQkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f90si2893234plb.362.2019.01.06.15.37.00; Sun, 06 Jan 2019 15:37:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726206AbfAFXf4 (ORCPT + 99 others); Sun, 6 Jan 2019 18:35:56 -0500 Received: from ozlabs.org ([203.11.71.1]:54359 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbfAFXfz (ORCPT ); Sun, 6 Jan 2019 18:35:55 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 43XvzD45bCz9s7h; Mon, 7 Jan 2019 10:35:50 +1100 (AEDT) From: Michael Ellerman To: Arnd Bergmann , Finn Thain Cc: Greg Kroah-Hartman , Benjamin Herrenschmidt , Paul Mackerras , Linux Kernel Mailing List , linux-m68k , linuxppc-dev Subject: Re: [PATCH v8 24/25] powerpc: Adopt nvram module for PPC64 In-Reply-To: References: <2fe2b8e6395aeacfafcbde590a50922d4e632189.1545784679.git.fthain@telegraphics.com.au> Date: Mon, 07 Jan 2019 10:36:10 +1100 Message-ID: <8736q5xst1.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann writes: > On Wed, Dec 26, 2018 at 1:43 AM Finn Thain wrote: > >> +static ssize_t ppc_nvram_get_size(void) >> +{ >> + if (ppc_md.nvram_size) >> + return ppc_md.nvram_size(); >> + return -ENODEV; >> +} > >> +const struct nvram_ops arch_nvram_ops = { >> + .read = ppc_nvram_read, >> + .write = ppc_nvram_write, >> + .get_size = ppc_nvram_get_size, >> + .sync = ppc_nvram_sync, >> +}; > > Coming back to this after my comment on the m68k side, I notice that > there is now a double indirection through function pointers. Have you > considered completely removing the operations from ppc_md instead > by having multiple copies of nvram_ops? > > With the current method, it does seem odd to have a single > per-architecture instance of the exported structure containing > function pointers. This doesn't give us the flexibility of having > multiple copies in the kernel the way that ppc_md does, but it adds > overhead compared to simply exporting the functions directly. Yeah TBH I'm not convinced the arch ops is the best solution. Why can't each arch just implement the required ops functions? On ppc we'd still use ppc_md but that would be a ppc detail. Optional ops are fairly easy to support by providing a default implementation, eg. instead of: + if (arch_nvram_ops.get_size == NULL) + return -ENODEV; + + nvram_size = arch_nvram_ops.get_size(); + if (nvram_size < 0) + return nvram_size; We do in some header: #ifndef arch_nvram_get_size static inline int arch_nvram_get_size(void) { return -ENODEV; } #endif And then: nvram_size = arch_nvram_get_size(); if (nvram_size < 0) return nvram_size; But I haven't digested the whole series so maybe I'm missing something? cheers