From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 B327F3C3C07 for ; Mon, 17 Aug 2026 11:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786964612; cv=none; b=L3dMmM7Rp+b68Ec+AGXXevC+VCZvEJva0pIUNMy/TbWOIvo8+tBD81nhtbhD2qzSsA+mvk6kGkBOHKtOTRlCyqim4G61AMh0HUk29HHvr4oDLryY8/KEyYtn3fYECx3BgO7+AzOlM9ebrFF55NRHI9Y6JODoXwWo+nhY/FISfOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786964612; c=relaxed/simple; bh=suZfBo0+h+lEinP3UPlOlZXIwfGGYyAEiCu+0L3JEGw=; h=Mime-Version:Content-Type:Date:Message-Id:To:From:Subject:Cc: References:In-Reply-To; b=eo//gcZhvG8zj1/X/RlXxIFuVXpeJodGO0d8rPAoOpmOToSVi0UClHLO6EfLAdG9PJKPDsvLCXgSP8aPYeYbP1rTb7yHioud0NGVHHPzn7S0VmRsv8E2sTD2st8MycAwuWdQAnQtcvhdOdURAOQ5S9Zbj7LxdT7s3doPKf9CARg= ARC-Authentication-Results:i=1; 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=mZXn22bf; arc=none smtp.client-ip=209.85.218.54 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="mZXn22bf" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-c20e70a0962so434810066b.2 for ; Mon, 17 Aug 2026 04:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786964609; x=1787569409; darn=vger.kernel.org; h=in-reply-to:references:cc:subject:from:to:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=QMpSx30Kp01tyA9cA0s6xV9Jsh7jLN7uH1MhPtoZ3m4=; b=mZXn22bfLMwSzIf73G5OcXWdgg98bwBu+G6PzQO+TCcxQmDlNzGCJOf94V3xHHBaX3 OyMVshlaZkaFwOpW5BjIkGCj80RcUjClPDXw1REjYyrzETABldXxKVrOoBGi0ht5T1Ec vcybk3c+AACGh77I7wuP3VNZx+2MLzi8mJ9pPSCPZc1tfyJBLegPSzeyHt/eBULBw/2s BTgfZPJExzQNuu6UEBe3mATlHTxs6GUXGsYb6/VZSLdYVVh2Yd42RF92jnydlhowmkn9 Ytn0r5vdpZLUsE3iT75H/VZdQRiOGSIZhnhJQm45dyEL1aTrjxZhvXQk0fu6C327pTY1 evnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786964609; x=1787569409; h=in-reply-to:references:cc:subject:from:to:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QMpSx30Kp01tyA9cA0s6xV9Jsh7jLN7uH1MhPtoZ3m4=; b=ISemGh3eOzRZpaN9bC9K6d7KgrFaahijKPfFIhLIeqIGTDgkhlLP3Bfz3YIS+r9D4s Nn45sHe8sEXO3uBlcK4HqRK/WSYscsJYN+g27+laDuDpGuOvVB7GsvP7d8e+Z2xEBry9 L+6R78SoxPKr38AAkZFGE9jcT8kJwXoMCKch4otLMWXVoITad2B8UFlTRU2w6x6KbU+9 2J1nHzo11V03qJxWjU+63122I4eX9KMZVfs5JeCrvWrhyAEsnQVTqBbHesstd/WkL6wF As4nO5eSitFAJtKc6JAS0ryq09PdEhbYBpDo6rsI3AeJ2sRI0VWfkcCuJmYKFz56w8nR Wifw== X-Forwarded-Encrypted: i=1; AHgh+Ro5Hgvzr9DxfyzNThBA7lQfoYmo/RF7iA4yLE8/h+Ik6gI2iiqpoVBIMz2Dvpx5LDFeN3ifoxxCz90Smtw=@vger.kernel.org X-Gm-Message-State: AOJu0YxHuVoBCv9ayQZyQ2yHePvwmWEXvsYzIEKaKTfanGjfA6KGBBhG 84KU6/t4Jvpuz+RRPxXFyb2mSweGRIZ+puKiZl36vDBV9n11nQjOzvRY8Dt+0A== X-Gm-Gg: AR+sD11i5K0tMIVFeMbOlNp34OnGJb2pRKlo+1Ale+h90Lzj+lnnSl7PxsUGlwa4Y9T 43XsEdMCQFFDbyIoaZHDCqskwCPSsnVKQ/+n1XduR7AK90zgpdw8Yfmu5rKnp0u743YlAOPXZOk Dnan7AMJRPUDOQivduSJU7Rg4DHS5lsTlkywJRabUShdzH68Y/p1iY/CQO2+SAE5fpiZpeVfghT EItXN0HXDS7w/PjqKwkCj/jA90WpuwUOSBlkLeTvj4V2qu+peZbNyWDZlUrs07wY9AsRFP7wT16 6v21wImZwX3v5I8ZQAWZt3MmeIiDdpq7aE60tZRUMeKblWinqTmh9fM33EP8Q6yb+klhF4rGCpE vUGSITp3wwHrZcq/BR+iS2thIi0G/XUMMbFb8Fd140DLo7qrQLkjbQ7B763ieNptj7b9L3jx3nm NHneZgglQ4HimI6EYmJaJ4Yp2YY+hwrF6+deii3OVl/5pW2biKBVgTZuHAFV6ya4MXX28ZB5Jxs ZA= X-Received: by 2002:a17:907:a4b:b0:c20:23f8:99a5 with SMTP id a640c23a62f3a-c212a0f32bcmr1095328266b.15.1786964608636; Mon, 17 Aug 2026 04:03:28 -0700 (PDT) Received: from localhost ([2001:4bb8:17a:e1ae:4021:4903:88de:847e]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2185b977a3sm6849866b.45.2026.08.17.04.03.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Aug 2026 04:03:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 17 Aug 2026 13:03:25 +0200 Message-Id: To: "Jonathan Cameron" , "Javier Carrasco" From: "Javier Carrasco" Subject: Re: [PATCH v6 2/4] iio: light: add support for veml6031x00 ALS series Cc: "Lars-Peter Clausen" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "David Lechner" , =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , , , X-Mailer: aerc 0.21.0-143-g2f3a2e260c09 References: <20260812-veml6031x00-v6-0-7eef6e4ce290@gmail.com> <20260812-veml6031x00-v6-2-7eef6e4ce290@gmail.com> <20260813020429.54031688@jic23-huawei> In-Reply-To: <20260813020429.54031688@jic23-huawei> On Thu Aug 13, 2026 at 3:04 AM CEST, Jonathan Cameron wrote: ... > >> +static int veml6031x00_probe(struct i2c_client *i2c) >> +{ >> + struct device *dev =3D &i2c->dev; >> + struct veml6031x00_data *data; >> + struct iio_dev *iio; >> + int ret; >> + >> + iio =3D devm_iio_device_alloc(dev, sizeof(*data)); >> + if (!iio) >> + return -ENOMEM; >> + >> + data =3D iio_priv(iio); >> + i2c_set_clientdata(i2c, iio); >> + >> + data->chip =3D i2c_get_match_data(i2c); >> + if (!data->chip) >> + return dev_err_probe(dev, -EINVAL, "Failed to get chip data\n"); >> + >> + data->regmap =3D devm_regmap_init_i2c(i2c, &veml6031x00_regmap_config)= ; >> + if (IS_ERR(data->regmap)) >> + return dev_err_probe(dev, PTR_ERR(data->regmap), >> + "Failed to set regmap\n"); >> + >> + iio->name =3D data->chip->name; >> + iio->channels =3D veml6031x00_channels; >> + iio->num_channels =3D ARRAY_SIZE(veml6031x00_channels); >> + iio->modes =3D INDIO_DIRECT_MODE; >> + iio->info =3D &veml6031x00_info; >> + >> + ret =3D devm_mutex_init(dev, &data->scale_lock); >> + if (ret) >> + return ret; >> + >> + ret =3D veml6031x00_regfield_init(data); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to init regfield\n"); >> + >> + ret =3D devm_regulator_get_enable(dev, "vdd"); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to enable regulator\n"); >> + >> + /* The device starts in power down mode by default */ >> + ret =3D veml6031x00_set_power(data, true); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to power on the device\n"); >> + >> + ret =3D devm_add_action_or_reset(dev, veml6031x00_als_shutdown_action,= data); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to add shutdown action\n"); >> + >> + pm_runtime_set_autosuspend_delay(dev, 2000); >> + pm_runtime_use_autosuspend(dev); >> + ret =3D devm_pm_runtime_set_active_enabled(dev); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to enable runtime PM\n"); >> + >> + pm_runtime_get_noresume(dev); >> + >> + ret =3D veml6031x00_validate_part_id(data); >> + if (ret) >> + goto err_pm_put; >> + >> + ret =3D veml6031x00_hw_init(iio); >> + if (ret) >> + goto err_pm_put; >> + >> + pm_runtime_put_autosuspend(dev); > > This and the get_noresume() above smell like they are probably here to en= sure > a 1->0 transition for the runtime pm reference count and hence kick off t= he timer > for autosuspend. That shouldn't be necessary as there is code in the dr= iver > core to try a suspend. Look for pm_request_idle() calls in drivers/base/d= d.c > > Note that we've had sashiko give what we have concluded in the past are f= alse > positives on this dance being required. > Given you have device to hand, just probe it and check if it suspends. > > I haven't quite had the nerve to yet post a series removing this dance fr= om > drivers I can't test! > I tested that mechanism with several devices of this family, and it worked consistently. I will remove the calls to pm_runtime_get_noresume() and pm_runtime_put_autosuspend(), and with that all the goto jumps in the probe function. I still believe that they are absolutely fine when combined with devm_*() calls, but there is now a better reason to remove them. I may have some more IIO devices to validate it with different hardware, but that's an experiment that will have to wait for a while... Anyway, right now this dance is suboptimal but harmless, isn't it? >> + >> + ret =3D devm_iio_device_register(dev, iio); >> + if (ret) >> + return dev_err_probe(dev, ret, "Failed to register iio device\n"); >> + >> + return 0; >> + >> +err_pm_put: >> + pm_runtime_put_noidle(dev); >> + return ret; >> +} Best regards, Javier