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

Commit 8e2fc39d authored by Dominik Brodowski's avatar Dominik Brodowski
Browse files

pcmcia: pcmcia_config_loop() default CIS entry handling



Many drivers use the default CIS entry within their pcmcia_config_loop()
callback function. Therefore, factor the default CIS entry handling out.

Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 498ac189
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)

struct pcmcia_config_check {
	config_info_t conf;
	cistpl_cftable_entry_t dflt;
	unsigned long ctl_base;
	int skip_vcc;
	int is_kme;
@@ -159,6 +158,7 @@ struct pcmcia_config_check {

static int pcmcia_check_one_config(struct pcmcia_device *pdev,
				   cistpl_cftable_entry_t *cfg,
				   cistpl_cftable_entry_t *dflt,
				   void *priv_data)
{
	struct pcmcia_config_check *stk = priv_data;
@@ -166,21 +166,23 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
	/* Check for matching Vcc, unless we're desperate */
	if (!stk->skip_vcc) {
		if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
			if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
				goto next_entry;
		} else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
			if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000)
				goto next_entry;
			if (stk->conf.Vcc !=
			    cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
				return -ENODEV;
		} else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
			if (stk->conf.Vcc !=
			    dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
				return -ENODEV;
		}
	}

	if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
		pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
	else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
		pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
	else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
		pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;

	if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) {
		cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io;
	if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
		cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
		pdev->io.BasePort1 = io->win[0].base;
		pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
		if (!(io->flags & CISTPL_IO_16BIT))
@@ -190,23 +192,19 @@ static int pcmcia_check_one_config(struct pcmcia_device *pdev,
			pdev->io.BasePort2 = io->win[1].base;
			pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1;
			if (pcmcia_request_io(pdev, &pdev->io) != 0)
				goto next_entry;
				return -ENODEV;
			stk->ctl_base = pdev->io.BasePort2;
		} else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
			pdev->io.NumPorts1 = io->win[0].len;
			pdev->io.NumPorts2 = 0;
			if (pcmcia_request_io(pdev, &pdev->io) != 0)
				goto next_entry;
				return -ENODEV;
			stk->ctl_base = pdev->io.BasePort1 + 0x0e;
		} else
			goto next_entry;
			return -ENODEV;
		/* If we've got this far, we're done */
		return 0;
	}
next_entry:
	if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
		memcpy(&stk->dflt, cfg, sizeof(stk->dflt));

	return -ENODEV;
}

@@ -264,7 +262,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
	CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
	stk->skip_vcc = io_base = ctl_base = 0;
	if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
		memset(&stk->dflt, 0, sizeof(stk->dflt));
		stk->skip_vcc = 1;
		if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
			goto failed; /* No suitable config found */
+2 −0
Original line number Diff line number Diff line
@@ -680,6 +680,7 @@ static void bt3c_detach(struct pcmcia_device *link)

static int bt3c_check_config(struct pcmcia_device *p_dev,
			     cistpl_cftable_entry_t *cf,
			     cistpl_cftable_entry_t *dflt,
			     void *priv_data)
{
	unsigned long try = (unsigned long) priv_data;
@@ -699,6 +700,7 @@ static int bt3c_check_config(struct pcmcia_device *p_dev,

static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
				      cistpl_cftable_entry_t *cf,
				      cistpl_cftable_entry_t *dflt,
				      void *priv_data)
{
	static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+2 −0
Original line number Diff line number Diff line
@@ -609,6 +609,7 @@ static void btuart_detach(struct pcmcia_device *link)

static int btuart_check_config(struct pcmcia_device *p_dev,
			       cistpl_cftable_entry_t *cf,
			       cistpl_cftable_entry_t *dflt,
			       void *priv_data)
{
	unsigned long try = (unsigned long) priv_data;
@@ -628,6 +629,7 @@ static int btuart_check_config(struct pcmcia_device *p_dev,

static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
					cistpl_cftable_entry_t *cf,
					cistpl_cftable_entry_t *dflt,
					void *priv_data)
{
	static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
+1 −0
Original line number Diff line number Diff line
@@ -592,6 +592,7 @@ static void dtl1_detach(struct pcmcia_device *link)

static int dtl1_confcheck(struct pcmcia_device *p_dev,
			  cistpl_cftable_entry_t *cf,
			  cistpl_cftable_entry_t *dflt,
			  void *priv_data)
{
	if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
+1 −0
Original line number Diff line number Diff line
@@ -1761,6 +1761,7 @@ static void cmm_cm4000_release(struct pcmcia_device * link)

static int cm4000_config_check(struct pcmcia_device *p_dev,
			       cistpl_cftable_entry_t *cfg,
			       cistpl_cftable_entry_t *dflt,
			       void *priv_data)
{
	if (!cfg->io.nwin)
Loading