From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98EADC43331 for ; Sat, 7 Sep 2019 17:12:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 729DE218AE for ; Sat, 7 Sep 2019 17:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395128AbfIGRMz (ORCPT ); Sat, 7 Sep 2019 13:12:55 -0400 Received: from mga12.intel.com ([192.55.52.136]:50196 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731167AbfIGRMz (ORCPT ); Sat, 7 Sep 2019 13:12:55 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2019 10:12:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,478,1559545200"; d="scan'208";a="199750399" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2019 10:12:52 -0700 Received: from andy by smile with local (Exim 4.92.1) (envelope-from ) id 1i6eGZ-00008r-D3; Sat, 07 Sep 2019 20:12:51 +0300 Date: Sat, 7 Sep 2019 20:12:51 +0300 From: Andy Shevchenko To: Dmitry Torokhov Cc: "Rafael J. Wysocki" , Heikki Krogerus , Linus Walleij , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: Re: [PATCH v2 1/3] software node: implement reference properties Message-ID: <20190907171251.GL2680@smile.fi.intel.com> References: <20190906222611.223532-1-dmitry.torokhov@gmail.com> <20190907160819.GH2680@smile.fi.intel.com> <20190907163240.GA27112@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190907163240.GA27112@dtor-ws> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 07, 2019 at 09:32:40AM -0700, Dmitry Torokhov wrote: > On Sat, Sep 07, 2019 at 07:08:19PM +0300, Andy Shevchenko wrote: > > On Fri, Sep 06, 2019 at 03:26:09PM -0700, Dmitry Torokhov wrote: > > > + } else if (src->type == DEV_PROP_REF) { > > > + /* All reference properties must be arrays */ > > > + return -EINVAL; > > > > Hmm... What about to duplicate pointer under value union and use is_array to > > distinguish which one to use? Because... > > Then we have to special-case copying this entry, similar to the pains we > are going with the strings. I can't see it as a pain. Simple do the same kmemdup() for the case when is_array = false and DEV_TYPE_REF? By the way, don't we need to update property_entry_{get,set}_pointer()? > > > + .is_array = true, \ > > > > I really don't like this "cheating". > > This is not cheating. Any single value can be represented as an array of > one element. Actually, the only reason we have this "is_array" business > is because for scalar values and short strings it is much cheaper to > store single value in-line instead of out of line + pointer, especially > on 64 bit arches. Yes, and this is a lot of benefit! > If you want we can change is_array into is_inline. Nope, is_array is exactly what it tells us about the content. Its functional load is to distinguish which union (value vs. pointer) we are using. -- With Best Regards, Andy Shevchenko