[PATCH v6 05/22] soc: qcom: apr: Add GPR support

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Wed Sep 15 17:47:10 CEST 2021


> +gpr_port_t *gpr_alloc_port(struct apr_device *gdev, struct device *dev,
> +				gpr_port_cb cb,	void *priv)
> +{
> +	struct packet_router *pr = dev_get_drvdata(gdev->dev.parent);
> +	gpr_port_t *port;
> +	struct pkt_router_svc *svc;
> +	int id;
> +
> +	port = kzalloc(sizeof(*port), GFP_KERNEL);
> +	if (!port)
> +		return ERR_PTR(-ENOMEM);
> +
> +	svc = port;
> +	svc->callback = cb;
> +	svc->pr = pr;
> +	svc->priv = priv;
> +	svc->dev = dev;
> +	spin_lock_init(&svc->lock);
> +
> +	spin_lock(&pr->svcs_lock);
> +	id = idr_alloc_cyclic(&pr->svcs_idr, svc, GPR_DYNAMIC_PORT_START,
> +			      GPR_DYNAMIC_PORT_END, GFP_ATOMIC);
> +	if (id < 0) {
> +		dev_err(dev, "Unable to allocate dynamic GPR src port\n");
> +		kfree(port);
> +		spin_unlock(&pr->svcs_lock);
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	svc->id = id;
> +	spin_unlock(&pr->svcs_lock);
> +
> +	dev_info(dev, "Adding GPR src port (%x)\n", svc->id);

nit-pick: isn't this a bit verbose?

> +
> +	return port;
> +}
> +EXPORT_SYMBOL_GPL(gpr_alloc_port);

> +struct gpr_pkt {
> +	struct gpr_hdr hdr;
> +	uint32_t payload[0];
> +};

looks like a zero-length array?

should this be

struct gpr_pkt {
    struct gpr_hdr hdr;
    uint32_t payload[];
};

?



More information about the Alsa-devel mailing list