Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d5f022f authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman
Browse files

staging: most: remove proprietary kobjects



This patch removes the proprietary kobjects used by the driver modules and
replaces them with device structs. The patch is needed to have the driver
being integrated into the kernel's device model.

Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2c22cdfb
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -412,7 +412,6 @@ static int aim_tx_completion(struct most_interface *iface, int channel_id)
 * @iface: pointer to interface instance
 * @channel_id: channel index/ID
 * @cfg: pointer to actual channel configuration
 * @parent: pointer to kobject (needed for sysfs hook-up)
 * @name: name of the device to be created
 *
 * This allocates achannel object and creates the device node in /dev
@@ -420,15 +419,14 @@ static int aim_tx_completion(struct most_interface *iface, int channel_id)
 * Returns 0 on success or error code otherwise.
 */
static int aim_probe(struct most_interface *iface, int channel_id,
		     struct most_channel_config *cfg,
		     struct kobject *parent, char *name)
		     struct most_channel_config *cfg, char *name)
{
	struct aim_channel *c;
	unsigned long cl_flags;
	int retval;
	int current_minor;

	if ((!iface) || (!cfg) || (!parent) || (!name)) {
	if ((!iface) || (!cfg) || (!name)) {
		pr_info("Probing AIM with bad arguments");
		return -EINVAL;
	}
+234 −569

File changed.

Preview size limit exceeded, changes collapsed.

+9 −4
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#define __MOST_CORE_H__

#include <linux/types.h>
#include <linux/device.h>

struct kobject;
struct module;

/**
@@ -232,6 +232,7 @@ struct mbo {
 * @priv Private field used by mostcore to store context information.
 */
struct most_interface {
	struct device dev;
	struct module *mod;
	enum most_interface_type interface;
	const char *description;
@@ -249,6 +250,8 @@ struct most_interface {
	void *priv;
};

#define to_most_interface(d) container_of(d, struct most_interface, dev)

/**
 * struct most_aim - identifies MOST device driver to mostcore
 * @name: Driver name
@@ -259,10 +262,10 @@ struct most_interface {
 * @context: context pointer to be used by mostcore
 */
struct most_aim {
	struct device dev;
	const char *name;
	int (*probe_channel)(struct most_interface *iface, int channel_idx,
			     struct most_channel_config *cfg,
			     struct kobject *parent, char *name);
			     struct most_channel_config *cfg, char *name);
	int (*disconnect_channel)(struct most_interface *iface,
				  int channel_idx);
	int (*rx_completion)(struct mbo *mbo);
@@ -270,6 +273,8 @@ struct most_aim {
	void *context;
};

#define to_most_aim(d) container_of(d, struct most_aim, dev)

/**
 * most_register_interface - Registers instance of the interface.
 * @iface: Pointer to the interface instance description.
@@ -279,7 +284,7 @@ struct most_aim {
 * Note: HDM has to ensure that any reference held on the kobj is
 * released before deregistering the interface.
 */
struct kobject *most_register_interface(struct most_interface *iface);
int most_register_interface(struct most_interface *iface);

/**
 * Deregisters instance of the interface.
+11 −8
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ struct hdm_channel {
 * @atx_idx: index of async tx channel
 */
struct dim2_hdm {
	struct device dev;
	struct hdm_channel hch[DMA_CHANNELS];
	struct most_channel_capability capabilities[DMA_CHANNELS];
	struct most_interface most_iface;
@@ -738,7 +739,6 @@ static int dim2_probe(struct platform_device *pdev)
	struct dim2_hdm *dev;
	struct resource *res;
	int ret, i;
	struct kobject *kobj;
	int irq;

	dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -826,17 +826,20 @@ static int dim2_probe(struct platform_device *pdev)
	dev->most_iface.enqueue = enqueue;
	dev->most_iface.poison_channel = poison_channel;
	dev->most_iface.request_netinfo = request_netinfo;
	dev->dev.init_name = "dim2_state";
	dev->dev.parent = &dev->most_iface.dev;

	kobj = most_register_interface(&dev->most_iface);
	if (IS_ERR(kobj)) {
		ret = PTR_ERR(kobj);
	ret = most_register_interface(&dev->most_iface);
	if (ret) {
		dev_err(&pdev->dev, "failed to register MOST interface\n");
		goto err_stop_thread;
	}

	ret = dim2_sysfs_probe(&dev->bus, kobj);
	if (ret)
	ret = dim2_sysfs_probe(&dev->dev);
	if (ret) {
		dev_err(&pdev->dev, "failed to create sysfs attribute\n");
		goto err_unreg_iface;
	}

	ret = startup_dim(pdev);
	if (ret) {
@@ -847,7 +850,7 @@ static int dim2_probe(struct platform_device *pdev)
	return 0;

err_destroy_bus:
	dim2_sysfs_destroy(&dev->bus);
	dim2_sysfs_destroy(&dev->dev);
err_unreg_iface:
	most_deregister_interface(&dev->most_iface);
err_stop_thread:
@@ -875,7 +878,7 @@ static int dim2_remove(struct platform_device *pdev)
	if (pdata && pdata->destroy)
		pdata->destroy(pdata);

	dim2_sysfs_destroy(&dev->bus);
	dim2_sysfs_destroy(&dev->dev);
	most_deregister_interface(&dev->most_iface);
	kthread_stop(dev->netinfo_task);

+16 −76
Original line number Diff line number Diff line
@@ -11,99 +11,39 @@

#include <linux/kernel.h>
#include "sysfs.h"
#include <linux/device.h>

struct bus_attr {
	struct attribute attr;
	ssize_t (*show)(struct medialb_bus *bus, char *buf);
	ssize_t (*store)(struct medialb_bus *bus, const char *buf,
			 size_t count);
};

static ssize_t state_show(struct medialb_bus *bus, char *buf)
static ssize_t state_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{
	bool state = dim2_sysfs_get_state_cb();

	return sprintf(buf, "%s\n", state ? "locked" : "");
}

static struct bus_attr state_attr = __ATTR_RO(state);
DEVICE_ATTR_RO(state);

static struct attribute *bus_default_attrs[] = {
	&state_attr.attr,
static struct attribute *dev_attrs[] = {
	&dev_attr_state.attr,
	NULL,
};

static const struct attribute_group bus_attr_group = {
	.attrs = bus_default_attrs,
static struct attribute_group dev_attr_group = {
	.attrs = dev_attrs,
};

static void bus_kobj_release(struct kobject *kobj)
{
}

static ssize_t bus_kobj_attr_show(struct kobject *kobj, struct attribute *attr,
				  char *buf)
{
	struct medialb_bus *bus =
		container_of(kobj, struct medialb_bus, kobj_group);
	struct bus_attr *xattr = container_of(attr, struct bus_attr, attr);

	if (!xattr->show)
		return -EIO;

	return xattr->show(bus, buf);
}

static ssize_t bus_kobj_attr_store(struct kobject *kobj, struct attribute *attr,
				   const char *buf, size_t count)
{
	struct medialb_bus *bus =
		container_of(kobj, struct medialb_bus, kobj_group);
	struct bus_attr *xattr = container_of(attr, struct bus_attr, attr);

	if (!xattr->store)
		return -EIO;

	return xattr->store(bus, buf, count);
}

static struct sysfs_ops const bus_kobj_sysfs_ops = {
	.show = bus_kobj_attr_show,
	.store = bus_kobj_attr_store,
};

static struct kobj_type bus_ktype = {
	.release = bus_kobj_release,
	.sysfs_ops = &bus_kobj_sysfs_ops,
static const struct attribute_group *dev_attr_groups[] = {
	&dev_attr_group,
	NULL,
};

int dim2_sysfs_probe(struct medialb_bus *bus, struct kobject *parent_kobj)
int dim2_sysfs_probe(struct device *dev)
{
	int err;

	kobject_init(&bus->kobj_group, &bus_ktype);
	err = kobject_add(&bus->kobj_group, parent_kobj, "bus");
	if (err) {
		pr_err("kobject_add() failed: %d\n", err);
		goto err_kobject_add;
	}

	err = sysfs_create_group(&bus->kobj_group, &bus_attr_group);
	if (err) {
		pr_err("sysfs_create_group() failed: %d\n", err);
		goto err_create_group;
	}

	return 0;

err_create_group:
	kobject_put(&bus->kobj_group);

err_kobject_add:
	return err;
	dev->groups = dev_attr_groups;
	return device_register(dev);
}

void dim2_sysfs_destroy(struct medialb_bus *bus)
void dim2_sysfs_destroy(struct device *dev)
{
	kobject_put(&bus->kobj_group);
	device_unregister(dev);
}
Loading