public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation: i2c: drop unnecessary .owner field in examples
@ 2018-01-15 12:08 Nicholas Mc Guire
  2018-01-15 20:24 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2018-01-15 12:08 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Jonathan Corbet, linux-i2c, linux-doc, linux-kernel,
	Nicholas Mc Guire

From: Nicholas Mc Guire <hofrat@osadl.at>

 Currently there are a few drivers that still set the .owner
 in the i2c_driver structure - all of which are reported by
 coccinelle (scripts/coccinelle/api/platform_no_drv_owner.cocci)
 and there are no cases that set the .onwer and do not call any
 of the functions that set the .owner field anyway in any of the
 drivers (checked by a modified coccinelle script based on the
 above) so it seems that the examples are no longer valid and
 .owner = THIS_MODULE, can be removed here.

 While at it an obvious typo (new new) was also fixed.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.at>
---

Patch is against 4.15-rc7 (localversion-next is -next-20180112)

 Documentation/i2c/upgrading-clients | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/i2c/upgrading-clients b/Documentation/i2c/upgrading-clients
index ccba3ff..d5e51ae 100644
--- a/Documentation/i2c/upgrading-clients
+++ b/Documentation/i2c/upgrading-clients
@@ -7,7 +7,7 @@ Introduction
 ------------
 
 This guide outlines how to alter existing Linux 2.6 client drivers from
-the old to the new new binding methods.
+the old to the new binding methods.
 
 
 Example old-style driver
