Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5687657rdb; Wed, 13 Dec 2023 16:59:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZ4lH14HFkVjpP88oyxthRvMB3EcvNzPSWM7jGh0fM7qDWAJpAMFEUJ6IY6aTCYhlWhs+w X-Received: by 2002:a05:6a20:e113:b0:18b:93cc:c9fb with SMTP id kr19-20020a056a20e11300b0018b93ccc9fbmr12666015pzb.54.1702515561160; Wed, 13 Dec 2023 16:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702515561; cv=none; d=google.com; s=arc-20160816; b=Uyxdb1NKgxXNA9nxgRzs06Sa64Sd+SG+luK+cLkP9PpWu1Kzu+MT6kq48pqF92Elkp kqYM+pIX2wGfscfwdu12jQft7jxXmGjk7B6hs53SNVt8LidVFuv/GXmyk+A55Rv9SSOh KwX5vlCVHRmDuTtu6mYe8/4Z8GtGO0ZhkEieRWTF7W/83/vGd6G0ORgV83gXNQhfuz2e AG8TldwXjB4uaSjkcijZsaT4Kt8785mugbUQdUV1F9Dc3hxSVnfAZGb/jcUE6DEKj8dG KvXYfZ7BFG+tJSGjp3+OUVS0mrn/IdziWZd80zEpGNLTPF7VCVBY4d7uCT9k39d4Lps6 ZnpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=TLPQRFERPZKZe4sP96FP5UOkMogbBRWOBLXtIS+wgKA=; fh=NUS17hlIOlMkHsf63rhWjPR2XqZktva1ib6jdu0mFqM=; b=FshVx3656M/g1rhd6XHOZK7joccJOFGY6XYKn93u2VBDTrejzAH1X3RbxWEyr24Pkx gHXicatlymXOZGVPOHd0sJ8eLXNrjc0YjDM/tdL//IRwDbOvvqMcuDWgyygT1P8QTVsV isVcgOWA6XkCFDJj61wLNCWFR7yWqX7qRszpO7UnuEdkCh8hES424SELqp9ur4G7lOyY tLf82m3Nt+73NFpk/r+fXsyM8d/ktDKIVmXu8uAPTf4lz7JkLnnRmFRBj9tXnisWH6S4 nDq3847W7dYci3Xdha29WlK7KWYNPt3I09X9sJHoHfe3s6yYrjhrqUoGr6rimtd0AtfH BSqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H+HCa4Du; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id cm22-20020a056a020a1600b005c67bab07f9si10498514pgb.614.2023.12.13.16.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:59:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=H+HCa4Du; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B06A680320D6; Wed, 13 Dec 2023 16:59:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbjLNA7B (ORCPT + 99 others); Wed, 13 Dec 2023 19:59:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234117AbjLNA7A (ORCPT ); Wed, 13 Dec 2023 19:59:00 -0500 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B4BF100 for ; Wed, 13 Dec 2023 16:59:06 -0800 (PST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c9ea37ac87so105003481fa.3 for ; Wed, 13 Dec 2023 16:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702515544; x=1703120344; darn=vger.kernel.org; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:from:to:cc:subject:date:message-id :reply-to; bh=TLPQRFERPZKZe4sP96FP5UOkMogbBRWOBLXtIS+wgKA=; b=H+HCa4Dum7Yqt6M+Vya5PNZ9+zhC6v6nSGCkjXiZNSJL8vobmRR9jQwjxW9HeiWm6H SeWzH4GxlydbCrGFArGv7H1LSq0cu1QFXCQsoQ8RV8qH00V/rvt2NhGll4r2mMlY8KJV khPbSsqL01hzPqoON5GpJEB1bXDyXt7eVLVB4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702515544; x=1703120344; h=cc:to:subject:message-id:date:user-agent:from:references :in-reply-to:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TLPQRFERPZKZe4sP96FP5UOkMogbBRWOBLXtIS+wgKA=; b=g++teJ0UMPvGKL/jDfnZuRna69eKwh5RHHkOA/DBu2PeD4/ENbDz4eI/FWJxXsNyDA 4o8/8LBOIZjVjmoW9YJ6g6ADTSZUgvoapBZu+VZftUkZeMizOyMpr0QvGF2D0QyZbg/d m2MjUYgoeeK3HDyOY+n9Kb3Fq426cjMD/xQhwvAbfIErmlddY87gNkY5Ga0r0r6a7OG3 3CPthAxuRmOi2jkbN/o08v1QrjnBhE50e1xLQcRcPn/yuks+o8PTSz409ju00zPgfOqm vne8fD2qBu/bppzmlrdqi3LFQhym2k/qst1ddQ+JpsbkXqN5jd352XviarYXoCtRVum3 Y81g== X-Gm-Message-State: AOJu0YwiYrx8Uwmy0n/9oVVTOf4UN98g6Jx3WE72St3J3/w02SWF6nZU cRjM/uFcfyV1Yj6EGFCV7EG9qarAVIgaZRJ/TY0uaw== X-Received: by 2002:a2e:a4b8:0:b0:2cc:1d91:83fc with SMTP id g24-20020a2ea4b8000000b002cc1d9183fcmr2754449ljm.30.1702515544589; Wed, 13 Dec 2023 16:59:04 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 13 Dec 2023 16:59:04 -0800 MIME-Version: 1.0 In-Reply-To: <20231212-strncpy-drivers-iio-proximity-sx9324-c-v3-1-b8ae12fc8a5d@google.com> References: <20231212-strncpy-drivers-iio-proximity-sx9324-c-v3-1-b8ae12fc8a5d@google.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Wed, 13 Dec 2023 16:59:04 -0800 Message-ID: Subject: Re: [PATCH v3] iio: sx9324: avoid copying property strings To: Jonathan Cameron , Justin Stitt , Lars-Peter Clausen Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 16:59:18 -0800 (PST) Quoting Justin Stitt (2023-12-11 16:42:52) > diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c > index 438f9c9aba6e..e3bc30b57b19 100644 > --- a/drivers/iio/proximity/sx9324.c > +++ b/drivers/iio/proximity/sx9324.c > @@ -873,6 +873,32 @@ static int sx9324_init_compensation(struct iio_dev *indio_dev) > 20000, 2000000); > } > > +static u32 sx9324_parse_phase_prop(struct device *dev, return u8? because that's the type of struct sx_common_reg_default::def. > + struct sx_common_reg_default *reg_def, > + int idx, const char *prop) > +{ > + unsigned int pin_defs[SX9324_NUM_PINS]; > + int count, ret, pin; > + u8 default_def; > + u32 raw = 0; > + > + default_def = sx9324_default_regs[idx].def; Do we need to do this? Isn't this reg_def->def? > + > + count = device_property_count_u32(dev, prop); > + if (count != ARRAY_SIZE(pin_defs)) > + return default_def; return reg_def->def? > + ret = device_property_read_u32_array(dev, prop, pin_defs, > + ARRAY_SIZE(pin_defs)); > + if (ret) > + return default_def; return reg_def->def? > + > + for (pin = 0; pin < SX9324_NUM_PINS; pin++) > + raw |= (pin_defs[pin] << (2 * pin)) & > + SX9324_REG_AFE_PH0_PIN_MASK(pin); > + > + return raw; > +} > + > static const struct sx_common_reg_default * > sx9324_get_default_reg(struct device *dev, int idx, > struct sx_common_reg_default *reg_def) > @@ -884,35 +910,30 @@ sx9324_get_default_reg(struct device *dev, int idx, > #define SX9324_PIN_DEF "semtech,ph0-pin" > #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution" > #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength" Can you send a followup to remove these defines? > - unsigned int pin_defs[SX9324_NUM_PINS]; > - char prop[] = SX9324_PROXRAW_DEF; > + const char *prop = SX9324_PROXRAW_DEF; This can be left unassigned now, right? > u32 start = 0, raw = 0, pos = 0; > - int ret, count, ph, pin; > const char *res; > + int ret;