intel_th: pci: Use drvdata for quirks

Allow attaching miscellaneous quirk information to devices as drvdata.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
This commit is contained in:
Alexander Shishkin 2017-08-18 17:57:35 +03:00
parent efb3669e14
commit 3321371b5d
3 changed files with 26 additions and 10 deletions

View File

@ -576,6 +576,7 @@ intel_th_subdevice_alloc(struct intel_th *th,
if (!thdev) if (!thdev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
thdev->drvdata = th->drvdata;
memcpy(res, subdev->res, memcpy(res, subdev->res,
sizeof(struct resource) * subdev->nres); sizeof(struct resource) * subdev->nres);
@ -789,8 +790,8 @@ static const struct file_operations intel_th_output_fops = {
* @irq: irq number * @irq: irq number
*/ */
struct intel_th * struct intel_th *
intel_th_alloc(struct device *dev, struct resource *devres, intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,
unsigned int ndevres, int irq) struct resource *devres, unsigned int ndevres, int irq)
{ {
struct intel_th *th; struct intel_th *th;
int err; int err;
@ -812,6 +813,7 @@ intel_th_alloc(struct device *dev, struct resource *devres,
goto err_ida; goto err_ida;
} }
th->dev = dev; th->dev = dev;
th->drvdata = drvdata;
th->resource = devres; th->resource = devres;
th->num_resources = ndevres; th->num_resources = ndevres;

View File

@ -47,9 +47,20 @@ struct intel_th_output {
bool active; bool active;
}; };
/**
* struct intel_th_drvdata - describes hardware capabilities and quirks
* @tscu_enable: device needs SW to enable time stamping unit
*/
struct intel_th_drvdata {
unsigned int tscu_enable : 1;
};
#define INTEL_TH_CAP(_th, _cap) ((_th)->drvdata ? (_th)->drvdata->_cap : 0)
/** /**
* struct intel_th_device - device on the intel_th bus * struct intel_th_device - device on the intel_th bus
* @dev: device * @dev: device
* @drvdata: hardware capabilities/quirks
* @resource: array of resources available to this device * @resource: array of resources available to this device
* @num_resources: number of resources in @resource array * @num_resources: number of resources in @resource array
* @type: INTEL_TH_{SOURCE,OUTPUT,SWITCH} * @type: INTEL_TH_{SOURCE,OUTPUT,SWITCH}
@ -60,6 +71,7 @@ struct intel_th_output {
*/ */
struct intel_th_device { struct intel_th_device {
struct device dev; struct device dev;
struct intel_th_drvdata *drvdata;
struct resource *resource; struct resource *resource;
unsigned int num_resources; unsigned int num_resources;
unsigned int type; unsigned int type;
@ -206,8 +218,8 @@ static inline struct intel_th *to_intel_th(struct intel_th_device *thdev)
} }
struct intel_th * struct intel_th *
intel_th_alloc(struct device *dev, struct resource *devres, intel_th_alloc(struct device *dev, struct intel_th_drvdata *drvdata,
unsigned int ndevres, int irq); struct resource *devres, unsigned int ndevres, int irq);
void intel_th_free(struct intel_th *th); void intel_th_free(struct intel_th *th);
int intel_th_driver_register(struct intel_th_driver *thdrv); int intel_th_driver_register(struct intel_th_driver *thdrv);
@ -248,6 +260,7 @@ struct intel_th {
struct intel_th_device *thdev[TH_SUBDEVICE_MAX]; struct intel_th_device *thdev[TH_SUBDEVICE_MAX];
struct intel_th_device *hub; struct intel_th_device *hub;
struct intel_th_drvdata *drvdata;
struct resource *resource; struct resource *resource;
unsigned int num_thdevs; unsigned int num_thdevs;

View File

@ -30,6 +30,7 @@
static int intel_th_pci_probe(struct pci_dev *pdev, static int intel_th_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
struct intel_th_drvdata *drvdata = (void *)id->driver_data;
struct intel_th *th; struct intel_th *th;
int err; int err;
@ -41,7 +42,7 @@ static int intel_th_pci_probe(struct pci_dev *pdev,
if (err) if (err)
return err; return err;
th = intel_th_alloc(&pdev->dev, pdev->resource, th = intel_th_alloc(&pdev->dev, drvdata, pdev->resource,
DEVICE_COUNT_RESOURCE, pdev->irq); DEVICE_COUNT_RESOURCE, pdev->irq);
if (IS_ERR(th)) if (IS_ERR(th))
return PTR_ERR(th); return PTR_ERR(th);