From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB5A031F992 for ; Sat, 4 Jul 2026 18:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.218.41 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783191185; cv=pass; b=BnKRANTDJi01+QlznXu1jITifNnqvjKYfU4UlLpopPu4DkSjD4nvhi0RaXAsLQ4qHw829Bk39EzuvzNMaaH3ouo6Z8o9dpriDLGfZ2j4Q23bzoBYcw7+EhLTB1eRUrFJqg8KrD/gbRxrEXqnyU1Dw6XWdLNe05/gYY1JJ+uZ41U= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783191185; c=relaxed/simple; bh=GfnlmAFvUSAqS3ZrwBAbcQ1Hx67x/lz6NtI32WD2Khc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZJ6A2Bwg4vp76acxWT21t5btoFdBWYeYMzhaJWIMl208WStLfS0D1NzMg0xNxMJFApTLxXyOLbdNHtwbt4NR32M/3+6mSf1yLUtR6KBcsZTAUhB9QIVCORYoVtobeHa1tGr8dzwLYSxZUWXNXwTQ5OfgZViSCVRoHtjVpjK7D2E= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MBl9N54m; arc=pass smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MBl9N54m" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-c126fe7d0f3so192799266b.0 for ; Sat, 04 Jul 2026 11:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783191182; cv=none; d=google.com; s=arc-20260327; b=H+/wpE7mLRPdpw+SYJYpaFlRS9Pzr/VtsQvIVsh0D3ZeqjRh9v2SOJp8ySuykSJE7F zgrwvmwl2tV76nem8bAszyaKvZ02Amg52bZlGXZco8VD0VpNyzl5mfJfGQZh3ptuSppX 88yohJ0m7hpA8NOd5tsyKuuqRcZHlh06tOqoPJ0jpbPFl/6a0ZnbWrofOvT/X9PSH7O5 qBZGHqhiJqO8Z2Nerj20cOG2YxdP/NbHnhQLSKoBZWUp02tG9z9H1kgmXYhCozpcxEWu FLY1NN9LLh41HaDWVjQp6OcAjxg1bnENLB3f1LNaRyJ7vn+3BHW2Eyjo3WGAPPnoPSEz Z0aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=f+BkGnn82LQN6bHnpZs3JGZAnAhIdCPQEanxeSEyBEM=; fh=tAP5sr8jksnLc0KdvcirVYqHqsC8VDFPE+X4LoMOMUw=; b=F+AbLDf9DiQSk3p9xnfSp7bvUG/03pfh+oAlEYtiDmDksdoGfvLQduuEax9KDixNNH wXoZpM04dgsiRITMWtXtoijpL6uz/4+q3QDs6VnTlKuNQIM6aC0tekeY954A4MRPlIl9 8b+mk1EEdd4qZcEAm/i9KcmcbWA5q+smlqXFHRbiWhK6pWONDWUv6LKYxO2KJZtur8oW bxSaoQqZDWbLXIVil+D2HShqvqbDSRWrv2EWfnNLUKmg08TCsiFZjMMIwmoR9rZ7pgwd aYRAwxs9HGv1HsvLPvhGECpSZwu72M7TvsCeVMChfQRNj23QnbnQsCVmf0nn6R5n50ZN XWKg==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783191182; x=1783795982; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=f+BkGnn82LQN6bHnpZs3JGZAnAhIdCPQEanxeSEyBEM=; b=MBl9N54mjc4tJuE+tFBvEd21jYVWHVytcvHI3UUdy0vRjod+8RGxgJSj2mj9Bjf5B2 1MzS6BUJIPVKkEIz3RCrv1gsjEmHV+wyyMSvx8ZKbtKRsIEcjFifKHgIpn7GisHN6OIa 7LUkwvuvLFCuqgQm46lUxhKnBUoHIJupc5pYcxYXiPIzhO3zyxSP9nEyQKL63Ud6/K3L LLILucDyS0kbVc3Koicepfk87PUcKTnnsdgzuokgj1LH2Fpdv/ERRnKhYMq4gFpBooAp MHISeat7T7+qJg0OxfCrkvMfVBI5wYb0D2Wmjb6XxW+pTLTCMlIAfp65uT2QYkim5lNr lGkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783191182; x=1783795982; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f+BkGnn82LQN6bHnpZs3JGZAnAhIdCPQEanxeSEyBEM=; b=dKCqT4Pym1sLUg8duJyc6Sw5REUhb7NbWD5csE/vRCY5k6j3XvCtmQ8Gc/siY5BTpm bRoNVnj5xNYmA/ZDKp+3bc1hEpQscL1h78AfTNH2nDnflNu+5FD97oLJWCitVsLy6w1v Z9j4Ll5hzdBXv8+q/SuDoXvuhyVq/aoFCUsprKJYFsg4PAFlUjktLRWEACdRWb1DzC0F 2O82UM0t9plENrBQGyZA8L7GInI1FstHHI45LXFAfJcgRMH1Qb6QWzU+E49OJG3521E5 y847Y3cKKpYyk8e+l7D4ndBLz+gjfCOvFa5UpjnET3VSdDQiajOb45ddg8CJPB88k7he d1Eg== X-Forwarded-Encrypted: i=1; AHgh+Rrd4o0BakJOhX1/Z70XosTTxE0SNw1fyJYFOD5xjtJ+j9FmM/KFOJvRNOW9oDRbS9gT3ISVo6XpdwOrNDM=@vger.kernel.org X-Gm-Message-State: AOJu0YxTKpIK/5ec7rgoKmlU5k1v/pKaRAfmP3FUOIglvKNAUoB748DR 71Cmhg4A/AoOfFRM9Qi4V1V1pBGovmlcCT3xvR435j/bx9hJUTDaAMIAgOhT63fD8S0wnOSBgJF 4/bKuuT3xpDi340miVjuzqJfeDZzR0c4= X-Gm-Gg: AfdE7ckMjSgNv59nzzjk9SEUG0Y6RmpONjJwarupoKxrIpVxTMUR2bXEpWk4Saeadmj yYZbT2oScFPaaGJlJv/9/zAhbxCyp1YfbnKz7gpUEtxNKZ/ZHpq7MTohoe5v1lcCkPF2J72M5b0 Ryb8RbFnM+ZW8TRGu2/7ImM68I/msbbyl24J+DED1kX4k1Y8hAuz/hz+/gEoNl2/8YzWjeNRX7s qKuhlOt07vFUbgS+PpBUwUG1pHRuBZxFGuGCDJ2acL0ScNfJE81CGhilIEMzDm8gU7jlWBYmpaS qKQQL+WqvFanrMpT2vcwrSz6JjJueiVpal7iUfQsaq7Wm+ZDFrCiEaGysevWkURc9yN+hGMyRDL 6RixNby9BF7f/MFTGbvi3ab/0WQu+xLSWLZl6PnyWwiySCpLwUuG0xdEnD7Pe0KaMcx4A X-Received: by 2002:a17:907:25c3:b0:c12:45fc:c44 with SMTP id a640c23a62f3a-c12e6bff31emr137459066b.62.1783191181998; Sat, 04 Jul 2026 11:53:01 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260703102941.1141341-1-stefan.popa@analog.com> <20260703102941.1141341-3-stefan.popa@analog.com> <9878f042f424bfbd7fab24175298224b58e87779.camel@linux.dev> In-Reply-To: From: Andy Shevchenko Date: Sat, 4 Jul 2026 21:52:25 +0300 X-Gm-Features: AVVi8CdyAnuqpwp7HErpmAcpd3YTiWdAQ5q92MiljKmxpMmIe5DU0ndquU9wm84 Message-ID: Subject: Re: [PATCH v1 2/2] iio: adc: add MAX40080 current-sense amplifier driver To: Siratul Islam Cc: Andy Shevchenko , Stefan Popa , Jonathan Cameron , David Lechner , =?UTF-8?B?TnVubyBTw6E=?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ciprian Hegbeli , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jul 4, 2026 at 8:30=E2=80=AFPM Siratul Islam wrote: > July 4, 2026 at 11:05 PM, "Andy Shevchenko" wrote: > > On Sat, Jul 04, 2026 at 10:32:32PM +0600, Siratul Islam wrote: > > > On 26/07/04 03:05PM, Andy Shevchenko wrote: > > > On Sat, Jul 04, 2026 at 01:42:39AM +0600, Siratul Islam wrote: > > > > On Fri, 2026-07-03 at 13:29 +0300, Stefan Popa wrote: ... > > > > > +static int max40080_get_range(struct max40080_state *st, unsigne= d int *range) > > > > > +{ > > > > > + int tmp; > > > > > + > > > > > + tmp =3D i2c_smbus_read_word_data(st->client, MAX40080_REG_CFG)= ; > > > > I think tmp can be initialized, since it is only assigned once. > > > > > > I don't get this comment. You mean switching to ret? > > > > > > I meant tmp is assigned only once so the indirection here, i.e. > > > declaring and assigning in two steps doesn't buy us anything. Instea= d, > > > it could be initialized like "int tmp =3D i2c_smbus_read_word_data()= ." > > > > > Ah, definitely no to this suggestion. It makes code harder to maintain > > and the pattern you proposed is actually discouraged. You can search in > > mail archive and find like ~1-2 year old message from me with the detai= led > > explanation why. > > > Thanks! I'll look into it. Learning a lot of stuff. But I'm trying to und= erstand where to draw the line though. > Like "struct xxx* data =3D iio_priv(indio_dev);" and "s64 ts =3D iio_get_= time_ns(indio_dev);" are pretty common. > Do these calls make a special case for it? When the assigned value is coupled with a (validation) check, definitely do not assign and define simultaneously. When it's used as a counter, it's better to assign it closer to the user (meaning the counters that can't be folded into a for-loop). This is the rough rule of thumb. Plus use common sense. > > > > > + if (tmp < 0) > > > > > + return tmp; > > > > > + > > > > > + *range =3D FIELD_GET(MAX40080_RANGE_MSK, tmp); > > > > > + > > > > > + return 0; > > > > > +} --=20 With Best Regards, Andy Shevchenko