@@ -77,7 +77,6 @@ static int example_attach_adapter(struct i2c_adapter *adap)
 
 static struct i2c_driver example_driver = {
  	.driver		= {
-		.owner		= THIS_MODULE,
 		.name		= "example",
 		.pm		= &example_pm_ops,
 	},
@@ -217,7 +216,6 @@ and other utilities:
 
 static struct i2c_driver example_driver = {
  	.driver		= {
-		.owner		= THIS_MODULE,
 		.name		= "example",
 	},
 +	.id_table	= example_ids,
@@ -269,7 +267,6 @@ MODULE_DEVICE_TABLE(i2c, example_idtable);
 
 static struct i2c_driver example_driver = {
  	.driver		= {
-		.owner		= THIS_MODULE,
 		.name		= "example",
 		.pm		= &example_pm_ops,
 	},
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Documentation: i2c: drop unnecessary .owner field in examples
  2018-01-15 12:08 [PATCH] Documentation: i2c: drop unnecessary .owner field in examples Nicholas Mc Guire
@ 2018-01-15 20:24 ` Andy Shevchenko
  2018-01-15 20:28   ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2018-01-15 20:24 UTC (permalink / raw)
  To: Nicholas Mc Guire
  Cc: Wolfram Sang, Jonathan Corbet, linux-i2c,
	Linux Documentation List, Linux Kernel Mailing List,
	Nicholas Mc Guire

On Mon, Jan 15, 2018 at 2:08 PM, Nicholas Mc Guire <hofrat@osadl.org> wrote:
> From: Nicholas Mc Guire <hofrat@osadl.at>
>
>  Currently there are a few drivers that still set the .owner
>  in the i2c_driver structure - all of which are reported by
>  coccinelle (scripts/coccinelle/api/platform_no_drv_owner.cocci)
>  and there are no cases that set the .onwer and do not call any
>  of the functions that set the .owner field anyway in any of the
>  drivers (checked by a modified coccinelle script based on the
>  above) so it seems that the examples are no longer valid and
>  .owner = THIS_MODULE, can be removed here.
>
>  While at it an obvious typo (new new) was also fixed.

AFAIU It is right only in case when someone does this, e.g.
module_i2c_driver() macro. Otherwise the field is pretty valid and
must be filled.


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Documentation: i2c: drop unnecessary .owner field in examples
  2018-01-15 20:24 ` Andy Shevchenko
@ 2018-01-15 20:28   ` Wolfram Sang
  2018-02-03 15:11     ` Nicholas Mc Guire
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2018-01-15 20:28 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Nicholas Mc Guire, Jonathan Corbet, linux-i2c,
	Linux Documentation List, Linux Kernel Mailing List,
	Nicholas Mc Guire

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]

On Mon, Jan 15, 2018 at 10:24:52PM +0200, Andy Shevchenko wrote:
> On Mon, Jan 15, 2018 at 2:08 PM, Nicholas Mc Guire <hofrat@osadl.org> wrote:
> > From: Nicholas Mc Guire <hofrat@osadl.at>
> >
> >  Currently there are a few drivers that still set the .owner
> >  in the i2c_driver structure - all of which are reported by
> >  coccinelle (scripts/coccinelle/api/platform_no_drv_owner.cocci)
> >  and there are no cases that set the .onwer and do not call any
> >  of the functions that set the .owner field anyway in any of the
> >  drivers (checked by a modified coccinelle script based on the
> >  above) so it seems that the examples are no longer valid and
> >  .owner = THIS_MODULE, can be removed here.
> >
> >  While at it an obvious typo (new new) was also fixed.
> 
> AFAIU It is right only in case when someone does this, e.g.
> module_i2c_driver() macro. Otherwise the field is pretty valid and
> must be filled.

It gets filled with i2c_add_driver. module_i2c_driver uses
i2c_add_driver. I was about to suggest to keep the field in the old
driver and describe that it can be removed when using one of
i2c_add_driver or module_i2c_driver.

But then I realised that the kernel tree does not have any such old
drivers anymore and I couldn't even find out-of-tree code via some
search engines (I tried looking for "I2C_CLIENT_INSMOD").

I consider this obsolete and irrelevant these days. It might be good to
simply remove it to not confuse users.

Thoughts?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Documentation: i2c: drop unnecessary .owner field in examples
  2018-01-15 20:28   ` Wolfram Sang
@ 2018-02-03 15:11     ` Nicholas Mc Guire
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Mc Guire @ 2018-02-03 15:11 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Andy Shevchenko, Nicholas Mc Guire, Jonathan Corbet, linux-i2c,
	Linux Documentation List, Linux Kernel Mailing List

On Mon, Jan 15, 2018 at 09:28:47PM +0100, Wolfram Sang wrote:
> On Mon, Jan 15, 2018 at 10:24:52PM +0200, Andy Shevchenko wrote:
> > On Mon, Jan 15, 2018 at 2:08 PM, Nicholas Mc Guire <hofrat@osadl.org> wrote:
> > > From: Nicholas Mc Guire <hofrat@osadl.at>
> > >
> > >  Currently there are a few drivers that still set the .owner
> > >  in the i2c_driver structure - all of which are reported by
> > >  coccinelle (scripts/coccinelle/api/platform_no_drv_owner.cocci)
> > >  and there are no cases that set the .onwer and do not call any
> > >  of the functions that set the .owner field anyway in any of the
> > >  drivers (checked by a modified coccinelle script based on the
> > >  above) so it seems that the examples are no longer valid and
> > >  .owner = THIS_MODULE, can be removed here.
> > >
> > >  While at it an obvious typo (new new) was also fixed.
> > 
> > AFAIU It is right only in case when someone does this, e.g.
> > module_i2c_driver() macro. Otherwise the field is pretty valid and
> > must be filled.
> 
> It gets filled with i2c_add_driver. module_i2c_driver uses
> i2c_add_driver. I was about to suggest to keep the field in the old
> driver and describe that it can be removed when using one of
> i2c_add_driver or module_i2c_driver.
> 
> But then I realised that the kernel tree does not have any such old
> drivers anymore and I couldn't even find out-of-tree code via some
> search engines (I tried looking for "I2C_CLIENT_INSMOD").
> 
> I consider this obsolete and irrelevant these days. It might be good to
> simply remove it to not confuse users.
> 
Not sure what the status of this is now - but I would
want to clean up some of the coccinelle findings - as a pre-requisite
it would make sense to either drop the examples inclusion of
.owner = THIS_MODULE or add a note in the documentation making
clear that this is only needed in case where the appropriate
module initialization helpers are not used. Is there any good
reason *not* to use these initialization helpers when upgrading
a driver ? If not (and I could not find one) then it might simply
be the right way to recommend using the initialization helpers and
drop the .owner = THIS_MODULE from the examples.

Anyway - cleaning up coccinelle findings would seem futile if the
documentation may be the cause.

thx!
hofrat

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-03 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 12:08 [PATCH] Documentation: i2c: drop unnecessary .owner field in examples Nicholas Mc Guire
2018-01-15 20:24 ` Andy Shevchenko
2018-01-15 20:28   ` Wolfram Sang
2018-02-03 15:11     ` Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox