* [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide
@ 2020-08-05 18:31 Stephen Kitt
2020-08-05 21:53 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Kitt @ 2020-08-05 18:31 UTC (permalink / raw)
To: Wolfram Sang, linux-i2c; +Cc: linux-kernel, Stephen Kitt
All the drivers have long since been upgraded, and all the important
information here is also included in the "Implementing I2C device
drivers" guide.
Signed-off-by: Stephen Kitt <steve@sk2.org>
---
Documentation/i2c/upgrading-clients.rst | 285 ------------------------
1 file changed, 285 deletions(-)
delete mode 100644 Documentation/i2c/upgrading-clients.rst
diff --git a/Documentation/i2c/upgrading-clients.rst b/Documentation/i2c/upgrading-clients.rst
deleted file mode 100644
index 1708090d7b8f..000000000000
--- a/Documentation/i2c/upgrading-clients.rst
+++ /dev/null
@@ -1,285 +0,0 @@
-=================================================
-Upgrading I2C Drivers to the new 2.6 Driver Model
-=================================================
-
-Ben Dooks <ben-linux@fluff.org>
-
-Introduction
-------------
-
-This guide outlines how to alter existing Linux 2.6 client drivers from
-the old to the new binding methods.
-
-
-Example old-style driver
-------------------------
-
-::
-
- struct example_state {
- struct i2c_client client;
- ....
- };
-
- static struct i2c_driver example_driver;
-
- static unsigned short ignore[] = { I2C_CLIENT_END };
- static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END };
-
- I2C_CLIENT_INSMOD;
-
- static int example_attach(struct i2c_adapter *adap, int addr, int kind)
- {
- struct example_state *state;
- struct device *dev = &adap->dev; /* to use for dev_ reports */
- int ret;
-
- state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
- if (state == NULL) {
- dev_err(dev, "failed to create our state\n");
- return -ENOMEM;
- }
-
- example->client.addr = addr;
- example->client.flags = 0;
- example->client.adapter = adap;
-
- i2c_set_clientdata(&state->i2c_client, state);
- strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name));
-
- ret = i2c_attach_client(&state->i2c_client);
- if (ret < 0) {
- dev_err(dev, "failed to attach client\n");
- kfree(state);
- return ret;
- }
-
- dev = &state->i2c_client.dev;
-
- /* rest of the initialisation goes here. */
-
- dev_info(dev, "example client created\n");
-
- return 0;
- }
-
- static int example_detach(struct i2c_client *client)
- {
- struct example_state *state = i2c_get_clientdata(client);
-
- i2c_detach_client(client);
- kfree(state);
- return 0;
- }
-
- static int example_attach_adapter(struct i2c_adapter *adap)
- {
- return i2c_probe(adap, &addr_data, example_attach);
- }
-
- static struct i2c_driver example_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "example",
- .pm = &example_pm_ops,
- },
- .attach_adapter = example_attach_adapter,
- .detach_client = example_detach,
- };
-
-
-Updating the client
--------------------
-
-The new style binding model will check against a list of supported
-devices and their associated address supplied by the code registering
-the busses. This means that the driver .attach_adapter and
-.detach_client methods can be removed, along with the addr_data,
-as follows::
-
- - static struct i2c_driver example_driver;
-
- - static unsigned short ignore[] = { I2C_CLIENT_END };
- - static unsigned short normal_addr[] = { OUR_ADDR, I2C_CLIENT_END };
-
- - I2C_CLIENT_INSMOD;
-
- - static int example_attach_adapter(struct i2c_adapter *adap)
- - {
- - return i2c_probe(adap, &addr_data, example_attach);
- - }
-
- static struct i2c_driver example_driver = {
- - .attach_adapter = example_attach_adapter,
- - .detach_client = example_detach,
- }
-
-Add the probe and remove methods to the i2c_driver, as so::
-
- static struct i2c_driver example_driver = {
- + .probe = example_probe,
- + .remove = example_remove,
- }
-
-Change the example_attach method to accept the new parameters
-which include the i2c_client that it will be working with::
-
- - static int example_attach(struct i2c_adapter *adap, int addr, int kind)
- + static int example_probe(struct i2c_client *client,
- + const struct i2c_device_id *id)
-
-Change the name of example_attach to example_probe to align it with the
-i2c_driver entry names. The rest of the probe routine will now need to be
-changed as the i2c_client has already been setup for use.
-
-The necessary client fields have already been setup before
-the probe function is called, so the following client setup
-can be removed::
-
- - example->client.addr = addr;
- - example->client.flags = 0;
- - example->client.adapter = adap;
- -
- - strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name));
-
-The i2c_set_clientdata is now::
-
- - i2c_set_clientdata(&state->client, state);
- + i2c_set_clientdata(client, state);
-
-The call to i2c_attach_client is no longer needed, if the probe
-routine exits successfully, then the driver will be automatically
-attached by the core. Change the probe routine as so::
-
- - ret = i2c_attach_client(&state->i2c_client);
- - if (ret < 0) {
- - dev_err(dev, "failed to attach client\n");
- - kfree(state);
- - return ret;
- - }
-
-
-Remove the storage of 'struct i2c_client' from the 'struct example_state'
-as we are provided with the i2c_client in our example_probe. Instead we
-store a pointer to it for when it is needed.
-
-::
-
- struct example_state {
- - struct i2c_client client;
- + struct i2c_client *client;
-
-the new i2c client as so::
-
- - struct device *dev = &adap->dev; /* to use for dev_ reports */
- + struct device *dev = &i2c_client->dev; /* to use for dev_ reports */
-
-And remove the change after our client is attached, as the driver no
-longer needs to register a new client structure with the core::
-
- - dev = &state->i2c_client.dev;
-
-In the probe routine, ensure that the new state has the client stored
-in it::
-
- static int example_probe(struct i2c_client *i2c_client,
- const struct i2c_device_id *id)
- {
- struct example_state *state;
- struct device *dev = &i2c_client->dev;
- int ret;
-
- state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
- if (state == NULL) {
- dev_err(dev, "failed to create our state\n");
- return -ENOMEM;
- }
-
- + state->client = i2c_client;
-
-Update the detach method, by changing the name to _remove and
-to delete the i2c_detach_client call. It is possible that you
-can also remove the ret variable as it is not needed for any
-of the core functions.
-
-::
-
- - static int example_detach(struct i2c_client *client)
- + static int example_remove(struct i2c_client *client)
- {
- struct example_state *state = i2c_get_clientdata(client);
-
- - i2c_detach_client(client);
-
-And finally ensure that we have the correct ID table for the i2c-core
-and other utilities::
-
- + struct i2c_device_id example_idtable[] = {
- + { "example", 0 },
- + { }
- +};
- +
- +MODULE_DEVICE_TABLE(i2c, example_idtable);
-
- static struct i2c_driver example_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "example",
- },
- + .id_table = example_ids,
-
-
-Our driver should now look like this::
-
- struct example_state {
- struct i2c_client *client;
- ....
- };
-
- static int example_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
- {
- struct example_state *state;
- struct device *dev = &client->dev;
-
- state = kzalloc(sizeof(struct example_state), GFP_KERNEL);
- if (state == NULL) {
- dev_err(dev, "failed to create our state\n");
- return -ENOMEM;
- }
-
- state->client = client;
- i2c_set_clientdata(client, state);
-
- /* rest of the initialisation goes here. */
-
- dev_info(dev, "example client created\n");
-
- return 0;
- }
-
- static int example_remove(struct i2c_client *client)
- {
- struct example_state *state = i2c_get_clientdata(client);
-
- kfree(state);
- return 0;
- }
-
- static struct i2c_device_id example_idtable[] = {
- { "example", 0 },
- { }
- };
-
- MODULE_DEVICE_TABLE(i2c, example_idtable);
-
- static struct i2c_driver example_driver = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "example",
- .pm = &example_pm_ops,
- },
- .id_table = example_idtable,
- .probe = example_probe,
- .remove = example_remove,
- };
base-commit: 2324d50d051ec0f14a548e78554fb02513d6dcef
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide
2020-08-05 18:31 [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide Stephen Kitt
@ 2020-08-05 21:53 ` Wolfram Sang
2020-08-06 7:09 ` Stephen Kitt
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2020-08-05 21:53 UTC (permalink / raw)
To: Stephen Kitt; +Cc: linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 585 bytes --]
Hi Stephen,
On Wed, Aug 05, 2020 at 08:31:49PM +0200, Stephen Kitt wrote:
> All the drivers have long since been upgraded, and all the important
> information here is also included in the "Implementing I2C device
> drivers" guide.
>
> Signed-off-by: Stephen Kitt <steve@sk2.org>
True! Thanks.
But I can't apply the patch?
> base-commit: 2324d50d051ec0f14a548e78554fb02513d6dcef
Maybe because I don't have the commit in my tree? Can you rebase on top
of 5.8?
And please also remove the reference in Documentation/i2c/index.rst
Kind regards,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide
2020-08-05 21:53 ` Wolfram Sang
@ 2020-08-06 7:09 ` Stephen Kitt
2020-08-06 8:33 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Kitt @ 2020-08-06 7:09 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]
Hi Wolfram,
On Wed, 5 Aug 2020 23:53:51 +0200, Wolfram Sang <wsa@kernel.org> wrote:
> On Wed, Aug 05, 2020 at 08:31:49PM +0200, Stephen Kitt wrote:
> > All the drivers have long since been upgraded, and all the important
> > information here is also included in the "Implementing I2C device
> > drivers" guide.
> >
> > Signed-off-by: Stephen Kitt <steve@sk2.org>
>
> True! Thanks.
>
> But I can't apply the patch?
>
> > base-commit: 2324d50d051ec0f14a548e78554fb02513d6dcef
>
> Maybe because I don't have the commit in my tree? Can you rebase on top
> of 5.8?
Ah, yes, the commit is on top of Linus’ current master, following the merge
of docs-5.9 from Jon’s tree. In 5.8 the file is a .txt file, but Mauro
converted it to .rst for 5.9, and this patch removes the latter file (to
avoid a merge conflict later on...). If you prefer, I can submit it to the
docs tree instead!
> And please also remove the reference in Documentation/i2c/index.rst
Oops, yes, I’ll do that in v2 once we decide where it should go.
Regards,
Stephen
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide
2020-08-06 7:09 ` Stephen Kitt
@ 2020-08-06 8:33 ` Wolfram Sang
2020-08-06 16:13 ` Stephen Kitt
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2020-08-06 8:33 UTC (permalink / raw)
To: Stephen Kitt; +Cc: linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 772 bytes --]
> > Maybe because I don't have the commit in my tree? Can you rebase on top
> > of 5.8?
>
> Ah, yes, the commit is on top of Linus’ current master, following the merge
> of docs-5.9 from Jon’s tree. In 5.8 the file is a .txt file, but Mauro
> converted it to .rst for 5.9, and this patch removes the latter file (to
> avoid a merge conflict later on...). If you prefer, I can submit it to the
> docs tree instead!
I see. Thanks for the heads up!
> > And please also remove the reference in Documentation/i2c/index.rst
>
> Oops, yes, I’ll do that in v2 once we decide where it should go.
I am fine with either it going via the doc-tree or you sending me v2
again after 5.9-rc1. For the first case:
Acked-by: Wolfram Sang <wsa@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide
2020-08-06 8:33 ` Wolfram Sang
@ 2020-08-06 16:13 ` Stephen Kitt
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Kitt @ 2020-08-06 16:13 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: Wolfram Sang, linux-i2c, linux-kernel, linux-doc
[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]
Hi Jon,
You’ll see v2 of this patch show up soon, see the context below — this is a
patch on top of Mauro’s conversion of the i2c docs to .rst.
Regards,
Stephen
On Thu, 6 Aug 2020 10:33:56 +0200, Wolfram Sang <wsa@the-dreams.de> wrote:
> > > Maybe because I don't have the commit in my tree? Can you rebase on top
> > > of 5.8?
> >
> > Ah, yes, the commit is on top of Linus’ current master, following the
> > merge of docs-5.9 from Jon’s tree. In 5.8 the file is a .txt file, but
> > Mauro converted it to .rst for 5.9, and this patch removes the latter
> > file (to avoid a merge conflict later on...). If you prefer, I can submit
> > it to the docs tree instead!
>
> I see. Thanks for the heads up!
>
> > > And please also remove the reference in Documentation/i2c/index.rst
> >
> > Oops, yes, I’ll do that in v2 once we decide where it should go.
>
> I am fine with either it going via the doc-tree or you sending me v2
> again after 5.9-rc1. For the first case:
>
> Acked-by: Wolfram Sang <wsa@kernel.org>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-06 22:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 18:31 [PATCH] docs: remove the 2.6 "Upgrading I2C Drivers" guide Stephen Kitt
2020-08-05 21:53 ` Wolfram Sang
2020-08-06 7:09 ` Stephen Kitt
2020-08-06 8:33 ` Wolfram Sang
2020-08-06 16:13 ` Stephen Kitt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.