tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] Cleanup chardev instances with helper function
@ 2017-02-21  5:00 Logan Gunthorpe
       [not found] ` <1487653253-11497-1-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 29+ messages in thread
From: Logan Gunthorpe @ 2017-02-21  5:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Williams, Alexander Viro,
	Johannes Thumshirn, Jan Kara, Arnd Bergmann, Sajjan Vikas C,
	Dmitry Torokhov, Linus Walleij, Alexandre Courbot, Peter Huewe,
	Marcel Selhorst, Jarkko Sakkinen, Jason Gunthorpe,
	Olof Johansson, Doug Ledford, Sean Hefty, Hal Rosenstock,
	Dmitry Vyukov, Haggai Eran, Parav Pandit, Leon Romanovsky,
	Jonathan
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	osd-dev-yNzVSZO3znNg9hUCZPvPmw,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-media-u79uwXL29TY76Z2rM5mHXA

Hello,

Our story for this patch-set begins with a new driver I wrote and am in
the process of submitting upstream. That driver creates a fairly
standard char device and the code for it was copied from a similar
instance in device-dax. However, upon review, Greg Kroah-Hartman
noticed [1] a suspicious line that assigned to the parent field of
the underlying kobject for the char device.

I removed that from my code and endeavoured to remove it from the
code I copied as well. However, Dan Williams pointed out [2] that this
code is necessary for correct reference counting of the underlying
structures. This prompted me to do a fair bit more research and
investigation into whats going on and I found it to be a common pattern.
(Although misleading and though required to be correct, frequently
forgotten.) This pattern is used in at least 15 places in the kernel
and probably should have been used in at least 5 more.

This patch-set aims to correct this and hopefully prevent future
developers from wasting their time on it. The first patch introduces
a new helper API as originally proposed by Dan Williams [3]. Please
see the commit message for that patch for a longer description of the
problem and history.

The subsequent patches either update correct instances to use the
new API or fix incorrect usages to ensure the cdev correctly takes
a reference count using the new API (this is noted in those patches).

This moves all except four of the cdev.kobj.parent usages into the one
cdev function, the remaining four are in the infiniband subsystem and
I've left alone because that subsystem seems to make use of kobjects
directly (instead of struct devices). These are noted in patch 7 of
this series.

This series is based on v4.10 with the exception of the last patch
which is for my new driver which, as yet, has not been accepted
upstream.

@Dan the first patch in this series will need your sign-off.

Thanks,

Logan

[1] https://lkml.org/lkml/2017/2/10/370
[2] https://lkml.org/lkml/2017/2/10/607
[3] https://lkml.org/lkml/2017/2/13/700

Logan Gunthorpe (14):
  chardev: add helper function to register char devs with a struct
    device
  device-dax: utilize new device_add_cdev helper function
  input: utilize new device_add_cdev helper function
  gpiolib: utilize new device_add_cdev helper function
  tpm-chip: utilize new device_add_cdev helper function
  platform/chrome: utilize new device_add_cdev helper function
  infiniband: utilize new device_add_cdev helper function
  iio:core: utilize new device_add_cdev helper function
  media: utilize new device_add_cdev helper function
  mtd: utilize new device_add_cdev helper function
  rapidio: utilize new device_add_cdev helper function
  rtc: utilize new device_add_cdev helper function
  scsi: utilize new device_add_cdev helper function
  switchtec: utilize new device_add_cdev helper function

 drivers/char/tpm/tpm-chip.c              |  3 +--
 drivers/dax/dax.c                        |  5 ++---
 drivers/gpio/gpiolib.c                   |  3 +--
 drivers/iio/industrialio-core.c          |  3 +--
 drivers/infiniband/core/ucm.c            |  8 +++++---
 drivers/input/evdev.c                    |  3 +--
 drivers/input/joydev.c                   |  3 +--
 drivers/input/mousedev.c                 |  3 +--
 drivers/media/cec/cec-core.c             |  3 +--
 drivers/media/media-devnode.c            |  3 +--
 drivers/mtd/ubi/build.c                  |  8 +++++---
 drivers/mtd/ubi/vmt.c                    | 10 +++++-----
 drivers/pci/switch/switchtec.c           |  3 +--
 drivers/platform/chrome/cros_ec_dev.c    |  6 ++----
 drivers/rapidio/devices/rio_mport_cdev.c |  9 ++++++---
 drivers/rtc/rtc-dev.c                    |  3 +--
 drivers/scsi/osd/osd_uld.c               |  9 +++++----
 fs/char_dev.c                            | 24 ++++++++++++++++++++++++
 include/linux/cdev.h                     |  1 +
 19 files changed, 65 insertions(+), 45 deletions(-)

--
2.1.4

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

end of thread, other threads:[~2017-02-23  8:37 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21  5:00 [PATCH 00/14] Cleanup chardev instances with helper function Logan Gunthorpe
     [not found] ` <1487653253-11497-1-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21  5:00   ` [PATCH 01/14] chardev: add helper function to register char devs with a struct device Logan Gunthorpe
     [not found]     ` <1487653253-11497-2-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21  5:35       ` Dmitry Torokhov
2017-02-21  6:35         ` Logan Gunthorpe
     [not found]           ` <17f32963-1d0e-5d17-64c9-742b05415722-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21 18:18             ` Dan Williams
     [not found]               ` <CAPcyv4jOWDxjQoBdZ8GQ+yhcAcL2gOBoEEHE-02beopXKFmGQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-21 23:41                 ` Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 02/14] device-dax: utilize new device_add_cdev helper function Logan Gunthorpe
     [not found]     ` <1487653253-11497-3-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21 11:37       ` Alexandre Belloni
     [not found]         ` <20170221113704.ibwkk2vuc5imkmae-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
2017-02-21 19:26           ` Dan Williams
2017-02-21  5:00   ` [PATCH 03/14] input: " Logan Gunthorpe
     [not found]     ` <1487653253-11497-4-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-23  8:37       ` Dmitry Torokhov
2017-02-21  5:00   ` [PATCH 04/14] gpiolib: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 05/14] tpm-chip: " Logan Gunthorpe
     [not found]     ` <1487653253-11497-6-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21 18:39       ` Jason Gunthorpe
2017-02-21  5:00   ` [PATCH 06/14] platform/chrome: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 07/14] infiniband: " Logan Gunthorpe
     [not found]     ` <1487653253-11497-8-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21 19:09       ` Jason Gunthorpe
     [not found]         ` <20170221190905.GD13138-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-21 23:54           ` Logan Gunthorpe
     [not found]             ` <c7d34394-a9e8-fc9f-92f5-42c56a73ad1f-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-22  0:48               ` Jason Gunthorpe
2017-02-22  8:18               ` Lars-Peter Clausen
2017-02-21  5:00   ` [PATCH 08/14] iio:core: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 09/14] media: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 10/14] mtd: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 11/14] rapidio: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 12/14] rtc: " Logan Gunthorpe
2017-02-21  5:00   ` [PATCH 13/14] scsi: " Logan Gunthorpe
     [not found]     ` <1487653253-11497-14-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2017-02-21 12:52       ` Boaz Harrosh
2017-02-21  5:00   ` [PATCH 14/14] switchtec: " Logan Gunthorpe
2017-02-21  7:54   ` [PATCH 00/14] Cleanup chardev instances with " Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).