summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorxingtong.wu <xingtong.wu@siemens.com>2023-07-28 10:36:51 +0200
committerHans de Goede <hdegoede@redhat.com>2023-07-31 13:13:48 +0200
commitd0563dd3345f7d6feb950204a3480f169d93a659 (patch)
treefe30a748e727d8737c7787c1d6cf1ae2a25d09ca /drivers/platform
parent9bc289b8123ce149bc4088dbe74300057fa244c3 (diff)
platform/x86/siemens: simatic-ipc-batt: fix bat reading in BX_21A
There was a case missing in a switch statement which lead to that model not actually reading the GPIOs. That switch statement got simplified now. Additionally on that model we need to initialize one pin differently. As a drive-by finding also add a missing newline. Fixes: 917f54340794 ("platform/x86: simatic-ipc: add CMOS battery monitoring") Reported-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: xingtong.wu <xingtong.wu@siemens.com> Signed-off-by: Henning Schild <henning.schild@siemens.com> Link: https://lore.kernel.org/r/20230728083651.19747-1-henning.schild@siemens.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/siemens/simatic-ipc-batt.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/platform/x86/siemens/simatic-ipc-batt.c b/drivers/platform/x86/siemens/simatic-ipc-batt.c
index d2791ff84f23..e34417ca9e13 100644
--- a/drivers/platform/x86/siemens/simatic-ipc-batt.c
+++ b/drivers/platform/x86/siemens/simatic-ipc-batt.c
@@ -92,19 +92,14 @@ static long simatic_ipc_batt_read_value(struct device *dev)
next_update = priv.last_updated_jiffies + msecs_to_jiffies(BATT_DELAY_MS);
if (time_after(jiffies, next_update) || !priv.last_updated_jiffies) {
- switch (priv.devmode) {
- case SIMATIC_IPC_DEVICE_127E:
- case SIMATIC_IPC_DEVICE_227G:
- case SIMATIC_IPC_DEVICE_BX_39A:
- priv.current_state = simatic_ipc_batt_read_gpio();
- break;
- case SIMATIC_IPC_DEVICE_227E:
+ if (priv.devmode == SIMATIC_IPC_DEVICE_227E)
priv.current_state = simatic_ipc_batt_read_io(dev);
- break;
- }
+ else
+ priv.current_state = simatic_ipc_batt_read_gpio();
+
priv.last_updated_jiffies = jiffies;
if (priv.current_state < SIMATIC_IPC_BATT_LEVEL_FULL)
- dev_warn(dev, "CMOS battery needs to be replaced.");
+ dev_warn(dev, "CMOS battery needs to be replaced.\n");
}
return priv.current_state;
@@ -163,6 +158,7 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
struct simatic_ipc_platform *plat;
struct device *dev = &pdev->dev;
struct device *hwmon_dev;
+ unsigned long flags;
int err;
plat = pdev->dev.platform_data;
@@ -196,7 +192,10 @@ int simatic_ipc_batt_probe(struct platform_device *pdev, struct gpiod_lookup_tab
}
if (table->table[2].key) {
- priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, GPIOD_OUT_HIGH);
+ flags = GPIOD_OUT_HIGH;
+ if (priv.devmode == SIMATIC_IPC_DEVICE_BX_21A)
+ flags = GPIOD_OUT_LOW;
+ priv.gpios[2] = devm_gpiod_get_index(dev, "CMOSBattery meter", 2, flags);
if (IS_ERR(priv.gpios[2])) {
err = PTR_ERR(priv.gpios[1]);
priv.gpios[2] = NULL;