fpga: mgr: Use standard dev_release for class driver

The FPGA manager class driver data structure is being treated as a
managed resource instead of using the standard dev_release call-back
function to release the class data structure. This change removes
the managed resource code for the freeing of the class data structure
and combines the create() and register() functions into a single
register() or register_full() function.

The register_full() function accepts an info data structure to provide
flexibility in passing optional parameters. The register() function
supports the current parameter list for users that don't require the
use of optional parameters.

The devm_fpga_mgr_register() function is retained, and the
devm_fpga_mgr_register_full() function is added.

Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Reviewed-by: Xu Yilun <yilun.xu@intel.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
This commit is contained in:
Russ Weight
2021-11-18 17:55:51 -08:00
committed by Moritz Fischer
parent fa55b7dcdc
commit 4ba0b2c294
17 changed files with 226 additions and 270 deletions

View File

@@ -105,6 +105,36 @@ struct fpga_image_info {
#endif
};
/**
* struct fpga_compat_id - id for compatibility check
*
* @id_h: high 64bit of the compat_id
* @id_l: low 64bit of the compat_id
*/
struct fpga_compat_id {
u64 id_h;
u64 id_l;
};
/**
* struct fpga_manager_info - collection of parameters for an FPGA Manager
* @name: fpga manager name
* @compat_id: FPGA manager id for compatibility check.
* @mops: pointer to structure of fpga manager ops
* @priv: fpga manager private data
*
* fpga_manager_info contains parameters for the register_full function.
* These are separated into an info structure because they some are optional
* others could be added to in the future. The info structure facilitates
* maintaining a stable API.
*/
struct fpga_manager_info {
const char *name;
struct fpga_compat_id *compat_id;
const struct fpga_manager_ops *mops;
void *priv;
};
/**
* struct fpga_manager_ops - ops for low level fpga manager drivers
* @initial_header_size: Maximum number of bytes that should be passed into write_init
@@ -143,17 +173,6 @@ struct fpga_manager_ops {
#define FPGA_MGR_STATUS_IP_PROTOCOL_ERR BIT(3)
#define FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR BIT(4)
/**
* struct fpga_compat_id - id for compatibility check
*
* @id_h: high 64bit of the compat_id
* @id_l: low 64bit of the compat_id
*/
struct fpga_compat_id {
u64 id_h;
u64 id_l;
};
/**
* struct fpga_manager - fpga manager structure
* @name: name of low level fpga manager
@@ -191,17 +210,18 @@ struct fpga_manager *fpga_mgr_get(struct device *dev);
void fpga_mgr_put(struct fpga_manager *mgr);
struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name,
const struct fpga_manager_ops *mops,
void *priv);
void fpga_mgr_free(struct fpga_manager *mgr);
int fpga_mgr_register(struct fpga_manager *mgr);
struct fpga_manager *
fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info);
struct fpga_manager *
fpga_mgr_register(struct device *parent, const char *name,
const struct fpga_manager_ops *mops, void *priv);
void fpga_mgr_unregister(struct fpga_manager *mgr);
int devm_fpga_mgr_register(struct device *dev, struct fpga_manager *mgr);
struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name,
const struct fpga_manager_ops *mops,
void *priv);
struct fpga_manager *
devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info);
struct fpga_manager *
devm_fpga_mgr_register(struct device *parent, const char *name,
const struct fpga_manager_ops *mops, void *priv);
#endif /*_LINUX_FPGA_MGR_H */