From patchwork Sun Nov 10 19:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13870038 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 EA7CE146A79; Sun, 10 Nov 2024 19:24:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731266671; cv=none; b=Zb8eo/RbtcNiWdweRZlrIdiVHOSPXrVFhms1k/WWt7RZxg7ENnrDnbN3lw3P2cVrcFyDROCdKK7tEi8G9FxyyGDLmhVPy4Beywly/6aScJ62jGEgB3ShnzkWpAdx/mX0ZvKHuEJlLD+c/dMrMNWE4LeHOa3yD0+vMlxH84/V2qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731266671; c=relaxed/simple; bh=gES/YI8J+uY43qFcYFJFQDdZCjIIvFKdVHt8Cx7j4Ks=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K6R29HxcZn+z5pamznpxDlQlaXZ57nXYCNPYoZvEd/ysGFRapEfFeii7e1/0tBp8GKTrHqxTea6QPUlE+XiMJA0NS9I4ESd1rLjmPJW6cEdgFjVK5goDQUJYOXNkcN9a1gODlhGmxN53AJUM8U4ZBqvrFkUsk91PyRsMO9/i5dY= 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=acSfFGVf; arc=none smtp.client-ip=209.85.128.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="acSfFGVf" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4316cce103dso48645655e9.3; Sun, 10 Nov 2024 11:24:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731266668; x=1731871468; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=n7VSA4VpES10XaA8gB1WdvZsXgmDNfsDCe5+S5WIIkA=; b=acSfFGVfuzr3frauGhqb49l3H7Rg1Ar2YtBjNyT4te41f1VfFzv6vaOcuri92aYSvd hDxTm7hmhrankWp9G2uzuWSrsNHsnCk9wqkABZltbJ8HAsGIYHti6XEF+pQ6tXowv5+A imUfQD8/EgGFj3HWkDCaZOT1ba7Gzxpg42CIY08OPao8Yep8rgKtS2j6AdlKneESMbkM ba7SOrGG4zymySU1PaTqvuFF5qwQ6lYCShksc6vacGjz8tT0tB0eQDDZT0R3R5oNZK0h xGiiruSLIjH9m/PtLOn+dvB9OW62QZCtydwvZyHjoFSj8LjK0GF1hMQuV2u08ikvOyeF vatQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731266668; x=1731871468; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n7VSA4VpES10XaA8gB1WdvZsXgmDNfsDCe5+S5WIIkA=; b=Qc16OrsuxzU0R5OK+DgSkCYIZ8bYPel6BF12hguhO3n//L/tFXRxc0A2gHgUIdYY/z F/AX4HxUr62SmJh+HczZxyXLE8A0mwk6nfxmLFER1WBdSTtQovWyn7dLCdLFeRQleI3o RPOTRlapt+Z7JungUClmY6mCD6LCy8MXseTZ2y1T7myhpM/VTMX8x2Y/8H490Tmvn7G4 OiQLYNHdDmBMb8pNkxK5d+I4qrRRVdsWoBJjom09FUYPkEKfRZ0AwbLNkm8/NKkWntZO PoEAh3+4AdRU6aEyapoWkFfwic3jPQJT1PED8yfOr7MMh2FDTJuBvizOj7d3blJSZsi+ hj5w== X-Forwarded-Encrypted: i=1; AJvYcCU320BUkOixURxRqRXvpsuB4EdoJkjJUh5DIHyLuumzz5sM9vEy11tMVEFgPw6EW1EP8t4YCXoGRsy5@vger.kernel.org, AJvYcCVqUhvIzSqp7zf9BAlg0bu4jvqpV2IJc9OiGea8NwYC2qwsmYfUYDJubVJyIoObpFaj8Hlrsy8NnhI0+Y2K@vger.kernel.org, AJvYcCWNB8Jn3+8FEC/dPXfnUtKJ+McexPfGUmZJBSGnUAospFFhdPj12PNhW1uny3yE5yyji9R+RuQFsUxgiiBYBQ==@vger.kernel.org, AJvYcCXtdK/CM1SDp7dS2b2vsv1AXwBI9mWT4tTENMaOOjOu/FbQhc/HLA+e2WZO2Dy0segqzLI0R/jGyVpj0GdM0bNXSKI=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ3nJzfiGIO8CtqfVjZhfh8Mhgv6PHIFCfRzwn5UVd+1hU0p6o C1Y07OGbjSOpg9PgJeldjUdM28rjKjxe/qOz69xeNWbrkFFFFdCJ X-Google-Smtp-Source: AGHT+IGgpSw3jllLpv9qQZg4A+baIMwrCRGNX/rDvc376OiGzFy2u/Lnf48/wvV7+Plv5EMw7gqc9g== X-Received: by 2002:a5d:6c66:0:b0:37d:47e0:45fb with SMTP id ffacd0b85a97d-381f186c5f2mr11167988f8f.21.1731266668020; Sun, 10 Nov 2024 11:24:28 -0800 (PST) Received: from [127.0.1.1] (leased-line-46-53-189-50.telecom.by. [46.53.189.50]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-a9ee0e0fabesm502497666b.174.2024.11.10.11.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 11:24:27 -0800 (PST) From: Dzmitry Sankouski Date: Sun, 10 Nov 2024 22:24:15 +0300 Subject: [PATCH v2 1/2] power: supply: max17042: make interrupt shared Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241108-b4-max17042-v2-1-f058f7a16bab@gmail.com> References: <20241108-b4-max17042-v2-0-f058f7a16bab@gmail.com> In-Reply-To: <20241108-b4-max17042-v2-0-f058f7a16bab@gmail.com> To: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Sebastian Reichel , Rob Herring , Conor Dooley , Alim Akhtar , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Bjorn Andersson , Konrad Dybcio Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731266662; l=1055; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=gES/YI8J+uY43qFcYFJFQDdZCjIIvFKdVHt8Cx7j4Ks=; b=hkNy7+sERWKdTJVRRUXl6kSD0hutXgVSx9H34Jeil05Y2fuKUhG/CScfxoHg1ESGkG6jYCRBA rN9iIrmtHkCCHftg66YAeKHeBlQNA7x7LKlJkd0nxvrukflRvAwcT+L X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Fuelgauge blocks often are incorporated in bigger chip, which may use only 1 line for interrupts. Make interrupt shared. Signed-off-by: Dzmitry Sankouski --- drivers/power/supply/max17042_battery.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 496c3e1f2ee6..99bf6915aa23 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1103,14 +1103,7 @@ static int max17042_probe(struct i2c_client *client) } if (client->irq) { - unsigned int flags = IRQF_ONESHOT; - - /* - * On ACPI systems the IRQ may be handled by ACPI-event code, - * so we need to share (if the ACPI code is willing to share). - */ - if (acpi_id) - flags |= IRQF_SHARED | IRQF_PROBE_SHARED; + unsigned int flags = IRQF_ONESHOT | IRQF_SHARED | IRQF_PROBE_SHARED; ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, From patchwork Sun Nov 10 19:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13870039 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 073BD155325; Sun, 10 Nov 2024 19:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731266674; cv=none; b=DcRXwB2DqZ3RsppWsmy8UAdhXNqTZzQyEwMog12054AXMlLyaJh63sGDJQUlcbjFLDcMtdRQumLER6nRkXKRtHKDBa2vpxo7WgWdRYDO1HwU9LHhBdfkVSiSp34DXoANFVfOP3fYLTK7z9H+bCAtv64gdoeN3k6QsweIw1z3d7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731266674; c=relaxed/simple; bh=U4A1URsY+DSB9fqZhsXbXU4iN6/BssEpg8gHHdYuWhI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FLKgIbDMwqElIM9F+DdU7hg8Ey95jNficMLrl7yBaLTZedAhtdgBhIow3w/X6uIgubFH5OdPFUBc+RGJDJV8PgJ6yXB5Rj5W4E3A75LXPoFXwKAzwgUeMpbJuxNOaR1CnUarUEEpddcVgFxB3aUqQDaHI1/pkG5IgWKE/NQIu8U= 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=HHhaP79e; arc=none smtp.client-ip=209.85.218.43 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="HHhaP79e" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a99f646ff1bso595165166b.2; Sun, 10 Nov 2024 11:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731266671; x=1731871471; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QzjTpF4vcCvC+88m4NTYCvpBKv5iwpeXsY67V7asRZs=; b=HHhaP79eLvp/+H5nqvVLvH8kqt2mE0wHRClVRnaVTd/z9Fdvb1rz3Yqb02z5QpOXGj oHOFWYvKcEhkCdxy3GYYHdrnfw495Dm6erxdXKbmFpU9Cm7UooNdIpXOTzltt9T5Oo66 /3zfpl9lBnKDlxftfYz6qG5FewNOaaPr15b/qq9+3KAwg/abff/kiFdH8xCdfBWNhuEW eKDbpR9sd7wzUDu4wSqlcNSZz1HShIZHVf2vz2NuaZrNzxGVhXaWGjLcvjd7XX7F0xbI vaQBg+wT1HuGTPAYGls/j+0crGD/MTSGEF4KouKp7U2DeXXZDkDTA3Hr1oBjwbBveViN EAFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731266671; x=1731871471; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QzjTpF4vcCvC+88m4NTYCvpBKv5iwpeXsY67V7asRZs=; b=KJMSEP5dHxwdBZ0BIrLDIc3BCCLRFAvqxuN9/8V3RE240s/Ct0pT3EoE/EwukROk9q /3xaTy9C6g4DazNAa+mLbmK8GW7S/eMq+aV/luZnG/EeTgMK2ZzA97vee8JvHabDmsCu YZpSYJocx3KENQY8hpqLrSFYr5EScErnM0O4Gc2yglfBN3DfPmPTcZAX40G15LtleFdj akBLZ7dVxcrltjDT3agQD1UBc8cnhUgBWLNWzZvTP31kW1dFmYobcfqQ2OiP1QTAOPo0 yxLg6qzF9QO6muo7f54lb8xG5xgFUxYls7tYSJ57u22pRjy5XkNyCkNLjRYvpWdRH3Lf Ta+w== X-Forwarded-Encrypted: i=1; AJvYcCUBTtS6yKf68j85YvNLhGYMOlssBXpKE6Hr5ijwv8CQF+o/ObpnPluylc5+mM+RPEvdL7DjozCTH9YC7RNq@vger.kernel.org, AJvYcCWPjQbRWeMsjbZbxF0j1Ugt375ITSfo3z9KGwD3/hx98dreKHf0Co5nmBdSO7YRmtcvDN+JLHcjql4j@vger.kernel.org, AJvYcCWZ4ZpB46gBzHiuHMrR90HCsJJnMV3Zo1tTzBmAELFcvM2wwmP+MqAvmDnapa0tcx+6D6qR3kTpGueNy9FID3qrcys=@vger.kernel.org, AJvYcCXlO/hMZiWJVYpLkvZiwiychsh7ZhEjk7QdfYE9b7bnptUO0wYZGrZwgTnMLstdYlM/l9RhyVmpXhuBDYMK3g==@vger.kernel.org X-Gm-Message-State: AOJu0Yx7unFqiPFS8pHrjVLXb5KZ4kz7Ud+NZGBr08JTUKWdhGTBBJxb MmKmiaDPabIVZnwwi9jtLWWwfQY1xMN4lbxcpsqRKG1KeIpSHoWI X-Google-Smtp-Source: AGHT+IFHsrzKAH1JXGqmrjEG47YYUuWxOy0DeShOLNpqUqSJjuxWTT1PZUGZb3HouVX3vdnd7BOhRw== X-Received: by 2002:a17:907:7f28:b0:a9a:5cf8:9e40 with SMTP id a640c23a62f3a-a9eeff10a14mr923178466b.24.1731266670951; Sun, 10 Nov 2024 11:24:30 -0800 (PST) Received: from [127.0.1.1] (leased-line-46-53-189-50.telecom.by. [46.53.189.50]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-a9ee0e0fabesm502497666b.174.2024.11.10.11.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 11:24:29 -0800 (PST) From: Dzmitry Sankouski Date: Sun, 10 Nov 2024 22:24:16 +0300 Subject: [PATCH v2 2/2] power: supply: max17042: add platform driver variant Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241108-b4-max17042-v2-2-f058f7a16bab@gmail.com> References: <20241108-b4-max17042-v2-0-f058f7a16bab@gmail.com> In-Reply-To: <20241108-b4-max17042-v2-0-f058f7a16bab@gmail.com> To: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Sebastian Reichel , Rob Herring , Conor Dooley , Alim Akhtar , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Bjorn Andersson , Konrad Dybcio Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, imx@lists.linux.dev, linux-arm-msm@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731266662; l=5546; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=U4A1URsY+DSB9fqZhsXbXU4iN6/BssEpg8gHHdYuWhI=; b=swSnXIKrCHvZ5yseK48cwBu0mSP/TUGzwXb8VhRn0lHC1PwRDPUPLDuPb9x3Y5JunOH2lOS9s 2asjCJJ555aCA3CYUHrWF0g0UhPt+3BUGGw3zNgbvGaWX3mirK5TGs9 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Maxim PMICs may include fuel gauge with additional features, which is out of single Linux power supply driver scope. For example, in max77705 PMIC fuelgauge has additional registers, like IIN_REG, VSYS_REG, ISYS_REG. Those needed to measure PMIC input current, system voltage and current respectively. Those measurements cannot be bound to any of fuelgauge properties. The solution here add and option to use max17042 driver as a MFD sub device, thus allowing any additional functionality be implemented as another sub device. This will help to reduce code duplication in MFD fuel gauge drivers. Signed-off-by: Dzmitry Sankouski --- drivers/power/supply/max17042_battery.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 99bf6915aa23..e78c177802db 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1029,13 +1030,12 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = { .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, }; -static int max17042_probe(struct i2c_client *client) +static int max17042_probe(struct i2c_client *client, enum max170xx_chip_type chip_type) { - const struct i2c_device_id *id = i2c_client_get_device_id(client); + pr_info("do probe!\n"); struct i2c_adapter *adapter = client->adapter; const struct power_supply_desc *max17042_desc = &max17042_psy_desc; struct power_supply_config psy_cfg = {}; - const struct acpi_device_id *acpi_id = NULL; struct device *dev = &client->dev; struct max17042_chip *chip; int ret; @@ -1050,15 +1050,6 @@ static int max17042_probe(struct i2c_client *client) return -ENOMEM; chip->client = client; - if (id) { - chip->chip_type = id->driver_data; - } else { - acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); - if (!acpi_id) - return -ENODEV; - - chip->chip_type = acpi_id->driver_data; - } chip->regmap = devm_regmap_init_i2c(client, &max17042_regmap_config); if (IS_ERR(chip->regmap)) { dev_err(&client->dev, "Failed to initialize regmap\n"); @@ -1139,6 +1130,40 @@ static int max17042_probe(struct i2c_client *client) return 0; } +static int max17042_i2c_probe(struct i2c_client *client) +{ + pr_info("i2c probe!\n"); + const struct i2c_device_id *id = i2c_client_get_device_id(client); + const struct acpi_device_id *acpi_id = NULL; + struct device *dev = &client->dev; + enum max170xx_chip_type chip_type; + + if (id) { + chip_type = id->driver_data; + } else { + acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!acpi_id) + return -ENODEV; + + chip_type = acpi_id->driver_data; + } + + return max17042_probe(client, chip_type); +} + + +static int max17042_platform_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct i2c_client *i2c = dev_get_platdata(dev); + const struct platform_device_id *id = platform_get_device_id(pdev); + + if (!i2c) + return -EINVAL; + + return max17042_probe(i2c, id->driver_data); +} + #ifdef CONFIG_PM_SLEEP static int max17042_suspend(struct device *dev) { @@ -1204,6 +1229,16 @@ static const struct i2c_device_id max17042_id[] = { }; MODULE_DEVICE_TABLE(i2c, max17042_id); +static const struct platform_device_id max17042_platform_id[] = { + { "max17042", MAXIM_DEVICE_TYPE_MAX17042 }, + { "max17047", MAXIM_DEVICE_TYPE_MAX17047 }, + { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, + { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, + { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, + { } +}; +MODULE_DEVICE_TABLE(platform, max17042_platform_id); + static struct i2c_driver max17042_i2c_driver = { .driver = { .name = "max17042", @@ -1211,10 +1246,44 @@ static struct i2c_driver max17042_i2c_driver = { .of_match_table = of_match_ptr(max17042_dt_match), .pm = &max17042_pm_ops, }, - .probe = max17042_probe, + .probe = max17042_i2c_probe, .id_table = max17042_id, }; -module_i2c_driver(max17042_i2c_driver); + +static struct platform_driver max17042_platform_driver = { + .driver = { + .name = "max17042", + .acpi_match_table = ACPI_PTR(max17042_acpi_match), + .of_match_table = of_match_ptr(max17042_dt_match), + .pm = &max17042_pm_ops, + }, + .probe = max17042_platform_probe, + .id_table = max17042_platform_id, +}; + +static int __init __driver_max17042_platform_init(void) +{ + int ret = 0; + + ret = platform_driver_register(&max17042_platform_driver); + + if (ret) { + platform_driver_unregister(&max17042_platform_driver); + return ret; + } + + ret = i2c_add_driver(&max17042_i2c_driver); + + return ret; +} +module_init(__driver_max17042_platform_init); + +static void __exit __driver_max17042_platform_exit(void) +{ + i2c_del_driver(&max17042_i2c_driver); + platform_driver_unregister(&max17042_platform_driver); +} +module_exit(__driver_max17042_platform_exit); MODULE_AUTHOR("MyungJoo Ham "); MODULE_DESCRIPTION("MAX17042 Fuel Gauge");