Commit 6eaf9f6a authored by Jonathan Cameron's avatar Jonathan Cameron

iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque

Continuing move to hide internal elements from drivers, move this structure
element over.  It's only accessed from iio core files so this one was
straight forward and no accessor functions are needed.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarAlexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-4-jic23@kernel.org
parent e5333ed0
...@@ -1858,7 +1858,7 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) ...@@ -1858,7 +1858,7 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (!indio_dev->info) if (!indio_dev->info)
return -EINVAL; return -EINVAL;
indio_dev->driver_module = this_mod; iio_dev_opaque->driver_module = this_mod;
/* If the calling driver did not initialize of_node, do it here */ /* If the calling driver did not initialize of_node, do it here */
if (!indio_dev->dev.of_node && indio_dev->dev.parent) if (!indio_dev->dev.of_node && indio_dev->dev.parent)
indio_dev->dev.of_node = indio_dev->dev.parent->of_node; indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
#include <linux/iio/iio-opaque.h>
#include <linux/iio/trigger.h> #include <linux/iio/trigger.h>
#include "iio_core.h" #include "iio_core.h"
#include "iio_core_trigger.h" #include "iio_core_trigger.h"
...@@ -240,12 +241,13 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, int irq) ...@@ -240,12 +241,13 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, int irq)
int iio_trigger_attach_poll_func(struct iio_trigger *trig, int iio_trigger_attach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf) struct iio_poll_func *pf)
{ {
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev);
bool notinuse = bool notinuse =
bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
int ret = 0; int ret = 0;
/* Prevent the module from being removed whilst attached to a trigger */ /* Prevent the module from being removed whilst attached to a trigger */
__module_get(pf->indio_dev->driver_module); __module_get(iio_dev_opaque->driver_module);
/* Get irq number */ /* Get irq number */
pf->irq = iio_trigger_get_irq(trig); pf->irq = iio_trigger_get_irq(trig);
...@@ -284,13 +286,14 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, ...@@ -284,13 +286,14 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
out_put_irq: out_put_irq:
iio_trigger_put_irq(trig, pf->irq); iio_trigger_put_irq(trig, pf->irq);
out_put_module: out_put_module:
module_put(pf->indio_dev->driver_module); module_put(iio_dev_opaque->driver_module);
return ret; return ret;
} }
int iio_trigger_detach_poll_func(struct iio_trigger *trig, int iio_trigger_detach_poll_func(struct iio_trigger *trig,
struct iio_poll_func *pf) struct iio_poll_func *pf)
{ {
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(pf->indio_dev);
bool no_other_users = bool no_other_users =
bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1;
int ret = 0; int ret = 0;
...@@ -304,7 +307,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig, ...@@ -304,7 +307,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig,
trig->attached_own_device = false; trig->attached_own_device = false;
iio_trigger_put_irq(trig, pf->irq); iio_trigger_put_irq(trig, pf->irq);
free_irq(pf->irq, pf); free_irq(pf->irq, pf);
module_put(pf->indio_dev->driver_module); module_put(iio_dev_opaque->driver_module);
return ret; return ret;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* struct iio_dev_opaque - industrial I/O device opaque information * struct iio_dev_opaque - industrial I/O device opaque information
* @indio_dev: public industrial I/O device information * @indio_dev: public industrial I/O device information
* @id: used to identify device internally * @id: used to identify device internally
* @driver_module: used to make it harder to undercut users
* @event_interface: event chrdevs associated with interrupt lines * @event_interface: event chrdevs associated with interrupt lines
* @attached_buffers: array of buffers statically attached by the driver * @attached_buffers: array of buffers statically attached by the driver
* @attached_buffers_cnt: number of buffers in the array of statically attached buffers * @attached_buffers_cnt: number of buffers in the array of statically attached buffers
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
struct iio_dev_opaque { struct iio_dev_opaque {
struct iio_dev indio_dev; struct iio_dev indio_dev;
int id; int id;
struct module *driver_module;
struct iio_event_interface *event_interface; struct iio_event_interface *event_interface;
struct iio_buffer **attached_buffers; struct iio_buffer **attached_buffers;
unsigned int attached_buffers_cnt; unsigned int attached_buffers_cnt;
......
...@@ -488,7 +488,6 @@ struct iio_buffer_setup_ops { ...@@ -488,7 +488,6 @@ struct iio_buffer_setup_ops {
/** /**
* struct iio_dev - industrial I/O device * struct iio_dev - industrial I/O device
* @driver_module: [INTERN] used to make it harder to undercut users
* @modes: [DRIVER] operating modes supported by device * @modes: [DRIVER] operating modes supported by device
* @currentmode: [DRIVER] current operating mode * @currentmode: [DRIVER] current operating mode
* @dev: [DRIVER] device structure, should be assigned a parent * @dev: [DRIVER] device structure, should be assigned a parent
...@@ -522,8 +521,6 @@ struct iio_buffer_setup_ops { ...@@ -522,8 +521,6 @@ struct iio_buffer_setup_ops {
* **MUST** be accessed **ONLY** via iio_priv() helper * **MUST** be accessed **ONLY** via iio_priv() helper
*/ */
struct iio_dev { struct iio_dev {
struct module *driver_module;
int modes; int modes;
int currentmode; int currentmode;
struct device dev; struct device dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment