From nobody Sat Jun 20 07:11:37 2026 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 5FE3B392C50 for ; Sat, 18 Apr 2026 14:47:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523669; cv=none; b=ty3cyGSQhfG1iHMUtgf7Az/jujeX+UpVxfFOB/U1A1FRWn7VDRiqRb5Gl3mTEFOyCLygC6P5SOma51TqJbynCIx3HuD94btXvZpHDv5zjF9LWqL4CGwRXHrbrfD+2B0MqpgHEgqQbcVSNcXXWkCzHraivUbj83ORZqYAFWBWkOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523669; c=relaxed/simple; bh=Wxb9PwFATd17PDPb2rUk06CPpwp/tCyfuCX8k/OSLuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ElLg+nbU22AwRLxw25mUWi6jgnqQtgDa+ZuzOlM/tVqh3iCbgwfkzb8vcW+MOOm3NyGv5TpA0iGUQFfBMxSYx//4ZWJ2ef0C9ZA/S3AQiyLr4TX7WmlmB4jvHRd0pZ28uWbC4/Via+PSX+CJ4yNHeQ/fkM4epBzTa9ESMC1velA= 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=dUUw2TB5; arc=none smtp.client-ip=209.85.208.180 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="dUUw2TB5" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-38df1889fb9so16234041fa.1 for ; Sat, 18 Apr 2026 07:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776523666; x=1777128466; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MNGi9+tIDznq2/odkG3FnpQo5XY+nW6Im4pa9lH4ZmA=; b=dUUw2TB5DO60Dp+VSmLmon0yQjxrrUlpv8UXD2++STW6LR6xUqlTcv36HsIrd0G4Rz JdX7gdHoEESzmzh0k3wCJS04MV1oH/zelvLpVvXU0xzTlp+YcdY/0MGg5a6QC10DMorW 6FUq/6/B9BFf5wACoGZmh9g+XK6KMHyE/sARMV6tFM4uf+dq8ndEsoAnrlZwTbeTEaHx 0QYzKHPEDc46ngnoMwRKMjgelFIgV9IctnIr0+7MlPDId2wpRgqgVM0aVPqhuA35PqkF 1vFe1dHH8YDadB+7bgLLf7c1O4tYh1cDdON4Tjw+fFlYmR90FHzhA1XE4SO9gimhl+n5 sstg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776523666; x=1777128466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MNGi9+tIDznq2/odkG3FnpQo5XY+nW6Im4pa9lH4ZmA=; b=tAfz0ycm0f01KZjRShDrpy0RTl5g8CMswcEGaQklMxT00rosgytP2lEgZcq1J0mR44 mY7SoHudpKCiP1ZT+SK3ucLZfbEmz+24bAAZQ+w6ipeOtrtES5UI1AxsspcrmWnLRAFC yC3kBQSDk3ivb5CzKi5qkwl6uKalZvy+8q5y+UOCkrhuKzjZv4uo/kGbVQWRc5gMSpV5 1p9ldYuaRq3ECgSW4HV1SZfJxOK/mAuimQjY+bVibKIB1qZpVOgrZJl6nf47oOFY3Pnl poVbV+cjvME8HO78FmPJYbxlcn37FAjf3nNQOZYT190KpmFQZnHX5BcewNCEC678PfQk Aj9Q== X-Forwarded-Encrypted: i=1; AFNElJ/h1O0pB2SAvNFUXN/A/k4uYM6BpkhYp7nIeBfKkmgen+olH5cqql5FXACi/D2q4GlTutFFGsOdouyp5Lg=@vger.kernel.org X-Gm-Message-State: AOJu0YyKCT2WF4sHr59iM9SdclpZnVtruWXAB0MSM8lp+lkNX8Nf/BAF cYKZGFgcWOsoyoMy7LaPO0r/IYeg57kLg/n4dCrE5lZeeCl0gq8XdPHc X-Gm-Gg: AeBDiev2Yg7gmjxTtBLId2hkqGi6zDsxRrEdeQf+SqjpMczqwwsW/1Jjt3roBZZVtHU BgvOLvJqPdgyD8Cu5A6lQ73BVelnTNOUsFVX0XjcMcMxb4W9YCA6US0sc8zDrTPZ98tsZT/rP1j C0zCHvAe/Xi9H1JyZ9J2tm7skByhSfAu+v9wWoxoO15X//5blPBVCuke01/wFhd7BdrBvNe67S2 AjPVb/sMh3uOvP3L/aPUdM96VYXSDh5/hFLt694oXR0mBzDWpoDKlYHKA+3OhRvajx6uTK5YcVQ WUCNtMjBToy88B2tui32SZoEA1eBXKKOxiHSJQd/kCIdKtEjcmmCP8MQBrf7Pzdb8QYx28m6J/5 qCR1b+OvrDIQR5f4vJ13Dg3LlWA3m7AQXZ8yIuOk4efNaBlOIeVZNaAHqHKxr0so4oEJg9xnkhC G580/RLz4sKPkCFNHeDMj1VycUxUK8nQWPSA== X-Received: by 2002:a2e:a549:0:b0:38e:1ebe:95f6 with SMTP id 38308e7fff4ca-38ec7b2a3camr23980721fa.28.1776523666347; Sat, 18 Apr 2026 07:47:46 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb4f51easm10901001fa.6.2026.04.18.07.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 07:47:45 -0700 (PDT) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Randy Dunlap Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] dt-bindings: iio: light: Document Avago APDS9900/9901 ALS/Proximity sensor Date: Sat, 18 Apr 2026 17:47:12 +0300 Message-ID: <20260418144716.132936-2-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260418144716.132936-1-clamor95@gmail.com> References: <20260418144716.132936-1-clamor95@gmail.com> 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" Document Avago APDS-9900/9901 combined ALS/IR-LED/Proximity sensor. Signed-off-by: Svyatoslav Ryhel --- .../bindings/iio/light/avago,apds9900.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/avago,apds9= 900.yaml diff --git a/Documentation/devicetree/bindings/iio/light/avago,apds9900.yam= l b/Documentation/devicetree/bindings/iio/light/avago,apds9900.yaml new file mode 100644 index 000000000000..f5fb79439e56 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/avago,apds9900.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/avago,apds9900.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Avago APDS-9900/9901 combined ALS/IR-LED/Proximity sensor + +maintainers: + - Svyatoslav Ryhel + +description: | + The APDS-9900/9901 provides digital ambient light sensing (ALS), + IR LED and a complete proximity detection system in a single + 8 pin package over I2C interface. + Datasheet at https://docs.broadcom.com/doc/AV02-2867EN + +properties: + compatible: + enum: + - avago,apds9900 + - avago,apds9901 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: true + + avago,pdrive-microamp: + description: + The LED drive current is controlled by a regulated current + sink on the LDR pin. This feature eliminates the need to use + a current limiting resistor to control LED current. The LED + drive current can be configured for 12.5 mA, 25 mA, 50 mA + or 100 mA. For higher LED drive requirements, an external + P type transistor can be used to control the LED current. + enum: [12500, 25000, 50000, 100000] + default: 100000 + + avago,ppcount: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The number of LED pulses can be programmed to a value of 1 to + 255 pulses as needed. Increasing the number of LED pulses at a + given current will increase the sensor sensitivity. Sensitivity + grows by the square root of the number of pulses. Each pulse + has a 16 mS period. + minimum: 1 + maximum: 255 + default: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + light-sensor@39 { + compatible =3D "avago,apds9900"; + reg =3D <0x39>; + + interrupt-parent =3D <&gpio>; + interrupts =3D <82 IRQ_TYPE_EDGE_RISING>; + + vdd-supply =3D <&vdd_2v85_als>; + + avago,pdrive-microamp =3D <100000>; + avago,ppcount =3D <3>; + }; + }; +... --=20 2.51.0 From nobody Sat Jun 20 07:11:37 2026 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 92831397E76 for ; Sat, 18 Apr 2026 14:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523672; cv=none; b=ul0kEoBBlvdS+n2c73shP30C2KvP1+qr/bkZytxZVr/mVel8aLOpPHwnMsmRNdn2PlnFEMWL69KLqh+FYfoAMqa1vSgUVOW11EoELmkIbUxPal0JU6OkcrG9YP29SaZKeLCHqFZSP0EQgsVZjENW+ZyuVKdf65jLEDO/1HsN9Jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523672; c=relaxed/simple; bh=ph482mdUz0pWl0OhYadrfp4dm9vKSDKlVaw1EwDrgLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X9nWUb44KMm+Ugjo14iuYUXyHUmHIl9PvgQzRvg0oszdDVjRf+N5j9dONKhZ80wCyA+0UJ0ZIf8yFi9Pgz8HJzdPrA3wsPo1tdGGhe+1Yat2hyWxgwqsv8zSU6uQ8ALEN1wGrCoeCBAADiUyFOO1c0klas9W3lzuARWGysftc6o= 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=A/aeekct; arc=none smtp.client-ip=209.85.167.53 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="A/aeekct" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5a40b2bc96dso1816427e87.3 for ; Sat, 18 Apr 2026 07:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776523669; x=1777128469; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bJ0ZocjWEH0SujlKl/cIeDMBxgBomMJ+ZN9u8iNbXAE=; b=A/aeekctnv0Q0F5ZOFiHtN4aqotpscFYLvTQdFf2KD8pirGp6sHbU3bdPJZ121qnxm b3Oinian//IwLbH9h6DkQ74S28UnnYTyM2MW/58oaj6In0rXhxjL+EZ7Q2VjtQkYXRZY UXepEzGECgGJRF0I42L2S25aUJXlwzN7jmg/POyL6FbHswNJR5OVNiKUN0fqXVPH4rsu 7DDhKi0IpWPU36hITwaNt6sm7PePfC8w/mZy4zmBkiL5u13ywKLPJd/BwYaBRSAhCWkQ sZKaLKAYAzd0ss+0/xgwqr3dZnicUwC91yH18zYlv6r6p7ei0KjqSaRYRlfSWVK6pIGR QE+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776523669; x=1777128469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bJ0ZocjWEH0SujlKl/cIeDMBxgBomMJ+ZN9u8iNbXAE=; b=T2pwL3XpohURNfN0rx9v1x0KcHX+WoFv08+3Qa8gLS77fR96PgAS41WZaAFbxQMxRR OyoAnJaWFie1zNut+McHJMsU6dYB5uDLf3BbWlS2VJHKpI6IcmwhXcEirNiNLdYPh59i ePHnj5AaQN8JQPeyIYFqUCvLKxz6SVb91Rmvcs/2MWtYaX27OyM8b9DXtRLJXE5IlRyZ wQE7GfbhP8XmmhXtbiKqxHqBqqJJ5X0BE/CPC7ltr+G+yZe1Pyt7ghB4XjpG7jw+EF7L BWDCxZizCYvbDh8DM+9E7DAYkC48uudZP10PpBkRLvFd/QEqJWB/zdi5OREe3ZNG2HA7 byQQ== X-Forwarded-Encrypted: i=1; AFNElJ+SFNc/jFExFNb6Voit47w3eNOBLLedX58Vin4Ab/Yv3o3w+q2pwH3Qv4+euYZ5kSAWkjjCwrEFyxs+ysc=@vger.kernel.org X-Gm-Message-State: AOJu0YwHcW6kLuhbAViBXbwAepK/hKS6aVl62hx4g6ayNvYYt97DETVS o+LtPWzZIb2LNnZJm+yRgcMfVOU51yAs6OJlEYAYWYHh7JFOiP5LrJk6 X-Gm-Gg: AeBDiesMT/0vlVlhqMuwvjogoNDdoBtlYISGJ5I/4MDxFlK28hwBcjApRrLkVNEiUpx rgnmYaKpdZdqZWuklFaFgR+aRwcF2zaFcdIC7+5k4EZODQ0e2YgJqFeOLjKPHgaK03GJul3G+H7 VaGyAL8qMj2CcOcdhb91uXrFh2q88JwQO9WlXsDgP/cuWBUVbFPE/xnywXX2KtAzh7uOqLhJfJ6 N9kQPApswtqtrLP33ScBl/OKKkipE2GzeE45JxgNAKY1O539eSE8+TekeWG2X7PzRS7rX5bK67I IEA/J+ZLkFgPtz8e6wGG+mff0q5W3FpS/UreoGp4iCjOvF3fhiJK9oqdGGgPu7xqCjXiIuf3X4r +fuoLkEWg+P6rq/f2vl3b6QgeIhC0JKtlH6pKgMMZMhr7ucIFlzX/evkkTWet9Tr+1IKajbNDRp Z4oE5DurtK7rXCzE/JJJ7pRpoUsj99VPtYDA== X-Received: by 2002:a05:6512:6193:b0:5a4:1add:c574 with SMTP id 2adb3069b0e04-5a41addc6aamr1448350e87.5.1776523668435; Sat, 18 Apr 2026 07:47:48 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb4f51easm10901001fa.6.2026.04.18.07.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 07:47:47 -0700 (PDT) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Randy Dunlap Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] misc: apds990x: Use more device managed approach in the probe Date: Sat, 18 Apr 2026 17:47:13 +0300 Message-ID: <20260418144716.132936-3-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260418144716.132936-1-clamor95@gmail.com> References: <20260418144716.132936-1-clamor95@gmail.com> 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" No functional changes to the driver. The probe code was refactored to switch to devm_ versions of functions and reduce the nesting of labels. This is in preparation for OF conversion and platform data removal. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 80 +++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 52 deletions(-) diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index b69c3a1c94d1..742ab331a221 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -1053,9 +1053,10 @@ static const struct attribute_group apds990x_attribu= te_group[] =3D { static int apds990x_probe(struct i2c_client *client) { struct apds990x_chip *chip; + struct device *dev =3D &client->dev; int err; =20 - chip =3D kzalloc_obj(*chip); + chip =3D devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; =20 @@ -1066,11 +1067,8 @@ static int apds990x_probe(struct i2c_client *client) mutex_init(&chip->mutex); chip->pdata =3D client->dev.platform_data; =20 - if (chip->pdata =3D=3D NULL) { - dev_err(&client->dev, "platform data is mandatory\n"); - err =3D -EINVAL; - goto fail1; - } + if (chip->pdata =3D=3D NULL) + return dev_err_probe(dev, -EINVAL, "platform data is mandatory\n"); =20 if (chip->pdata->cf.ga =3D=3D 0) { /* set uncovered sensor default parameters */ @@ -1113,75 +1111,61 @@ static int apds990x_probe(struct i2c_client *client) chip->regs[0].supply =3D reg_vcc; chip->regs[1].supply =3D reg_vled; =20 - err =3D regulator_bulk_get(&client->dev, - ARRAY_SIZE(chip->regs), chip->regs); - if (err < 0) { - dev_err(&client->dev, "Cannot get regulators\n"); - goto fail1; - } + err =3D devm_regulator_bulk_get(dev, ARRAY_SIZE(chip->regs), chip->regs); + if (err) + return dev_err_probe(dev, err, "failed to get supplies\n"); =20 err =3D regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); - if (err < 0) { - dev_err(&client->dev, "Cannot enable regulators\n"); - goto fail2; - } + if (err < 0) + return dev_err_probe(dev, err, "cannot enable regulators\n"); =20 usleep_range(APDS_STARTUP_DELAY, 2 * APDS_STARTUP_DELAY); =20 err =3D apds990x_detect(chip); if (err < 0) { - dev_err(&client->dev, "APDS990X not found\n"); - goto fail3; + dev_err(dev, "APDS990X not found\n"); + goto error_regulator; } =20 - pm_runtime_set_active(&client->dev); + pm_runtime_set_active(dev); =20 apds990x_configure(chip); apds990x_set_arate(chip, APDS_LUX_DEFAULT_RATE); apds990x_mode_on(chip); =20 - pm_runtime_enable(&client->dev); + pm_runtime_enable(dev); =20 if (chip->pdata->setup_resources) { err =3D chip->pdata->setup_resources(); if (err) { err =3D -EINVAL; - goto fail4; + goto error_pm; } } =20 - err =3D sysfs_create_group(&chip->client->dev.kobj, - apds990x_attribute_group); + err =3D devm_device_add_group(dev, apds990x_attribute_group); if (err < 0) { - dev_err(&chip->client->dev, "Sysfs registration failed\n"); - goto fail5; + dev_err(dev, "Sysfs registration failed\n"); + goto error_resourses; } =20 - err =3D request_threaded_irq(client->irq, NULL, - apds990x_irq, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW | - IRQF_ONESHOT, - "apds990x", chip); + err =3D devm_request_threaded_irq(dev, client->irq, NULL, apds990x_irq, + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW | + IRQF_ONESHOT, "apds990x", chip); if (err) { - dev_err(&client->dev, "could not get IRQ %d\n", - client->irq); - goto fail6; + dev_err(dev, "could not get IRQ %d\n", client->irq); + goto error_resourses; } + return err; -fail6: - sysfs_remove_group(&chip->client->dev.kobj, - &apds990x_attribute_group[0]); -fail5: +error_resourses: if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); -fail4: - pm_runtime_disable(&client->dev); -fail3: +error_pm: + pm_runtime_disable(dev); +error_regulator: regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); -fail2: - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); -fail1: - kfree(chip); + return err; } =20 @@ -1189,10 +1173,6 @@ static void apds990x_remove(struct i2c_client *clien= t) { struct apds990x_chip *chip =3D i2c_get_clientdata(client); =20 - free_irq(client->irq, chip); - sysfs_remove_group(&chip->client->dev.kobj, - apds990x_attribute_group); - if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); =20 @@ -1201,10 +1181,6 @@ static void apds990x_remove(struct i2c_client *clien= t) =20 pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); - - kfree(chip); } =20 #ifdef CONFIG_PM_SLEEP --=20 2.51.0 From nobody Sat Jun 20 07:11:37 2026 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 A0D343976A1 for ; Sat, 18 Apr 2026 14:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523677; cv=none; b=rbmlvQhWaP7o0aIMeXVITdws1c95Ziw23ZllQRAheDRp6MP/HaoK9ZoBii1yB3tP67JWYxHRwiOUYncnHgEvdFLwaboDRw5LzkttkxgZOdtJJ60HpkgIrIdsEtX6/4z/sZJL1Q7tKyOteDNOZg/0Wcqu2LsJJsT3NzonLlIRiPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523677; c=relaxed/simple; bh=XKtOaV+bu3GvFb00eX45ajrX/DX5a1syVpVsKIHtT+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UFod7XzEkxGpS2DXE+CwNaSmWxIL3lLTj/hI4IhayWeryKKk0650U8fOWnpBQ9bR1XNXclF440C1u83ggyxK6CNE82CEUX5uYePsFvbyi4rODlvbIEbusRAidNXOvs1NL7JfC3LFotvotOdXzTe9VoD17yxszKeo7UO4R1FYmzM= 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=QwHZS1HB; arc=none smtp.client-ip=209.85.208.175 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="QwHZS1HB" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-38e91b06006so13026091fa.2 for ; Sat, 18 Apr 2026 07:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776523671; x=1777128471; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CjixepHmZluQFzutL7IUoBNMtxTYec1nzIsEup2SLc4=; b=QwHZS1HB7y2cHsS0zZaLVw5mgiblgjtZL9OQg4LWZS7YHSOrwTACoGfkc+nBgrTwjJ l0CiPXZhHIQVP+DT5NlNUIOlDX2JhKdQh2rzLfcrPOC2WXuLpYhdaYqFWPRsYAoHI1VF im+iyRR0RFPhr4fH+bjE15Vf84b1sCnHos0710rtGpIygt5d+0T7l6bEYO+g2LpLlUAq YLc2nGAquDJmz4uHAEXiw8g0tqGoADWRJunJe5B5TkyvrKfzybR8Kj/IHGbQDN+d/Bo5 1UgTxWWOmwM0eCz2R3OdS6DCpsseOndxbgeTKsNW32kCv7NM0Xq65ITzu0mvcwhBHV5u 2tCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776523671; x=1777128471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CjixepHmZluQFzutL7IUoBNMtxTYec1nzIsEup2SLc4=; b=Eipw6hEy1aPa2fD5eE7ezxTg+TqOzyADCwlYaGQyr+/fFa7CB8bjctfhbrakstUu15 L/0/i/jmhZWLTkIfe1ZqgK40l1Soy7yWK6lYcNwejN+0KEjEM81QbCqFaENWJMS0enIK /AG1FpEWnT8bzdbF/uLQ7a6On/CMHObf7d3tCO2gywHEISLK6nf3o/VYOtOjMkqB0S9z ulyz9ptYiv89Buo0MAVd/Ymx5crss/+pY8oBoRXkZoQrRnU4KWwcB20rePlJ8ii/WDg2 bU0sm/flAhu0ZHrB7bE5dAfG6fim69t79/gOGMuo/oGhApZQRIownKoLTtx35m/NXqzv UUCg== X-Forwarded-Encrypted: i=1; AFNElJ8nXVO81/WsfXajCTi6S9BC0FYByp2bePGkHhk3ShiaVVH6sQHGvUvwaoCKL+DhDffWtmPDYUGqLY8BUhE=@vger.kernel.org X-Gm-Message-State: AOJu0YwrW7jgybdHQnzgvT8aRRtXFslaGumE0p7IeHq8m1zHb6hqF73R E+ORgTAInrhnCMtL/aPuU32Wt07g4X337wJGxY0TqzDz7VvySu2fJWUn X-Gm-Gg: AeBDieuqErnsNy+0bKDA8osx39kU5pSADi2M+Gw4FAl13V+zxtkU9UJPvYPVUTW8f+5 aIL7AOIZjryQU5npW8d6zgtmcv6Uux9LOA7Pj28A0EFdW9eW0QNK6hqyR6RgB4fb+kVsXfAxlmt W09cH5U0nS2deRQ0BDZVoDW6yd4NLfB+1/nMYaWQoNeMMiFXL9CBlYm5wUbOqifQQIbC7IjTchp 9WkLo1RU4LdO86zvSkkPiOUoOiP5ibkjDgKz3KI/7VtgC92dRiplJmWLPEUM671mabqeNUFVD3O PFR/qZ5/4X32ZnOzeSt2pjUfHg8vo9CH8jqxDd9LDcWTIJeaM1EW/IEEAcFnlwNgOQ6rDhfw+AB mhQefxryxE0YHAbrlodYExhm0ZRTRAeLmERxvPUgg//CHnt2kBbd9GNxDs8JXKLjd0K31yVma/K VWC8mIy5aejwS0vmyiZPOcmA4= X-Received: by 2002:a05:651c:144a:b0:38b:f0f0:e3f7 with SMTP id 38308e7fff4ca-38ec77f4afbmr20680301fa.7.1776523670642; Sat, 18 Apr 2026 07:47:50 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb4f51easm10901001fa.6.2026.04.18.07.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 07:47:49 -0700 (PDT) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Randy Dunlap Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] misc: apds990x: Drop Vled supply Date: Sat, 18 Apr 2026 17:47:14 +0300 Message-ID: <20260418144716.132936-4-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260418144716.132936-1-clamor95@gmail.com> References: <20260418144716.132936-1-clamor95@gmail.com> 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" According to the APDS9900/9901 documentation, this chip has only one supply, VDD; hence, drop the Vled supply. Additionally, supply has been set to lowercase for consistency. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 742ab331a221..264335b581c1 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -113,7 +113,7 @@ struct apds990x_chip { struct apds990x_platform_data *pdata; struct i2c_client *client; struct mutex mutex; /* avoid parallel access */ - struct regulator_bulk_data regs[2]; + struct regulator *vdd_supply; wait_queue_head_t wait; =20 int prox_en; @@ -179,10 +179,6 @@ static const u8 again[] =3D {1, 8, 16, 120}; /* ALS ga= in steps */ static const u16 arates_hz[] =3D {10, 5, 2, 1}; static const u8 apersis[] =3D {1, 2, 4, 5}; =20 -/* Regulators */ -static const char reg_vcc[] =3D "Vdd"; -static const char reg_vled[] =3D "Vled"; - static int apds990x_read_byte(struct apds990x_chip *chip, u8 reg, u8 *data) { struct i2c_client *client =3D chip->client; @@ -597,8 +593,9 @@ static int apds990x_detect(struct apds990x_chip *chip) #ifdef CONFIG_PM static int apds990x_chip_on(struct apds990x_chip *chip) { - int err =3D regulator_bulk_enable(ARRAY_SIZE(chip->regs), - chip->regs); + int err; + + err =3D regulator_enable(chip->vdd_supply); if (err < 0) return err; =20 @@ -615,7 +612,7 @@ static int apds990x_chip_on(struct apds990x_chip *chip) static int apds990x_chip_off(struct apds990x_chip *chip) { apds990x_write_byte(chip, APDS990X_ENABLE, APDS990X_EN_DISABLE_ALL); - regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); + regulator_disable(chip->vdd_supply); return 0; } =20 @@ -1108,14 +1105,12 @@ static int apds990x_probe(struct i2c_client *client) chip->prox_persistence =3D APDS_DEFAULT_PROX_PERS; chip->prox_continuous_mode =3D false; =20 - chip->regs[0].supply =3D reg_vcc; - chip->regs[1].supply =3D reg_vled; - - err =3D devm_regulator_bulk_get(dev, ARRAY_SIZE(chip->regs), chip->regs); - if (err) - return dev_err_probe(dev, err, "failed to get supplies\n"); + chip->vdd_supply =3D devm_regulator_get(dev, "vdd"); + if (IS_ERR(chip->vdd_supply)) + return dev_err_probe(dev, PTR_ERR(chip->vdd_supply), + "failed to get vdd-supply\n"); =20 - err =3D regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); + err =3D regulator_enable(chip->vdd_supply); if (err < 0) return dev_err_probe(dev, err, "cannot enable regulators\n"); =20 @@ -1164,7 +1159,7 @@ static int apds990x_probe(struct i2c_client *client) error_pm: pm_runtime_disable(dev); error_regulator: - regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); + regulator_disable(chip->vdd_supply); =20 return err; } --=20 2.51.0 From nobody Sat Jun 20 07:11:37 2026 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 D653438758B for ; Sat, 18 Apr 2026 14:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523678; cv=none; b=WtRFvOoKagptnGxhVgGHNrenurHmIAdLAGeWWJ91b3pipa3RArBCRdICmXYeUwWZS4pLk2bad302xZ5BpCdKrOJdiCiYQxYC9LGwRuZkE1CRSVU8LWR5liD7iFhWnRuCkMlahrg471+1r3ZqOXRv2rqG56zGgyWocT9Zh/f0+dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523678; c=relaxed/simple; bh=rCQzvUH792A34KGa82QobcsaKhrIVTRQsg+4lXUOtso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ulkLL9ljHgXTcncNts2nuCbO4AcLMnxfvLWWd9eahTTJ9/qrW03xEXHBcfovEBeHpfnBCKJPjhfYOZHHJUHE+JMX7vShU78Z7Ii59WXnZEfmQ7p7kNUR4HU+TFmo1sXx71Cd/wrf+GxHZSGX9jUrKjdy7bw2AustMxJ2trsjRyA= 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=ZSjQpjp5; arc=none smtp.client-ip=209.85.208.175 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="ZSjQpjp5" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-38e8292423fso13654441fa.0 for ; Sat, 18 Apr 2026 07:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776523673; x=1777128473; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T70S8dN9ner/tiva8iQd9tojxAAdiyEdJbrj8X3EImo=; b=ZSjQpjp5Er5v6XDasK6sabopBfrHSd9733dNHoKA+kY7LGZFOY+oZxIF9Vts2q7ERf uu9nynfT286Q+5yKeg/yd6e7/SBCxvJ0SQQX3vZngNWe3MO6xVTYVen57B0YhxEPlZRr /d4ezaMjdihzZUI8KiikJtvxNIe2XySCUtUgTYh0UQ9PiSn8MGKiuWZpwX75PVaiVHYx 3gg3pGgzFk2Vc2awMoExCD52ovnQwNRrZTx9GAYbH3VO2qOJQBo4/P5HxTNnFRbXKM7V GhotQVw7VF3sTnogfg/jBep3zke/yEeLhN+f+ZylDlMS50AYxMGNG79MF1oWp8Bja6Wu o3EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776523673; x=1777128473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=T70S8dN9ner/tiva8iQd9tojxAAdiyEdJbrj8X3EImo=; b=MxIw7LsHbO/guhwjjsTNhxCx7QGIEq9Uu4laHO8yv57Z/ivydNh3npUYInWI7xQpGu HPASPvxjb8kT5RfGD0lozc2wiL8ITlvbU2qfMoBDJXKCEaXY16DgigpCZvcyz3khorki luM2N+J7Zf47ar2mQ5U3jG4l0jMz2OLDnUJoG+u8al0EXVWLW/C5ULQyyBEHekpycF4k idpCcUKN1N3lH8IxwkdPpIT6gek7Fh3s0T2s2uIF37Lj53QKDgu9EAR4Z7SEBe/QY7PQ UfofzmcPmQlOMn+NDz5dvr0uGF4NBWTetk8y2F6/Vl4/+BSTTq5eqH16pZ/5glBo180v RPXw== X-Forwarded-Encrypted: i=1; AFNElJ/9K4/zvaF3tj0IETr/5WKu0jexV/N5fPtkfn/MkNBa7j2KvPa74NyKZQaEmmSvO++7SeaZNT76skJFDEo=@vger.kernel.org X-Gm-Message-State: AOJu0YxlVrep4DupzkRUWQ/Yt/j+P1cl9MAa9gOjlkc+gUbwGV8LLKqN Fe6areG6SOixkLY8trRbr/RH8GoTVteNubgEZhBrCnNCOpEIL5VOtGmU X-Gm-Gg: AeBDieu6tgoZKDePyItgT47qwzHyn/c0UskMcX4wnVpyZWdsShbBwf5sM3Q9BuycGIx 1LcR6hl6ld4L2kywL6HVe9cVjphb17Uu+Eww1wzU8lT1prhPGgFlOS5qpXz10hg03Z6uynpxBdo aMKcr4yGH6a4QcJj+5x1x3yNoWyO1T38K2hnyUomM6buEM3M1VhPnwVH3J0dxjeNe2iApJfTkky Mm2GNHwlbdFdFbz7aLXZFNrZGHEEXQN2bvBAwv4pWniINUyIgDA2jzy90U+btPRa2edBVe+LfSm 6JD445lQt5vp56hkmkjxsh+SGQ7SMPbQRCj3s9cYoXkM6nSqqa9/XoiUmcVMcipOXb3yTFeQb29 d0GGbj8HXLnwqUG9kd4Yd34J2IlwNLCcWVZ+5ADaQMI/Ao1oDlHzWHu8PEAKIlmkVb7O/x0FTJw XsofTpOJFBf42AXAp/oNzRr58= X-Received: by 2002:a05:651c:1056:b0:38a:f5a6:9173 with SMTP id 38308e7fff4ca-38ec7b4aaf8mr14252721fa.27.1776523672748; Sat, 18 Apr 2026 07:47:52 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb4f51easm10901001fa.6.2026.04.18.07.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 07:47:51 -0700 (PDT) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Randy Dunlap Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] misc: apds990x: Convert to use OF bindings Date: Sat, 18 Apr 2026 17:47:15 +0300 Message-ID: <20260418144716.132936-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260418144716.132936-1-clamor95@gmail.com> References: <20260418144716.132936-1-clamor95@gmail.com> 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" Since there are no users of this driver via platform data, remove platform data and switch to using device tree bindings. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 112 +++++++++++++++++-------- include/linux/platform_data/apds990x.h | 65 -------------- 2 files changed, 76 insertions(+), 101 deletions(-) delete mode 100644 include/linux/platform_data/apds990x.h diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 264335b581c1..557c8476ea80 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -12,13 +12,14 @@ #include #include #include +#include #include +#include #include #include #include #include #include -#include =20 /* Register map */ #define APDS990X_ENABLE 0x00 /* Enable of states and interrupts */ @@ -100,6 +101,36 @@ =20 #define APDS990X_LUX_OUTPUT_SCALE 10 =20 +#define APDS_IRLED_CURR_12mA 0x3 +#define APDS_IRLED_CURR_25mA 0x2 +#define APDS_IRLED_CURR_50mA 0x1 +#define APDS_IRLED_CURR_100mA 0x0 + +#define APDS_PARAM_SCALE 4096 + +/** + * struct apds990x_chip_factors - defines effect of the cover window + * @ga: Total glass attenuation + * @cf1: clear channel factor 1 for raw to lux conversion + * @irf1: IR channel factor 1 for raw to lux conversion + * @cf2: clear channel factor 2 for raw to lux conversion + * @irf2: IR channel factor 2 for raw to lux conversion + * @df: device factor for conversion formulas + * + * Structure for tuning ALS calculation to match with environment. + * Values depend on the material above the sensor and the sensor + * itself. If the GA is zero, driver will use uncovered sensor default val= ues + * format: decimal value * APDS_PARAM_SCALE except df which is plain integ= er. + */ +struct apds990x_chip_factors { + int ga; + int cf1; + int irf1; + int cf2; + int irf2; + int df; +}; + /* Reverse chip factors for threshold calculation */ struct reverse_factors { u32 afactor; @@ -110,7 +141,6 @@ struct reverse_factors { }; =20 struct apds990x_chip { - struct apds990x_platform_data *pdata; struct i2c_client *client; struct mutex mutex; /* avoid parallel access */ struct regulator *vdd_supply; @@ -131,6 +161,7 @@ struct apds990x_chip { u8 pgain; u8 pdiode; u8 pdrive; + u8 ppcount; u8 lux_persistence; u8 prox_persistence; =20 @@ -546,7 +577,7 @@ static int apds990x_configure(struct apds990x_chip *chi= p) (chip->lux_persistence << APDS990X_APERS_SHIFT) | (chip->prox_persistence << APDS990X_PPERS_SHIFT)); =20 - apds990x_write_byte(chip, APDS990X_PPCOUNT, chip->pdata->ppcount); + apds990x_write_byte(chip, APDS990X_PPCOUNT, chip->ppcount); =20 /* Start with relatively small gain */ chip->again_meas =3D 1; @@ -1051,6 +1082,7 @@ static int apds990x_probe(struct i2c_client *client) { struct apds990x_chip *chip; struct device *dev =3D &client->dev; + u32 pdrive_ua =3D 100000, ppcount =3D 1; int err; =20 chip =3D devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); @@ -1062,22 +1094,14 @@ static int apds990x_probe(struct i2c_client *client) =20 init_waitqueue_head(&chip->wait); mutex_init(&chip->mutex); - chip->pdata =3D client->dev.platform_data; - - if (chip->pdata =3D=3D NULL) - return dev_err_probe(dev, -EINVAL, "platform data is mandatory\n"); - - if (chip->pdata->cf.ga =3D=3D 0) { - /* set uncovered sensor default parameters */ - chip->cf.ga =3D 1966; /* 0.48 * APDS_PARAM_SCALE */ - chip->cf.cf1 =3D 4096; /* 1.00 * APDS_PARAM_SCALE */ - chip->cf.irf1 =3D 9134; /* 2.23 * APDS_PARAM_SCALE */ - chip->cf.cf2 =3D 2867; /* 0.70 * APDS_PARAM_SCALE */ - chip->cf.irf2 =3D 5816; /* 1.42 * APDS_PARAM_SCALE */ - chip->cf.df =3D 52; - } else { - chip->cf =3D chip->pdata->cf; - } + + /* set uncovered sensor default parameters */ + chip->cf.ga =3D 1966; /* 0.48 * APDS_PARAM_SCALE */ + chip->cf.cf1 =3D 4096; /* 1.00 * APDS_PARAM_SCALE */ + chip->cf.irf1 =3D 9134; /* 2.23 * APDS_PARAM_SCALE */ + chip->cf.cf2 =3D 2867; /* 0.70 * APDS_PARAM_SCALE */ + chip->cf.irf2 =3D 5816; /* 1.42 * APDS_PARAM_SCALE */ + chip->cf.df =3D 52; =20 /* precalculate inverse chip factors for threshold control */ chip->rcf.afactor =3D @@ -1098,13 +1122,35 @@ static int apds990x_probe(struct i2c_client *client) chip->lux_calib =3D APDS_LUX_NEUTRAL_CALIB_VALUE; =20 chip->prox_thres =3D APDS_PROX_DEF_THRES; - chip->pdrive =3D chip->pdata->pdrive; chip->pdiode =3D APDS_PDIODE_IR; chip->pgain =3D APDS_PGAIN_1X; chip->prox_calib =3D APDS_PROX_NEUTRAL_CALIB_VALUE; chip->prox_persistence =3D APDS_DEFAULT_PROX_PERS; chip->prox_continuous_mode =3D false; =20 + err =3D device_property_read_u32(dev, "avago,pdrive-microamp", &pdrive_ua= ); + if (!err) { + switch (pdrive_ua) { + case 12500: + chip->pdrive =3D APDS_IRLED_CURR_12mA; + break; + case 25000: + chip->pdrive =3D APDS_IRLED_CURR_25mA; + break; + case 50000: + chip->pdrive =3D APDS_IRLED_CURR_50mA; + break; + case 100000: + chip->pdrive =3D APDS_IRLED_CURR_100mA; + break; + default: + return -EINVAL; + } + } + + device_property_read_u32(dev, "avago,ppcount", &ppcount); + chip->ppcount =3D ppcount; + chip->vdd_supply =3D devm_regulator_get(dev, "vdd"); if (IS_ERR(chip->vdd_supply)) return dev_err_probe(dev, PTR_ERR(chip->vdd_supply), @@ -1130,18 +1176,10 @@ static int apds990x_probe(struct i2c_client *client) =20 pm_runtime_enable(dev); =20 - if (chip->pdata->setup_resources) { - err =3D chip->pdata->setup_resources(); - if (err) { - err =3D -EINVAL; - goto error_pm; - } - } - err =3D devm_device_add_group(dev, apds990x_attribute_group); if (err < 0) { dev_err(dev, "Sysfs registration failed\n"); - goto error_resourses; + goto error_pm; } =20 err =3D devm_request_threaded_irq(dev, client->irq, NULL, apds990x_irq, @@ -1149,13 +1187,10 @@ static int apds990x_probe(struct i2c_client *client) IRQF_ONESHOT, "apds990x", chip); if (err) { dev_err(dev, "could not get IRQ %d\n", client->irq); - goto error_resourses; + goto error_pm; } =20 return err; -error_resourses: - if (chip->pdata && chip->pdata->release_resources) - chip->pdata->release_resources(); error_pm: pm_runtime_disable(dev); error_regulator: @@ -1168,9 +1203,6 @@ static void apds990x_remove(struct i2c_client *client) { struct apds990x_chip *chip =3D i2c_get_clientdata(client); =20 - if (chip->pdata && chip->pdata->release_resources) - chip->pdata->release_resources(); - if (!pm_runtime_suspended(&client->dev)) apds990x_chip_off(chip); =20 @@ -1224,6 +1256,13 @@ static int apds990x_runtime_resume(struct device *de= v) =20 #endif =20 +static const struct of_device_id apds990x_of_match[] =3D { + { .compatible =3D "avago,apds9900" }, + { .compatible =3D "avago,apds9901" }, + { } +}; +MODULE_DEVICE_TABLE(of, apds990x_of_match); + static const struct i2c_device_id apds990x_id[] =3D { { "apds990x" }, {} @@ -1242,6 +1281,7 @@ static struct i2c_driver apds990x_driver =3D { .driver =3D { .name =3D "apds990x", .pm =3D &apds990x_pm_ops, + .of_match_table =3D apds990x_of_match, }, .probe =3D apds990x_probe, .remove =3D apds990x_remove, diff --git a/include/linux/platform_data/apds990x.h b/include/linux/platfor= m_data/apds990x.h deleted file mode 100644 index 37684f68c04f..000000000000 --- a/include/linux/platform_data/apds990x.h +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * This file is part of the APDS990x sensor driver. - * Chip is combined proximity and ambient light sensor. - * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Samu Onkalo - */ - -#ifndef __APDS990X_H__ -#define __APDS990X_H__ - - -#define APDS_IRLED_CURR_12mA 0x3 -#define APDS_IRLED_CURR_25mA 0x2 -#define APDS_IRLED_CURR_50mA 0x1 -#define APDS_IRLED_CURR_100mA 0x0 - -/** - * struct apds990x_chip_factors - defines effect of the cover window - * @ga: Total glass attenuation - * @cf1: clear channel factor 1 for raw to lux conversion - * @irf1: IR channel factor 1 for raw to lux conversion - * @cf2: clear channel factor 2 for raw to lux conversion - * @irf2: IR channel factor 2 for raw to lux conversion - * @df: device factor for conversion formulas - * - * Structure for tuning ALS calculation to match with environment. - * Values depend on the material above the sensor and the sensor - * itself. If the GA is zero, driver will use uncovered sensor default val= ues - * format: decimal value * APDS_PARAM_SCALE except df which is plain integ= er. - */ -struct apds990x_chip_factors { - int ga; - int cf1; - int irf1; - int cf2; - int irf2; - int df; -}; -#define APDS_PARAM_SCALE 4096 - -/** - * struct apds990x_platform_data - platform data for apsd990x.c driver - * @cf: chip factor data - * @pdrive: IR-led driving current - * @ppcount: number of IR pulses used for proximity estimation - * @setup_resources: interrupt line setup call back function - * @release_resources: interrupt line release call back function - * - * Proximity detection result depends heavily on correct ppcount, pdrive - * and cover window. - * - */ - -struct apds990x_platform_data { - struct apds990x_chip_factors cf; - u8 pdrive; - u8 ppcount; - int (*setup_resources)(void); - int (*release_resources)(void); -}; - -#endif --=20 2.51.0 From nobody Sat Jun 20 07:11:37 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 58692373BFC for ; Sat, 18 Apr 2026 14:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523677; cv=none; b=AtGv5dJlqVnbJeSSldwkmF3rGZG5h9nhAFtzG4jxzEhAH84NTfPvy/UkRkhLgDSwSxj5MM+0bj0dlE7Y0IAeUCgzuAv2ae+FHHIJzAILokJOMH4KdyIMu0vTjZxQ681A3GAcOWJkVvId/bL/OHVReuFRTIRvrRAbe2wSCG0NFaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776523677; c=relaxed/simple; bh=l6nManMeR7Jg1MhkwUdhEH7FHLLqb5lCwS/P/91//S4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o0K4a1YH2EhV1hK+CR0JaDuWFomFDX4FycbcwLckOnHqxpmvH6XuYUAEw1AGp+Vrbv301noX7hgF4AsPhNaXaSW3Wq4IgRxJALe+Qe97oWVNgRxS9Imb1PL7RG34XEYIPBkFlRC8wqJ4gJPHlrqfcRagNJaetHoT206T8d03rq0= 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=HwX/3Dpa; arc=none smtp.client-ip=209.85.167.49 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="HwX/3Dpa" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-59e5aa4ca41so1606287e87.2 for ; Sat, 18 Apr 2026 07:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776523674; x=1777128474; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BjNK/Cg8+mI3iZeqCtPR1pHEgjWGhrHjIwJvfOxtDFI=; b=HwX/3DpampM+CMwhED1aecYg/VaICmqO9bw106y9Vw42qmuqKkHg/aZ3eTfmRy6UxS EdYjzv44WxovYglJ+muO6qBfy/bv1qEPgU2urnuM3pwWO7hjhjIMaoKHy1COtqH7SBoH EAToDzRq4edXme7kdhxYP30rwASQ+eo8T3qMbctuMTk4OI4VKn//6Uysey0//aEMZx7b lRBgKcAuRMm+e2GJIh/gL2Xh5K3YzpbI6bLaGlmSAW5Y6mjlcu03StySMyce9pG/DNVe YN5WysbE8B1Gw+IjU7UrXY3pWs5dcGY7xxCjC0EA+BtV+2DxIwhb2Gtbaib3Po2olVec dCYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776523674; x=1777128474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BjNK/Cg8+mI3iZeqCtPR1pHEgjWGhrHjIwJvfOxtDFI=; b=Bk5iQ85P82E056iOADPYy5B3Zx7s2tIXoX2X1F8LwoXV2wi8vRb1ZRjhABvz+FvuHr UETGoFS18ZPj5XL/LzE5i4nOaoAun1uK66cMCVGDlhHq/WnwOPnA1teACjjdgCwZo5jW p1GQb/Nl3bA2Dno/AD7nTlEwHYIrJmtEFj0gDIG4XFx4ARQFYR+Jg/1JT6AbVKHL154U lRFM+e/p10KxWemcpRxR8qgI53Ql5Je07bFx/7fIuqdrsGotx6/+sQcrGPyuLuQGOlo2 fMX14YCe+AoCLhwNAFJIycbVYRE4WDelig2SGuzXeFU3xnUMf7NJeb6LyLpnzOz6nfQT 1MhA== X-Forwarded-Encrypted: i=1; AFNElJ9KcWL1uS7Rob5F46WJ4tJGzX4Yr1AqIsLSlvrqHvTIdqyYpySjSF4rvS7+Pc0UHV+0AnLZ5I70iSB9dqQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5G8Z3ol/BIiWflDHG5UTf8uJRURJX5bbqMT6tWM0TQCUWQo3s rCuVkplsmj3zW6Fee00/yfsSEyJYReTC/rRDvre80Tn21GE8A9DreEJ9 X-Gm-Gg: AeBDiesKmTg9hgrkr3VLymWI4+bf2/etQrkusuuW6m9bn6mfS1bl+id+dcU1ySO2MYM Arw2uc0QkzgHY9nHjJrR1NdLfXFFMDjyMPABxOGLOIqhRC7y075VX1+pnqb7lyvhuSHtfpqj8kO 75OZMzDDA7mVHIxTHvqhg3MgvaAMwtMXU4pyxdcJxP0xqoB7Z5QbbcqVs1XGZrjNXWDo75+TZg8 IRrGaJO6swqLcreTB1rFWlglXySF+oaZczw9n172V02xJLM5bS7U3ZmwNyDn44AUoW+2/py5pON KJs7UfXrOWAZ8wAM08Pwrnw+rERbk1i6vFRtLfc+ErdEI2ydK2fufyNEvaSMEcpHI5pH+g/DNyY ky1VV2D22TOm3mkQPMu6but3jngiVWkFXiIisbs+4rdFkiNuqgX8J1NmdShZKeH7c5fMWxccRGM fWUJPKzfWB7+0Ak8FkeYLXlKw= X-Received: by 2002:a05:6512:1242:b0:5a4:640:9f07 with SMTP id 2adb3069b0e04-5a4172e7b8bmr2429015e87.31.1776523674389; Sat, 18 Apr 2026 07:47:54 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb4f51easm10901001fa.6.2026.04.18.07.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2026 07:47:53 -0700 (PDT) From: Svyatoslav Ryhel To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Arnd Bergmann , Greg Kroah-Hartman , Svyatoslav Ryhel , Randy Dunlap Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] misc: apds990x: Drop IRQF_TRIGGER_LOW trigger Date: Sat, 18 Apr 2026 17:47:16 +0300 Message-ID: <20260418144716.132936-6-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260418144716.132936-1-clamor95@gmail.com> References: <20260418144716.132936-1-clamor95@gmail.com> 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" Predefined IRQF_TRIGGER_LOW causes a conflict when setting triggers in the device tree node. Remove IRQF_TRIGGER_LOW from the interrupt; it can be specified in the device tree if needed. Signed-off-by: Svyatoslav Ryhel --- drivers/misc/apds990x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 557c8476ea80..51037cdc2c47 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -1183,8 +1183,8 @@ static int apds990x_probe(struct i2c_client *client) } =20 err =3D devm_request_threaded_irq(dev, client->irq, NULL, apds990x_irq, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW | - IRQF_ONESHOT, "apds990x", chip); + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "apds990x", chip); if (err) { dev_err(dev, "could not get IRQ %d\n", client->irq); goto error_pm; --=20 2.51.0