From 244b2c5ca8b14627e4a17755e5922221e121c771 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Wed, 09 Oct 2024 06:15:07 +0000
Subject: [PATCH] change system file
---
kernel/drivers/power/supply/gpio-charger.c | 58 +++-------------------------------------------------------
1 files changed, 3 insertions(+), 55 deletions(-)
diff --git a/kernel/drivers/power/supply/gpio-charger.c b/kernel/drivers/power/supply/gpio-charger.c
index a2428d9..68212b3 100644
--- a/kernel/drivers/power/supply/gpio-charger.c
+++ b/kernel/drivers/power/supply/gpio-charger.c
@@ -1,19 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
* Driver for chargers which report their online status through a GPIO pin
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
*/
-#include <linux/extcon-provider.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/interrupt.h>
@@ -40,13 +30,11 @@
struct power_supply *charger;
struct power_supply_desc charger_desc;
- struct extcon_dev *edev;
struct gpio_desc *gpiod;
struct gpio_desc *charge_status;
struct gpio_descs *current_limit_gpios;
struct gpio_mapping *current_limit_map;
- struct notifier_block cable_cg_nb;
u32 current_limit_map_size;
u32 charge_current_limit;
};
@@ -249,22 +237,6 @@
return 0;
}
-static int gpio_charger_evt_notifier(struct notifier_block *nb,
- unsigned long event, void *ptr)
-{
- int limit_ua;
- struct gpio_charger *charger =
- container_of(nb, struct gpio_charger, cable_cg_nb);
-
- limit_ua = charger->current_limit_map[charger->current_limit_map_size - 1].limit_ua;
- if (extcon_get_state(charger->edev, EXTCON_CHG_USB_DCP) > 0)
- limit_ua = charger->current_limit_map[0].limit_ua;
-
- set_charge_current_limit(charger, limit_ua);
-
- return NOTIFY_DONE;
-}
-
/*
* The entries will be overwritten by driver's probe routine depending
* on the available features. This list ensures, that the array is big
@@ -280,7 +252,6 @@
{
struct device *dev = &pdev->dev;
const struct gpio_charger_platform_data *pdata = dev->platform_data;
- struct extcon_dev *edev;
struct power_supply_config psy_cfg = {};
struct gpio_charger *gpio_charger;
struct power_supply_desc *charger_desc;
@@ -299,27 +270,6 @@
return -ENOMEM;
gpio_charger->dev = dev;
- if (of_property_read_bool(dev->of_node, "extcon")) {
- edev = extcon_get_edev_by_phandle(dev, 0);
- if (IS_ERR(edev)) {
- if (PTR_ERR(edev) != -EPROBE_DEFER)
- dev_err(dev, "Invalid or missing extcon\n");
- return PTR_ERR(edev);
- }
- gpio_charger->edev = edev;
- gpio_charger->cable_cg_nb.notifier_call =
- gpio_charger_evt_notifier;
- ret = devm_extcon_register_notifier(dev, edev,
- EXTCON_CHG_USB_DCP,
- &gpio_charger->cable_cg_nb);
- if (ret) {
- dev_err(dev, "failed to register notifier for CDP\n");
- return ret;
- }
- } else {
- gpio_charger->edev = ERR_PTR(-ENODEV);
- }
-
/*
* This will fetch a GPIO descriptor from device tree, ACPI or
* boardfile descriptor tables. It's good to try this first.
@@ -327,10 +277,8 @@
gpio_charger->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN);
if (IS_ERR(gpio_charger->gpiod)) {
/* Just try again if this happens */
- if (PTR_ERR(gpio_charger->gpiod) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- dev_err(dev, "error getting GPIO descriptor\n");
- return PTR_ERR(gpio_charger->gpiod);
+ return dev_err_probe(dev, PTR_ERR(gpio_charger->gpiod),
+ "error getting GPIO descriptor\n");
}
if (gpio_charger->gpiod) {
--
Gitblit v1.6.2