w1: gpio: Some cleanup and simplifiction
v2 cover w1: gpio: Some cleanup and simplifiction
Hello,
v1 is available at
https://lore.kernel.org/r/[email protected].
The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next
Best regards
Uwe
Uwe Kleine-König (3):
w1: gpio: Don't use platform data for driver data
w1: gpio: Drop unused enable_external_pullup from driver data
w1: gpio: rename pointer to driver data from pdata to ddata
drivers/w1/masters/w1-gpio.c | 118 +++++++++++++---------------------- include/linux/w1-gpio.h | 22 ------- 2 files changed, 42 insertions(+), 98 deletions(-) delete mode 100644 include/linux/w1-gpio.h
base-commit: 629a3b49f3f957e975253c54846090b8d5ed2e9b
Signature · 1 line
2.42.0
PATCH v2 1/3 w1: gpio: Don't use platform data for driver data
struct device's .platform_data isn't for drivers to write to. For driver-specific data there is .driver_data instead.
As there is no in-tree platform that provides w1_gpio_platform_data, drop the include file and replace it by a local struct w1_gpio_ddata.
--- drivers/w1/masters/w1-gpio.c | 56 +++++++++++++++++------------------- include/linux/w1-gpio.h | 22 -------------- 2 files changed, 27 insertions(+), 51 deletions(-) delete mode 100644 include/linux/w1-gpio.h
drivers/w1/masters/w1-gpio.c +27 -29
@@ -9,7 +9,6 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> -#include <linux/w1-gpio.h> #include <linux/gpio/consumer.h> #include <linux/of_platform.h> #include <linux/err.h>
@@ -18,9 +17,16 @@#include <linux/w1.h> +struct w1_gpio_ddata { +struct gpio_desc *gpiod; +struct gpio_desc *pullup_gpiod; +void (*enable_external_pullup)(int enable); +unsigned int pullup_duration; +}; +static u8 w1_gpio_set_pullup (void *data,int delay) { -struct w1_gpio_platform_data *pdata = data; +struct w1_gpio_ddata *pdata = data;if (delay) { pdata->pullup_duration = delay;
@@ -46,14 +52,14 @@ static u8 w1_gpio_set_pullup(void *data, int delay)static void w1_gpio_write_bit (void *data,u8 bit) { -struct w1_gpio_platform_data *pdata = data; +struct w1_gpio_ddata *pdata = data;gpiod_set_value (pdata->gpiod, bit); }static u8 w1_gpio_read_bit (void *data) { -struct w1_gpio_platform_data *pdata = data; +struct w1_gpio_ddata *pdata = data;return gpiod_get_value (pdata->gpiod) ?1 :0 ; }
@@ -69,35 +75,25 @@ MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids);static int w1_gpio_probe (struct platform_device *pdev) {struct w1_bus_master *master; -struct w1_gpio_platform_data *pdata; +struct w1_gpio_ddata *pdata;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node;/* Enforce open drain mode by default */ enum gpiod_flags gflags =GPIOD_OUT_LOW_OPEN_DRAIN ;int err; -if (of_have_populated_dt ()) { - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) +return -ENOMEM ; -/* -* This parameter means that something else than the gpiolib has -* already set the line into open drain mode, so we should just -* driver it high/low like we are in full control of the line and -* open drain will happen transparently. -*/ -if (of_property_present (np,"linux,open-drain" )) - gflags =GPIOD_OUT_LOW ; - - pdev->dev.platform_data = pdata; - } - pdata =dev_get_platdata (dev); - -if (!pdata) { -dev_err (dev,"No configuration data\n" ); -return -ENXIO ; - } +/* +* This parameter means that something else than the gpiolib has +* already set the line into open drain mode, so we should just +* driver it high/low like we are in full control of the line and +* open drain will happen transparently. +*/ +if (of_property_present (np,"linux,open-drain" )) + gflags =GPIOD_OUT_LOW ; master =devm_kzalloc (dev,sizeof (struct w1_bus_master ),GFP_KERNEL );
@@ -152,7 +148,7 @@ static int w1_gpio_probe(struct platform_device *pdev)static int w1_gpio_remove (struct platform_device *pdev) {struct w1_bus_master *master =platform_get_drvdata (pdev); -struct w1_gpio_platform_data *pdata =dev_get_platdata (&pdev->dev); +struct w1_gpio_ddata *pdata = master->data;if (pdata->enable_external_pullup) pdata->enable_external_pullup (0 );
@@ -167,7 +163,8 @@ static int w1_gpio_remove(struct platform_device *pdev)static int __maybe_unused w1_gpio_suspend (struct device *dev) { -struct w1_gpio_platform_data *pdata =dev_get_platdata (dev); +struct w1_bus_master *master =dev_get_drvdata (dev); +struct w1_gpio_ddata *pdata = master->data;if (pdata->enable_external_pullup) pdata->enable_external_pullup (0 );
@@ -177,7 +174,8 @@ static int __maybe_unused w1_gpio_suspend(struct device *dev)static int __maybe_unused w1_gpio_resume (struct device *dev) { -struct w1_gpio_platform_data *pdata =dev_get_platdata (dev); +struct w1_bus_master *master =dev_get_drvdata (dev); +struct w1_gpio_ddata *pdata = master->data;if (pdata->enable_external_pullup) pdata->enable_external_pullup (1 );
include/linux/w1-gpio.h deleted +0 -22
@@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* w1-gpio interface to platform code -* -* Copyright (C) 2007 Ville Syrjala <[email protected]> -*/ -#ifndef _LINUX_W1_GPIO_H -#define _LINUX_W1_GPIO_H - -struct gpio_desc ; - -/** -* struct w1_gpio_platform_data - Platform-dependent data for w1-gpio -*/ -struct w1_gpio_platform_data { -struct gpio_desc *gpiod; -struct gpio_desc *pullup_gpiod; -void (*enable_external_pullup)(int enable); -unsigned int pullup_duration; -}; - -#endif /* _LINUX_W1_GPIO_H */
Signature · 1 line
2.42.0
PATCH v2 2/3 w1: gpio: Drop unused enable_external_pullup from driver data
In reply to Uwe Kleine-KönigThis member is always NULL, so drop it. That makes the suspend and resume callbacks empty, so they can be dropped, too.
--- drivers/w1/masters/w1-gpio.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
drivers/w1/masters/w1-gpio.c +0 -32
@@ -20,7 +20,6 @@struct w1_gpio_ddata {struct gpio_desc *gpiod;struct gpio_desc *pullup_gpiod; -void (*enable_external_pullup)(int enable);unsigned int pullup_duration; };
@@ -134,9 +133,6 @@ static int w1_gpio_probe(struct platform_device *pdev)return err; } -if (pdata->enable_external_pullup) - pdata->enable_external_pullup (1 ); -if (pdata->pullup_gpiod)gpiod_set_value (pdata->pullup_gpiod,1 );
@@ -150,9 +146,6 @@ static int w1_gpio_remove(struct platform_device *pdev)struct w1_bus_master *master =platform_get_drvdata (pdev);struct w1_gpio_ddata *pdata = master->data; -if (pdata->enable_external_pullup) - pdata->enable_external_pullup (0 ); -if (pdata->pullup_gpiod)gpiod_set_value (pdata->pullup_gpiod,0 );
@@ -161,34 +154,9 @@ static int w1_gpio_remove(struct platform_device *pdev)return 0 ; } -static int __maybe_unused w1_gpio_suspend (struct device *dev) -{ -struct w1_bus_master *master =dev_get_drvdata (dev); -struct w1_gpio_ddata *pdata = master->data; - -if (pdata->enable_external_pullup) - pdata->enable_external_pullup (0 ); - -return 0 ; -} - -static int __maybe_unused w1_gpio_resume (struct device *dev) -{ -struct w1_bus_master *master =dev_get_drvdata (dev); -struct w1_gpio_ddata *pdata = master->data; - -if (pdata->enable_external_pullup) - pdata->enable_external_pullup (1 ); - -return 0 ; -} - -static SIMPLE_DEV_PM_OPS(w1_gpio_pm_ops, w1_gpio_suspend, w1_gpio_resume); -static struct platform_driver w1_gpio_driver = { .driver = { .name ="w1-gpio" , - .pm = &w1_gpio_pm_ops, .of_match_table =of_match_ptr (w1_gpio_dt_ids), }, .probe = w1_gpio_probe,
Signature · 1 line
2.42.0
PATCH v2 3/3 w1: gpio: rename pointer to driver data from pdata to ddata
In reply to Uwe Kleine-Königpdata is a relict when this was still platform data.
--- drivers/w1/masters/w1-gpio.c | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/w1/masters/w1-gpio.c +27 -27
@@ -25,25 +25,25 @@ struct w1_gpio_ddata {static u8 w1_gpio_set_pullup (void *data,int delay) { -struct w1_gpio_ddata *pdata = data; +struct w1_gpio_ddata *ddata = data;if (delay) { - pdata->pullup_duration = delay; + ddata->pullup_duration = delay; }else { -if (pdata->pullup_duration) { +if (ddata->pullup_duration) {/* * This will OVERRIDE open drain emulation and force-pull * the line high for some time. */ -gpiod_set_raw_value (pdata->gpiod,1 ); -msleep (pdata->pullup_duration); +gpiod_set_raw_value (ddata->gpiod,1 ); +msleep (ddata->pullup_duration);/* * This will simply set the line as input since we are doing * open drain emulation in the GPIO library. */ -gpiod_set_value (pdata->gpiod,1 ); +gpiod_set_value (ddata->gpiod,1 ); } - pdata->pullup_duration =0 ; + ddata->pullup_duration =0 ; }return 0 ;
@@ -51,16 +51,16 @@ static u8 w1_gpio_set_pullup(void *data, int delay)static void w1_gpio_write_bit (void *data,u8 bit) { -struct w1_gpio_ddata *pdata = data; +struct w1_gpio_ddata *ddata = data; -gpiod_set_value (pdata->gpiod, bit); +gpiod_set_value (ddata->gpiod, bit); }static u8 w1_gpio_read_bit (void *data) { -struct w1_gpio_ddata *pdata = data; +struct w1_gpio_ddata *ddata = data; -return gpiod_get_value (pdata->gpiod) ?1 :0 ; +return gpiod_get_value (ddata->gpiod) ?1 :0 ; }#if defined(CONFIG_OF )
@@ -74,15 +74,15 @@ MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids);static int w1_gpio_probe (struct platform_device *pdev) {struct w1_bus_master *master; -struct w1_gpio_ddata *pdata; +struct w1_gpio_ddata *ddata;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node;/* Enforce open drain mode by default */ enum gpiod_flags gflags =GPIOD_OUT_LOW_OPEN_DRAIN ;int err; - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) + ddata =devm_kzalloc (&pdev->dev,sizeof (*ddata),GFP_KERNEL ); +if (!ddata)return -ENOMEM ;/*
@@ -99,23 +99,23 @@ static int w1_gpio_probe(struct platform_device *pdev)if (!master)return -ENOMEM ; - pdata->gpiod =devm_gpiod_get_index (dev,NULL ,0 , gflags); -if (IS_ERR (pdata->gpiod)) { + ddata->gpiod =devm_gpiod_get_index (dev,NULL ,0 , gflags); +if (IS_ERR (ddata->gpiod)) {dev_err (dev,"gpio_request (pin) failed\n" ); -return PTR_ERR (pdata->gpiod); +return PTR_ERR (ddata->gpiod); } - pdata->pullup_gpiod = + ddata->pullup_gpiod =devm_gpiod_get_index_optional (dev,NULL ,1 ,GPIOD_OUT_LOW ); -if (IS_ERR (pdata->pullup_gpiod)) { +if (IS_ERR (ddata->pullup_gpiod)) {dev_err (dev,"gpio_request_one " "(ext_pullup_enable_pin) failed\n" ); -return PTR_ERR (pdata->pullup_gpiod); +return PTR_ERR (ddata->pullup_gpiod); } - master->data = pdata; + master->data = ddata; master->read_bit = w1_gpio_read_bit; -gpiod_direction_output (pdata->gpiod,1 ); +gpiod_direction_output (ddata->gpiod,1 ); master->write_bit = w1_gpio_write_bit;/*
@@ -133,8 +133,8 @@ static int w1_gpio_probe(struct platform_device *pdev)return err; } -if (pdata->pullup_gpiod) -gpiod_set_value (pdata->pullup_gpiod,1 ); +if (ddata->pullup_gpiod) +gpiod_set_value (ddata->pullup_gpiod,1 );platform_set_drvdata (pdev, master);
@@ -144,10 +144,10 @@ static int w1_gpio_probe(struct platform_device *pdev)static int w1_gpio_remove (struct platform_device *pdev) {struct w1_bus_master *master =platform_get_drvdata (pdev); -struct w1_gpio_ddata *pdata = master->data; +struct w1_gpio_ddata *ddata = master->data; -if (pdata->pullup_gpiod) -gpiod_set_value (pdata->pullup_gpiod,0 ); +if (ddata->pullup_gpiod) +gpiod_set_value (ddata->pullup_gpiod,0 );w1_remove_master_device (master);
Signature · 1 line
2.42.0
Krzysztof Kozlowski
maintainerQuoted 9 lines · Uwe Kleine-König
Hello,
v1 is available at
https://lore.kernel.org/r/[email protected].The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next
✗ No key: openpgp/[email protected]
Are you sure you exported your key to openpgp and verified addresses?
Best regards,
Krzysztof
Hello Krzysztof,
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Uwe Kleine-König
Hello,
v1 is available at
https://lore.kernel.org/r/[email protected].
Quoted 8 lines
Quoted 4 lines
The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next✗ No key: openpgp/[email protected]
Are you sure you exported your key to openpgp and verified addresses?
Works for me:
$ gpg --locate-keys [email protected] gpg: directory '/home/test/.gnupg' created gpg: keybox '/home/test/.gnupg/pubring.kbx' created gpg: /home/test/.gnupg/trustdb.gpg: trustdb created gpg: key E2DCDD9132669BD6: public key "Uwe Kleine-König <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 gpg: no ultimately trusted keys found pub rsa4096 2010-06-15 [SC] [expires: 2024-06-21] 0D2511F322BFAB1C1580266BE2DCDD9132669BD6 uid [ unknown] Uwe Kleine-König <[email protected]> sub rsa2048 2023-03-17 [A] [expires: 2025-03-16] sub rsa2048 2023-03-17 [S] [expires: 2025-03-16] sub rsa2048 2023-03-17 [E] [expires: 2025-03-16]
also https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git seems to have the current key since commit 5151fbdbeb53 "Update E2DCDD9132669BD6 (Uwe Kleine-König)".
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Krzysztof Kozlowski
maintainerQuoted 35 lines · Uwe Kleine-König
Hello Krzysztof,
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Uwe Kleine-König
Hello,
v1 is available at
https://lore.kernel.org/r/[email protected].Quoted 8 lines
Quoted 4 lines
The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next✗ No key: openpgp/[email protected]
Are you sure you exported your key to openpgp and verified addresses?
Works for me:
$ gpg --locate-keys [email protected] gpg: directory '/home/test/.gnupg' created gpg: keybox '/home/test/.gnupg/pubring.kbx' created gpg: /home/test/.gnupg/trustdb.gpg: trustdb created gpg: key E2DCDD9132669BD6: public key "Uwe Kleine-König <[email protected]>" imported gpg: Total number processed: 1 gpg: imported: 1 gpg: no ultimately trusted keys found pub rsa4096 2010-06-15 [SC] [expires: 2024-06-21] 0D2511F322BFAB1C1580266BE2DCDD9132669BD6 uid [ unknown] Uwe Kleine-König <[email protected]> sub rsa2048 2023-03-17 [A] [expires: 2025-03-16] sub rsa2048 2023-03-17 [S] [expires: 2025-03-16] sub rsa2048 2023-03-17 [E] [expires: 2025-03-16]
Quoted 4 lines
also https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git seems to have the current key since commit
5151fbdbeb53"Update E2DCDD9132669BD6 (Uwe Kleine-König)".
Huh, I think I misunderstood the message from b4. I thought it is trying to get your key from keys.openpgp.org and your key is just not there. Are you saying that it was looking only in my local keyring?
Best regards,
Krzysztof
Hello Krzysztof,
Quoted 10 lines · Krzysztof Kozlowski
Quoted 9 lines · Uwe Kleine-König
Hello Krzysztof,
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Uwe Kleine-König
Hello,
v1 is available at
https://lore.kernel.org/r/[email protected].
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next✗ No key: openpgp/[email protected]
I think "openpgp" isn't about the keys.openpgp.org keyserver, but just the signature algorithm.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Are you sure you exported your key to openpgp and verified addresses?
Works for me:
$ gpg --locate-keys [email protected]
FTR: This lookup used WKD, but my key is also on keys.openpgp.org.
Quoted 14 lines
Quoted 14 lines
gpg: directory '
/home/test/.gnupg' created
gpg: keybox '/home/test/.gnupg/pubring.kbx' created
gpg:/home/test/.gnupg/trustdb.gpg: trustdb created
gpg: key E2DCDD9132669BD6: public key "Uwe Kleine-König <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: no ultimately trusted keys found
pub rsa4096 2010-06-15 [SC] [expires: 2024-06-21]0D2511F322BFAB1C1580266BE2DCDD9132669BD6 uid [ unknown] Uwe Kleine-König <[email protected]> sub rsa2048 2023-03-17 [A] [expires: 2025-03-16] sub rsa2048 2023-03-17 [S] [expires: 2025-03-16] sub rsa2048 2023-03-17 [E] [expires: 2025-03-16]
Quoted 7 lines
Quoted 3 lines
also https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git seems to have the current key since commit
5151fbdbeb53"Update E2DCDD9132669BD6 (Uwe Kleine-König)".Huh, I think I misunderstood the message from b4. I thought it is trying to get your key from keys.openpgp.org and your key is just not there. Are you saying that it was looking only in my local keyring?
I didn't check how the keyhandling is implemented in b4, but I guess it just calls gpg and leaves it to you to get my key into your keyring.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Krzysztof Kozlowski
AppliedQuoted 9 lines · Uwe Kleine-König
v1 is available at
https://lore.kernel.org/r/[email protected].The changes in this v2 since then are:
- Fix a build problem in patch #3
- Rebase to today's next[...]
Applied, thanks!
[1/3] w1: gpio: Don't use platform data for driver data
https://git.kernel.org/krzk/linux-w1/c/9c0a5b3f9e55cf9a3dc85843666cae28adfdf7e3 [2/3] w1: gpio: Drop unused enable_external_pullup from driver data https://git.kernel.org/krzk/linux-w1/c/deaba3d687b7cb1a2868bd514fd665ee5efcaaf3 [3/3] w1: gpio: rename pointer to driver data from pdata to ddata https://git.kernel.org/krzk/linux-w1/c/0ca9223fe9f75dce6e5cd306c685ee687a0bbdeb
Best regards,
Signature · 1 line
Krzysztof Kozlowski <[email protected]>